00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #pragma once
00011
00023 #include "maxheap.h"
00024 #include "export.h"
00025 #include "baseinterface.h"
00026 #include "mncommon.h"
00027 #include "hitdata.h"
00028 #include "point3.h"
00029 #include "bitarray.h"
00030 #include "matrix3.h"
00031 #include "box3.h"
00032 #include "TabTypes.h"
00033 #include "GraphicsConstants.h"
00034 #include "channels.h"
00035 #include "mesh.h"
00036
00037
00038 class Point3;
00039 class RVertex;
00040 class GraphicsWindow;
00041 class Material;
00042 class TVFace;
00043 class StripData;
00044 class PerData;
00045 class Mesh;
00046 class MeshOpProgress;
00047 class UVWMapper;
00048 class HitRegion;
00049 class SubObjHitList;
00050 class IHardwareShader;
00051 class TriStrip;
00052 class MNMesh;
00053
00054 #define REALLOC_SIZE 10
00055
00057 #define MNMESH_FACEDATA_IMPL
00058
00059 #pragma region MNMesh Component Flags
00060
00061
00062
00067
00068 #define MN_SEL (1<<0) //!< Indicates that a component is selected.
00069 #define MN_DEAD (1<<1) //!< Indicates that a component is not used and should be ignored. Vertices with the MN_DEAD flag are deleted in the next call MNMesh::CollapseDeadVerts().
00070 #define MN_TARG (1<<2) //!< Indicates that a component is targeted. (See the MNMesh methods starting with the words TargetBy.
00071 #define MN_BACKFACING (1<<3) //!< Indicates that the vertex faces "backwards" in the current viewport. This changes often.
00072 #define MN_HIDDEN (1<<4)
00073 #define MN_CACHEINVALID (1<<5)
00074 #define MN_INFOREGROUND (1<<7) //!< Tags a face as not renderable but can be hit-test. 1<<6 is skipped because the tri strip uses that as face flag signifying a face to be stripped
00075 #define MN_WHATEVER (1<<16) //!< \internal SDK users should use MN_USER and higher flags.
00076 #define MN_LOCAL_SEL (1<<17) //!< Alternate selections (not passed up the pipe).
00077 #define MN_HITTEST_CULLED (1<<18) //!< Used to indicate culled components (neither selected nor not selected) in window-region hit testing.
00078 #define MN_USER (1<<24) //!< Any value above this can be used by applications.
00079
00080
00082
00083 #define MN_VERT_DONE (1<<8) //!< Set in algorithms that may accidentally revisit the same vertex (MNVertext twice, to keep them from processing it the second time.
00084 #define MN_VERT_WELDED (1<<9) //!< Used by MNMesh::WeldBorderVerts()
00085 #define MN_VERT_SUBDIVISION_CORNER (1<<10) //!< Track which vertices are direct "descendants" of the original cage vertices in subdivision.
00086
00087
00089
00090 #define MN_EDGE_INVIS (1<<8) //!< Both faces using this edge consider it invisible.
00091 #define MN_EDGE_NOCROSS (1<<9) //!< This edge should not be crossed in algorithms like MNMesh::SabinDoo that can mix faces across edges.
00092 #define MN_EDGE_MAP_SEAM (1<<10) //!< Track which edges are direct descendants of the original cage edges in subdivision.
00093 #define MN_EDGE_SUBDIVISION_BOUNDARY (1<<11) //!< Track unwanted edges created by Cut, so they might be removed later.
00094 #define MN_EDGE_CUT_EXTRA (1<<12) //!< Used with MNMesh::CutPrepare() and MNMEsh::CutCleanUp()
00095
00096
00098 #pragma endregion
00099
00100 const int kMNNurmsHourglassLimit = 2500;
00101
00102
00103 #define MNM_SELCONV_REQUIRE_ALL 0x02
00104
00106
00107
00108 #define IMNMESHUTILITIES8_INTERFACE_ID Interface_ID(0xf5235e73, 0x3b304334)
00109
00111 #define IMNTEMPDATA10_INTERFACE_ID Interface_ID(0x56d8fa2, 0x3459c774)
00112
00113
00114
00116
00117
00120 #define MN_FACE_OPEN_REGION (1<<8)
00121
00122 #define MN_FACE_CHECKED (1<<9)
00123
00127 #define MN_FACE_CHANGED (1<<10)
00128
00129 #define MN_FACE_CULLED (1<<11)
00130
00131
00133
00134 #define MAX_EDGEDATA 10
00135 #define EDATA_KNOT 0
00136 #define EDATA_CREASE 1
00137
00138
00144 #define MN_MESH_NONTRI (1<<0)
00145
00146 #define MN_MESH_FILLED_IN (1<<1)
00147
00156 #define MN_MESH_RATSNEST (1<<2)
00157
00159 #define MN_MESH_NO_BAD_VERTS (1<<3)
00160
00161 #define MN_MESH_VERTS_ORDERED (1<<4)
00162
00163 #define MN_MESH_FACE_NORMALS_INVALID (1<<6)
00164
00167 #define MN_MESH_HAS_VOLUME (1<<7)
00168
00169 #define MN_MESH_HITTEST_REQUIRE_ALL (1<<8)
00170
00172 #define MN_MESH_PARTIALCACHEINVALID (1<<16)
00173 #define MN_MESH_CACHE_FLAGS (MN_MESH_FILLED_IN|MN_MESH_NO_BAD_VERTS|MN_MESH_VERTS_ORDERED)
00174
00175
00177
00178 #define MN_MESH_TEMP_1 (1<<13) //!< \internal
00179 #define MN_MESH_TEMP_2 (1<<14) //!< \internal
00180 #define MN_MESH_DONTTRISTRIP (1<<15) //!< \internal
00181
00182
00186 enum PMeshSelLevel { MNM_SL_OBJECT, MNM_SL_VERTEX, MNM_SL_EDGE, MNM_SL_FACE, MNM_SL_CURRENT };
00187
00188
00190
00191 #define MNDISP_VERTTICKS 0x01 //!< Display vertex tick marks.
00192 #define MNDISP_SELVERTS 0x02 //!< Display selected vertices.
00193 #define MNDISP_SELFACES 0x04 //!< Display selected faces.
00194 #define MNDISP_SELEDGES 0x08 //!< Display selected edges
00195 #define MNDISP_NORMALS 0x10 //!< Display face normals.
00196
00197
00198 #define MNDISP_SMOOTH_SUBSEL 0x20
00199 #define MNDISP_BEEN_DISP 0x40 //!< Set when the MNMesh has been displayed (at the end of the render method.)
00200 #define MNDISP_DIAGONALS 0x80 //!< Set when diagonals should be displayed.
00201 #define MNDISP_HIDE_SUBDIVISION_INTERIORS 0x100
00202
00203
00204
00205
00206
00207
00208
00209
00211
00212
00213
00214 #define SUBHIT_MNUSECURRENTSEL (1<<22)
00215 #define SUBHIT_OPENONLY (1<<23)
00216 #define SUBHIT_MNVERTS (1<<24)
00217 #define SUBHIT_MNFACES (1<<25)
00218 #define SUBHIT_MNEDGES (1<<26)
00219
00220 #define SUBHIT_MNDIAGONALS (1<<27)
00221 #define SUBHIT_MNTYPEMASK (SUBHIT_MNVERTS|SUBHIT_MNFACES|SUBHIT_MNEDGES|SUBHIT_MNDIAGONALS)
00222
00223
00225
00226 #define MN_SUBDIV_NEWMAP 0x01
00227 #define MN_SUBDIV_HIDE_INTERNAL_EDGES 0x10
00228
00229
00232 class MNVert : public FlagUser {
00233 public:
00234 Point3 p;
00235 int orig;
00236
00238 MNVert () { orig = -1; }
00239
00241 DllExport MNVert & operator= (const MNVert & from);
00242
00244 bool operator==(const MNVert & from) { return (from.p==p)&&(from.ExportFlags()==ExportFlags()); }
00245 };
00246
00253 class MNEdge : public FlagUser {
00254 public:
00255
00257 int v1;
00258
00260 int v2;
00261
00264 int f1;
00265
00269 int f2;
00270
00271 int track;
00272
00274 MNEdge() { Init(); }
00275
00277 MNEdge (int vv1, int vv2, int fc) { f1=fc; f2=-1; v1=vv1; v2=vv2; track=-1; }
00278
00280 void Init() { v1=v2=f1=0; f2=-1; track=-1; }
00281
00286 int OtherFace (int ff) { return (ff==f1) ? f2 : f1; }
00287
00291 int OtherVert (int vv) { return (vv==v1) ? v2 : v1; }
00292
00296 void Invert () { int hold=v1; v1=v2; v2=hold; hold=f1; f1=f2; f2=hold; }
00297
00306 DllExport void ReplaceFace (int of, int nf, int vv1=-1);
00307
00310 void ReplaceVert (int ov, int nv) { if (v1 == ov) v1 = nv; else { DbgAssert (v2==ov); v2 = nv; } }
00311
00315 DllExport bool Uncrossable ();
00316
00318 DllExport MNEdge & operator= (const MNEdge & from);
00319
00321 bool operator==(MNEdge & f) { return (f.v1==v1)&&(f.v2==v2)&&(f.f1==f1)&&(f.f2==f2)&&(f.ExportFlags()==ExportFlags()); }
00322
00324 int& operator[](int i) { return i ? v2 : v1; }
00325
00327 const int& operator[](int i) const { return i ? v2 : v1; }
00328
00338 DllExport void MNDebugPrint ();
00339 };
00340
00341 class MNFace;
00342
00347 class MNMapFace: public MaxHeapOperators {
00348 friend class MNMesh;
00349 int dalloc;
00350 public:
00352 int deg;
00353
00355 int *tv;
00356
00358 MNMapFace() { Init(); }
00359
00364 DllExport MNMapFace (int d);
00365
00367 ~MNMapFace () { Clear(); }
00368
00371 DllExport void Init();
00372
00374 DllExport void Clear();
00375
00382 DllExport void SetAlloc (int d);
00383
00389 void SetSize (int d) { SetAlloc(d); deg=d; }
00390
00398 DllExport void MakePoly (int fdeg, int *tt);
00399
00407 DllExport void Insert (int pos, int num=1);
00408
00414 DllExport void Delete (int pos, int num=1);
00415
00422 DllExport void RotateStart (int newstart);
00423
00425 DllExport void Flip ();
00426
00432 DllExport int VertIndex (int vv);
00433
00441 DllExport void ReplaceVert (int ov, int nv);
00442
00444 DllExport MNMapFace & operator= (const MNMapFace & from);
00445
00447 DllExport MNMapFace & operator= (const MNFace & from);
00448
00450 DllExport bool operator== (const MNMapFace & from);
00451
00453 DllExport void MNDebugPrint ();
00454 };
00455
00469 DllExport void DiagSort (int dnum, int *diag);
00470
00476 class MNFace : public FlagUser {
00477 friend class MNMesh;
00478
00479
00480
00481 int dalloc;
00482
00483 void SwapContents (MNFace & from);
00484 public:
00485
00487 int deg;
00488
00491 int *vtx;
00492
00497 int *edg;
00498
00507 int *diag;
00508
00510 DWORD smGroup;
00511
00513 MtlID material;
00514
00516 int track;
00517
00520 BitArray visedg;
00521
00524 BitArray edgsel;
00525
00527 BitArray bndedg;
00528
00530 MNFace() { Init(); }
00531
00534 MNFace (int d) { Init(); SetDeg (d); }
00535
00538 DllExport MNFace (const MNFace *from);
00539
00541 ~MNFace () { Clear(); }
00542
00544 DllExport void Init();
00545
00550 DllExport void SetDeg (int d);
00551
00553 DllExport void Clear();
00554
00556 int TriNum() { return deg-2; }
00557
00568 DllExport int FindTriPoint (int edge);
00569
00583 DllExport int FindTriPoint (int a, int b);
00584
00590 DllExport void GetTriangles (Tab<int> &tri);
00591
00597 DllExport void SetAlloc (int d);
00598
00623 DllExport void MakePoly (int fdeg, int *vv, bool *vis=NULL, bool *sel=NULL);
00624
00639 DllExport void Insert (int pos, int num=1);
00640
00671 DllExport bool Delete (int pos, int num=1, int edir=1, bool fixtri=TRUE);
00672
00677 DllExport void RotateStart (int newstart);
00678
00682 DllExport void Flip ();
00683
00697 DllExport int VertIndex (int vv, int ee=-1);
00698
00711 DllExport int EdgeIndex (int ee, int vv=-1);
00712
00718 DllExport void ReplaceVert (int ov, int nv, int ee=-1);
00719
00725 DllExport void ReplaceEdge (int oe, int ne, int vv=-1);
00726
00729 DllExport MNFace & operator= (const MNFace & from);
00730
00732 DllExport bool operator== (const MNFace &from);
00733
00735 int& operator[](int i) { return vtx[i]; }
00736
00738 const int& operator[](int i) const { return vtx[i]; }
00739
00753 DllExport void MNDebugPrint (bool triprint=FALSE);
00754
00755 DllExport IOResult Save (ISave *isave);
00756 DllExport IOResult Load (ILoad *iload);
00757 };
00758
00766 class MNMap : public FlagUser {
00767 friend class MNMesh;
00768 int nv_alloc, nf_alloc;
00769 public:
00771 MNMapFace *f;
00772
00774 UVVert *v;
00775
00777 int numv;
00778
00780 int numf;
00781
00783 MNMap () { Init(); }
00784
00786 ~MNMap () { ClearAndFree (); }
00787
00789
00790
00792 DllExport void Init ();
00793
00803 DllExport void VAlloc (int num, bool keep=TRUE);
00804
00812 DllExport void FAlloc (int num, bool keep=TRUE);
00814
00816
00817
00818 int VNum () const { return numv; }
00819
00824 UVVert V(int i) const { return v[i]; }
00825
00827 int FNum () const { return numf; }
00828
00833 MNMapFace *F(int i) const { return &(f[i]); }
00835
00843 DllExport int NewTri (int a, int b, int c);
00844
00850 DllExport int NewTri (int *vv);
00851
00861 DllExport int NewQuad (int a, int b, int c, int d);
00862
00868 DllExport int NewQuad (int *vv);
00869
00878 DllExport int NewFace (int degg=0, int *vv=NULL);
00879
00884 DllExport void setNumFaces (int nfnum);
00885
00897 DllExport int NewVert (UVVert p, int uoff=0, int voff=0);
00898
00903 DllExport void setNumVerts (int nvnum);
00904
00914 DllExport void CollapseDeadVerts (MNFace *faces);
00915
00923 DllExport void CollapseDeadFaces (MNFace *faces);
00924
00926 DllExport void Clear ();
00927
00929 DllExport void ClearAndFree ();
00930
00935 DllExport void Transform (Matrix3& xfm);
00936
00938
00939
00940 DllExport MNMap & operator= (const MNMap & from);
00941
00946 DllExport MNMap & operator+= (const MNMap & from);
00947
00956 DllExport MNMap & operator+= (const MNMesh & from);
00958
00964 DllExport void ShallowCopy (const MNMap & from);
00965
00968 DllExport void NewAndCopy ();
00969
00976 DllExport void MNDebugPrint (MNFace *faces);
00977
00999 DllExport bool CheckAllData (int mapChannel, int nf, MNFace *faces);
01000
01002 DllExport IOResult Save (ISave *isave, MNFace *faces=NULL);
01003
01005 DllExport IOResult Load (ILoad *iload, MNFace *faces=NULL);
01006 };
01007
01008 DllExport int EdgeDataType (int edID);
01009 DllExport void *EdgeDataDefault (int edID);
01010
01011 class MNMeshBorder;
01012 class MNChamferData;
01013 class MNChamferData10;
01014 class MNFaceClusters;
01015
01019 class MNDiagonalHitData : public HitData {
01020 public:
01023 int mFace, mDiag;
01024
01026 MNDiagonalHitData (int face, int diagonal) : mFace(face), mDiag(diagonal) { }
01027
01029 ~MNDiagonalHitData () { }
01030 };
01031
01032 namespace MaxGraphics {
01033
01034 class IMNMeshInternal;
01035 }
01036
01037
01038
01060 class MNMesh : public FlagUser, public BaseInterfaceServer {
01061 friend class HardwareMNMesh;
01062 friend void gfxCleanup(void *data);
01063 friend class MNNormalSpec;
01064 friend class MNMeshUtilites8Impl;
01065 friend class MNMeshUtilities10Impl;
01066 friend class MNMeshFGBGObject;
01067 friend class MaxGraphics::IMNMeshInternal;
01068
01069 private:
01070
01071 #pragma region Private Member Variables
01072 static int refCount;
01073 static HANDLE workMutex;
01074 static HANDLE workEndEvent;
01075
01076 int nv_alloc;
01077 int ne_alloc;
01078 int nf_alloc;
01079 int nm_alloc;
01080
01081
01083
01084 Box3 bdgBox;
01085 Point3* fnorm;
01086 RVertex* rVerts;
01087 GraphicsWindow *cacheGW;
01089
01090
01091 UINT mDXMeshCacheDrawCount;
01092 UINT mRedrawCountFromLoad;
01093
01094 UINT mBoxDisplayCount;
01095
01096
01097
01098
01099
01100 int normalsBuilt;
01101 float norScale;
01102
01103
01104
01105
01106 MNMap *hmap;
01107
01108 MNMap *m;
01109
01110
01111 int curVCChan;
01112 UVVert *curVCVerts;
01113 MNMapFace *curVCFaces;
01114
01115 DWTab norInd;
01116 int normalCount;
01117 Point3 * gfxNormals;
01118
01119
01120 int numTexCoords[GFX_MAX_TEXTURES];
01121 Point3 * texCoords[GFX_MAX_TEXTURES];
01122
01123 #pragma endregion
01124
01125 #pragma region Private Methods
01126
01127 void SDVEdgeFace (int id, int vid, int *fv, Tab<Tab<int> *> & fmv, int selLevel);
01128
01129
01130 DWORD FindReplacementSmGroup (int ff, DWORD os, int call);
01131
01132
01133 int BooleanZip (DWORD sortFlag, float weldThresh);
01134 bool BoolZipSeam (Tab<int> *lpi, Tab<int> *lpj, int & starth, int & startk, float weldThresh);
01135 void BoolPaintClassification (int ff, DWORD classification);
01136
01137
01138 void buildBoundingBox ();
01139 void buildFaceNormals ();
01140
01141 GraphicsWindow *getCacheGW() { return cacheGW; }
01142 void setCacheGW (GraphicsWindow *gw) { cacheGW = gw; }
01143
01144
01145 BitArray mInvalidVerts;
01146 BitArray mInvalidFaces;
01147 Tab<int> mInvalidVertList;
01148 Tab<int> mInvalidFaceList;
01149
01151
01153 void DrawOnlySelectedEdges(GraphicsWindow *gw);
01154
01156
01158 void DrawOnlySelectedFaces(GraphicsWindow *gw);
01159
01161
01163 void DrawNormals(GraphicsWindow *gw);
01164
01166
01169 void DrawVertexTicks(GraphicsWindow *gw);
01170
01171
01173
01175 void DrawVertexTicksGen(GraphicsWindow *gw);
01176
01178
01181 void DrawVertexTicksDX(GraphicsWindow *gw);
01182
01188
01205 void DrawMeshDX_NoCache(GraphicsWindow *gw, int compFlags, Material *ma, int numMat=-1);
01206
01208
01223 void DrawMeshGenHW(GraphicsWindow *gw, int compFlags, Material *ma, int numMat=-1);
01224
01226
01241 void DrawMeshSZB(GraphicsWindow *gw, int compFlags, Material *ma, int numMat=-1);
01242
01243
01244
01245
01246 bool CanDrawTriStrips(DWORD rndMode, int numMtls, Material *mtl);
01247 bool BuildTriStrips(DWORD rndMode, int numMtls, Material *mtl);
01248 void TriStripify(DWORD rndMode, int numTex, TVFace *tvf[], TriStrip *s, StripData *sd, int vtx);
01249 void Draw3DTriStrips(IHardwareShader *phs, int numMat, Material *ma);
01250 void Draw3DWireTriStrips(IHardwareShader *phs, int numMat, Material *ma);
01251 void Draw3DVisEdgeList(IHardwareShader *phs, DWORD flags);
01252 int render3DTriStrips(IHardwareShader *phs, int kmat, int kstrips);
01253 int render3DWireTriStrips(IHardwareShader *phs, int kmat, int kstrips);
01254 int render3DFaces(IHardwareShader *phs, DWORD index, int *custVis=NULL);
01255
01256
01257 bool RemoveInternalVertex (int vertex);
01258 bool RemoveBorderVertex (int vertex);
01259
01260
01261 void renderSingleDiagonal (GraphicsWindow *gw, int ff, int d);
01262
01263
01264 bool ConnectEdges (DWORD edgeFlag, int segments=2, int pinch = 0, int slide = 0 );
01265 void MultiDivideEdge (int edge, int segments, int pinch, int slide, bool in_flipEdge );
01266
01267
01268 bool SplitFlaggedVertices (DWORD in_vertexFlag, float in_distance );
01269 bool SplitFlaggedEdges ( DWORD in_edgeFlag , float in_distance );
01270
01271
01272 bool ChamferVertices (DWORD in_flag, MNChamferData *in_mcd, bool in_open);
01273 bool ChamferEdges (DWORD in_flag, MNChamferData *in_mcd, bool in_open );
01274
01275
01276 bool ChamferEdges (DWORD in_flag, MNChamferData10& in_mcd, bool in_open, int in_segments);
01277 #pragma endregion
01278
01279 public:
01280
01281 #pragma region Public Member Variables
01282 MNVert *v;
01283 MNEdge *e;
01284 MNFace *f;
01285 int numv;
01286 int nume;
01287 int numf;
01288 int numm;
01289
01294 PerData *vd;
01295
01298 BitArray vdSupport;
01299
01303 PerData *ed;
01304
01307 BitArray edSupport;
01308
01310 int selLevel;
01311
01313 DWORD dispFlags;
01314
01320 Tab<int> *vedg;
01321
01327 Tab<int> *vfac;
01328 #pragma endregion
01329
01330 #pragma region Constructors and Destructors
01331
01332
01333
01334 MNMesh () { Init(); DefaultFlags (); }
01335
01338 MNMesh (const Mesh & from) { Init(); SetFromTri (from); FillInMesh (); }
01339
01341 MNMesh (const MNMesh & from) { Init(); DefaultFlags(); *this = from; }
01342
01344 DllExport ~MNMesh();
01346 #pragma endregion
01347
01348 #pragma region Allocation and Initialization Methods
01349
01350
01351
01352 void DefaultFlags () { ClearAllFlags (); }
01353
01375 DllExport void Init ();
01376
01383 DllExport void VAlloc (int num, bool keep=TRUE);
01384
01390 DllExport void VShrink (int num=-1);
01391
01394 DllExport void freeVEdge();
01395
01397 DllExport void VEdgeAlloc();
01398
01400 DllExport void freeVFace();
01401
01403 DllExport void VFaceAlloc();
01404
01412 DllExport void EAlloc (int num, bool keep=TRUE);
01413
01420 DllExport void EShrink (int num=-1);
01421
01429 DllExport void FAlloc (int num, bool keep=TRUE);
01430
01437 DllExport void FShrink (int num=-1);
01438
01446 DllExport void MAlloc (int num, bool keep=TRUE);
01447
01454 DllExport void MShrink (int num=-1);
01456 #pragma endregion
01457
01458 #pragma region Component Access Functions
01459
01460
01461
01462 int VNum () const { return numv; }
01463
01465 MNVert *V(int i) const { return &(v[i]); }
01466
01468 Point3 & P(int i) const { return v[i].p; }
01469
01471 int ENum () const { return nume; }
01472
01474 MNEdge *E(int i) const { return &(e[i]); }
01475
01477 int FNum () const { return numf; }
01478
01480 MNFace *F(int i) const { return &(f[i]); }
01481
01483 int MNum () const { return numm; }
01484
01486 DllExport int TriNum () const;
01487 #pragma endregion
01488
01489 #pragma region Mapping Methods
01490
01491
01492
01496 DllExport MNMap *M(int mapChannel) const;
01497
01504 DllExport void SetMapNum (int mpnum);
01505
01515 DllExport void InitMap (int mapChannel);
01516
01525 DllExport void ClearMap (int mapChannel);
01526
01537 DllExport UVVert MV (int mapChannel, int i) const;
01538
01550 DllExport MNMapFace *MF (int mapChannel, int i) const;
01551
01570 DllExport UVVert ExtrapolateMapValue (int face, int edge, Point3 & pt, int mapChannel);
01571
01581 DllExport bool SeparateMapVerticesInFaceCluster (MNFaceClusters & fclust, int clusterID);
01582
01591 DllExport bool IsEdgeMapSeam (int mapChannel, int edge);
01592
01604 DllExport void FindEdgeListMapVerts (const Tab<int> & lp, Tab<int> & mv, int mapChannel);
01606 #pragma endregion
01607
01608 #pragma region Per-Vertex Data
01609
01610
01611
01618 DllExport void setNumVData (int ct, BOOL keep=FALSE);
01620 int VDNum () const { return vdSupport.GetSize(); }
01628 DllExport BOOL vDataSupport (int vdChannel) const;
01639 DllExport void setVDataSupport (int vdChannel, BOOL support=TRUE);
01647 void *vertexData (int vdChannel) const { return vDataSupport(vdChannel) ? vd[vdChannel].data : NULL; }
01655 float *vertexFloat (int vdChannel) const { return (float *) vertexData (vdChannel); }
01662 DllExport void freeVData (int vdChannel);
01665 DllExport void freeAllVData ();
01667 #pragma endregion
01668
01669 #pragma region Vertex Weight Methods
01670
01671
01672
01673 float *getVertexWeights () { return vertexFloat(VDATA_WEIGHT); }
01676 void SupportVertexWeights () { setVDataSupport (VDATA_WEIGHT); }
01678 void freeVertexWeights () { freeVData (VDATA_WEIGHT); }
01680 float *getVSelectionWeights () { return vertexFloat(VDATA_SELECT); }
01683 void SupportVSelectionWeights () { setVDataSupport (VDATA_SELECT); }
01685 void freeVSelectionWeights () { freeVData (VDATA_SELECT); }
01687 #pragma endregion
01688
01689 #pragma region Per-Edge Data
01690
01691
01692
01699 DllExport void setNumEData (int ct, BOOL keep=FALSE);
01701 int EDNum () const { return edSupport.GetSize(); }
01709 DllExport BOOL eDataSupport (int edChannel) const;
01718 DllExport void setEDataSupport (int edChannel, BOOL support=TRUE);
01726 void *edgeData (int edChannel) const { return eDataSupport(edChannel) ? ed[edChannel].data : NULL; }
01734 float *edgeFloat (int edChannel) const { return (float *) edgeData (edChannel); }
01741 DllExport void freeEData (int edChannel);
01744 DllExport void freeAllEData ();
01746 #pragma endregion
01747
01748 #pragma region Edge Knot Methods
01749
01750
01751
01752 float *getEdgeKnots () { return edgeFloat(EDATA_KNOT); }
01754 void SupportEdgeKnots () { setEDataSupport (EDATA_KNOT); }
01756 void freeEdgeKnots () { freeEData (EDATA_KNOT); }
01758 #pragma endregion
01759
01760 #pragma region Vertex Face and Edge Methods
01761
01762
01763
01765 DllExport void VClear (int vv);
01771 DllExport void VInit (int vv);
01787 DllExport int VFaceIndex (int vv, int ff, int ee=-1);
01800 DllExport int VEdgeIndex (int vv, int ee);
01811 void VDeleteEdge (int vv, int ee) { if (vedg) vedg[vv].Delete (VEdgeIndex(vv, ee), 1); }
01823 DllExport void VDeleteFace (int vv, int ff);
01836 DllExport void VReplaceEdge (int vv, int oe, int ne);
01851 DllExport void VReplaceFace (int vv, int of, int nf);
01863 DllExport void CopyVert (int nv, int ov);
01876 DllExport void MNVDebugPrint (int vv);
01878 #pragma endregion
01879
01880 #pragma region Mesh Building Functions
01881
01882
01883
01893 DllExport int NewTri (int a, int b, int c, DWORD smG=0, MtlID mt=0);
01905 DllExport int NewTri (int *vv, DWORD smG=0, MtlID mt=0);
01917 DllExport int NewQuad (int a, int b, int c, int d, DWORD smG=0, MtlID mt=0);
01929 DllExport int NewQuad (int *vv, DWORD smG=0, MtlID mt=0);
01951 DllExport int NewFace (int initFace, int degg=0, int *vv=NULL, bool *vis=NULL, bool *sel=NULL);
01970 DllExport int CreateFace (int degg, int *vv);
01975 DllExport int AppendNewFaces (int nfnum);
01980 DllExport void setNumFaces (int nfnum);
01996 DllExport int RegisterEdge (int v1, int v2, int f, int fpos);
02003 DllExport int SimpleNewEdge (int v1, int v2);
02016 DllExport int NewEdge (int v1, int v2, int f, int fpos);
02021 DllExport int AppendNewEdges (int nenum);
02026 DllExport void setNumEdges (int nenum);
02031 DllExport int NewVert (Point3 & p);
02042 DllExport int NewVert (Point3 & p, int vid);
02049 DllExport int NewVert (int vid);
02061 DllExport int NewVert (int v1, int v2, float prop);
02067 DllExport int AppendNewVerts (int nvnum);
02072 DllExport void setNumVerts (int nvnum);
02076 DllExport int InsertSpur (int face, int vertIndex, Tab<int> *ptMapVertArray=NULL);
02078 #pragma endregion
02079
02080 #pragma region Component Removal Routines
02081
02082
02083
02084
02085
02088 DllExport void CollapseDeadVerts ();
02092 DllExport void CollapseDeadEdges ();
02096 DllExport void CollapseDeadFaces ();
02099 DllExport void CollapseDeadStructs();
02104 DllExport void Clear ();
02107 DllExport void ClearAndFree ();
02109 DllExport void freeVerts();
02111 DllExport void freeEdges();
02113 DllExport void freeFaces();
02122 DllExport void freeMap(int mapChannel);
02124 DllExport void freeMaps();
02125
02126 DllExport bool RemoveVertex (int vertex);
02127
02128
02129
02130 DllExport bool RemoveSpur (int spur);
02131
02145 DllExport void DeleteFlaggedFaces (DWORD deathflags, DWORD nvCopyFlags=0x0);
02146
02155 DllExport void RemoveEdge (int edge);
02156
02167 DllExport void EliminateCollinearVerts ();
02178 DllExport void EliminateCoincidentVerts (float thresh=MNEPS);
02180 #pragma endregion
02181
02182 #pragma region Bulk Flag Clearing and Setting Functions
02183
02184
02185
02186 void ClearVFlags (DWORD fl) { for (int i=0; i<numv; i++) v[i].ClearFlag (fl); }
02188 void ClearEFlags (DWORD fl) { for (int i=0; i<nume; i++) e[i].ClearFlag (fl); }
02190 void ClearFFlags (DWORD fl) { for (int i=0; i<numf; i++) f[i].ClearFlag (fl); }
02201 DllExport void PaintFaceFlag (int ff, DWORD fl, DWORD fenceflags=0x0);
02237 DllExport int PropegateComponentFlags (int slTo, DWORD flTo,
02238 int slFrom, DWORD flFrom, bool ampersand=FALSE, bool set=TRUE);
02249 DllExport void UpdateBackfacing (GraphicsWindow *gw, bool force);
02251 #pragma endregion
02252
02253 #pragma region Selection Methods
02254
02255
02256
02262 DllExport void VertexSelect (const BitArray & vsel);
02269 DllExport void EdgeSelect (const BitArray & esel);
02276 DllExport void FaceSelect (const BitArray & fsel);
02282 bool getVertexSel (BitArray & vsel) { return getVerticesByFlag (vsel, MN_SEL); }
02287 bool getEdgeSel (BitArray & esel) { return getEdgesByFlag (esel, MN_SEL); }
02292 bool getFaceSel (BitArray & fsel) { return getFacesByFlag (fsel, MN_SEL); }
02299 DllExport void SelectEdgeLoop (BitArray & edgeSel);
02300
02307 DllExport void SelectEdgeRing (BitArray & edgeSel);
02323 DllExport BitArray VertexTempSel (DWORD fmask=MN_DEAD|MN_SEL, DWORD fset=MN_SEL);
02325 #pragma endregion
02326
02327 #pragma region Getting Components by Flag
02328
02329
02330
02342 DllExport bool getVerticesByFlag (BitArray & vset, DWORD flags, DWORD fmask=0x0);
02355 DllExport bool getEdgesByFlag (BitArray & eset, DWORD flags, DWORD fmask=0x0);
02368 DllExport bool getFacesByFlag (BitArray & fset, DWORD flags, DWORD fmask=0x0);
02379 DllExport void ElementFromFace (int ff, BitArray & fset);
02391 DllExport void BorderFromEdge (int ee, BitArray & eset);
02393 #pragma endregion
02394
02395 #pragma region Edge Visibility and Selection Methods
02396
02397
02398
02407 DllExport void SetEdgeVis (int ee, BOOL vis=TRUE);
02417 DllExport void SetEdgeSel (int ee, BOOL sel=TRUE);
02419 #pragma endregion
02420
02421 #pragma region Mesh Compatibility Functions
02422
02423
02424
02426 void SetFromTri (const Mesh & from) { Clear (); AddTri (from); }
02429 DllExport void AddTri (const Mesh & from);
02434 DllExport void OutToTri (Mesh & tmesh);
02436 #pragma endregion
02437
02438 #pragma region Mesh Computation Functions
02439
02440
02441
02447 DllExport void FillInMesh ();
02450 DllExport void FillInFaceEdges ();
02453 DllExport void FillInVertEdgesFaces ();
02475 DllExport bool EliminateBadVerts (DWORD flag=0);
02484 DllExport void OrderVerts ();
02494 DllExport void OrderVert (int vid);
02496 #pragma endregion
02497
02498 #pragma region Mesh Triangulation Routines
02499
02500
02501
02505 DllExport void Triangulate ();
02512 DllExport void TriangulateFace (int ff);
02524 DllExport int DivideFace (int ff, Tab<float> & bary);
02526 #pragma endregion
02527
02528 #pragma region Bounding Box Methods
02529
02530
02531
02533 DllExport void FaceBBox (int ff, Box3 & bbox);
02543 DllExport void BBox (Box3 & bbox, bool targonly=FALSE);
02553 DllExport Box3 getBoundingBox (Matrix3 *tm=NULL, bool targonly=FALSE);
02555 #pragma endregion
02556
02557 #pragma region Targeting Methods
02558
02559
02560
02569 DllExport int TargetVertsBySelection (int selLevel);
02579 DllExport int TargetEdgesBySelection (int selLevel);
02589 DllExport int TargetFacesBySelection (int selLevel);
02608 DllExport void DetargetVertsBySharpness (float sharpval);
02610 #pragma endregion
02611
02612 #pragma region Face-Center methods
02613
02614
02615
02623 DllExport void ComputeCenters (Point3 *ctr, bool targonly=FALSE);
02626 DllExport void ComputeCenter (int ff, Point3 & ctr);
02638 DllExport void ComputeNormal (int ff, Point3 & normal, Point3 *ctr=NULL);
02650 DllExport void ComputeSafeCenters (Point3 *ctr, bool targonly=FALSE, bool detarg=FALSE);
02664 DllExport bool ComputeSafeCenter (int ff, Point3 & ctr);
02666 #pragma endregion
02667
02668 #pragma region Triangulation-of-polygon Methods
02669
02670
02671
02675 DllExport void RetriangulateFace (int ff);
02687 DllExport void FindDiagonals (int ff, int *diag);
02697 DllExport void FindDiagonals (int deg, int *vv, int *diag);
02709 DllExport void BestConvexDiagonals (int ff, int *diag=NULL);
02720 DllExport void BestConvexDiagonals (int deg, int *vv, int *diag);
02721 DllExport bool SetDiagonal (int ff, int d1, int d2);
02723 #pragma endregion
02724
02725 #pragma region Unification Methods
02726
02727
02728
02729
02737 DllExport void MakePolyMesh (int maxdeg=0, BOOL elimCollin=TRUE);
02738
02750 DllExport void MakeConvexPolyMesh (int maxdeg=0);
02752 #pragma endregion
02753
02754 #pragma region Normal methods
02755
02756
02757
02758
02765 DllExport int FindEdgeFromVertToVert (int vrt1, int vrt2);
02789 DllExport void GetVertexSpace (int vrt, Matrix3 & tm);
02797 DllExport Point3 GetVertexNormal (int vrt);
02803 DllExport Point3 GetEdgeNormal (int ed);
02815 DllExport Point3 GetFaceNormal (int fc, bool nrmlz=FALSE);
02820 Point3 GetEdgeNormal (int vrt1, int vrt2) { return GetEdgeNormal (FindEdgeFromVertToVert(vrt1, vrt2)); }
02829 DllExport float EdgeAngle (int ed);
02847 DllExport void FlipNormal(int faceIndex);
02857 DllExport void checkNormals (BOOL illum);
02867 DllExport void buildNormals ();
02872 DllExport void buildRenderNormals ();
02880 DllExport bool FlipElementNormals (DWORD flag=MN_SEL);
02882 DllExport bool FlipFaceNormals (DWORD faceFlag);
02884 #pragma endregion
02885
02886 #pragma region Smoothing Group Handling
02887
02888
02889
02911 DllExport void Resmooth (bool smooth=TRUE, bool targonly=FALSE, DWORD targmask=~0x0);
02918 DllExport DWORD CommonSmoothing (bool targonly=FALSE);
02927 DllExport DWORD GetNewSmGroup (bool targonly=FALSE);
02934 DllExport MtlID GetNewMtlID (bool targonly = FALSE);
02941 DllExport DWORD GetOldSmGroup (bool targonly=FALSE);
02948 DllExport DWORD GetAllSmGroups (bool targonly=FALSE);
02964 DllExport DWORD FindReplacementSmGroup (int ff, DWORD os);
02975 DllExport void PaintNewSmGroup (int ff, DWORD os, DWORD ns);
02985 DllExport bool SeparateSmGroups (int v1, int v2);
03015 DllExport void AutoSmooth(float angle,BOOL useSel,BOOL preventIndirectSmoothing);
03017 #pragma endregion
03018
03019 #pragma region Fence Methods
03020
03021
03022
03023
03024
03026 DllExport void FenceMaterials ();
03029 DllExport void FenceSmGroups ();
03033 DllExport void FenceFaceSel ();
03036 DllExport void FenceOneSidedEdges();
03053 DllExport void FenceNonPlanarEdges (float thresh=.9999f, bool makevis=FALSE);
03057 DllExport void SetMapSeamFlags ();
03065 DllExport void SetMapSeamFlags (int mapChannel);
03067 #pragma endregion
03068
03069 #pragma region Face Point Functions
03070
03071
03072
03073
03097 DllExport int FindFacePointTri (int ff, Point3 & pt, double *bary, int *tri);
03112 DllExport UVVert FindFacePointMapValue (int ff, Point3 & pt, int mapChannel);
03114 #pragma endregion
03115
03116 #pragma region Hole Fixing Functions
03117
03118
03119
03133 DllExport void GetBorder (MNMeshBorder & brd, int selLevel=MNM_SL_OBJECT, DWORD targetFlag=MN_SEL);
03144 DllExport void FillInBorders (MNMeshBorder *b=NULL);
03156 DllExport void FindOpenRegions ();
03158 #pragma endregion
03159
03160 #pragma region Doubled Mapping Vertex Functions
03161
03176 DllExport BOOL CheckForDoubledMappingVerts();
03177
03179 DllExport void EliminateDoubledMappingVerts();
03181 #pragma endregion
03182
03183 #pragma region Isolated Mapping Vertex Functions
03184
03185
03186
03187
03188 DllExport void EliminateIsoMapVerts();
03189
03191 DllExport void EliminateIsoMapVerts(int mapChannel);
03193 #pragma endregion
03194
03195 #pragma region Operators
03196
03197
03198
03200 DllExport MNMesh & operator= (const MNMesh & from);
03208 DllExport MNMesh & operator+= (const MNMesh & from);
03218 #pragma endregion
03219
03220 #pragma region Debugging Functions
03221
03222
03223 DllExport void MNDebugPrint (bool triprint=FALSE);
03232 DllExport void MNDebugPrintVertexNeighborhood (int vv, bool triprint=FALSE);
03270 DllExport bool CheckAllData ();
03272 #pragma endregion
03273
03274 #pragma region Splitting and Subdividing Methods
03275
03276
03277
03308 DllExport int SplitTriEdge (int ee, float prop=.5f, float thresh=MNEPS,
03309 bool neVis=TRUE, bool neSel=FALSE);
03342 DllExport int SplitTriFace (int ff, double *bary=NULL, float thresh=MNEPS,
03343 bool neVis=TRUE, bool neSel=FALSE);
03369 DllExport void SplitTri6 (int ff, double *bary=NULL, int *nv=NULL);
03383 DllExport int SplitEdge (int ee, float prop=.5f);
03397 DllExport int SplitEdge (int ee, float prop, Tab<int> *newTVerts);
03441 DllExport int SplitEdge (int ff, int ed, float prop, bool right, int *nf=NULL,
03442 int *ne=NULL, bool neVis=FALSE, bool neSel=FALSE, bool allconvex=FALSE);
03462 DllExport int IndentFace (int ff, int ei, int nv, int *ne=NULL, bool nevis=TRUE, bool nesel=FALSE);
03487 DllExport void SeparateFace (int ff, int a, int b, int & nf, int & ne, bool neVis=FALSE, bool neSel=FALSE);
03510 DllExport bool Slice (Point3 & N, float off, float thresh, bool split, bool remove, bool flaggedFacesOnly=false, DWORD faceFlags=MN_SEL);
03522 DllExport bool SplitFlaggedVertices (DWORD flag=MN_SEL);
03532 DllExport bool SplitFlaggedEdges (DWORD flag=MN_SEL);
03533
03534
03535
03536
03537
03538 DllExport bool SplitFacesUsingBothSidesOfEdge (DWORD edgeFlag=0x0);
03545 DllExport void MultiDivideEdge (int edge, int segments);
03548 DllExport void MakeConvex ();
03556 DllExport void MakeFaceConvex (int ff);
03563 DllExport void RestrictPolySize (int maxdeg);
03564 #pragma endregion
03565
03566 #pragma region Planar functions
03567
03572 DllExport void MakePlanar (float planarThresh);
03573
03582 DllExport void MakeFacePlanar (int ff, float planarThresh);
03584 #pragma endregion
03585
03586 #pragma region Welding Functions
03587
03588
03589
03595 DllExport bool WeldVerts (int a, int b);
03601 DllExport bool WeldEdge (int ee);
03612 DllExport bool WeldBorderVerts (int v1, int v2, Point3 *destination);
03627 DllExport bool WeldBorderEdges (int e1, int e2);
03650 DllExport bool WeldBorderVerts (float thresh, DWORD flag=MN_SEL);
03652 DllExport bool WeldOpposingEdges (DWORD edgeFlag);
03654 #pragma endregion
03655
03656 #pragma region Tessellation Methods
03657
03658
03659
03674 DllExport void TessellateByEdges (float bulge, MeshOpProgress* mop = NULL);
03708 DllExport bool AndersonDo (float interp, int selLevel, MeshOpProgress *mop=NULL, DWORD subdivFlags=0);
03714 DllExport void TessellateByCenters (MeshOpProgress *mop=NULL);
03762 DllExport void SabinDoo (float interp, int selLevel, MeshOpProgress *mop=NULL, Tab<Point3> *offsets=NULL);
03801 DllExport void SabinDooVert (int vid, float interp, int selLevel, Point3 *ctr, Tab<Point3> *offsets=NULL);
03829 DllExport void CubicNURMS (MeshOpProgress *mop=NULL,
03830 Tab<Point3> *offsets=NULL, DWORD subdivFlags=0);
03832 #pragma endregion
03833
03834 #pragma region Boolean Methods
03835
03836
03837
03840 DllExport void PrepForBoolean ();
03869 DllExport bool BooleanCut (MNMesh & m2, int cutType, int fstart=0, MeshOpProgress *mop=NULL);
03921 DllExport bool MakeBoolean (MNMesh & m1, MNMesh & m2, int type, MeshOpProgress *mop=NULL);
03923 #pragma endregion
03924
03925 #pragma region Connection Methods
03926
03927
03928
03960 DllExport void Connect (MNMeshBorder & borderList, int segs, float tension,
03961 bool sm_bridge, bool sm_ends, Tab<int> *vsep=NULL);
03987 DllExport void ConnectLoops (Tab<int> & loop1, Tab<int> & loop2,
03988 int segs, float tension, DWORD smGroup, MtlID mat, bool sm_ends);
03997 DllExport bool ConnectEdges (DWORD edgeFlag, int segments=2);
03998
04005 DllExport bool ConnectVertices (DWORD vertexFlag);
04007 #pragma endregion
04008
04009 #pragma region Barycentric Functions
04010
04029 DllExport void FacePointBary (int ff, Point3 & p, Tab<float> & bary);
04030
04031
04032 DllExport void FindFaceBaryVector (int face, int vertIndex, Point3 & vector, Tab<float> & tBary);
04034 #pragma endregion
04035
04036 #pragma region Cloning and Copying Operations
04037
04038
04039
04047 DllExport void CloneVerts (DWORD cloneFlag = MN_SEL, bool clear_orig=TRUE);
04056 DllExport void CloneFaces (DWORD cloneFlag = MN_SEL, bool clear_orig=TRUE);
04057
04068 DllExport void CopyBasics (const MNMesh & from, bool copyEdges = false);
04070 #pragma endregion
04071
04072 #pragma region Plane Methods
04073
04074
04075
04090 DllExport bool MakeFlaggedPlanar (int selLev, DWORD flag=MN_SEL, Point3 *delta=NULL);
04103 DllExport bool MoveVertsToPlane (Point3 & norm, float offset, DWORD flag=MN_SEL, Point3 *delta=NULL);
04105 #pragma endregion
04106
04107 #pragma region Detach Operations
04108
04109
04110
04120 DllExport bool DetachFaces (DWORD flag=MN_SEL);
04137 DllExport bool DetachElementToObject (MNMesh & nmesh, DWORD fflags=MN_SEL, bool delDetached=true);
04139 #pragma endregion
04140
04141 #pragma region Extrusion Methods
04142
04143
04144
04156 DllExport bool ExtrudeFaceClusters (MNFaceClusters & fclust);
04170 DllExport bool ExtrudeFaceCluster (MNFaceClusters & fclust, int cl);
04182 DllExport bool ExtrudeFaces (DWORD flag=MN_SEL);
04183
04184
04185
04186
04187 DllExport void GetExtrudeDirection (MNChamferData *mcd, DWORD faceFlag);
04206 DllExport void GetExtrudeDirection (MNChamferData *mcd,
04207 MNFaceClusters *fclust=NULL, Point3 *clustNormals=NULL);
04240 DllExport bool ExtrudeVertices (DWORD vertexFlag, MNChamferData *pMCD, Tab<Point3> & tUpDir);
04241
04275 DllExport bool ExtrudeEdges (DWORD edgeFlag, MNChamferData *pMCD, Tab<Point3> & tUpDir);
04276
04286 DllExport bool ExtrudeFaceClusterAlongPath (Tab<Matrix3> tFrenets, MNFaceClusters & fclust, int clusterID, bool align);
04287
04289 #pragma endregion
04290
04291 #pragma region Coloring Methods
04292
04293
04294
04308 DllExport bool SetVertColor (UVVert clr, int mapChannel, DWORD flag=MN_SEL);
04325 DllExport bool SetFaceColor (UVVert clr, int mapChannel, DWORD flag=MN_SEL);
04327 #pragma endregion
04328
04329 #pragma region Chamfer Operations
04330
04331
04332
04348 DllExport bool ChamferVertices (DWORD flag=MN_SEL, MNChamferData *mcd=NULL);
04365 DllExport bool ChamferEdges (DWORD flag=MN_SEL, MNChamferData *mcd=NULL);
04367 #pragma endregion
04368
04369 #pragma region Cutting Methods
04370
04371
04372
04393 DllExport int CutFace (int f1, Point3 & p1, Point3 & p2, Point3 & Z, bool split);
04421 DllExport int CutEdge (int e1, float prop1, int e2, float prop2, Point3 & Z, bool split);
04441 DllExport int Cut (int startv, Point3 & end, Point3 & Z, bool split);
04443 #pragma endregion
04444
04445 #pragma region Pipeline Object Functions
04446
04447
04448
04463 DllExport void ApplyMapper (UVWMapper & mapChannel, int channel=0, BOOL useSel=FALSE);
04464
04467 DllExport void InvalidateGeomCache ();
04468
04469
04470
04471
04472
04473
04479 DllExport void InvalidateTopoCache ( bool in_clearCacheFlags = true );
04487 DllExport void UpdateDisplayVertexColors ();
04498 DllExport void SetDisplayVertexColors (int chan);
04507 DllExport void SetDisplayVertexColors (UVVert *mv, MNMapFace *mf);
04519 DllExport void PrepForPipeline ();
04522 DllExport void allocRVerts ();
04525 DllExport void updateRVerts (GraphicsWindow *gw);
04527 DllExport void freeRVerts ();
04529 #pragma endregion
04530
04531 #pragma region Display Flag Methods
04532
04533
04534
04535
04536 void SetDispFlag(DWORD f) { dispFlags |= f; }
04538 DWORD GetDispFlag(DWORD f) { return dispFlags & f; }
04540 void ClearDispFlag(DWORD f) { dispFlags &= ~f; }
04542 #pragma endregion
04543
04544 #pragma region Render Methods
04545
04546
04547
04575 DllExport void render(GraphicsWindow *gw, Material *ma, RECT *rp, int compFlags, int numMat=1, InterfaceServer *pi=NULL);
04583 DllExport void renderFace (GraphicsWindow *gw, int ff);
04592 DllExport void render3DFace (GraphicsWindow *gw, int ff);
04597 DllExport void render3DDiagonals (GraphicsWindow *gw, DWORD compFlags);
04601 DllExport void renderDiagonals (GraphicsWindow *gw, DWORD compFlags);
04619 DllExport void renderDiagonal (GraphicsWindow *gw, int ff, bool useSegments=false, bool *lastColorSubSel=NULL);
04624 DllExport void render3DEdges (GraphicsWindow *gw, DWORD compFlags);
04628 DllExport void renderEdges (GraphicsWindow *gw, DWORD compFlags);
04646 DllExport void renderEdge (GraphicsWindow *gw, int ee, bool useSegments=false, bool *lastColorSubSel=NULL);
04648 #pragma endregion
04649
04650 #pragma region Intersection and Hit Testing Functions
04651
04652
04653
04669 DllExport BOOL select (GraphicsWindow *gw, Material *ma, HitRegion *hr, int abortOnHit=FALSE, int numMat=1);
04696 DllExport BOOL SubObjectHitTest(GraphicsWindow *gw, Material *ma, HitRegion *hr,
04697 DWORD flags, SubObjHitList& hitList, int numMat=1 );
04709 DllExport int IntersectRay (Ray& ray, float& at, Point3& norm);
04728 DllExport int IntersectRay (Ray& ray, float& at, Point3& norm, int &fi, Tab<float> & bary);
04730 #pragma endregion
04731
04732 #pragma region Object Overrides
04733
04734
04735
04736 DllExport void ShallowCopy(MNMesh *amesh, ChannelMask channels);
04737 DllExport void NewAndCopyChannels(ChannelMask channels);
04738 DllExport void FreeChannels (ChannelMask channels, BOOL zeroOthers=1);
04740 #pragma endregion
04741
04742 #pragma region IO Functions
04743
04744
04745
04746 DllExport IOResult Save (ISave *isave);
04747 DllExport IOResult Load (ILoad *iload);
04749 #pragma endregion
04750
04751 #pragma region FlagUser Overrides
04752
04753
04754
04755 DllExport void ClearFlag (DWORD fl);
04757 #pragma endregion
04758
04759 #pragma region InterfaceServer Overrides
04760
04761
04762
04763 DllExport BaseInterface* GetInterface(Interface_ID id);
04765 #pragma endregion
04766
04767 #pragma region Cache and Optimization Methods
04768
04769
04770
04773 DllExport void ReduceDisplayCaches();
04774
04781 DllExport bool NeedGWCacheRebuilt(GraphicsWindow *gw, Material *ma, int numMat);
04782
04790 DllExport void BuildGWCache(GraphicsWindow *gw, Material *ma, int numMat, BOOL threaded);
04798 DllExport void InvalidateHardwareMesh (DWORD keepFlags=0);
04803 DllExport void SetStaticMesh(bool staticMesh);
04805 #pragma endregion
04806
04807 #pragma region Specified Normal Methods
04808
04809
04810
04815 DllExport MNNormalSpec *GetSpecifiedNormals();
04823 DllExport MNNormalSpec *GetSpecifiedNormalsForDisplay();
04826 DllExport void ClearSpecifiedNormals ();
04833 DllExport void SpecifyNormals ();
04835 #pragma endregion
04836
04837 #pragma region Miscellaneous Methods
04838
04839
04840
04841 DllExport void Transform (Matrix3 & xfm);
04842
04847 bool IsClosed() { for (int i=0; i<nume; i++) if (e[i].f2<0) return FALSE; return nume?TRUE:FALSE; }
04848
04862 DllExport void Relax (float relaxval, bool targonly=TRUE);
04863
04875 DllExport bool LiftFaceClusterFromEdge (int liftEdge, float liftAngle, int segments, MNFaceClusters & fclust, int clusterID);
04876
04887 DllExport void SmoothByCreases (DWORD creaseFlag);
04888
04889 #ifdef SEPARATE_GEOM_TOPO_INVALIDATION
04890 DllExport void InvalidateHardwareMeshTopo (DWORD keepFlags=0);
04891 #endif
04892
04894 #pragma endregion
04895 };
04896
04910 class MNMeshBorder: public MaxHeapOperators {
04911 friend class MNMesh;
04915 Tab<Tab<int> *> bdr;
04916 BitArray btarg;
04917 public:
04921 ~MNMeshBorder () { Clear(); }
04924 DllExport void Clear ();
04927 int Num () { return bdr.Count(); }
04929 Tab<int> *Loop (int i) { return bdr[i]; }
04931 bool LoopTarg (int i) { return ((i>=0) && (i<bdr.Count()) && (btarg[i])); }
04940 DllExport void MNDebugPrint (MNMesh *m);
04941 };
04942
04954 class MNFaceElement: public MaxHeapOperators {
04955 public:
04956
04957 Tab<int> elem;
04958 int count;
04959
04964 DllExport MNFaceElement (MNMesh &mesh);
04965
04967 int operator[](int i) {return elem[i];}
04968 };
04969
04986 class MNFaceClusters: public MaxHeapOperators {
04987 public:
04989 Tab<int> clust;
04990
04992 int count;
04993
05004 DllExport MNFaceClusters (MNMesh & mesh, DWORD clusterFlags);
05005
05020 DllExport MNFaceClusters (MNMesh & mesh, float angle, DWORD clusterFlags);
05021
05023 int operator[](int i) { return (i<clust.Count()) ? clust[i] : -1; }
05024
05036 DllExport void MakeVertCluster(MNMesh &mesh, Tab<int> & vclust);
05037
05049 DllExport void GetNormalsCenters (MNMesh &mesh, Tab<Point3> & norm, Tab<Point3> & ctr);
05050
05071 DllExport void GetBorder (MNMesh &mesh, int clustID, Tab<int> & cbord);
05072
05090 DllExport void GetOutlineVectors (MNMesh & m, Tab<Point3> & cnorms, Tab<Point3> & odir);
05091 };
05092
05105 class MNEdgeClusters: public MaxHeapOperators {
05106 public:
05109 Tab<int> clust;
05110
05112 int count;
05113
05122 DllExport MNEdgeClusters (MNMesh &mesh, DWORD clusterFlags);
05123
05125 int operator[](int i) {return clust[i];}
05126
05137 DllExport void MakeVertCluster (MNMesh &mesh, Tab<int> & vclust);
05138
05153 DllExport void GetNormalsCenters (MNMesh &mesh, Tab<Point3> & norm, Tab<Point3> & ctr);
05154 };
05155
05174 class MNChamferData: public MaxHeapOperators {
05175 Tab<UVVert> hmdir[NUM_HIDDENMAPS];
05176 public:
05177 Tab<Point3> vdir;
05178 Tab<float> vmax;
05179 Tab<UVVert> *mdir;
05180
05182 MNChamferData () { mdir=NULL;}
05183
05190 MNChamferData (const MNMesh & m) { mdir=NULL; InitToMesh(m);}
05191
05193 DllExport ~MNChamferData ();
05194
05200 DllExport void InitToMesh (const MNMesh & m);
05201
05215 DllExport void setNumVerts (int nv, bool keep=TRUE, int resizer=0);
05216
05218 DllExport void ClearLimits ();
05219
05229 DllExport void GetDelta (float amount, Tab<Point3> & delta);
05230
05243 DllExport bool GetMapDelta (MNMesh & mm, int mapChannel, float amount, Tab<UVVert> & delta);
05244
05249 Tab<UVVert> & MDir (int mapChannel) { return (mapChannel<0) ? hmdir[-1-mapChannel] : mdir[mapChannel]; }
05250 };
05251
05252
05262 DllExport void MNChamferDataDebugPrint (MNChamferData & mcd, int mapNum);
05263
05312 class MNTempData : public BaseInterfaceServer {
05313 private:
05314 MNEdgeClusters *edgeCluster;
05315 MNFaceClusters *faceCluster;
05316 Tab<int> *vertCluster;
05317 Tab<Point3> *normals;
05318 Tab<Point3> *centers;
05319 Tab<Point3> *vnormals;
05320 Tab<Tab<float> *> *clustDist;
05321 Tab<float> *selDist;
05322 Tab<float> *vsWeight;
05323 MNChamferData *chamData;
05324
05325 Tab<Point3> *outlineDir;
05326
05327 MNMesh *mesh;
05328
05329
05330
05331
05332 float mFalloffLimit;
05333
05334 public:
05336
05337
05338 DllExport MNTempData ();
05339
05345 DllExport MNTempData (MNMesh *m);
05346
05348 DllExport ~MNTempData ();
05350
05355 void SetMesh (MNMesh *m) { mesh = m; }
05356
05357 #pragma region Cluster Methods
05358
05359
05360
05369 DllExport MNFaceClusters *FaceClusters (DWORD clusterFlags=MN_SEL);
05370
05380 DllExport MNEdgeClusters *EdgeClusters (DWORD clusterFlags=MN_SEL);
05397 DllExport Tab<int> *VertexClusters (int sl, DWORD clusterFlags=MN_SEL);
05398
05416 DllExport Tab<Point3> *ClusterNormals (int sl, DWORD clusterFlags=MN_SEL);
05417
05433 DllExport Tab<Point3> *ClusterCenters (int sl, DWORD clusterFlags=MN_SEL);
05434
05444 DllExport Matrix3 ClusterTM (int clust);
05445
05473 DllExport Tab<float> *ClusterDist (int sl, DWORD clusterFlags, int clustId, BOOL useEdgeDist, int edgeIts);
05475 #pragma endregion
05476
05481 DllExport Tab<Point3> *VertexNormals ();
05482
05523 DllExport Tab<float> *VSWeight (BOOL useEdgeDist, int edgeIts,
05524 BOOL ignoreBack, float falloff, float pinch, float bubble,
05525 DWORD selFlags=MN_SEL);
05526
05548 DllExport Tab<float> *SelectionDist (BOOL useEdgeDist, int edgeIts, DWORD selFlags=MN_SEL, float falloffLimit = -1.0f);
05549
05550
05551
05567 DllExport Tab<Point3> *OutlineDir (int extrusionType, DWORD clusterFlags=MN_SEL);
05568
05575 DllExport MNChamferData *ChamferData();
05576
05599 DllExport void Invalidate (DWORD part);
05600
05604 DllExport void InvalidateDistances ();
05605
05610 DllExport void InvalidateSoftSelection ();
05611
05614 DllExport void freeClusterDist ();
05615
05617 DllExport void freeBevelInfo ();
05618
05620 DllExport void freeChamferData();
05621
05623 DllExport void freeAll ();
05624
05626 DllExport BaseInterface* GetInterface(Interface_ID id);
05627 };
05628
05637 class IMNTempData10 : public BaseInterface {
05638 public:
05640 Interface_ID GetID() { return IMNTEMPDATA10_INTERFACE_ID; }
05641
05644 virtual MNChamferData10& ChamferData() = 0;
05645
05647 virtual void freeChamferData() = 0;
05648 };
05649
05664 DllExport void SelectionDistance (MNMesh & mesh, float *selDist, DWORD selFlags);
05665
05685 DllExport void SelectionDistance (MNMesh & mesh, float *selDist, int iters, DWORD selFlags);
05686
05710 DllExport void ClustDistances (MNMesh & mesh, int numClusts, int *vclust,
05711 Tab<float> **clustDist);
05736 DllExport void ClustDistances (MNMesh & mesh, int numClusts, int *vclust,
05737 Tab<float> **clustDist, int iters);
05738
05740 class BasisFinder: public MaxHeapOperators {
05741 public:
05748 DllExport static void BasisFromZDir (Point3 & zDir, Point3 & xDir, Point3 & yDir);
05749 };
05750
05788 class MNMeshSelectionConverter : public FlagUser {
05789 public:
05805 DllExport void FaceToElement (MNMesh & mesh, BitArray & faceSel, BitArray & elementSel);
05806 DllExport void EdgeToBorder (MNMesh & mesh, BitArray & edgeSel, BitArray & borderSel);
05807
05824 DllExport void VertexToEdge (MNMesh & mesh, BitArray & vertexSel, BitArray & edgeSel);
05825 DllExport void VertexToFace (MNMesh & mesh, BitArray & vertexSel, BitArray & faceSel);
05826 };
05827
05829 class MNMeshUtilities: public MaxHeapOperators
05830 {
05831 private:
05832 MNMesh *mpMesh;
05833
05834
05835
05836 void GetBorderVertices (Tab<int> & border, Tab<int> & verts, bool reversedLoop=false);
05837 void GetBorderMapVertices (Tab<int> & border, Tab<int> & mapVerts, int mapChannel, bool reversedLoop=false);
05838 void InterpolateVertices (int v1, int v2, float f, int outputVert);
05839 void GetBridgeSmoothingGroups (Tab<int> & smVerts, Tab<int> & lgVerts, Tab<int> & match,
05840 float smoothThresh, Tab<DWORD> & smoothers);
05841 MtlID GetBridgeMaterial (Tab<int> & smaller, Tab<int> & larger);
05842
05843
05844 bool PolygonToBorder (int face, int start, Tab<int> & border);
05845 bool OrientBorders (Tab<int> & border1, Tab<int> & border2);
05846 bool SynchBorders (Tab<int> & border1, Tab<int> & border2);
05847 bool BridgeLoops (Tab<int> & smaller, Tab<int> & larger, float smoothThresh);
05848 bool BridgeLoops (Tab<int> & smaller, Tab<int> & larger, float smoothThresh,
05849 int segments, float taper, float bias);
05850 void MatchLoops (Tab<Tab<int> *> & loopList, Tab<int> & loopMatch,
05851 Tab<int> *loopClusterID=NULL, Tab<int> *clusterMatch=NULL);
05852
05853 public:
05858 MNMeshUtilities (MNMesh *mesh) { mpMesh = mesh; }
05859
05869 DllExport bool GetBorderFromEdge (int edge, Tab<int> & border);
05870
05881 DllExport bool AutoSmooth (float threshold, DWORD faceFlag);
05882
05890 DllExport bool FlipHingeAngle (Point3 & origin, Point3 & axis, int hingeEdge, DWORD faceFlag);
05891
05907 DllExport bool HingeFromEdge (Point3 & origin, Point3 & axis, float angle, int segments,
05908 MNFaceClusters & fclust, int clusterID);
05913 DllExport bool MakeFlaggedPlanar (int selLev, DWORD flag, float *softSel, Point3 *delta=NULL);
05914
05920 DllExport bool MoveVertsToPlane (Point3 & norm, float offset, float *softSel, Point3 *delta=NULL);
05921
05929 DllExport bool CollapseEdges (DWORD edgeFlag);
05930
05944 DllExport bool CollapseEdges (DWORD edgeFlag, Tab<int>& pointDest);
05945
05950 DllExport void ConstrainDeltaToEdges (Tab<Point3> *deltaIn, Tab<Point3> *deltaOut);
05951
05956 DllExport void ConstrainDeltaToFaces (Tab<Point3> *deltaIn, Tab<Point3> *deltaOut);
05957
05968 DllExport bool ExtrudeOpenEdges (DWORD edgeFlag, bool clearFlagOnOldEdges, bool useTracking);
05969
05989 DllExport bool BridgeBorders (int edge1, int twist1, int edge2, int twist2,
05990 float smoothThresh, int segments, float taper, float bias);
05991
06009 DllExport bool BridgePolygons (int face1, int twist1, int face2, int twist2,
06010 float smoothThresh, int segments, float taper, float bias);
06011
06026 DllExport bool BridgePolygonClusters (DWORD polyFlag, float smoothThresh, int segments, float taper, float bias,
06027 int twist1, int twist2);
06028
06044 DllExport bool BridgeSelectedBorders (DWORD edgeFlag, float smoothThresh, int segments, float taper, float bias,
06045 int twist1, int twist2);
06046
06054 DllExport int FindDefaultBridgeTwist (int face1, int face2);
06055
06067 DllExport bool TurnDiagonal (int face, int diagonal);
06068
06097 DllExport bool Relax (DWORD vertexFlag, float *softSel, float relaxAmount,
06098 int relaxIters, bool holdBoundaryPts, bool holdOuterPts, Point3 *delta=NULL);
06099
06113 DllExport int SelectPolygonsByAngle (int startPolygon, float angle, BitArray & polySel);
06114
06119 DllExport void CutPrepare ();
06120
06126 DllExport void CutCleanup ();
06127 };
06128
06138 class MNMapPreserveData: public MaxHeapOperators
06139 {
06140 private:
06141 Tab<Point3> mFcx, mFcy;
06142 Tab<Point3 *> mMapXDir, mMapYDir;
06143 int mDegreeSum;
06144 bool mProtectVertexColors;
06145
06146 public:
06148 MNMapPreserveData () : mDegreeSum(0), mProtectVertexColors(true) { }
06149
06151 ~MNMapPreserveData () { Clear(); }
06152
06154 DllExport void Clear ();
06155
06162 DllExport void Initialize (MNMesh & mm, const MapBitArray & mapsToDo);
06163
06172 DllExport void Apply (MNMesh & mm, Point3 *pDelta, int numDeltas);
06173 };
06174
06188 class IMNMeshUtilities8 : public BaseInterface
06189 {
06190 public:
06191 virtual Interface_ID GetID() { return IMNMESHUTILITIES8_INTERFACE_ID; }
06192
06206 virtual bool BridgeTwoEdges(
06207 const int in_Edge1,
06208 const int in_Edge2,
06209 const int in_segmentsNumber,
06210 const int in_prevColumnIndex = 0,
06211 const DWORD in_smoothingGroup = 0,
06212 const MtlID in_materialId = 0,
06213 const bool in_triangleAdded = false) = 0 ;
06214
06228 virtual bool BridgeSelectedEdges (
06229 const DWORD in_edgeFlag,
06230 const float in_smoothThresh,
06231 const int in_segmentsNumber,
06232 const float in_adjacentAngle,
06233 const bool in_reverseTriangle ) = 0;
06234
06247 virtual bool ConnectEdges (
06248 const DWORD in_edgeFlag,
06249 const int in_segments = 2,
06250 const int in_pinch = 0,
06251 const int in_slide = 0 ) = 0 ;
06252
06258 virtual void SelectEdgeRingShift(
06259 const int in_ring_shift,
06260 BitArray& io_edgeSel) = 0;
06261
06267 virtual void SelectEdgeLoopShift(
06268 const int in_loop_shift,
06269 BitArray& io_edgeSel)=0;
06270
06276 virtual bool SplitFlaggedVertices (
06277 const DWORD in_vertexFlag = MN_SEL,
06278 const float in_distance = 0.0 ) =0;
06279
06285 virtual bool SplitFlaggedEdges (
06286 const DWORD in_edgeFlag = MN_SEL,
06287 const float in_distance = 0.0 )= 0;
06288
06296 virtual void GetFlippedEdges(
06297 BitArray& io_edgeFlip,
06298 const bool in_useOnlySelectedEdges = false) = 0;
06299
06307 virtual bool ChamferEdges (
06308 const DWORD in_flag = MN_SEL,
06309 MNChamferData *in_mcd = NULL,
06310 const bool in_open = false) = 0;
06311
06319 virtual bool ChamferVertices (
06320 const DWORD flag = MN_SEL,
06321 MNChamferData *mcd = NULL,
06322 const bool in_open = false) = 0 ;
06323
06325
06326
06334 virtual bool isFaceCacheInvalid(int faceIndex) = 0;
06335
06345 virtual void InvalidateVertexCache (int vertex) = 0;
06347 };
06348
06349 #define IMNMESHUTILITIES10_INTERFACE_ID Interface_ID(0x7b1acb31, 0x763982d5)
06350
06360 class IMNMeshUtilities10 : public BaseInterface {
06361 public:
06362 Interface_ID GetID() { return IMNMESHUTILITIES10_INTERFACE_ID; }
06363
06372 virtual bool ChamferEdges (
06373 const DWORD in_flag,
06374 MNChamferData10 &in_mcd,
06375 const bool in_open,
06376 const int in_segments) = 0;
06377
06385 virtual bool ConstrainDeltaToNormals (Tab<Point3> *deltaIn, Tab<Point3> *deltaOut) = 0;
06386
06387 };
06388
06389 #define IMNMESHUTILITIES13_INTERFACE_ID Interface_ID(0x4dfa07c3, 0x637941b0)
06390
06399 class IMNMeshUtilities13 : public BaseInterface {
06400 public:
06401 Interface_ID GetID() { return IMNMESHUTILITIES13_INTERFACE_ID; }
06402
06409 virtual bool FindLoopVertex(BitArray &hitSel, const BitArray &curSel) = 0;
06410
06417 virtual bool FindLoopOrRingEdge(BitArray &hitSel, const BitArray &curSel) = 0;
06418
06425 virtual bool FindLoopFace(BitArray &hitSel, const BitArray &curSel) = 0;
06426 };
06427