00001 /*======================================================================= 00002 * Copyright 1991-1996, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * 00005 * UNPUBLISHED -- Rights reserved under the copyright laws of the United 00006 * States. Use of a copyright notice is precautionary only and does not 00007 * imply publication or disclosure. 00008 * 00009 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: 00010 * Use, duplication or disclosure by the Government is subject to restrictions 00011 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights 00012 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or 00013 * in similar or successor clauses in the FAR, or the DOD or NASA FAR 00014 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., 00015 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 00016 * 00017 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY 00018 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, 00019 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY 00020 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON 00021 * GRAPHICS, INC. 00022 **=======================================================================*/ 00023 /*======================================================================= 00024 ** Author : Paul S. Strauss (MMM yyyy) 00025 **=======================================================================*/ 00026 /*======================================================================= 00027 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00028 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00029 *** *** 00030 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00031 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00032 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00033 *** *** 00034 *** RESTRICTED RIGHTS LEGEND *** 00035 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00036 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00037 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00038 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00039 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00040 *** *** 00041 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00042 *** BORDEAUX, FRANCE *** 00043 *** ALL RIGHTS RESERVED *** 00044 **=======================================================================*/ 00045 /*======================================================================= 00046 ** Modified by : VSG (MMM YYYY) 00047 **=======================================================================*/ 00048 00049 00050 #ifndef _SO_TRIANGLE_STRIP_SET_ 00051 #define _SO_TRIANGLE_STRIP_SET_ 00052 00053 #include <Inventor/fields/SoMFInt32.h> 00054 #include <Inventor/fields/SoSFNode.h> 00055 #include <Inventor/nodes/SoNonIndexedShape.h> 00056 #include <Inventor/nodes/SoVertexProperty.h> 00057 00059 // 00060 // Class: SoTriangleStripSet 00061 // 00062 // Triangle strip set node. Each strip in the set consists of n 00063 // vertices located at consecutive entries in the current 00064 // coordinates. The startIndex field gives the starting coordinate 00065 // index for the first strip. If materials or normals are bound to 00066 // vertices, they will begin at that index, as well; otherwise, they 00067 // will start at index 0. The number of vertices in each strip is 00068 // determined by successive entries in the numVertices field. 00069 // 00071 00072 class SoCoordinateElement; 00073 class SoVolumeTriangleStripSet; 00074 00075 #ifndef IV_STRICT 00076 // Deprecated feature; specifying USE_REST_OF_VERTICES as the last 00077 // value in the numVertices field will use all the points in the 00078 // coordinate array. 00079 #define SO_TRI_STRIP_SET_USE_REST_OF_VERTICES (-1) 00080 #endif 00081 00167 class SoTriangleStripSet : public SoNonIndexedShape { 00168 00169 SO_NODE_HEADER(SoTriangleStripSet); 00170 00171 public: 00172 // Fields 00177 SoMFInt32 numVertices; 00178 00182 SoTriangleStripSet(); 00183 00184 private: 00188 virtual void GLRender(SoGLRenderAction *action); 00189 00194 virtual void generateDefaultNormals(SoState *state, 00195 const SbVec3f *coords, 00196 int numCoords, 00197 SoNormalBundle *nb, 00198 SbBool storeRef = FALSE); 00199 00203 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action); 00204 00205 private: 00206 // returns the number of PARTS 00207 inline int getNumStrips(void) const { return numVertices.getNum(); } 00208 00209 // returns the number of PARTS 00210 inline int getNumParts(void) const { return getNumStrips(); }// PARTS are strips 00211 00212 // returns the number of FACES 00213 inline int getNumFaces(void) const { return totalNumVertices - 2 * getNumStrips(); } // FACES are triangles 00214 00215 // returns the number of vertices needed 00216 int getNumVerticesNeeded(void) const; 00217 00218 // Checks if enough vertices, normals, textureCoord, colors...etc... 00219 bool check_RenderVectors( SoState *state, bool bUseTexCoordsAnyway ); 00220 00221 00222 00223 static void initClass(); 00224 static void exitClass(); 00225 00226 //Typedef of pointer to method on TriangleStripSet; 00227 //This will be used to simplify declaration and initialization. 00228 typedef void (SoTriangleStripSet::*PMTSS)(SoGLRenderAction *); 00229 00230 // Compute transformations from Modelling coordinate to tangent space (facet space). 00231 virtual SbMatrix3* computeVtxTangentSpaceMat(const float *bumpTexCoords, int &numMat) const ; 00232 00233 private: 00234 00235 // Generates triangles representing strips 00236 virtual void generatePrimitives(SoAction *action); 00237 00238 SbBool m_usingUSE_REST; 00239 00240 SbBool m_nvNotifyEnabled; 00241 00242 void setNvNotifyEnabled(SbBool nvNotifyEnabled) 00243 { 00244 m_nvNotifyEnabled = nvNotifyEnabled; 00245 } 00246 00247 SbBool getNvNotifyEnabled(){return m_nvNotifyEnabled;} 00248 00249 //Free memory 00250 virtual void exitRender(SoState *state,int stateFlag, 00251 SoTextureCoordinateBundle *tcb, 00252 SoTextureCoordinate3Bundle *tc3b); 00253 00254 virtual void callDEBUGGLRender(SoGLRenderAction *action,uint32_t useTexCoordsAnyway); 00255 00256 virtual int getNumPrim(){return totalNumVertices;} 00257 00258 // count primitives 00259 virtual void countPrim(); 00260 00261 // return num vertices for test 00262 virtual int getNumVert(); 00263 00264 // auto caching test 00265 virtual int getMaxTestValueForAutoCache(){return totalNumVertices;} 00266 00267 // auto caching test 00268 virtual int getMinTestValueForAutoCache(){return totalNumVertices;} 00269 00270 // invalid test 00271 virtual SbBool numPrimInvalid(){return totalNumVertices < 0 ;} 00272 00273 // render function 00274 void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle); 00275 00276 // Overrides standard method to create an SoFaceDetail instance 00277 virtual SoDetail *createTriangleDetail(SoRayPickAction *action, 00278 const SoPrimitiveVertex *v1, 00279 const SoPrimitiveVertex *v2, 00280 const SoPrimitiveVertex *v3, 00281 SoPickedPoint *pp); 00282 00283 virtual ~SoTriangleStripSet(); 00284 00285 private: 00286 // Blow vpCache when vertexProperty field changes: 00287 virtual void notify(SoNotList *list); 00288 00289 private: 00290 // This stores the total number of vertices; we use this 00291 // information to influence Separator's auto-caching algorithm 00292 // (shapes with very few triangles should be cached because 00293 // traversing them can be expensive, shapes with lots of triangles 00294 // shouldn't be cached because they'll take up too much memory). 00295 int totalNumVertices; 00296 00297 static const int AUTO_CACHE_TSS_MIN_WITHOUT_VP; 00298 static const int AUTO_CACHE_TSS_MAX; 00299 }; 00300 00301 #endif /* _SO_TRIANGLE_STRIP_SET_ */ 00302 00303 00304