00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __GU_PolyExtrude_h__
00020 #define __GU_PolyExtrude_h__
00021
00022 #include "GU_API.h"
00023 #include <UT/UT_Matrix4.h>
00024 #include <UT/UT_PtrArray.h>
00025 #include <UT/UT_Vector3.h>
00026
00027 class UT_IntArray;
00028 class GB_BaseGroup;
00029 class GB_Edge;
00030 class GB_PointGroup;
00031 class GB_PrimitiveGroup;
00032 class GEO_Face;
00033 class GEO_Point;
00034 class GEO_PointRefArray;
00035 class GEO_PointTree;
00036 class GU_Detail;
00037 class GU_PrimPoly;
00038
00039 enum GU_PolyExtrudeConsolidate
00040 {
00041 GU_EXTRUDE_CONSOLIDATE_FRONT = 0x01,
00042 GU_EXTRUDE_CONSOLIDATE_BACK = 0x02,
00043 GU_EXTRUDE_CONSOLIDATE_SIDE = 0x04,
00044 GU_EXTRUDE_CONSOLIDATE_ALL = 0x08,
00045
00046 GU_EXTRUDE_CONSOLIDATE_ALLPERPOINT = 0x10,
00047
00048 GU_EXTRUDE_CONSOLIDATE_PERFACE = (GU_EXTRUDE_CONSOLIDATE_FRONT |
00049 GU_EXTRUDE_CONSOLIDATE_BACK |
00050 GU_EXTRUDE_CONSOLIDATE_SIDE)
00051 };
00052
00053 enum GU_PolyExtrudeSymmetryAxis
00054 {
00055 GU_EXTRUDE_SYMMETRY_AXIS_X,
00056 GU_EXTRUDE_SYMMETRY_AXIS_Y,
00057 GU_EXTRUDE_SYMMETRY_AXIS_NONE,
00058 GU_EXTRUDE_SYMMETRY_ROTTOLEAD
00059 };
00060
00061 enum GU_PolyExtrudeKeepSharedPoints
00062 {
00063 GU_EXTRUDE_KSP_NO = 0,
00064 GU_EXTRUDE_KSP_ISECT,
00065 GU_EXTRUDE_KSP_AVERAGE
00066 };
00067
00068 class gu_PointTargetList;
00069 class gu_LocalSpaceAlgorithm;
00070
00071 typedef void (*GU_PolyExtrudeXformCallback)(int primnum, UT_Matrix4 &xform,
00072 void *user_data);
00073 typedef float (*GU_PolyExtrudeInsetCallback)(int primnum, int vtxnum, int ptnum,
00074 void *user_data);
00075 typedef int (*GU_PolyExtrudeDivCallback)(int primnum, void *user_data);
00076
00077 class GU_API GU_PolyExtrudeParms
00078 {
00079 public:
00080 GU_PolyExtrudeParms();
00081
00082 const GB_BaseGroup *myGroup;
00083
00084
00085 GB_PrimitiveGroup *myFrontGroup;
00086 GB_PrimitiveGroup *myBackGroup;
00087 GB_PrimitiveGroup *mySideGroup;
00088
00089 GB_BaseGroup *myOutputGroup;
00090
00091 bool myOutputFront;
00092 bool myOutputBack;
00093 bool myOutputSide;
00094
00095 bool myRemoveZeroAreaSides;
00096 bool myRemoveSharedSides;
00097
00098 unsigned int myConsolidatePoints;
00099
00100
00101 GU_PolyExtrudeSymmetryAxis mySymmetryAxis;
00102
00103 GU_PolyExtrudeKeepSharedPoints myKeepSharedPointsTogether;
00104
00105
00106
00107 bool myOrientEdgeFaces;
00108
00109
00110 float myTolerance;
00111
00112 void setLocalXform(const UT_Matrix4 &mat,
00113 GU_PolyExtrudeXformCallback cb);
00114 const UT_Matrix4 &getLocalXform(int primnum) const;
00115
00116 void setGlobalXform(const UT_Matrix4 &mat,
00117 GU_PolyExtrudeXformCallback cb);
00118 const UT_Matrix4 &getGlobalXform(int primnum) const;
00119
00120 void setInset(float inset, GU_PolyExtrudeInsetCallback cb);
00121 float getInset(int primnum, int vtxnum, int ptnum) const;
00122
00123 void setDivisions(int div, GU_PolyExtrudeDivCallback cb);
00124 int getDivisions(int primnum) const;
00125
00126
00127
00128 bool isFusing(unsigned int bit) const;
00129
00130
00131
00132 bool isConsolidatePerPoint() const;
00133
00134
00135
00136 bool isConsolidateAll() const;
00137
00138
00139 GU_PolyExtrudeXformCallback myLocalXformCallback;
00140 GU_PolyExtrudeXformCallback myGlobalXformCallback;
00141 GU_PolyExtrudeInsetCallback myInsetCallback;
00142 GU_PolyExtrudeDivCallback myDivCallback;
00143 void *myCBUserData;
00144
00145 private:
00146
00147
00148
00149 UT_Matrix4 myLocalXform;
00150 UT_Matrix4 myGlobalXform;
00151 mutable UT_Matrix4 myTempLXform;
00152 mutable UT_Matrix4 myTempGXform;
00153 int myDivisions;
00154 float myInset;
00155
00156 };
00157
00158
00159 class GU_API GU_PolyExtrude
00160 {
00161 public:
00162
00163 GU_PolyExtrude(GU_Detail *gdp);
00164 ~GU_PolyExtrude();
00165
00166
00167 void extrude(const GU_PolyExtrudeParms &parms);
00168
00169
00170 void removeSharedSides(GB_PrimitiveGroup *primgrp, float tolerance);
00171
00172
00173
00174 bool computeEdgeNormal(UT_Vector3 &nml, const GB_Edge &edge,
00175 bool cleanup);
00176
00177
00178
00179
00180
00181 static bool computeLocalSpace(const GEO_Face &face,
00182 UT_Matrix4 &mat);
00183 bool computeLocalSpace(const GB_Edge &edge, UT_Matrix4 &mat);
00184
00185 private:
00186 void extrudePolys(const GU_PolyExtrudeParms &parms);
00187 void extrudeEdges(const GU_PolyExtrudeParms &parms);
00188 bool extrudeFace(const GEO_Face &face, gu_LocalSpaceAlgorithm &lsa,
00189 const GU_PolyExtrudeParms &parms,
00190 GB_PrimitiveGroup *sideprims,
00191 const gu_PointTargetList &pt_target_list);
00192 void extrudeEdge(const GB_Edge &edge, gu_LocalSpaceAlgorithm &lsa,
00193 const GU_PolyExtrudeParms &parms,
00194 const gu_PointTargetList &pt_target_list);
00195
00196 void buildRails(const GU_PolyExtrudeParms &parms,
00197 UT_PtrArray<GEO_Point *> &ptlist0,
00198 UT_PtrArray<GEO_Point *> &ptlist1,
00199 GEO_Point *pt0, GEO_Point *pt1,
00200 GEO_Point *frontpt0, GEO_Point *frontpt1,
00201 const UT_Vector4 &extrudedir0,
00202 const UT_Vector4 &extrudedir1,
00203 float t, bool regenlist0, int divs);
00204
00205
00206
00207 GEO_Point *newPoint(const GU_PolyExtrudeParms &parms,
00208 const UT_Vector4 &atpos,
00209 GEO_Point *likept);
00210
00211 GU_PrimPoly *buildFrontFace(const GEO_Face &face,
00212 gu_LocalSpaceAlgorithm &lsa,
00213 const GU_PolyExtrudeParms &parms,
00214 const gu_PointTargetList &pt_target_list);
00215 void buildSideFaces(const GEO_Face &face,
00216 const GEO_Face &newface,
00217 const GU_PolyExtrudeParms &parms,
00218 const gu_PointTargetList &pt_target_list,
00219 UT_IntArray &new_sides);
00220
00221 GEO_Point *getEdgePoint(int ptnum, int div, float t,
00222 const UT_Vector4 &extrudedir,
00223 const GU_PolyExtrudeParms &parms,
00224 const gu_PointTargetList &pt_target_list);
00225
00226
00227 GU_Detail *myGdp;
00228 bool myInternalNormals;
00229
00230 GEO_PointTree *myNewPointsTree;
00231 GEO_PointRefArray *myPointRefArray;
00232 };
00233
00234 #endif