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 _SO_INDEXED_TRIANGLE_SET_
00026 #define _SO_INDEXED_TRIANGLE_SET_
00027
00028 #include <Inventor/nodes/SoIndexedShape.h>
00029
00030 class SoNormalBundle;
00031 class SoCoordinateElement;
00032 class SoShapeStyleElement;
00033 class SoVolumeIndexedTriangleSet;
00034
00035
00117 class SoIndexedTriangleSet : public SoIndexedShape {
00118
00119 SO_NODE_HEADER(SoIndexedTriangleSet);
00120
00121 public:
00122
00123
00127 SoIndexedTriangleSet();
00128
00129 private:
00130
00131
00133 virtual void GLRender(SoGLRenderAction *action);
00134
00136 virtual void generateDefaultNormals(SoState *state,
00137 const SbVec3f *coords,
00138 int numCoords,
00139 SoNormalBundle *nb,
00140 SbBool storeRef = FALSE);
00141
00143 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action);
00144
00145 private:
00146
00148 static void initClass();
00149
00151 static void exitClass();
00152
00153 virtual int getNumNeededNormals(SoState *state);
00154
00155 private:
00156
00157 enum Binding {
00158 OVERALL, PER_FACE, PER_FACE_INDEXED, PER_VERTEX,
00159 PER_VERTEX_INDEXED
00160 };
00161
00162 virtual SbBool shouldGenerateTexture3DCoordinates(){return TRUE;}
00163
00164 virtual void callSetupIndices(const SoShapeStyleElement* shapeStyle,uint32_t useTexCoordsAnyway);
00165
00166
00167 virtual SbBool checkTex3Coords(){return TRUE;}
00168
00169
00170
00171 virtual int getNumPrim()
00172 {
00173 if (totalNumVertices==-1)
00174 setupNumTrisQuadsFaces();
00175 return totalNumVertices;
00176 }
00177
00178 int getNumPrim(int& _numTris )
00179 {
00180 if (totalNumVertices==-1)
00181 setupNumTrisQuadsFaces();
00182 _numTris = numTris;
00183 return totalNumVertices;
00184 }
00185
00186 virtual void countPrim(){setupNumTrisQuadsFaces();}
00187
00188 virtual SbBool numPrimInvalid(){return numTris < 0 ;}
00189
00190
00191 virtual void generatePrimitives(SoAction *action);
00192
00193
00194 virtual void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle);
00195
00196
00197 virtual SoDetail * createTriangleDetail(SoRayPickAction *action,
00198 const SoPrimitiveVertex *v1,
00199 const SoPrimitiveVertex *v2,
00200 const SoPrimitiveVertex *v3,
00201 SoPickedPoint *pp);
00202
00203
00204 virtual void notify(SoNotList *list);
00205
00206
00207 virtual ~SoIndexedTriangleSet();
00208
00209 private:
00210
00211
00212
00213 bool doRenderingVBO(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle);
00214 bool doRenderingNonIndexedVBO(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle);
00215
00216
00217 Binding savedNormalBinding;
00218
00219
00220 static Binding getMaterialBinding(SoAction *action);
00221 Binding getNormalBinding(SoAction *action, SoNormalBundle *nb);
00222
00223
00224 void setupNumTrisQuadsFaces();
00225
00226
00227 int numTris, totalNumVertices;
00228
00229
00230 void buildPerFaceNormals(SoState *state,const SbVec3f *coords, const int numCoords, SoNormalBundle *nb);
00231
00232
00233 int32_t *buildConnectivity(const SbVec3f *coords, const int numCoords);
00234
00235 private:
00236 friend class SoVolumeIndexedTriangleSetDl;
00237 friend class SoVolumeIndexedTriangleSet;
00238 };
00239
00240 #endif
00241
00242
00243