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 * Cristin Barghiel 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 spline curves. 00017 * 00018 */ 00019 00020 #ifndef __GU_CurveCache_H__ 00021 #define __GU_CurveCache_H__ 00022 00023 #include "GU_API.h" 00024 #include <UT/UT_Vector4.h> 00025 #include <UT/UT_Vector4Array.h> 00026 #include <GB/GB_Attribute.h> 00027 #include "GU_AttribCache.h" 00028 #include "GU_DisplayCache.h" 00029 00030 class GEO_Curve; 00031 class GU_CurveCacheParms; 00032 00033 00034 class GU_API GU_CurveCache : public GU_DisplayCache 00035 { 00036 public: 00037 GU_CurveCache(void); 00038 virtual ~GU_CurveCache(void); 00039 00040 // Record the domain interval within which the curve needs to be recomputed 00041 void touchDomain(int ustart_idx, int ustop_idx); 00042 00043 // Build the cache. 00044 int refresh(GU_CurveCacheParms &parms); 00045 00046 int colorOffset (void) const { return theCdOffset; } 00047 int textureOffset(void) const { return theTxtOffset; } 00048 int tangentOffset(void) const { return theTangentOffset; } 00049 00050 int hasAttributes(void) const { return theCdOffset >= 0 || 00051 theTxtOffset >= 0 || 00052 theTangentOffset >= 0; } 00053 00054 // Get the tesselation commands, if any: 00055 const unsigned short *commands() const { return theCommands; } 00056 00057 // Find out how the cache was built: wire or shaded. 00058 GU_CacheMode builtAs(void) const { return theMode; } 00059 00060 UT_Vector3 *normal(void) const { return theNormal; } 00061 00062 const UT_Vector4Array &points() const { return thePoints; } 00063 const GU_AttribCache &colors() const 00064 { return theAttribs; } 00065 const UT_Vector4Array &tangents() const 00066 { return theTangents; } 00067 00068 protected: 00069 // Clear the cache data and other related info: 00070 virtual void initializeData(void); 00071 00072 // If pushXform is set, the cache data has not been updated with the 00073 // latest xform matrix. This method makes sure the data _is_ updated, 00074 // and turns off the flag. 00075 virtual void assimilateXform(void); 00076 00077 private: 00078 UT_Vector4Array thePoints; 00079 GU_AttribCache theAttribs; 00080 UT_Vector4Array theTangents; 00081 GU_CacheMode theMode; 00082 00083 UT_Vector3 *theNormal; 00084 UT_Vector3 *theSavedNormal; 00085 int theUMin, theUMax; // knot indices 00086 int theBreakIdx; // cached start breakpoint 00087 int theCdOffset, theTxtOffset; // pt color & texture offsets 00088 int theTangentOffset; // tangent offsets 00089 int theAttribSize; 00090 int theAttribDict; 00091 int theHasTangents; 00092 00093 unsigned short *theCommands; 00094 int theCommandSize; 00095 00096 // Resize the attribute data and the attribute list (if necessary): 00097 void resizeAttributes(GEO_Detail *gdp); 00098 00099 // Rebuild the tesselation assuming the curve is closed and we're shaded: 00100 void refreshTessellation(int maxsides); 00101 00102 // Rebuild our cache of tangents: 00103 void refreshTangents(const GEO_Curve *curve, int poffset); 00104 }; 00105 00106 class GU_API GU_CurveCacheParms : public GU_CacheParms 00107 { 00108 public: 00109 GU_CurveCacheParms(void) {} 00110 virtual ~GU_CurveCacheParms(void); 00111 00112 void curve(GEO_Curve *curve) { theCurve = curve; } 00113 GEO_Curve *curve(void) const { return theCurve; } 00114 void maxSides(int sides) { theMaxSides = sides; } 00115 int maxSides(void) const { return theMaxSides; } 00116 00117 void needTangents(bool val) { theNeedTangents = val; } 00118 bool needTangents() const { return theNeedTangents; } 00119 00120 private: 00121 GEO_Curve *theCurve; 00122 int theMaxSides; 00123 bool theNeedTangents; 00124 00125 }; 00126 00127 #endif
1.5.9