00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #pragma once
00015 #include <WTypes.h>
00016 #include "maxheap.h"
00017 #include "export.h"
00018 #include "point3.h"
00019 #include "TabTypes.h"
00020 #include "mesh.h"
00021
00022
00023 class Face;
00024 class AdjFaceList;
00025 class BitArray;
00026 class Mesh;
00027
00028 #ifndef UNDEFINED
00029 #define UNDEFINED 0xffffffff
00030 #endif
00031
00032
00033
00046 class MEdge: public MaxHeapOperators {
00047 public:
00048 DWORD f[2];
00049 DWORD v[2];
00050
00063 DllExport int EdgeIndex(Face *faces,int side);
00071 DllExport BOOL Selected (Face *faces,BitArray &esel);
00077 DllExport BOOL Visible (Face *faces);
00083 DllExport BOOL Hidden (Face *faces);
00088 DllExport Point3 Center(Point3* verts);
00094 DllExport BOOL AFaceSelected(BitArray &fsel);
00103 DllExport Point3 ButterFlySubdivide (Mesh *mesh,AdjFaceList *af,float tens);
00124 DllExport UVVert ButterFlyMapSubdivide (Mesh *mesh,AdjFaceList *af,float tens, int mp, bool & seam, UVVert & side2);
00129 DWORD OtherVert (DWORD vv) { return (v[0] == vv) ? v[1] : v[0]; }
00134 DWORD OtherFace (DWORD ff) { return (f[0] == ff) ? f[1] : f[0]; }
00135 };
00136
00153 class AdjEdgeList: public MaxHeapOperators {
00154 public:
00155 DWORDTab *list;
00156 Tab<MEdge> edges;
00157 int nverts;
00158
00165 DllExport AdjEdgeList(Mesh& amesh);
00167 DllExport ~AdjEdgeList();
00168
00172 DllExport void AddEdge( DWORD fi, DWORD v1, DWORD v2 );
00174 DWORDTab& operator[](int i) { return list[i]; }
00181 DllExport int FindEdge(DWORD v0, DWORD v1);
00184 DllExport int FindEdge(DWORDTab& vmap,DWORD v0, DWORD v1);
00187 DllExport void TransferEdges(DWORD from,DWORD to,DWORD except1,DWORD except2,DWORD del);
00190 DllExport void RemoveEdge(DWORD from,DWORD e);
00195 DllExport void OrderAllEdges (Face *faces);
00209 DllExport void OrderVertEdges (DWORD v, Face *faces, Tab<DWORD> *flist=NULL);
00217 DllExport void GetFaceList (DWORD v, Tab<DWORD> & flist);
00218
00219 DllExport void MyDebugPrint ();
00220
00227 void AddEdgeToVertex(DWORD v,DWORD e) { list[v].Append (1, &e); }
00228 };
00229
00237 class AdjFace: public MaxHeapOperators {
00238 public:
00239 DWORD f[3];
00241 AdjFace() {f[0] = f[1] = f[2] = UNDEFINED;}
00242 };
00243
00254 class AdjFaceList: public MaxHeapOperators {
00255 public:
00256 Tab<AdjFace> list;
00257
00260 AdjFace& operator[](int i) {return list[i];}
00263 DllExport AdjFaceList(Mesh& mesh,AdjEdgeList& el);
00264 };
00265
00282 class FaceElementList: public MaxHeapOperators {
00283 public:
00284
00285 DWORDTab elem;
00286 DWORD count;
00295 DllExport FaceElementList(Mesh &mesh,AdjFaceList& af);
00297 DWORD operator[](int i) {return elem[i];}
00298 };
00299
00322 class FaceClusterList: public MaxHeapOperators {
00323 public:
00324
00325 DWORDTab clust;
00326 DWORD count;
00327
00328
00352 DllExport FaceClusterList(Mesh *mesh, AdjFaceList& adj,float angle,BOOL useSel=TRUE);
00353
00371 DllExport FaceClusterList (BitArray& fsel, AdjFaceList& adj);
00373 DWORD operator[](int i) { return clust[i]; }
00389 DllExport void MakeVertCluster(Mesh &mesh, Tab<DWORD> & vclust);
00405 DllExport void GetNormalsCenters (Mesh &mesh, Tab<Point3> & norm, Tab<Point3> & ctr);
00430 DllExport void GetBorder (DWORD clustID, AdjFaceList & af, Tab<DWORD> & cbord);
00460 DllExport void GetOutlineVectors (Mesh & m, AdjFaceList & af, Tab<Point3> & cnorms, Tab<Point3> & odir);
00461 };
00462
00483 class EdgeClusterList: public MaxHeapOperators {
00484 public:
00485 DWORDTab clust;
00486 DWORD count;
00487
00498 DllExport EdgeClusterList(Mesh &mesh,BitArray &esel,AdjEdgeList &adj);
00505 DWORD ID(int f, int e) {return clust[f*3+e];}
00508 DWORD operator[](int i) {return clust[i];}
00519 DllExport void MakeVertCluster (Mesh &mesh, Tab<DWORD> & vclust);
00534 DllExport void GetNormalsCenters (Mesh &mesh, Tab<Point3> & norm, Tab<Point3> & ctr);
00535 };
00536
00563 class MeshChamferData: public MaxHeapOperators {
00564 Tab<UVVert> hmdir[NUM_HIDDENMAPS];
00565 public:
00566 Tab<Point3> vdir;
00567 Tab<float> vmax;
00568 Tab<UVVert> *mdir;
00569
00571 MeshChamferData () { mdir=NULL; }
00577 MeshChamferData (const Mesh & m) { mdir=NULL; InitToMesh(m); }
00579 DllExport ~MeshChamferData ();
00580
00586 DllExport void InitToMesh (const Mesh & m);
00600 DllExport void setNumVerts (int nv, bool keep=TRUE, int resizer=0);
00601 Tab<UVVert> & MDir (int mp) { return (mp<0) ? hmdir[-1-mp] : mdir[mp]; }
00602 };
00603
00604
00605
00606
00607
00619 DllExport void MeshChamferDataDebugPrint (MeshChamferData & mcd, int mapNum);
00620
00621
00622
00623
00624 #define MESH_EXTRUDE_CLUSTER 1
00625 #define MESH_EXTRUDE_LOCAL 2
00626
00669 class MeshTempData : public BaseInterfaceServer {
00670 private:
00671 AdjEdgeList *adjEList;
00672 AdjFaceList *adjFList;
00673 EdgeClusterList *edgeCluster;
00674 FaceClusterList *faceCluster;
00675 Tab<DWORD> *vertCluster;
00676 Tab<Point3> *normals;
00677 Tab<Point3> *centers;
00678 Tab<Point3> *vnormals;
00679 Tab<Tab<float> *> *clustDist;
00680 Tab<float> *selDist;
00681 Tab<float> *vsWeight;
00682 MeshChamferData *chamData;
00683
00684 Tab<Point3> *extDir;
00685 Tab<Point3> *outlineDir;
00686
00687 Mesh *mesh;
00688
00689
00690
00691
00692 float mFalloffLimit;
00693
00694 public:
00696 DllExport MeshTempData ();
00702 DllExport MeshTempData (Mesh *m);
00704 DllExport ~MeshTempData ();
00705
00710 void SetMesh (Mesh *m) { mesh = m; }
00711
00715 DllExport AdjEdgeList *AdjEList ();
00719 DllExport AdjFaceList *AdjFList ();
00724 DllExport FaceClusterList *FaceClusters ();
00729 DllExport EdgeClusterList *EdgeClusters ();
00742 DllExport Tab<DWORD> *VertexClusters (DWORD sl);
00755 DllExport Tab<Point3> *ClusterNormals (DWORD sl);
00767 DllExport Tab<Point3> *ClusterCenters (DWORD sl);
00777 DllExport Matrix3 ClusterTM (int clust);
00785 DllExport Tab<Point3> *VertexNormals ();
00822 DllExport Tab<float> *VSWeight (BOOL useEdgeDist, int edgeIts,
00823 BOOL ignoreBack, float falloff, float pinch, float bubble);
00824
00826
00845 DllExport Tab<float> *SelectionDist (BOOL useEdgeDist, int edgeIts, float falloffLimit = -1.0f);
00870 DllExport Tab<float> *ClusterDist (DWORD sl, int clustId, BOOL useEdgeDist, int edgeIts);
00887 DllExport Tab<Point3> *EdgeExtDir (Tab<Point3> *edir, int extrusionType);
00901 DllExport Tab<Point3> *FaceExtDir (int extrusionType);
00907 Tab<Point3> *CurrentExtDir () { return extDir; }
00917 DllExport Tab<Point3> *OutlineDir (int extrusionType);
00918
00929 DllExport MeshChamferData *ChamferData();
00930
00972 DllExport void Invalidate (DWORD part);
00975 DllExport void InvalidateDistances ();
00979 DllExport void InvalidateAffectRegion ();
00982 DllExport void freeClusterDist ();
00984 DllExport void freeBevelInfo ();
00986 DllExport void freeChamferData();
00988 DllExport void freeAll ();
00989 };
00990
00991
00992 #define SOFTSEL_MIN_FALLOFF 0.0f
00993 #define SOFTSEL_MAX_FALLOFF 999999.0f
00994 #define SOFTSEL_DEFAULT_FALLOFF 20.0f
00995
00996 #define SOFTSEL_MIN_PINCH -1000.0f
00997 #define SOFTSEL_MAX_PINCH 1000.0f
00998 #define SOFTSEL_DEFAULT_PINCH 0.0f
00999
01000 #define SOFTSEL_MIN_BUBBLE -1000.0f
01001 #define SOFTSEL_MAX_BUBBLE 1000.0f
01002 #define SOFTSEL_DEFAULT_BUBBLE 0.0f
01003
01039 DllExport float AffectRegionFunction (float dist, float falloff, float pinch, float bubble);
01040 DllExport Point3 SoftSelectionColor (float selAmount);
01049 DllExport void MatrixFromNormal (Point3& normal, Matrix3& mat);
01059 DllExport void AverageVertexNormals (Mesh & mesh, Tab<Point3> & vnormals);
01067 DllExport Point3 AverageSelVertNormal (Mesh& mesh);
01075 DllExport Point3 AverageSelVertCenter (Mesh& mesh);
01081 DllExport void DeselectHiddenFaces (Mesh &mesh);
01088 DllExport void DeselectHiddenEdges (Mesh &mesh);
01101 DllExport void HiddenFacesToVerts (Mesh &mesh, BitArray alsoHide);
01116 DllExport void SelectionDistance (Mesh & mesh, float *selDist, float falloffLimit = -1.0f);
01151 DllExport void SelectionDistance (Mesh & mesh, float *selDist, int iters, AdjEdgeList *ae=NULL);
01180 DllExport void ClustDistances (Mesh & mesh, DWORD numClusts, DWORD *vclust,
01181 Tab<float> **clustDist);
01217 DllExport void ClustDistances (Mesh & mesh, DWORD numClusts, DWORD *vclust,
01218 Tab<float> **clustDist, int iters, AdjEdgeList *ae=NULL);
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233 #define MESHSELECTCONVERT_INTERFACE Interface_ID(0x3da7dd5, 0x7ecf0391)
01234
01235
01236 #define MESH_SELCONV_REQUIRE_ALL 0x01 // Set during Mesh hit-testing (with window region)
01237
01238 class MeshSelectionConverter : public BaseInterface {
01239 public:
01240 DllExport MeshSelectionConverter ();
01241
01242
01261 DllExport void FaceToElement (Mesh & mesh, AdjFaceList *af, BitArray & faceSel, BitArray & elementSel);
01287 DllExport void FaceToPolygon (Mesh & mesh, AdjFaceList *af, BitArray & faceSel, BitArray & polygonSel,
01288 float faceThresh, bool ignoreVisEdge=false);
01305 DllExport void VertexToEdge (Mesh & mesh, BitArray & vertexSel, BitArray & edgeSel);
01306 DllExport void VertexToFace (Mesh & mesh, BitArray & vertexSel, BitArray & faceSel);
01307
01308
01338 DllExport void VertexToPolygon (Mesh & mesh, AdjFaceList *af, BitArray & vertexSel, BitArray & polygonSel,
01339 float faceThresh, bool ignoreVisEdge=false);
01362 DllExport void VertexToElement (Mesh & mesh, AdjFaceList *af, BitArray & vertexSel, BitArray & elementSel);
01363
01364
01372 BitArray & GetCull () { return mCull; }
01373
01374 void SetFlag (DWORD f, bool value=true) { if (value) mFlags |= f; else mFlags &= ~f; }
01375 void ClearFlag(DWORD f) { mFlags &= ~f; }
01376 bool GetFlag (DWORD f) { return (mFlags&f) ? true : false; }
01377
01378
01379 Interface_ID GetID() {return MESHSELECTCONVERT_INTERFACE;}
01380 DllExport void DeleteInterface();
01381 DllExport BaseInterface* GetInterface(Interface_ID id);
01382 DllExport BaseInterface* CloneInterface(void* remapDir = NULL);
01383
01384 private:
01385 DWORD mFlags;
01386 BitArray mCull;
01387 DWORD mCullLevel;
01388 };
01389
01390