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_VRMLINDEXED_SHAPE_ 00051 #define _SO_VRMLINDEXED_SHAPE_ 00052 00053 #include <Inventor/fields/SoMFInt32.h> 00054 #include <Inventor/VRMLnodes/SoVRMLVertexShape.h> 00055 00056 00057 #if defined(OIV_IGNORE_VRML_DEPRECATED) 00058 #include <SoDeprecationRules.h> 00059 #pragma push_macro("SoDEPRECATED_CLASS") 00060 #pragma push_macro("SoDEPRECATED_TYPEDEF") 00061 #undef SoDEPRECATED_CLASS 00062 #undef SoDEPRECATED_TYPEDEF 00063 #define SoDEPRECATED_CLASS(x,y) 00064 #define SoDEPRECATED_TYPEDEF(x,y) 00065 #endif 00066 00068 // 00069 // Class: SoVRMLIndexedShape 00070 // 00071 // Abstract indexed shape node class. All nodes derived from this 00072 // (such as SoVRMLIndexedFaceSet and SoVRMLIndexedLineSet) are shapes 00073 // that are constructed from vertices defined by indexing into the 00074 // current coordinates. The coordinate indices are stored in the 00075 // coordIndex field, which is used by all subclasses. 00076 // 00077 // One rule is used: all coordinate indices less than 0 may be used 00078 // for special purposes, such as to denote the end of a face or 00079 // polyline. This means that all indices < 0 can be ignored safely 00080 // when looking at vertices. 00081 // 00082 // Depending on the current material, normal, and texture coordinate 00083 // binding values, materials, normals, and texture coordinates may be 00084 // accessed in order or may be indexed using the colorIndex, 00085 // normalIndex, and textureCoordIndex fields. 00086 // 00088 class SoDEPRECATED SoVRMLIndexedShape : public SoVRMLVertexShape { 00126 00127 SO_NODE_ABSTRACT_HEADER(SoVRMLIndexedShape); 00128 00129 public: 00135 SoMFInt32 coordIndex; 00142 SoMFInt32 colorIndex; 00149 SoMFInt32 normalIndex; 00156 SoMFInt32 texCoordIndex; 00157 00158 private: 00159 00160 // This handles bounding box computation for all shapes derived 00161 // from this class. It sets the bounding box to contain all 00162 // vertices of the shape, assuming that the shape uses the 00163 // coordinates indexed by all non-negative values in the 00164 // coordIndex field. It also sets the center to the average of the 00165 // vertices' coordinates. 00166 virtual void computeBBox(SoAction *action, SbBox3f &box, 00167 SbVec3f ¢er); 00168 00169 private: 00170 static void initClass(); 00171 static void exitClass(); 00172 00173 private: 00174 // Constructor - makes this abstract 00175 SoVRMLIndexedShape(); 00176 00177 // Returns TRUE if texture coordinates should be indexed 00178 static SbBool areTexCoordsIndexed(SoAction *action); 00179 00180 // Starting at a given index in the coordIndex array, figure out 00181 // how many vertices there are before either the end of the array 00182 // or the next 'border' index 00183 int getNumVerts(int startCoord); 00184 00185 // Setup for fast rendering. This should be called by subclasses, 00186 // which can then use the textureI/colorI/normalI arrays (which 00187 // will either point to one of the coordIndex arrays, or to a 00188 // consective array of integers. This must be called AFTER the 00189 // vpCache has been filled in. 00190 void setupIndices(int numParts, int numFaces, 00191 SbBool needNormals, SbBool needTexCoords); 00192 00193 // These must not be called unless setupIndices has been called first: 00194 const int32_t * getNormalIndices() 00195 { return (normalI ? normalI : consecutiveIndices); } 00196 const int32_t * getColorIndices() 00197 { return (colorI ? colorI : consecutiveIndices); } 00198 const int32_t * getTexCoordIndices() 00199 { return (texCoordI ? texCoordI : consecutiveIndices); } 00200 00201 // Returns the SoNormalBindingElement normalBinding enum based on 00202 // the normal field and normalPerVertex field. 00203 00204 // Keep indices up to date if things change 00205 virtual void notify(SoNotList *list); 00206 00207 virtual ~SoVRMLIndexedShape(); 00208 00209 private: 00210 // Internal routines used to allocate sequential indices so the 00211 // same rendering loops can be used for indexed or non-indexed 00212 // cases: 00213 void allocateSequential(int howMany); 00214 int32_t* allocateSequentialWithHoles(); 00215 00216 // These are filled in by the setupIndices routine: 00217 const int32_t *texCoordI; 00218 const int32_t *colorI; 00219 const int32_t *normalI; 00220 static int32_t *consecutiveIndices; 00221 static int numConsecutiveIndicesAllocated; 00222 00223 unsigned char materialBinding; 00224 unsigned char normalBinding; 00225 unsigned char texCoordBinding; 00226 }; 00227 00228 00229 00230 #if defined(OIV_IGNORE_VRML_DEPRECATED) 00231 #pragma pop_macro("SoDEPRECATED_TYPEDEF") 00232 #pragma pop_macro("SoDEPRECATED_CLASS") 00233 #endif 00234 00235 #endif /* _SO_VRMLINDEXED_SHAPE_ */ 00236