00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __GU_PolyFrame__
00020 #define __GU_PolyFrame__
00021
00022 #include "GU_API.h"
00023
00024 #include <UT/UT_Vector3.h>
00025 #include <string.h>
00026
00027
00028 typedef enum
00029 {
00030 GU_POLYFRAME_FIRST_EDGE,
00031 GU_POLYFRAME_TWO_EDGES,
00032 GU_POLYFRAME_CENTROID,
00033 GU_POLYFRAME_TEXTURE_COORDS,
00034 GU_POLYFRAME_STYLE__count
00035 } GU_PolyFrameStyle;
00036
00037 typedef enum
00038 {
00039 GU_POLYFRAME_TANGENT = 1,
00040 GU_POLYFRAME_BITANGENT = 1 << 1,
00041 } GU_PolyFrameVector;
00042
00043 typedef enum
00044 {
00045 GU_POLYFRAME_NO_ERROR,
00046 GU_POLYFRAME_CREATE_ATTRIBUTE_FAILED,
00047 GU_POLYFRAME_MISSING_DETAIL,
00048 GU_POLYFRAME_MISSING_TEXTURE_COORDS,
00049 GU_POLYFRAME_ERROR__count
00050 } GU_PolyFrameError;
00051
00052 class GU_API GU_PolyFrameParms
00053 {
00054 public:
00055 GU_PolyFrameParms()
00056 : style(GU_POLYFRAME_FIRST_EDGE)
00057 , which(0)
00058 , orthogonal(false)
00059 {
00060 ::memset(names, 0, sizeof(const char *) * 3);
00061 }
00062
00063 GU_PolyFrameStyle style;
00064
00065
00066 int which;
00067
00068
00069
00070
00071 bool orthogonal;
00072
00073
00074 const char *names[3];
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 };
00085
00086 class GB_PointGroup;
00087 class GB_PrimitiveGroup;
00088 class GEO_Hull;
00089 class GEO_Face;
00090 class GU_Detail;
00091 class UT_BitArray;
00092 class UT_String;
00093
00094 class GU_API GU_PolyFrame
00095 {
00096 public:
00097 GU_PolyFrame(GU_Detail *gdp);
00098 virtual ~GU_PolyFrame();
00099
00100 GU_Detail *getDetail() const { return myGdp; }
00101 void setDetail(GU_Detail *gdp) { myGdp = gdp; }
00102
00103 GU_PolyFrameError computeFrames(const GU_PolyFrameParms &parms,
00104 const GB_PointGroup *point_group = NULL,
00105 const GB_PrimitiveGroup *prim_group
00106 = NULL);
00107
00108 private:
00109 void computeFrames(GEO_Face *prim,
00110 UT_BitArray *uncomputed,
00111 int &nleft);
00112
00113
00114
00115
00116 GU_PolyFrameError detailHook();
00117 void primitiveHook();
00118
00119 void setFrame();
00120
00121
00122 void computeFirstEdgeFrame();
00123 void computeTwoEdgesFrame();
00124 void computeCentroidFrame();
00125 void computeTexCoordsFrame();
00126 void computeDefaultFrame();
00127
00128
00129 static void computeCentroid(const GEO_Face *prim,
00130 UT_Vector3 ¢roid);
00131 static void computeMeshCentroid(const GEO_Hull *hull,
00132 int vertex_no,
00133 UT_Vector3 ¢roid);
00134 static void createPointNormals(GU_Detail *gdp, int offset);
00135 static int findAttrib(const GU_Detail *gdp, const char *name);
00136 static int findOrAddAttrib(GU_Detail *gdp,
00137 const char *name,
00138 bool per_vertex,
00139 bool &created);
00140 static const char *getLayeredAttribName(const GU_Detail *gdp,
00141 const char *name);
00142 static bool isStylePerVertex(GU_PolyFrameStyle style);
00143 static void makeOrthogonal(UT_Vector3 *frame);
00144
00145 static int theMinVertices[];
00146 GU_Detail *myGdp;
00147 const GU_PolyFrameParms *myParms;
00148 const GB_PointGroup *myPointGroup;
00149 const GB_PrimitiveGroup *myPrimGroup;
00150 GEO_Face *myCurPrim;
00151 int myCurVertexNo;
00152 int myCurPointNo;
00153 UT_Vector3 myFrame[3];
00154
00155
00156 UT_Vector3 myCentroid;
00157 int myOffsets[3];
00158 int myUvOffset;
00159 bool myPerVertex;
00160 bool myUvPerVertex;
00161 bool myAttribsCreated[3];
00162 };
00163
00164 #endif
00165