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 bezier surfaces. 00017 * 00018 */ 00019 00020 #ifndef __GU_PrimTriBezierCache_H__ 00021 #define __GU_PrimTriBezierCache_H__ 00022 00023 #include "GU_API.h" 00024 #include <UT/UT_Vector4.h> 00025 #include <UT/UT_Vector4Array.h> 00026 #include <UT/UT_Vector3Array.h> 00027 #include <GB/GB_Attribute.h> 00028 #include "GU_AttribCache.h" 00029 #include "GU_DisplayCache.h" 00030 00031 class GEO_TPSurf; 00032 class GU_Detail; 00033 class GEO_Detail; 00034 class GEO_Point; 00035 class GU_PrimTriBezierCacheParms; 00036 class GU_PrimTriBezier; 00037 00038 class GU_API GU_PrimTriBezierCache : public GU_DisplayCache 00039 { 00040 public: 00041 GU_PrimTriBezierCache(void); 00042 virtual ~GU_PrimTriBezierCache(void); 00043 00044 // Build the cache. 00045 int refresh(GU_PrimTriBezierCacheParms &parms); 00046 00047 // Find out how the cache was built: wire or shaded. 00048 GU_CacheMode builtAs(void) const { return theMode; } 00049 00050 // Get the curve and point counts given the internal lod, the build type, 00051 // and the mesh's "wrap" characteristics. 00052 int getFakeOrder() const; 00053 00054 int colorOffset (void) const { return theCdOffset; } 00055 int alphaOffset (void) const { return theAlphaOffset; } 00056 int textureOffset(void) const { return theTxtOffset; } 00057 00058 // we only worry about alpha if there is color as well 00059 int hasAttributes(GU_CacheMode mode) const 00060 { 00061 return (theCdOffset < 0 && mode != GU_CACHESHADED) 00062 ? 0 00063 : theCdOffset >= 0 || theTxtOffset>= 0 || 00064 theAlphaOffset >= 0; 00065 } 00066 00067 // Create point if req'd. 00068 GEO_Point *getPointAtIndex(GU_Detail *gdp, int index); 00069 00070 UT_Vector4 &getPos(int r, int c) 00071 { return thePoints((myFakeOrder-r)*(myFakeOrder-r-1)/2 + c); } 00072 UT_Vector3 &getNml(int r, int c) 00073 { return theNormals((myFakeOrder-r)*(myFakeOrder-r-1)/2 + c); } 00074 00075 const UT_Vector4Array &points () const { return thePoints; } 00076 const UT_Vector3Array &normals() const { return theNormals;} 00077 const GU_AttribCache &attribs() const { return theAttribs;} 00078 00079 protected: 00080 // Clear the cache data and other related info: 00081 virtual void initializeData(void); 00082 00083 // If pushXform is set, the cache data has not been updated with the 00084 // latest xform matrix. This method makes sure the data _is_ updated, 00085 // and turns off the flag. 00086 virtual void assimilateXform(void); 00087 00088 private: 00089 UT_Vector4Array thePoints; 00090 UT_Vector3Array theNormals; 00091 GU_AttribCache theAttribs; 00092 GU_CacheMode theMode; 00093 00094 int myFakeOrder; // THe order we look like. 00095 int theCdOffset, theTxtOffset; // pt color & textture offsets 00096 int theAlphaOffset; // alpha offset 00097 int theAttribSize; 00098 int theAttribDict; 00099 00100 // Resize the attribute data and the attribute list (if necessary): 00101 void resizeAttributes(GEO_Detail *gdp, int ptattrib = 1); 00102 00103 // Fill the array of float offsets based on what attributes are set. 00104 void buildFloatOffsets(void); 00105 00106 // Evaluate the surface because we know it's dirty. Return 0 if OK. 00107 int evaluateSurface(GU_PrimTriBezier *tribez); 00108 00109 // Evaluate the normals of the whole evaluated surface. 00110 void evaluateNormals(); 00111 }; 00112 00113 class GU_API GU_PrimTriBezierCacheParms : public GU_CacheParms 00114 { 00115 public: 00116 GU_PrimTriBezierCacheParms(void) {} 00117 virtual ~GU_PrimTriBezierCacheParms(void); 00118 00119 void triangle(GU_PrimTriBezier *tribez) { myTribez = tribez; } 00120 GU_PrimTriBezier *triangle(void) const { return myTribez; } 00121 00122 private: 00123 GU_PrimTriBezier *myTribez; 00124 }; 00125 00126 #endif
1.5.9