00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Jeff Lait 00008 * Side Effects 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: Geometry library (C++) 00015 * 00016 * COMMENTS: Display cache for triangular meshes. 00017 * 00018 */ 00019 00020 #ifndef __GU_TriMeshCache_H__ 00021 #define __GU_TriMeshCache_H__ 00022 00023 #include "GU_API.h" 00024 #include <UT/UT_BoundingSphere.h> 00025 #include <UT/UT_IntArray.h> 00026 #include <GB/GB_Attribute.h> 00027 #include "GU_DisplayCache.h" 00028 00029 class GU_Detail; 00030 class GU_TriMeshCacheParms; 00031 class GEO_PrimPoly; 00032 00033 00034 class GU_API GU_TriMeshVertex 00035 { 00036 public: 00037 UT_Vector3 myPos; 00038 UT_Vector3 myNml; 00039 int myParent; 00040 int myLevel; 00041 int myPt; // Offset of point 00042 }; 00043 00044 class GU_API GU_TriMeshTriangle 00045 { 00046 public: 00047 int isDegenerate() const 00048 { 00049 return (myIv[0] == myIv[1] || myIv[1] == myIv[2] 00050 || myIv[0] == myIv[2]); 00051 } 00052 UT_Vector3 computeNormal(GU_TriMeshVertex *vertexlist) const; 00053 int matchingEdge(int p1, int p2) const; 00054 int myIv[3]; 00055 int myPolyNum; 00056 }; 00057 00058 class GU_API GU_TriMeshTStrip 00059 { 00060 public: 00061 GU_TriMeshTStrip() { myNext = 0; } 00062 ~GU_TriMeshTStrip(); 00063 int myPolyNum; // Polygon used for attributes. 00064 UT_IntArray myIv; // My points. 00065 00066 GU_TriMeshTStrip *myNext; 00067 }; 00068 00069 // Describes a specific LOD 00070 class GU_API GU_TriMeshLOD 00071 { 00072 public: 00073 GU_TriMeshLOD() { myTrilist = 0; myNext = 0; myTStrips = 0; myOwnData = 1; } 00074 ~GU_TriMeshLOD() 00075 { 00076 if (myOwnData) 00077 { 00078 delete [] myTrilist; 00079 delete myTStrips; 00080 } 00081 delete myNext; 00082 } 00083 00084 float myPercent; // What percentage reduction this is 00085 00086 int myNumTri; 00087 int myOwnData; // Do we own the data? 00088 GU_TriMeshTriangle *myTrilist; // List o' tris. 00089 GU_TriMeshTStrip *myTStrips; 00090 00091 GU_TriMeshLOD *myNext; 00092 }; 00093 00094 class GU_API GU_TriMeshCache : public GU_DisplayCache 00095 { 00096 public: 00097 GU_TriMeshCache(void); 00098 virtual ~GU_TriMeshCache(void); 00099 00100 // Build the cache. 00101 int refresh(GU_TriMeshCacheParms &parms); 00102 00103 // Builds the strip list: 00104 void buildTStrip(); 00105 00106 UT_Vector3 &vertex(int idx) const 00107 { return myVertexlist[idx].myPos; } 00108 UT_Vector3 &normal(int idx) const 00109 { return myVertexlist[idx].myNml; } 00110 00111 GU_Detail *myGDP; 00112 00113 GU_TriMeshLOD *myBaseLOD; 00114 GU_TriMeshLOD *myLastLOD; 00115 int myNumVertex; 00116 int myPolyOnly; 00117 float myLODFactor; 00118 GU_TriMeshVertex *myVertexlist; 00119 UT_BoundingSphere mySphere; 00120 }; 00121 00122 class GU_API GU_TriMeshCacheParms : public GU_CacheParms 00123 { 00124 public: 00125 GU_TriMeshCacheParms(void) { myGDP = 0; } 00126 virtual ~GU_TriMeshCacheParms(void); 00127 00128 void geometry(GU_Detail *gdp) { myGDP = gdp; } 00129 GU_Detail *geometry(void) const { return myGDP; } 00130 00131 GU_Detail *myGDP; 00132 float myCutRate; // Rate of atrophy 00133 float myDistance; 00134 float myMinPercent; 00135 float myBorderWeight; 00136 float myLengthWeight; 00137 int myPolyOnly; 00138 00139 }; 00140 00141 #endif 00142
1.5.9