00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __GU_DisplayCache_H__
00024 #define __GU_DisplayCache_H__
00025
00026 #include "GU_API.h"
00027 #include <UT/UT_Vector3.h>
00028 #include <UT/UT_Matrix4.h>
00029
00030 class GU_DisplayAttribs;
00031
00032
00033
00034
00035 #define GU_GIVEUP 65535 // Something we can't deal with, so
00036
00037 #define GU_BEGINPOLY 65534 // Begin polygon
00038 #define GU_BEGINTRI 65533 // Begin triangle
00039 #define GU_BEGINQUAD 65532 // Begin quad
00040 #define GU_ENDPOLY 65531 // End polygon
00041 #define GU_ENDCOMMAND 65530 // End of all polygons
00042
00043 enum GU_CacheMode { GU_CACHEWIRE, GU_CACHESHADED };
00044
00045 class GU_API GU_DisplayMesh {
00046 public:
00047 GU_DisplayMesh() {}
00048 virtual ~GU_DisplayMesh() {}
00049
00050 void transform(const UT_Matrix4 &xform,
00051 const UT_Matrix4 &ixform,
00052 UT_Vector3 *P, UT_Vector3 *N, int npts);
00053
00054
00055
00056 virtual int iterateInit();
00057 virtual int iterateNext();
00058
00059
00060 virtual int extrapolateNormal();
00061
00062 virtual UT_Matrix4 *getLocalTransform();
00063 virtual int getRows() = 0;
00064 virtual int getCols() = 0;
00065 virtual int fillPN(UT_Vector3 *P, UT_Vector3 *N,
00066 int r0, int c0, int r1, int c1) = 0;
00067 };
00068
00069
00070 class GU_API GU_CacheFlags
00071 {
00072 public:
00073 GU_CacheFlags() {
00074 allDirty = 1;
00075 xformDirty = 0;
00076 xlateDirty = 0;
00077 uvDirty = 0;
00078 pushXform = 0;
00079 }
00080
00081 int isDirty(void) const
00082 { return allDirty|xformDirty|xlateDirty|uvDirty; }
00083 int howDirty(void) const
00084 { return allDirty+xformDirty+xlateDirty+uvDirty; }
00085 void clear(void)
00086 { allDirty = xformDirty = xlateDirty = uvDirty = 0; }
00087
00088
00089 unsigned allDirty:1,
00090 xformDirty:1,
00091 xlateDirty:1,
00092 uvDirty:1,
00093 pushXform:1;
00094 };
00095
00096 class GU_API GU_DisplayCache
00097 {
00098 public:
00099 GU_DisplayCache(void) { theLOD = -1.0f; }
00100 virtual ~GU_DisplayCache(void);
00101
00102
00103 int isDirty() const { return theFlags.isDirty(); }
00104 int isMessy() const { return theFlags.allDirty; }
00105 int howDirty()const { return theFlags.howDirty(); }
00106 void clear() { theFlags.clear(); }
00107 void dirty()
00108 {
00109 theFlags.clear();
00110 theFlags.pushXform = 0;
00111 theFlags.allDirty = 1;
00112 }
00113
00114
00115 int transformed() const { return theFlags.xformDirty; }
00116 void transform(const UT_Matrix4 &xform, int pushxform = 0);
00117
00118
00119 int translated(void) const { return theFlags.xlateDirty; }
00120 void translate(const UT_Vector3 &d);
00121
00122
00123 int uvChanged(void) const { return theFlags.uvDirty; }
00124 void uvChange(void);
00125
00126
00127
00128
00129
00130 int pushXform(void) const { return theFlags.pushXform; }
00131 void pushXform(int yesno) { theFlags.pushXform = yesno; }
00132
00133 float lod(void) const { return theLOD; }
00134 const UT_Matrix4 &transformation(void) const { return theXform; }
00135
00136 protected:
00137
00138 virtual void initializeData(void);
00139
00140
00141
00142
00143 virtual void assimilateXform(void);
00144
00145 UT_Vector3 &delta(void) { return theDelta; }
00146 const UT_Vector3 &delta(void) const { return theDelta; }
00147 UT_Matrix4 &transformation(void) { return theXform; }
00148 void lod(float l) { theLOD = l; }
00149
00150
00151 private:
00152 GU_CacheFlags theFlags;
00153 UT_Matrix4 theXform;
00154 UT_Vector3 theDelta;
00155 float theLOD;
00156 };
00157
00158
00159 class GU_API GU_CacheParms
00160 {
00161 public:
00162 GU_CacheParms(void) {}
00163 virtual ~GU_CacheParms(void);
00164
00165 void lod(float l) { theLOD = l; }
00166 float lod(void) const { return theLOD; }
00167 void mode(GU_CacheMode m) { theMode = m; }
00168 GU_CacheMode mode(void) const { return theMode; }
00169 void attributes(const GU_DisplayAttribs *a) { theAttribs=a;}
00170 const GU_DisplayAttribs *attributes() const { return theAttribs; }
00171
00172 private:
00173 float theLOD;
00174 GU_CacheMode theMode;
00175 const GU_DisplayAttribs *theAttribs;
00176 };
00177
00178 #endif