00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _CIvfGLPrimitive_h_
00026 #define _CIvfGLPrimitive_h_
00027
00028 #include <ivf/ivfconfig.h>
00029
00030 #include <ivf/IvfBase.h>
00031 #include <ivf/IvfShape.h>
00032 #include <ivf/IvfIndex.h>
00033 #include <ivf/IvfColor.h>
00034 #include <ivf/IvfMaterial.h>
00035 #include <ivf/IvfMaterialSet.h>
00036
00037 #include <ivfmath/IvfVec3d.h>
00038 #include <ivfmath/IvfPoint3d.h>
00039
00040 IvfSmartPointer(CIvfGLPrimitive);
00041
00079 class IVF_API CIvfGLPrimitive : public CIvfShape {
00080 private:
00081 bool m_useVertexNormals;
00082 protected:
00083 virtual void calcNormal(CIvfIndex* idx);
00084 std::vector<CIvfVec3d*> m_coordSet;
00085 std::vector<CIvfColor*> m_colorSet;
00086 std::vector<CIvfVec3d*> m_normalSet;
00087 CIvfMaterialSetPtr m_materialSet;
00088 std::vector<CIvfVec3d*> m_textureCoordSet;
00089
00090 std::vector<CIvfIndexPtr> m_coordIndexSet;
00091 std::vector<CIvfIndexPtr> m_colorIndexSet;
00092 std::vector<CIvfIndexPtr> m_normalIndexSet;
00093 std::vector<CIvfIndexPtr> m_textureIndexSet;
00094 std::vector<CIvfVec3d*> m_vertexNormalSet;
00095 std::vector<CIvfIndexPtr> m_vertexNormalIndexSet;
00096 std::vector<int> m_materialIndexSet;
00097 public:
00098 int getCoordIndexSetSize();
00100 CIvfGLPrimitive();
00101
00103 virtual ~CIvfGLPrimitive();
00104
00105 IvfClassInfo("CIvfGLPrimitive",CIvfShape);
00106
00108 void clear();
00109
00111 void addCoord(double x, double y, double z);
00112
00114 void addCoord(CIvfVec3d &coord);
00115
00117 void setCoord(int pos, double x, double y, double z);
00118
00120 void getCoord(long pos, double &x, double &y, double &z);
00121
00123 long getCoordSetSize();
00124
00126 void clearCoord();
00127
00129 void addMaterial(CIvfMaterial* material);
00130
00132 void clearMaterial();
00133
00135 int getMaterialSetSize();
00136
00138 CIvfMaterial* getMaterial(int pos);
00139
00141 CIvfMaterialSet* getMaterialSet();
00142
00144 void setMaterialSet(CIvfMaterialSet* materialSet);
00145
00147 void addMaterialIndex(int idx);
00148
00150 void clearMaterialIndex();
00151
00153 int getMaterialIndex(int pos);
00154
00160 void addCoordIndex(CIvfIndex* index);
00161
00163 CIvfIndex* getCoordIndex(long pos);
00164
00166 void clearCoordIndex();
00167
00169 void addColor(float red, float green, float blue);
00170
00172 void addColor(float red, float green, float blue, float alfa);
00173
00179 void setColor(int pos, float red, float green, float blue);
00180
00182 void setColor(int pos, float red, float green, float blue, float alfa);
00183
00185 void getColor(long pos, float &red, float &green, float &blue);
00186
00188 void getColor(int pos, float &red, float &green, float &blue, float &alfa);
00189
00191 void setAlfa(int pos, float alfa);
00192
00194 float getAlfa(int pos);
00195
00197 long getColorSetSize();
00198
00204 void addColorIndex(CIvfIndex* index);
00205
00207 CIvfIndex* getColorIndex(long pos);
00208
00210 void addNormal(double n1, double n2, double n3);
00211
00213 void getNormal(long pos, double &n1, double &n2, double &n3);
00214
00216 long getNormalSetSize();
00217
00223 void addNormalIndex(CIvfIndex* index);
00224
00226 CIvfIndex* getNormalIndex(long pos);
00227
00229 void addTextureCoord(double s, double t);
00230
00232 void setTextureCoord(int pos, double s, double t);
00233
00235 void getTextureCoord(long pos, double &s, double &t);
00236
00238 long getTextureCoordSetSize();
00239
00241 void clearTextureCoord();
00242
00248 void addTextureIndex(CIvfIndex* index);
00249
00251 CIvfIndex* getTextureIndex(long pos);
00252
00254 void refresh();
00255
00257 void setUseVertexNormals(bool flag);
00258
00260 bool getUseVertexNormals();
00261
00267 virtual void updateVertexNormals();
00268
00274 void updateBoundingSphere();
00275 };
00280 #endif