00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021
00022 #include "maxheap.h"
00023 #include "coreexp.h"
00024 #include "meshlib.h"
00025 #include "hitdata.h"
00026 #include "maxtess.h"
00027 #include "PatchTypeConstants.h"
00028
00029
00030
00031
00032
00033 #define PATCH_UNDEFINED -1
00034
00035
00036
00037
00038
00039 class HookPoint: public MaxHeapOperators
00040 {
00041 public:
00042 int upperPoint, lowerPoint;
00043 int upperVec,lowerVec;
00044 int upperHookVec, lowerHookVec;
00045 int hookPoint;
00046 int upperPatch, lowerPatch, hookPatch;
00047 int hookEdge, upperEdge, lowerEdge;
00048 };
00049
00050 class ExtrudeData: public MaxHeapOperators
00051 {
00052 public:
00053 int u,l,uvec,lvec;
00054
00055 Point3 edge;
00056 Point3 bevelDir;
00057 };
00058
00059 class ISave;
00060 class ILoad;
00061 class PatchMesh;
00062
00063 #define NEWPATCH
00064
00065 class PRVertex: public MaxHeapOperators {
00066 public:
00067 PRVertex() { rFlags = 0; }
00068 CoreExport ~PRVertex();
00069
00070 DWORD rFlags;
00071 int pos[3];
00072 };
00073
00074
00075 #define PVEC_INTERIOR (1<<0)
00076 #define PVEC_INTERIOR_MASK 0xfffffffe
00077
00078
00079 #define NUM_PATCH_VEC_FLAGS 1
00080 const DWORD PatchVecFlagMasks[] = {1};
00081 const int PatchVecFlagShifts[] = {0};
00082
00083
00084
00111 class PatchVec: public MaxHeapOperators {
00112 public:
00113 Point3 p;
00114 int vert;
00115 IntTab patches;
00116 DWORD flags;
00117 int aux1;
00118 int aux2;
00122 CoreExport PatchVec();
00128 CoreExport PatchVec(PatchVec &from);
00131 void ResetData() { vert = PATCH_UNDEFINED; patches.Delete(0,patches.Count());}
00138 CoreExport BOOL AddPatch(int index);
00143 CoreExport PatchVec& operator=(PatchVec& from);
00150 void Transform(Matrix3 &tm) { p = p * tm; }
00151
00154 CoreExport IOResult Save(ISave* isave);
00159 CoreExport IOResult Load(ILoad* iload);
00160 };
00161
00162
00163 #define PVERT_COPLANAR (1<<0)
00164 #define PVERT_CORNER (0)
00165 #define PVERT_TYPE_MASK 0xfffffffe
00166
00167 #define PVERT_HIDDEN (1<<1)
00168 #define PVERT_HIDDEN_MASK 0xfffffffd
00169
00170 #define PVERT_RESET (1<<2)
00171
00172
00173 #define NUM_PATCH_VERT_FLAGS 2
00174 const DWORD PatchVertFlagMasks[] = {1, 1};
00175 const int PatchVertFlagShifts[] = {0, 1};
00176
00177
00178
00221 class PatchVert: public MaxHeapOperators {
00222 public:
00223 Point3 p;
00224 IntTab vectors;
00225 IntTab patches;
00226 IntTab edges;
00227 DWORD flags;
00228 int aux1;
00229 int aux2;
00232 CoreExport PatchVert();
00238 CoreExport PatchVert(PatchVert &from);
00241 ~PatchVert() { ResetData(); }
00246 CoreExport PatchVert& operator=(PatchVert& from);
00249 CoreExport void ResetData();
00256 CoreExport int FindVector(int index);
00262 CoreExport void AddVector(int index);
00268 CoreExport void DeleteVector(int index);
00275 CoreExport int FindPatch(int index);
00281 CoreExport void AddPatch(int index);
00287 CoreExport void DeletePatch(int index);
00294 CoreExport int FindEdge(int index);
00300 CoreExport void AddEdge(int index);
00306 CoreExport void DeleteEdge(int index);
00313 void Transform(Matrix3 &tm) { p = p * tm; }
00314
00315
00322 CoreExport void SetHidden(BOOL sw = TRUE)
00323 {
00324 if(sw)
00325 flags |= PVERT_HIDDEN;
00326 else
00327 flags &= ~PVERT_HIDDEN;
00328 }
00329
00333 BOOL IsHidden() { return (flags & PVERT_HIDDEN) ? TRUE : FALSE; }
00334
00337 CoreExport IOResult Save(ISave* isave);
00342 CoreExport IOResult Load(ILoad* iload);
00343 };
00344
00356 class PatchTVert: public MaxHeapOperators {
00357 public:
00358 UVVert p;
00359 int aux1;
00362 CoreExport PatchTVert() { p = UVVert(0,0,0); aux1 = -1; }
00370 CoreExport PatchTVert(float u, float v, float w) { p=UVVert(u,v,w); aux1 = -1; }
00372 CoreExport operator UVVert&() { return p; }
00377 CoreExport PatchTVert& operator=(const UVVert &from) { p=from; return *this; }
00378 };
00379
00402 class PatchEdge: public MaxHeapOperators {
00403 public:
00404 int v1;
00405 int vec12;
00406 int vec21;
00407 int v2;
00408 IntTab patches;
00409 int aux1;
00410 int aux2;
00413 CoreExport PatchEdge();
00416 CoreExport PatchEdge(const PatchEdge &from);
00419 CoreExport PatchEdge(int v1, int vec12, int vec21, int v2, int p1, int p2, int aux1=-1, int aux2=-1);
00420
00424 CoreExport void Dump();
00427 CoreExport IOResult Save(ISave* isave);
00430 CoreExport IOResult Load(ILoad* iload);
00431 };
00432
00433
00434
00435 #define PATCH_AUTO (1<<0) // Interior verts computed automatically if set
00436 #define PATCH_MANUAL (0) // Interior verts stored in 'interior' array
00437 #define PATCH_INTERIOR_MASK 0xfffffffe
00438
00439 #define PATCH_HIDDEN (1<<1) //patch is hidden
00440
00441
00442 #define PATCH_LINEARMAPPING (1<<2) //patch uses the old liunear mapping scheme else use the new mapping
00443
00444 #define PATCH_USE_CURVED_MAPPING_ON_VERTEX_COLOR (1<<3) //patch will use the new curved mapping for vertex colors also
00445
00446
00447 #define PATCH_MATID_SHIFT 16
00448 #define PATCH_MATID_MASK 0xFFFF
00449
00450
00451 #define NUM_PATCH_PATCH_FLAGS 5
00452 const DWORD PatchPatchFlagMasks[] = {1, 1, 1, 1, 0xffff};
00453 const int PatchPatchFlagShifts[] = {0, 1, 2, 3, 16};
00454
00513 class Patch : public BaseInterfaceServer {
00514 public:
00515 int type;
00516 int v[4];
00517 int vec[8];
00518 int interior[4];
00519 Point3 aux[9];
00520 int edge[4];
00521 DWORD smGroup;
00522 DWORD flags;
00523 int aux1;
00524 int aux2;
00525
00526 #ifdef CHECK_TRI_PATCH_AUX
00527 Point3 auxSource[9];
00528 CoreExport void CheckTriAux(PatchMesh *pMesh);
00529 #endif //CHECK_TRI_PATCH_AUX
00530
00535 CoreExport Patch();
00536 CoreExport Patch(int type);
00539 CoreExport Patch(Patch& fromPatch);
00541 CoreExport ~Patch();
00544 CoreExport void Init();
00551 CoreExport void setVerts(int *vrt);
00557 void setVerts(int a, int b, int c) { assert(type == PATCH_TRI); v[0]=a; v[1]=b; v[2]=c; }
00563 void setVerts(int a, int b, int c, int d) { assert(type == PATCH_QUAD); v[0]=a; v[1]=b; v[2]=c; v[3]=d; }
00570 void setVecs(int ab, int ba, int bc, int cb, int ca, int ac) {
00571 assert(type == PATCH_TRI);
00572 vec[0]=ab; vec[1]=ba; vec[2]=bc; vec[3]=cb; vec[4]=ca; vec[5]=ac;
00573 }
00582 void setVecs(int ab, int ba, int bc, int cb, int cd, int dc, int da, int ad) {
00583 assert(type == PATCH_QUAD);
00584 vec[0]=ab; vec[1]=ba; vec[2]=bc; vec[3]=cb; vec[4]=cd; vec[5]=dc; vec[6]=da, vec[7]=ad;
00585 }
00591 void setInteriors(int a, int b, int c) {
00592 assert(type == PATCH_TRI);
00593 interior[0]=a; interior[1]=b; interior[2]=c;
00594 }
00601 void setInteriors(int a, int b, int c, int d) {
00602 assert(type == PATCH_QUAD);
00603 interior[0]=a; interior[1]=b; interior[2]=c; interior[3]=d;
00604 }
00610 int getVert(int index) { return v[index]; }
00612 int * getAllVerts(void) { return v; }
00613 MtlID getMatID() {return (int)((flags>>FACE_MATID_SHIFT)&FACE_MATID_MASK);}
00614 void setMatID(MtlID id) {flags &= 0xFFFF; flags |= (DWORD)(id<<FACE_MATID_SHIFT);}
00615 Point3 getUVW(int index) const;
00616 Point2 getUV(int index) const;
00617 bool getVertUVW(int vert, Point3 &uvw) const;
00618 bool getVertUV(int vert, Point2 &uv) const;
00619 Point3 BicubicSurface(PatchMesh *pMesh, const float *uu, const float *vv);
00633 CoreExport Point3 interp(PatchMesh *pMesh, float u, float v, float w);
00647 CoreExport Point3 interp(PatchMesh *pMesh, float u, float v);
00648 CoreExport Point3 WUTangent(PatchMesh *pMesh, float u, float v, float w);
00649 CoreExport Point3 UVTangent(PatchMesh *pMesh, float u, float v, float w);
00650 CoreExport Point3 VWTangent(PatchMesh *pMesh, float u, float v, float w);
00651 CoreExport Point3 UTangent(PatchMesh *pMesh, float u, float v);
00652 CoreExport Point3 VTangent(PatchMesh *pMesh, float u, float v);
00653 CoreExport Point3 Normal(PatchMesh *pMesh, float u, float v, float w);
00654 CoreExport Point3 Normal(PatchMesh *pMesh, float u, float v);
00657 CoreExport void ComputeAux(PatchMesh *pMesh, int index);
00658 CoreExport void ComputeAux(PatchMesh *pMesh);
00667 CoreExport void computeInteriors(PatchMesh* pMesh);
00678 CoreExport void SetType(int type, BOOL init = FALSE);
00683 CoreExport Patch& operator=(Patch& from);
00689 CoreExport void SetAuto(BOOL sw = TRUE);
00692 BOOL IsAuto() { return (flags & PATCH_AUTO) ? TRUE : FALSE; }
00693
00694
00701 CoreExport void SetHidden(BOOL sw = TRUE);
00702
00706 BOOL IsHidden() { return (flags & PATCH_HIDDEN) ? TRUE : FALSE; }
00707
00721 int WhichEdge(int v1, int v2);
00722
00736 int WhichVert(int v);
00737
00738
00739
00745 CoreExport void Dump();
00746
00747 CoreExport IOResult Save(ISave* isave);
00748 CoreExport IOResult Load(ILoad* iload);
00749 };
00750
00751
00765 class TVPatch: public MaxHeapOperators {
00766 public:
00767 int tv[4];
00768
00769 int handles[8];
00770 int interiors[4];
00771
00773 CoreExport TVPatch();
00776 CoreExport TVPatch(const TVPatch& fromPatch);
00779 CoreExport void Init();
00786 CoreExport void setTVerts(int *vrt, int count);
00791 CoreExport void setTVerts(int a, int b, int c, int d = 0);
00792
00793
00794
00801 CoreExport void setTHandles(int *vrt, int count);
00809 CoreExport void setTHandles(int a, int b, int c, int d ,
00810 int e, int f, int g = 0 , int h = 0);
00811
00819 CoreExport void setTInteriors(int *vrt, int count);
00825 CoreExport void setTInteriors(int a, int b, int c, int d = 0);
00826
00831 int getTVert(int index) { return tv[index]; }
00833 int * getAllTVerts(void) { return tv; }
00838 CoreExport TVPatch& operator=(const TVPatch& from);
00839
00842 CoreExport IOResult Save(ISave* isave);
00847 CoreExport IOResult Load(ILoad* iload);
00848 };
00849
00850 CoreExport void setPatchIntrFunc(INTRFUNC fn);
00851
00852
00853 #define PATCH_HIT_PATCH 0
00854 #define PATCH_HIT_EDGE 1
00855 #define PATCH_HIT_VERTEX 2
00856 #define PATCH_HIT_VECTOR 3
00857 #define PATCH_HIT_INTERIOR 4
00858
00880 class PatchSubHitRec: public MaxHeapOperators {
00881 private:
00882 PatchSubHitRec *next;
00883 public:
00884 DWORD dist;
00885 PatchMesh *patch;
00886 int index;
00887 int type;
00888
00891 PatchSubHitRec( DWORD dist, PatchMesh *patch, int index, int type, PatchSubHitRec *next )
00892 { this->dist = dist; this->patch = patch; this->index = index; this->type = type; this->next = next; }
00893
00895 PatchSubHitRec *Next() { return next; }
00896 };
00897
00903 class SubPatchHitList: public MaxHeapOperators {
00904 private:
00905 PatchSubHitRec *first;
00906 public:
00908 SubPatchHitList() { first = NULL; }
00910 CoreExport ~SubPatchHitList();
00911
00913 PatchSubHitRec *First() { return first; }
00933 CoreExport void AddHit( DWORD dist, PatchMesh *patch, int index, int type );
00934 };
00935
00936
00937
00955 class PatchHitData : public HitData {
00956 public:
00957 PatchMesh *patch;
00958 int index;
00959 int type;
00962 PatchHitData(PatchMesh *patch, int index, int type)
00963 { this->patch = patch; this->index = index; this->type = type; }
00964 ~PatchHitData() {}
00965 };
00966
00967
00968
00969
00970 #define SUBHIT_PATCH_SELONLY (1<<0)
00971 #define SUBHIT_PATCH_UNSELONLY (1<<2)
00972 #define SUBHIT_PATCH_ABORTONHIT (1<<3)
00973 #define SUBHIT_PATCH_SELSOLID (1<<4)
00974
00975 #define SUBHIT_PATCH_VERTS (1<<24)
00976 #define SUBHIT_PATCH_VECS (1<<25)
00977 #define SUBHIT_PATCH_PATCHES (1<<26)
00978 #define SUBHIT_PATCH_EDGES (1<<27)
00979 #define SUBHIT_PATCH_TYPEMASK (SUBHIT_PATCH_VERTS|SUBHIT_PATCH_VECS|SUBHIT_PATCH_EDGES|SUBHIT_PATCH_PATCHES)
00980 #define SUBHIT_PATCH_IGNORE_BACKFACING (1<<28)
00981
00982
00983
00984
00985 #define PATCH_OBJECT (1<<0)
00986 #define PATCH_VERTEX (1<<1)
00987 #define PATCH_PATCH (1<<2)
00988 #define PATCH_EDGE (1<<3)
00989 #define PATCH_HANDLE (1<<4)
00990
00991
00992 #define SUBDIV_EDGES 0
00993 #define SUBDIV_PATCHES 1
00994
00995
00996 #define DEF_PM_RELAX FALSE
00997 #define DEF_PM_RELAX_VIEWPORTS TRUE
00998 #define DEF_PM_RELAX_VALUE 0.0f
00999 #define DEF_PM_ITER 1
01000 #define DEF_PM_BOUNDARY TRUE
01001 #define DEF_PM_SADDLE FALSE
01002
01003
01004 #define PM_HITTEST_REQUIRE_ALL (1<<0) // Force faces to be hit only if all triangles are hit. (Internal use.)
01005
01006 namespace MaxGraphics {
01007 class IPatchMeshInternal;
01008 }
01009
01090 class PatchMesh : public BaseInterfaceServer {
01091 friend class Patch;
01092 friend class MaxGraphics::IPatchMeshInternal;
01093
01094 private:
01095 #if MULTI_PROCESSING
01096 static int refCount;
01097 static HANDLE xfmThread;
01098 static HANDLE xfmMutex;
01099 static HANDLE xfmStartEvent;
01100 static HANDLE xfmEndEvent;
01101 friend DWORD WINAPI xfmFunc(LPVOID ptr);
01102 #endif
01103
01104 PRVertex *rVerts;
01105 PRVertex *rVecs;
01106 GraphicsWindow *cacheGW;
01107 Box3 bdgBox;
01108
01109
01110 int meshSteps;
01111
01112 int meshStepsRender;
01113 BOOL showInterior;
01114 BOOL usePatchNormals;
01115
01116 BOOL adaptive;
01117
01118 TessApprox viewTess;
01119 TessApprox prodTess;
01120 TessApprox dispTess;
01121 BOOL mViewTessNormals;
01122 BOOL mProdTessNormals;
01123 BOOL mViewTessWeld;
01124 BOOL mProdTessWeld;
01125
01126
01127 int snapVCt;
01128 int snapPCt;
01129 char *snapV;
01130 char *snapP;
01131
01132
01133
01134 DWORD flags;
01135
01136
01137
01138 Tab<int> numHTVerts;
01139 Tab<PatchTVert *> htVerts;
01140 Tab<TVPatch *> htvPatches;
01141
01142
01143 BOOL relax;
01144 BOOL relaxViewports;
01145 float relaxValue;
01146 int relaxIter;
01147 BOOL relaxBoundary;
01148 BOOL relaxSaddle;
01149
01150 void SetFlag(DWORD fl, bool val=TRUE) { if (val) flags |= fl; else flags &= ~fl; }
01151 void ClearFlag(DWORD fl) { flags &= ~fl; }
01152 bool GetFlag(DWORD fl) const { return (flags & fl) ? true : false; }
01153
01154 int renderPatch( GraphicsWindow *gw, int index);
01155 int renderEdge( GraphicsWindow *gw, int index, HitRegion *hr);
01156 void checkRVertsAlloc(void);
01157 void setCacheGW(GraphicsWindow *gw) { cacheGW = gw; }
01158 GraphicsWindow *getCacheGW(void) { return cacheGW; }
01159
01160 void freeVerts();
01161 void freeTVerts(int channel=0);
01162 void freeVecs();
01163 void freePatches();
01164 void freeTVPatches(int channel=0);
01165 void freeEdges();
01166 void freeRVerts();
01167 void freeSnapData();
01168 int buildSnapData(GraphicsWindow *gw,int verts,int edges);
01169
01170
01171 Mesh unrelaxedMesh;
01172 Mesh relaxedMesh;
01173
01174
01175 Tab<int> mappingFaceToPatch;
01176
01177 public:
01178
01179 int numVerts;
01180 int numVecs;
01181 int numPatches;
01182 int numEdges;
01183 Patch * patches;
01184 PatchVec * vecs;
01185 PatchEdge * edges;
01186 Tab<HookPoint> hooks;
01187
01188
01189 Tab<Point3> hookTopoMarkers;
01190 Tab<Point3> hookTopoMarkersA;
01191 Tab<Point3> hookTopoMarkersB;
01192 CoreExport int HookFixTopology() ;
01193
01194
01195 Point3 * normals;
01196 BOOL normalsBuilt;
01197
01198
01199 PatchVert * verts;
01200
01201
01202 Tab<int> numTVerts;
01203 Tab<PatchTVert *> tVerts;
01204 Tab<TVPatch *> tvPatches;
01205
01206
01207 MtlID mtlIndex;
01208
01209
01210 BitArray vecSel;
01211 BitArray vertSel;
01212 BitArray edgeSel;
01213 BitArray patchSel;
01214
01215
01216 int bezVecVert;
01217
01218
01219 DWORD dispFlags;
01220
01221
01222 DWORD selLevel;
01223
01224
01225 int cacheSteps;
01226 BOOL cacheAdaptive;
01227 BOOL unrelaxedMeshValid;
01228 BOOL relaxedMeshValid;
01229
01232 CoreExport PatchMesh();
01235 CoreExport PatchMesh(PatchMesh& fromPatch);
01236
01283 CoreExport void Init();
01284
01286 CoreExport ~PatchMesh();
01287
01289 CoreExport PatchMesh& operator=(PatchMesh& fromPatchMesh);
01300 CoreExport PatchMesh& operator=(Mesh& fromMesh);
01301
01302
01303
01311 CoreExport void CopyPatchDataFrom(PatchMesh &fromPatchMesh);
01312
01322 CoreExport BOOL setNumVerts(int ct, BOOL keep = FALSE);
01324 int getNumVerts(void) { return numVerts; }
01325
01333 CoreExport BOOL setNumVecs(int ct, BOOL keep = FALSE);
01335 int getNumVecs(void) { return numVecs; }
01336
01344 CoreExport BOOL setNumPatches(int ct, BOOL keep = FALSE);
01346 int getNumPatches(void) { return numPatches; }
01347
01355 CoreExport BOOL setNumEdges(int ct, BOOL keep = FALSE);
01357 int getNumEdges(void) { return numEdges; }
01358
01365 void setVert(int i, const Point3 &xyz) { verts[i].p = xyz; }
01372 void setVert(int i, float x, float y, float z) { verts[i].p.x=x; verts[i].p.y=y; verts[i].p.z=z; }
01379 void setVec(int i, const Point3 &xyz) { vecs[i].p = xyz; }
01386 void setVec(int i, float x, float y, float z) { vecs[i].p.x=x; vecs[i].p.y=y; vecs[i].p.z=z; }
01387
01392 PatchVert & getVert(int i) { return verts[i]; }
01397 PatchVert * getVertPtr(int i) { return verts+i; }
01402 PatchVec & getVec(int i) { return vecs[i]; }
01407 PatchVec * getVecPtr(int i) { return vecs+i; }
01409 PRVertex & getRVert(int i) { return rVerts[i]; }
01411 PRVertex * getRVertPtr(int i) { return rVerts+i; }
01412 PRVertex & getRVec(int i) { return rVecs[i]; }
01413 PRVertex * getRVecPtr(int i) { return rVecs+i; }
01414
01415
01416
01417
01432 BOOL setNumTVertsChannel(int mp, int ct, BOOL keep=FALSE) { return setNumMapVerts (mp?0:1, ct, keep); }
01441 BOOL setNumTVerts(int ct, BOOL keep=FALSE) { return setNumMapVerts (1, ct, keep); }
01451 int getNumTVertsChannel(int mp) const { return numTVerts[mp?0:1]; }
01454 int getNumTVerts() const { return getNumMapVerts(1); }
01455
01456
01457
01472 CoreExport BOOL setNumMapVerts (int mp, int ct, BOOL keep = FALSE);
01480 CoreExport int getNumMapVerts (int mp) const;
01489 CoreExport PatchTVert *mapVerts (int mp) const;
01490 CoreExport TVPatch *mapPatches (int mp) const;
01491
01492
01493
01494
01495
01496
01497
01498
01526 BOOL setNumTVPatchesChannel(int channel, int ct, BOOL keep=FALSE, int oldCt=0) { return setNumMapPatches (channel?0:1, ct, keep, oldCt); }
01549 BOOL setNumTVPatches(int ct, BOOL keep=FALSE, int oldCt=0) { return setNumMapPatches (1, ct, keep, oldCt); }
01550
01577 CoreExport BOOL setNumMapPatches (int channel, int ct, BOOL keep=FALSE, int oldCt=0);
01578
01590 void setTVertChannel(int channel, int i, const UVVert &xyz) { tVerts[channel?0:1][i] = xyz; }
01597 void setTVert(int i, const UVVert &xyz) { tVerts[1][i] = xyz; }
01609 void setTVertChannel(int channel, int i, float x, float y, float z) { tVerts[channel?0:1][i].p.x=x; tVerts[channel?0:1][i].p.y=y; tVerts[channel?0:1][i].p.z=z; }
01616 void setTVert(int i, float x, float y, float z) { tVerts[1][i].p.x=x; tVerts[1][i].p.y=y; tVerts[1][i].p.z=z; }
01628 void setTVPatchChannel(int channel, int i, TVPatch &tvp) { tvPatches[channel?0:1][i] = tvp; }
01637 void setTVPatch(int i, TVPatch &tvp) { tvPatches[1][i] = tvp; }
01648 PatchTVert & getTVertChannel(int channel, int i) { return tVerts[channel?0:1][i]; }
01654 PatchTVert & getTVert(int i) { return tVerts[1][i]; }
01665 PatchTVert * getTVertPtrChannel(int channel, int i) { return tVerts[channel?0:1]+i; }
01671 PatchTVert * getTVertPtr(int i) { return tVerts[1]+i; }
01681 TVPatch & getTVPatchChannel(int channel, int i) { return tvPatches[channel?0:1][i]; }
01688 TVPatch & getTVPatch(int i) { return tvPatches[1][i]; }
01689
01690
01702 void setMapVert (int mp, int i, const UVVert &xyz) { mapVerts(mp)[i] = xyz; }
01718 void setMapVert (int mp, int i, float x, float y, float z) { Point3 MV(x,y,z); setMapVert (mp, i, MV); }
01730 void setMapPatch (int mp, int i, const TVPatch &tvp) { mapPatches(mp)[i] = tvp; }
01742 PatchTVert & getMapVert (int mp, int i) { return mapVerts(mp)[i]; }
01754 PatchTVert * getMapVertPtr (int mp, int i) { return mapVerts(mp) + i; }
01765 TVPatch & getMapPatch (int mp, int i) { return mapPatches(mp)[i]; }
01767 void setMtlIndex(MtlID i) { mtlIndex = i; }
01769 MtlID getMtlIndex(void) { return mtlIndex; }
01770 CoreExport MtlID getPatchMtlIndex(int i);
01771 CoreExport void setPatchMtlIndex(int i, MtlID id);
01772
01773
01774
01775
01776
01792 CoreExport BOOL buildLinkages(int patch=-1);
01793
01794
01800 CoreExport void computeInteriors();
01801
01802
01803 CoreExport void computeAux();
01804
01836 CoreExport void render(GraphicsWindow *gw, Material *ma, RECT *rp, int compFlags, int numMat=1);
01846 CoreExport void renderGizmo(GraphicsWindow *gw);
01863 CoreExport BOOL select(GraphicsWindow *gw, Material *ma, HitRegion *hr, int abortOnHit=FALSE, int numMat=1);
01877 CoreExport void snap(GraphicsWindow *gw, SnapInfo *snap, IPoint2 *p, Matrix3 &tm);
01915 CoreExport BOOL SubObjectHitTest(GraphicsWindow *gw, Material *ma, HitRegion *hr,
01916 DWORD flags, SubPatchHitList& hitList, int numMat=1 );
01917
01921 CoreExport void buildBoundingBox(void);
01926 CoreExport Box3 getBoundingBox(Matrix3 *tm=NULL);
01927
01928 CoreExport void GetDeformBBox(Box3& box, Matrix3 *tm=NULL, BOOL useSel=FALSE);
01929
01932 CoreExport void InvalidateGeomCache();
01933 CoreExport void InvalidateMesh();
01934 CoreExport void InvalidateRelaxedMesh();
01936 CoreExport void FreeAll();
01937
01938
01940 CoreExport void ShallowCopy(PatchMesh *amesh, ChannelMask channels);
01942 CoreExport void DeepCopy(PatchMesh *amesh, ChannelMask channels);
01944 CoreExport void NewAndCopyChannels(ChannelMask channels);
01946 CoreExport void FreeChannels(ChannelMask channels, int zeroOthers=1);
01947
01948
01953 void SetDispFlag(DWORD f) { dispFlags |= f; }
01958 DWORD GetDispFlag(DWORD f) { return dispFlags & f; }
01963 void ClearDispFlag(DWORD f) { dispFlags &= ~f; }
01964
01965
01966 BitArray& VecSel() { return vecSel; }
01970 BitArray& VertSel() { return vertSel; }
01973 BitArray& EdgeSel() { return edgeSel; }
01976 BitArray& PatchSel() { return patchSel; }
01977
01978
01983 CoreExport BitArray VertexTempSel();
01984
01985
01986
02002 CoreExport void ApplyConstraints(BOOL selOnly = FALSE);
02003
02004
02029 CoreExport BOOL MakeQuadPatch(int index, int va, int vab, int vba, int vb, int vbc, int vcb, int vc, int vcd, int vdc, int vd, int vda, int vad, int i1, int i2, int i3, int i4, DWORD sm);
02050 CoreExport BOOL MakeTriPatch(int index, int va, int vab, int vba, int vb, int vbc, int vcb, int vc, int vca, int vac, int i1, int i2, int i3, DWORD sm);
02051
02052
02058 CoreExport void SetMeshSteps(int steps);
02060 CoreExport int GetMeshSteps();
02061 #ifndef NO_OUTPUTRENDERER
02062
02069 CoreExport void SetMeshStepsRender(int steps);
02073 CoreExport int GetMeshStepsRender();
02074 #endif // NO_OUTPUTRENDERER
02075
02081 CoreExport void SetShowInterior(BOOL si);
02085 CoreExport BOOL GetShowInterior();
02086
02087 CoreExport void SetUsePatchNormals(BOOL usePatchNorm);
02088 CoreExport BOOL GetUsePatchNormals();
02089
02091 CoreExport void SetAdaptive(BOOL sw);
02093 CoreExport BOOL GetAdaptive();
02094
02102 CoreExport void SetViewTess(TessApprox tess);
02107 CoreExport TessApprox GetViewTess();
02116 CoreExport void SetProdTess(TessApprox tess);
02121 CoreExport TessApprox GetProdTess();
02129 CoreExport void SetDispTess(TessApprox tess);
02134 CoreExport TessApprox GetDispTess();
02139 CoreExport BOOL GetViewTessNormals();
02146 CoreExport void SetViewTessNormals(BOOL use);
02151 CoreExport BOOL GetProdTessNormals();
02155 CoreExport void SetProdTessNormals(BOOL use);
02160 CoreExport BOOL GetViewTessWeld();
02167 CoreExport void SetViewTessWeld(BOOL weld);
02172 CoreExport BOOL GetProdTessWeld();
02180 CoreExport void SetProdTessWeld(BOOL weld);
02181
02182
02184 int GetEdge(int v1, int v12, int v21, int v2, int p);
02185
02186 CoreExport Tab<int> GetEdge(int v1, int v2) const;
02187
02188
02189 CoreExport Tab<int> GetPatches(int v1, int v2) const;
02190
02191
02192 CoreExport Tab<int> GetPatches(int vert) const;
02193
02194
02195 CoreExport Tab<int> GetEdges(int vert) const;
02196
02197
02198 CoreExport Tab<int> GetVectors(int vert) const;
02199
02200
02201
02212 CoreExport void setNumMaps (int ct, BOOL keep=TRUE);
02216 int getNumMaps () { return numTVerts.Count(); }
02232 CoreExport void setMapSupport(int chan, BOOL init=TRUE);
02242 BOOL getMapSupport (int mp) { return ((mp<tvPatches.Count()) && tvPatches[mp]) ? TRUE : FALSE; }
02246 int NumMapChannels () { return MAX_MESHMAPS; }
02282 CoreExport void ApplyUVWMap(int type,
02283 float utile, float vtile, float wtile,
02284 int uflip, int vflip, int wflip, int cap,
02285 const Matrix3 &tm,int channel=1);
02286
02287
02288
02289
02290
02291
02298 CoreExport BOOL RecordTopologyTags();
02299
02308 CoreExport void Transform(Matrix3 &tm);
02309
02310
02314 CoreExport BOOL Weld(float thresh, BOOL weldIdentical=FALSE, int startVert=0);
02315
02316
02317 CoreExport BOOL PatchMesh::Weld(int fromVert, int toVert);
02318
02319
02325 CoreExport BOOL WeldEdges();
02326
02327
02336 CoreExport void DeletePatchParts(BitArray &delVerts, BitArray &delPatches);
02337
02338
02348 CoreExport void ClonePatchParts(BitArray *patches = NULL);
02349
02350
02363 CoreExport void Subdivide(int type, BOOL propagate);
02364
02365
02375 CoreExport void AddPatch(int type);
02376
02377
02381 CoreExport int AddHook();
02382
02386 CoreExport int AddHook(int index);
02390 CoreExport int AddHook(int vertIndex, int segIndex) ;
02391
02395 CoreExport int RemoveHook();
02396
02400 CoreExport int UpdateHooks();
02401
02402 Tab<Point3> extrudeDeltas;
02403 Tab<ExtrudeData> extrudeData;
02404 Tab<Point3> edgeNormals;
02405 Tab<int> newEdges;
02406 Tab<int> newVerts;
02407
02408
02409
02425 CoreExport void CreateExtrusion(int type = PATCH_PATCH, BOOL edgeClone=FALSE);
02426
02437 CoreExport Point3 AverageNormals(int type = PATCH_PATCH);
02441 CoreExport Point3 PatchNormal(int index);
02442 CoreExport void BuildPatchNormals();
02443 CoreExport void InvalidatePatchNormals();
02444 CoreExport Point3 EdgeNormal(int index);
02446 CoreExport void MoveNormal(float amount, BOOL useLocalNorms, int type);
02447
02456 CoreExport void FlipPatchNormal(int index);
02467 CoreExport void UnifyNormals(BOOL useSel);
02468
02469 BitArray bevelEdges;
02470 Tab<float> edgeDistances;
02474 CoreExport void CreateBevel();
02478 CoreExport void Bevel(float amount, int smoothStart, int smoothEnd);
02479
02483 Point3 GetBevelDir(int patchVertID);
02484
02485
02486 CoreExport void Attach(PatchMesh *attPatch, int mtlOffset);
02487
02488
02489 CoreExport void ChangePatchInterior(int index, int type);
02490
02491
02492 CoreExport void ChangeVertType(int index, int type);
02493
02494 CoreExport BOOL SelVertsSameType();
02495 CoreExport BOOL SelPatchesSameType();
02496
02497
02498 CoreExport BOOL ResetVertexTangents(int index);
02499 CoreExport BOOL ResetVertexTangents(bool useSel=true, const BitArray *vSel=NULL);
02500
02501
02502 CoreExport BOOL PatchSmoothVector(bool useSel=true, const BitArray *vSel=NULL);
02503 CoreExport BOOL PatchSmoothVertex(bool useSel=true, const BitArray *vSel=NULL);
02504 CoreExport BOOL PatchSmoothEdge(bool useSel=true, const BitArray *eSel=NULL);
02505 CoreExport BOOL PatchSmoothPatch(bool useSel=true, const BitArray *pSel=NULL);
02506
02507
02508 CoreExport void ShrinkSelection(int type);
02509 CoreExport void GrowSelection(int type);
02510 CoreExport void SelectEdgeRing(BitArray &eSel);
02511 CoreExport void SelectEdgeLoop(BitArray &eSel);
02512
02513
02517 CoreExport void Dump();
02518 #ifdef CHECK_TRI_PATCH_AUX
02519 CoreExport void CheckTriAux();
02520 #endif //CHECK_TRI_PATCH_AUX
02521
02522
02523 CoreExport void PrepareMesh();
02524 CoreExport void PrepareUnrelaxedMesh();
02525
02526
02527 CoreExport Mesh& GetMesh();
02528 CoreExport Mesh& GetUnrelaxedMesh();
02529
02530
02531
02549 CoreExport void ComputeMesh (Mesh & m, DWORD convertFlags);
02550
02567 CoreExport int IntersectRay(Ray& ray, float& at, Point3& norm);
02568
02569 CoreExport IOResult Save(ISave* isave);
02570 CoreExport IOResult Load(ILoad* iload);
02571
02572
02597 CoreExport void AutoSmooth(float angle,BOOL useSel,BOOL preventIndirectSmoothing);
02598
02599
02600
02610 CoreExport void ChangePatchToLinearMapping(int index);
02620 CoreExport void ChangePatchToCurvedMapping(int index);
02631 CoreExport BOOL ArePatchesLinearMapped(int index);
02642 CoreExport BOOL ArePatchesCurvedMapped(int index);
02649 CoreExport BOOL SingleEdgesOnly();
02659 CoreExport BitArray& GetElement(int index);
02660
02661
02662 CoreExport BaseInterface* GetInterface(Interface_ID id);
02663
02664
02665
02666
02667
02668
02669
02670 private:
02671
02672 int mVertexWeightSelectLevel;
02673 float * mpVertexWeights;
02674 int numVertexWeights;
02675 int * mpVertexEdgeDists;
02676 float * mpVertexDists;
02677
02678 public:
02679
02680
02681
02682 CoreExport void SetVertexWeightCount( int i );
02683 CoreExport void SetVertexWeight( int i, float w ) { assert( mpVertexWeights ); if ( i >= numVertexWeights ) return; mpVertexWeights[i] = w; }
02684 CoreExport float VertexWeight( int i ) { if ( !mpVertexWeights ) return 0.0f; if ( i >= numVertexWeights ) return 0.0f; return mpVertexWeights[i]; }
02685 CoreExport bool VertexWeightSupport() { if ( mpVertexWeights ) return true; return false; }
02693 CoreExport float *GetVSelectionWeights() { return mpVertexWeights; }
02699 CoreExport void SupportVSelectionWeights();
02700 CoreExport int VertexWeightSelectLevel() { return mVertexWeightSelectLevel; }
02701
02702 float mFalloff, mPinch, mBubble;
02703 int mEdgeDist, mUseEdgeDist, mAffectBackface, mUseSoftSelections;
02704
02705 CoreExport int UseEdgeDists( );
02706 CoreExport void SetUseEdgeDists( int edgeDist );
02707
02708 CoreExport int EdgeDist( );
02709 CoreExport void SetEdgeDist( int edgeDist );
02710
02711 CoreExport int UseSoftSelections();
02712 CoreExport void SetUseSoftSelections( int useSoftSelections );
02713
02714 CoreExport int AffectBackface( );
02715 CoreExport void SetAffectBackface( int affectBackface );
02716
02717 CoreExport float Falloff( );
02718 CoreExport void SetFalloff( float falloff );
02719
02720 CoreExport float Pinch( );
02721 CoreExport void SetPinch( float pinch );
02722
02723 CoreExport float Bubble( );
02724 CoreExport void SetBubble( float bubble );
02725
02726 CoreExport void InvalidateVertexWeights();
02727
02728 CoreExport void UpdateVertexDists();
02729 CoreExport void UpdateEdgeDists( );
02730 CoreExport void UpdateVertexWeights();
02731
02732 CoreExport Point3 VertexNormal( int vIndex );
02733
02734 CoreExport BOOL Relaxing();
02735 CoreExport BOOL SetRelax(BOOL v);
02736 CoreExport BOOL SetRelaxViewports(BOOL v);
02737 CoreExport BOOL SetRelaxValue(float v);
02738 CoreExport BOOL SetRelaxIter(int v);
02739 CoreExport BOOL SetRelaxBoundary(BOOL v);
02740 CoreExport BOOL SetRelaxSaddle(BOOL v);
02741 CoreExport BOOL GetRelax();
02742 CoreExport BOOL GetRelaxViewports();
02743 CoreExport float GetRelaxValue();
02744 CoreExport int GetRelaxIter();
02745 CoreExport BOOL GetRelaxBoundary();
02746 CoreExport BOOL GetRelaxSaddle();
02747 };
02748
02752 #define CONVERT_KEEPSEL 0x0001
02753 #define CONVERT_USESOFTSEL 0x0002
02754 #define CONVERT_SEL_LEVEL 0x0004
02755 #define CONVERT_PATCH_USEQUADS 0x0010
02756 #define CONVERT_NO_RELAX 0x0020
02757
02758
02759
02760 CoreExport void ConvertMeshToPatch (Mesh &m, PatchMesh &pm, DWORD flags=0);
02761 CoreExport void ConvertPatchToMesh (PatchMesh &pm, Mesh &m, DWORD flags=0);
02762
02764
02770 CoreExport void ConvertPatchToMeshWithMapping (PatchMesh &pm, Mesh &m, Tab<int> *mapping, DWORD flags=0);
02771 CoreExport void RelaxMesh(Mesh &mesh, float value, int iter, BOOL boundary, BOOL saddle);
02772