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 ** Modified by : Gavin Bell (MMM yyyy) 00026 **=======================================================================*/ 00027 /*======================================================================= 00028 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00029 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00030 *** *** 00031 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00032 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00033 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00034 *** *** 00035 *** RESTRICTED RIGHTS LEGEND *** 00036 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00037 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00038 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00039 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00040 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00041 *** *** 00042 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00043 *** BORDEAUX, FRANCE *** 00044 *** ALL RIGHTS RESERVED *** 00045 **=======================================================================*/ 00046 /*======================================================================= 00047 ** Modified by : VSG (MMM YYYY) 00048 **=======================================================================*/ 00049 00050 00051 #ifndef _SO_FACE_SET_ 00052 #define _SO_FACE_SET_ 00053 00054 #include <Inventor/SbLinear.h> 00055 #include <Inventor/fields/SoMFInt32.h> 00056 #include <Inventor/nodes/SoNonIndexedShape.h> 00057 00059 // 00060 // Class: SoFaceSet 00061 // 00062 // Set of faces. Each face consists of 3 or more vertices, taken in 00063 // order from the current coordinates. The startIndex field gives the 00064 // starting coordinate index for the first face. The number of 00065 // vertices in each face is determined by successive entries in the 00066 // numVertices field. 00067 // 00069 00070 // This value, when used in the numVertices field, means that the 00071 // corresponding face should use the rest of the vertices 00072 #define SO_FACE_SET_USE_REST_OF_VERTICES (-1) 00073 00074 class SoCoordinateElement; 00075 class SoNormalBundle; 00076 class SoState; 00077 class SoVolumeFaceSet; 00078 00225 class SoFaceSet : public SoNonIndexedShape { 00226 00227 SO_NODE_HEADER(SoFaceSet); 00228 00229 public: 00230 00234 SoMFInt32 numVertices; 00235 00239 SoFaceSet(); 00240 00241 private: 00242 // Implement actions 00243 virtual void GLRender(SoGLRenderAction *action); 00244 00245 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action); 00246 00247 // Generates default normals using the given normal bundle. 00248 // Returns TRUE. 00249 virtual void generateDefaultNormals(SoState *state, 00250 const SbVec3f *coords, 00251 int numCoords, 00252 SoNormalBundle *nb, 00253 SbBool storeRef = FALSE); 00254 00255 // Compute transformations from Modelling coordinate to tangent space (facet space). 00256 virtual SbMatrix3* computeVtxTangentSpaceMat(const float *bumpTexCoords, int &numMat) const ; 00257 00258 private: 00259 static void initClass(); 00260 static void exitClass(); 00261 00262 private: 00263 00264 // This enum is used to indicate the current material or normal binding 00265 enum Binding { 00266 OVERALL, PER_FACE, PER_VERTEX 00267 }; 00268 00269 //shape must check shape hints in GlRender 00270 virtual SbBool shouldCheckShapeHints(){ return TRUE;} 00271 00272 //Test function 00273 virtual SbBool shapeHintsTest(){ return (numQuads > 0 || numPolys > 0);} 00274 00275 virtual void callDEBUGGLRender(SoGLRenderAction *action,uint32_t useTexCoordsAnyway); 00276 00277 //Free memory 00278 virtual void exitRender(SoState *state,int stateFlag, 00279 SoTextureCoordinateBundle *tcb, 00280 SoTextureCoordinate3Bundle *tc3b); 00281 00282 // keep track of whether we are using USE_REST_OF_VERTICES 00283 SbBool m_usingUSE_REST; 00284 00285 SbBool m_nvNotifyEnabled; 00286 00287 void setNvNotifyEnabled(SbBool _nvNotifyEnabled) 00288 { 00289 m_nvNotifyEnabled = _nvNotifyEnabled; 00290 } 00291 00292 SbBool getNvNotifyEnabled(){return m_nvNotifyEnabled;} 00293 00294 virtual int getMaxTestValueForAutoCache(){return totalNumVertices;} 00295 00296 virtual int getMinTestValueForAutoCache(){return totalNumVertices;} 00297 00298 virtual int getNumPrim(){return totalNumVertices;} 00299 00300 virtual int getNumVert(); 00301 00302 virtual void countPrim(){setupNumTrisQuadsFaces();} 00303 00304 virtual SbBool numPrimInvalid(){return numTris < 0 ;} 00305 00306 // Generates triangles representing faces 00307 virtual void generatePrimitives(SoAction *action); 00308 00309 // render function 00310 void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle); 00311 00312 // Overrides standard method to create an SoFaceDetail instance 00313 virtual SoDetail * createTriangleDetail(SoRayPickAction *action, 00314 const SoPrimitiveVertex *v1, 00315 const SoPrimitiveVertex *v2, 00316 const SoPrimitiveVertex *v3, 00317 SoPickedPoint *pp); 00318 00319 ~SoFaceSet(); 00320 00321 private: 00322 // returns the number of PARTS 00323 inline int getNumParts(void) const { return numTris + numQuads + numPolys; } 00324 00325 // returns the number of FACES 00326 inline int getNumFaces(void) const { return numTris + numQuads + numPolys; } 00327 00328 // returns the number of vertices needed 00329 int getNumVerticesNeeded(void) const; 00330 00331 // Checks if enough vertices, normals, textureCoord, colors...etc... 00332 bool check_RenderVectors( SoState *state, bool bUseTexCoordsAnyway ); 00333 00334 // set numTris/Quads/Faces to -1, checks SO_USE_REST_OF_VERTICES 00335 // when notified 00336 virtual void notify(SoNotList *list); 00337 00338 private: 00339 00340 // used internally by doRendering 00341 // return true if shape was correctly drawn. 00342 bool doRenderingVBO(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle); 00343 00344 // Returns current material or normal binding from action's state 00345 static Binding getMaterialBinding(SoAction *action); 00346 Binding getNormalBinding(SoAction *action, SoNormalBundle *nb); 00347 00348 virtual int getNumNeededNormals(SoState *state); 00349 00350 // Set number of triangles/quads/faces, based on coordIndex array. 00351 void setupNumTrisQuadsFaces(); 00352 00353 // Number of triangles, quads, (n>4)-vertex faces, total vertices 00354 int numTris, numQuads, numPolys, totalNumVertices; 00355 00356 static const int AUTO_CACHE_FS_MIN_WITHOUT_VP; 00357 00358 static const int AUTO_CACHE_FS_MAX; 00359 }; 00360 00361 #endif /* _SO_FACE_SET_ */ 00362 00363