MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
VBOLeafBuilder.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 
6 #if !defined(_MGVBOLEAFBUILDER__INCLUDED_)
7 #define _MGVBOLEAFBUILDER__INCLUDED_
8 
9 #if _MSC_VER > 1000
10 #pragma once
11 #endif // _MSC_VER > 1000
12 
13 #include "MGCLStdAfx.h"
14 #include "mg/Position.h"
15 #include "mgGL/Color.h"
16 
18 // Vertex Buffer Object Class.
19 
21 
22 class vboFPoint{
23 public:
24  float m_x,m_y,m_z;
25  vboFPoint():m_x(0.f),m_y(0.f),m_z(0.f){;};
26  vboFPoint(float x, float y, float z):m_x(x),m_y(y),m_z(z){;};
27  vboFPoint(double x, double y, double z):m_x((float)x),m_y((float)y),m_z((float)z){;};
28  vboFPoint(const MGPosition& P):m_x((float)P[0]),m_y((float)P[1]),m_z((float)P[2]){;};
29  vboFPoint(const MGVector& P):m_x((float)P[0]),m_y((float)P[1]),m_z((float)P[2]){;};
30 };
31 class vboFP2D{
32 public:
33  float m_s,m_t;
34  vboFP2D():m_s(0.f),m_t(0.f){;};
35  vboFP2D(float s, float t):m_s(s),m_t(t){;};
36  vboFP2D(double s, double t):m_s((float)s),m_t((float)t){;};
37  vboFP2D(const MGPosition& P):m_s((float)P[0]),m_t((float)P[1]){;};
38  vboFP2D(const MGVector& P):m_s((float)P[0]),m_t((float)P[1]){;};
39 };
40 class vboColor{
41 public:
42  float m_color[4];
43  vboColor(const float colr[4]){for(int i=0; i<4; i++) m_color[i]=colr[i];};
44  vboColor(const MGColor& clr){clr.get_color(m_color);};
45 };
46 
47 
48 
52 class mgVBOLeafBuilder{
53 
54 friend class mgVBOLeaf;
55 
56 // オペレーション
57 public:
58 
59 mgVBOLeafBuilder(GLenum type):m_typeBegin(type),m_drawType(mgGLSL::Primitive),m_texture(0)
60 ,m_stippleFactor(-1),m_LineStipplePattern(0),m_lightMode(-1){;};
61 
62 mgVBOLeafBuilder(GLenum type, const MGColor& colorStatic, GLfloat sizeStatic)
63 :m_typeBegin(type),m_colorStatic(colorStatic),m_sizeStatic(sizeStatic),
64 m_drawType(mgGLSL::Primitive),m_texture(0)
65 ,m_stippleFactor(-1),m_LineStipplePattern(0),m_lightMode(-1){;};
66 
67 bool is_null()const{return m_VertexData.size()==0;};
68 
69 void setTypeBegin(GLenum typeBegin){m_typeBegin=typeBegin;};
70 unsigned typeBegin()const{return m_typeBegin;};
71 
75 void setStaticAttribColor(const MGColor& color){m_colorStatic=color;};
76 void setStaticAttribColor(const float color[4]){
77  m_colorStatic=MGColor(color[0],color[1],color[2],color[3]);};
78 void setStaticAttribColor(float r, float g, float b){
79  m_colorStatic=MGColor(r,g,b);};
80 const MGColor& colorStatic()const{return m_colorStatic;};
81 
82 void setStaticAttribSize(GLfloat size){m_sizeStatic=size;};
83 GLfloat sizeStatic()const{return m_sizeStatic;};
84 
90 void setLineStipple(short int factor,GLushort pattern){
91  m_stippleFactor=factor;
92  m_LineStipplePattern=pattern;
93 };
94 
96 void setLightMode(int mode){m_lightMode=mode;};
97 
98 void setDrawType(mgGLSL::DrawType drawType){m_drawType = drawType;};
99 mgGLSL::DrawType getDrawType()const{return m_drawType;};
100 
101 //void setFunctionID(int functionID){m_functionID=functionID;};
102 void setTexture(mgTexture* texture){m_texture=texture;};
103 //int getFunctionID()const{return m_functionID;};
104 mgTexture* getTexture()const{return m_texture;};
105 
106 void push_backVertex(const vboFPoint& v){m_VertexData.push_back(v);};
107 void push_backColor(const vboColor& c){m_ColorData.push_back(c);};
108 void push_backNormal(const vboFPoint& n){m_NormalData.push_back(n);};
109 void push_backTexture(const vboFP2D& t){m_TextureData.push_back(t);};
110 
111 private:
112 
113  //int m_functionID;///the function ID to set to the current mgGLSLProgram.
114  mgGLSL::DrawType m_drawType;
115 
116  mutable mgTexture* m_texture;
117 
118  unsigned m_typeBegin;
119  MGColor m_colorStatic;
120  GLfloat m_sizeStatic;
122 
124  short int m_stippleFactor;
125  GLushort m_LineStipplePattern;
128 
130  int m_lightMode;
131 
132  std::vector<vboFPoint> m_VertexData;
133  std::vector<vboColor> m_ColorData;
134  std::vector<vboFPoint> m_NormalData;
135  std::vector<vboFP2D> m_TextureData;
136 };
137 
139 
140 #endif // !defined(_MGVBOLEAFBUILDER__INCLUDED_)
Definition: glslprogram.h:26
void setStaticAttribColor(const MGColor &color)
Definition: VBOLeaf.h:143
void setLightMode(int mode)
Set light mode. mode=-1:undefined, =0:disabled, =1:enabled.
Vector of a general n space dimension.
Definition: Vector.h:26
mgGLSL::DrawType getDrawType() const
Definition: VBOLeaf.h:93
MGColor defines the OpenGL color (R,G,B,A).
Definition: Color.h:26
DrawType
Definition: glslprogram.h:25
Represent a positional data.
Definition: Position.h:28
Texture definition class.
Definition: Texture.h:29
void setTexture(mgTexture *texture)
Definition: glslprogram.h:18
const mgTexture * getTexture() const
Textureをset/getする。
void get_color(float color[4]) const
mgVBOに対して描画データ作成後の情報を保持するためのクラス.
Definition: VBOLeaf.h:38
void setLineStipple(short int factor, GLushort pattern)
void setDrawType(mgGLSL::DrawType drawType)
DrawTypeをセットする
Definition: VBOLeaf.h:92