00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_INDEXED_QUAD_MESH_
00025 #define _SO_INDEXED_QUAD_MESH_
00026
00027 #include <Inventor/fields/SoSFInt32.h>
00028 #include <Inventor/nodes/SoIndexedShape.h>
00029
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00046
00134 class SoIndexedQuadMesh : public SoIndexedShape {
00135
00136 SO_NODE_HEADER(SoIndexedQuadMesh);
00137
00138 public:
00139
00143 SoSFInt32 verticesPerColumn;
00147 SoSFInt32 verticesPerRow;
00148
00152 SoIndexedQuadMesh();
00153
00154 private:
00155
00156 virtual void GLRender(SoGLRenderAction *action);
00157
00158
00159
00160 virtual void generateDefaultNormals(SoState *state,
00161 const SbVec3f *coords,
00162 int numCoords,
00163 SoNormalBundle *nb,
00164 SbBool storeRef = FALSE);
00165
00166 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action);
00167
00168 private:
00169 int getNumRows(void) const;
00170 int getNumCols(void) const;
00171 int getNumQuads(void) const;
00172 int getNumMeshVerts(void) const;
00173
00174
00175 inline int getNumParts(void) const { return getNumRows(); }
00176
00177
00178 inline int getNumFaces(void) const { return getNumQuads(); }
00179
00180
00181 int getNumVerticesNeeded(void) { return getNumMeshVerts(); }
00182
00183
00184 bool check_RenderVectors( SoState *state, bool bUseTexCoordsAnyway );
00185
00186
00187 void generateDefaultNormals_QuadMesh(SoState *state, const SbVec3f *vecPQuadCoord[], SbVec3f normals[] );
00188
00189 virtual void callDEBUGGLRender(SoGLRenderAction *action,uint32_t useTexCoordsAnyway);
00190
00191 static void initClass();
00192 static void exitClass();
00193 private:
00194
00195 enum Binding {
00196 OVERALL,
00197 PER_ROW, PER_ROW_INDEXED,
00198 PER_QUAD, PER_QUAD_INDEXED,
00199 PER_VERTEX, PER_VERTEX_INDEXED
00200 };
00201
00202 virtual void generatePrimitives(SoAction *action);
00203
00204
00205 virtual SoDetail *createTriangleDetail(SoRayPickAction *action,
00206 const SoPrimitiveVertex *v1,
00207 const SoPrimitiveVertex *v2,
00208 const SoPrimitiveVertex *v3,
00209 SoPickedPoint *pp);
00210
00211 virtual void callSetupIndices(const SoShapeStyleElement* shapeStyle,uint32_t useTexCoordsAnyway);
00212
00213
00214 virtual int getMaxTestValueForAutoCache(){return totalNumVertices;}
00215
00216
00217 virtual int getMinTestValueForAutoCache(){return verticesPerColumn.getValue();}
00218
00219
00220 virtual void countPrim(){
00221 totalNumVertices = verticesPerColumn.getValue()* verticesPerRow.getValue();}
00222
00223
00224 virtual int getNumPrim(){return totalNumVertices;}
00225
00226
00227 virtual SbBool numPrimInvalid(){return totalNumVertices < 0 ;}
00228
00229
00230 void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle);
00231
00232 virtual ~SoIndexedQuadMesh();
00233
00234 private:
00235
00236
00237 static Binding getMaterialBinding(SoAction *action);
00238 Binding getNormalBinding(SoAction *action, SoNormalBundle* nb);
00239
00240
00241 Binding savedNormalBinding;
00242
00243
00244 static int getBindIndex(Binding binding, int vert, int row, int quad, const int32_t *indices);
00245
00246 virtual int getNumNeededNormals(SoState *state);
00247
00248
00249 virtual void notify(SoNotList *list);
00250
00251
00252
00253
00254
00255
00256 int totalNumVertices;
00257 };
00258
00259 inline int SoIndexedQuadMesh::getNumNeededNormals(SoState *)
00260 {
00261 return verticesPerColumn.getValue() * verticesPerRow.getValue();
00262 }
00263
00264
00265 #endif
00266
00267
00268