meshdelta.h

Go to the documentation of this file.
00001 //**************************************************************************/
00002 // Copyright (c) 1998-2006 Autodesk, Inc.
00003 // All rights reserved.
00004 // 
00005 // These coded instructions, statements, and computer programs contain
00006 // unpublished proprietary information written by Autodesk, Inc., and are
00007 // protected by Federal copyright law. They may not be disclosed to third
00008 // parties or copied or duplicated in any form, in whole or in part, without
00009 // the prior written consent of Autodesk, Inc.
00010 //**************************************************************************/
00011 // FILE:        MeshDelta.h
00012 // DESCRIPTION: 
00013 // AUTHOR:      Steve Anderson
00014 // HISTORY:     Created June 1998
00015 //**************************************************************************/
00016 
00017 #pragma once
00018 
00019 #include "maxheap.h"
00020 #include "export.h"
00021 #ifndef __MESHADJ__
00022 #include "meshadj.h"
00023 #endif
00024 
00025 // STEVE: MeshDeltas and/or MapDeltas lack the following clever features:
00026 // - Realloc amounts: currently we realloc arrays with no extra room for growth (dv especially).
00027 
00028 // These classes encompass the notion of a "Mesh Edit".  They are the principal means
00029 // of keeping track of what's going on in the Edit Mesh modifier, and have many standard
00030 // mesh edits available for use elsewhere.
00031 
00032 // Principle is that, while these work as designed on the right mesh, they will give
00033 // some result on the wrong mesh.
00034 
00035 // Order of operations:
00036 // Verts/TVerts/CVerts created or cloned.
00037 // Faces created -- indices correspond to original vert list, then create, then clone.
00038 // Face attributes & indices changed.
00039 // Verts & faces deleted.
00040 
00041 // "Channels" of data in MeshDelta -- different from PART_GEOM type channels!
00042 #define MDELTA_VMOVE 0x0001
00043 #define MDELTA_VCLONE 0x0004
00044 #define MDELTA_VCREATE MDELTA_VCLONE // MDELTA_VCREATE is used only by MapDelta and not MeshDelta
00045 #define MDELTA_VDELETE 0x0008
00046 #define MDELTA_VDATA 0x0010
00047 #define MDELTA_FREMAP 0x0020
00048 #define MDELTA_FCHANGE 0x0040
00049 #define MDELTA_FCREATE 0x0080
00050 #define MDELTA_FDELETE 0x0100
00051 #define MDELTA_FDATA 0x0200      // also used for per-face-data channel
00052 #define MDELTA_NUMBERS 0x0400
00053 #define MDELTA_FSMOOTH 0x0800
00054 #define MDELTA_ALL 0xffff
00055 
00067 class VertMove: public MaxHeapOperators {
00068 public:
00069    DWORD vid;
00070    Point3 dv;
00071 
00073    VertMove () {}
00076    VertMove (DWORD i, Point3 p) { vid=i; dv=p; }
00078     ~VertMove () {}
00080    VertMove & operator= (const VertMove & from) { vid=from.vid; dv=from.dv; return (*this); }
00081 };
00082 
00093 class UVVertSet: public MaxHeapOperators {
00094 public:
00095    DWORD vid;
00096    UVVert v;
00097 
00099    UVVertSet () {}
00102    UVVertSet (DWORD i, UVVert p) { vid=i; v=p; }
00104    ~UVVertSet () {}
00105 
00107    UVVertSet & operator= (const UVVertSet & from) { vid=from.vid; v=from.v; return (*this); }
00108 };
00109 
00127 class FaceCreate: public MaxHeapOperators {
00128 public:
00129    DWORD original;
00130    Face face;
00131 
00134    FaceCreate (DWORD f, const Face & fc) : original(f), face(fc) { }
00138    FaceCreate (const Face & fc) : original(UNDEFINED), face(fc) { }
00142    FaceCreate (DWORD f) : original(f) { }
00145    FaceCreate () : original(UNDEFINED) { }
00148    FaceCreate (const FaceCreate & fc) : original(fc.original), face(fc.face) { }
00153    FaceCreate & operator= (const FaceCreate & fc) { original = fc.original; face=fc.face; return *this; }
00154 };
00155 
00156 #define FR_V0  1
00157 #define FR_V1  2
00158 #define FR_V2  4
00159 #define FR_ALL 7
00160 
00180 class FaceRemap: public MaxHeapOperators {
00181 public:
00182    DWORD f, flags, v[3];   // Face being remapped
00184    FaceRemap () { f=flags=0; }
00193    DllExport FaceRemap (DWORD ff, DWORD fl, DWORD *vv);
00199    DllExport void Apply (Face &ff);
00207    DllExport void Apply (TVFace & tf);
00213    DllExport void Apply (FaceRemap & fr);
00215    Face operator* (Face &ff) { Face nf=ff; Apply(nf); return nf; }
00217    TVFace operator* (TVFace & ff) { TVFace nf=ff; Apply(nf); return nf; }
00218 };
00219 
00220 // Attribute changes available for faces:
00221 #define ATTRIB_EDGE_A      (1<<0)
00222 #define ATTRIB_EDGE_B      (1<<1)
00223 #define ATTRIB_EDGE_C      (1<<2)
00224 #define ATTRIB_EDGE_ALL  7
00225 #define ATTRIB_HIDE_FACE      (1<<3)
00226 #define ATTRIB_MATID    (1<<4)
00227 
00228 // Mat ID takes bits 5-21
00229 #define ATTRIB_MATID_SHIFT 5
00230 #define ATTRIB_MATID_MASK  0xffff
00231 
00253 class FaceChange: public MaxHeapOperators {
00254 public:
00255    DWORD f, flags, val;
00257    FaceChange () { f=flags=0; }
00268    FaceChange (DWORD ff, DWORD fl, DWORD v) { f=ff; flags=fl; val=v; }
00274    DllExport void Apply (Face &ff);
00280    DllExport void Apply (FaceChange & fa);
00281 };
00282 
00296 class FaceSmooth: public MaxHeapOperators {
00297 public:
00298    DWORD f, mask, val;
00300    FaceSmooth () { f=mask=0; }
00303    FaceSmooth (DWORD ff, DWORD mk, DWORD vl) { f=ff; mask=mk; val=vl; }
00308    DllExport void Apply (Face &ff);
00314    DllExport void Apply (FaceSmooth & fs);
00315 };
00316 
00317 //STEVE: someday support applying a standard mapping to selected faces?
00351 class MapDelta: public MaxHeapOperators {
00352 public:
00353    DWORD vnum, fnum;
00354    Tab<UVVertSet> vSet;
00355    Tab<Point3> vCreate;
00356    Tab<TVFace> fCreate; // New texture vert faces -- matches master MeshDelta fCreate in size.
00357    Tab<FaceRemap> fRemap;  // ordered list of faces using at least one new vertex.
00358 
00361    MapDelta () { vnum=0; fnum=0; }
00364    DllExport void ClearAllOps ();
00365 
00366    // Bookkeeping:
00373    DllExport int NumVSet (DWORD inVNum);
00383    DllExport void SetInVNum (DWORD n);
00393    DllExport void SetInFNum (DWORD n);
00396    DWORD outVNum () { return vnum + vCreate.Count(); }
00402    DWORD outVNum (DWORD inVNum) { return inVNum + vCreate.Count(); }
00408    bool IsCreate (DWORD i) { int j=i-vnum; return ((j>=0) && (j<vCreate.Count())); }
00416    DllExport DWORD SetID (DWORD i);
00417 
00418    // Topological ops:
00427    DllExport DWORD VCreate (UVVert *v, int num=1);
00436    DllExport void FCreate (TVFace *f, int num=1);
00445    DllExport void FCreateDefault (int num=1);
00453    DllExport void FCreateQuad (DWORD *t);
00469    DllExport void FClone (TVFace & tf, DWORD remapFlags=0, DWORD *v=NULL);
00490    DllExport void FRemap (DWORD f, DWORD flags, DWORD *v);  // Creates a (or modifies an existing) remap record.
00498    void FRemap (FaceRemap & fr) { FRemap (fr.f, fr.flags, fr.v); }
00507    DllExport DWORD RemapID (DWORD ff);
00517    DllExport DWORD IsRemapped (DWORD ff, DWORD vid);
00525    DllExport TVFace OutFace (TVFace *mf, DWORD ff);
00539    DllExport void FDelete (int offset, BitArray & fdel);
00540 
00541    // Geometric ops:
00551    DllExport void Set (DWORD i, const UVVert & p);
00552    DllExport void Set (BitArray & sel, const UVVert & p);
00553 
00554    // Uses:
00557    MapDelta & operator=(MapDelta & from) { CopyMDChannels (from, MDELTA_ALL); return *this; }
00565    DllExport MapDelta & operator*=(MapDelta & from);
00598    DllExport void Apply (UVVert *tv, TVFace *tf, DWORD inVNum, DWORD inFNum);
00599 
00600    // Handy debugging output
00603    DllExport void MyDebugPrint ();
00604 
00605    // Backup stuff:
00621    DllExport DWORD ChangeFlags ();
00633    DllExport void CopyMDChannels (MapDelta & from, DWORD channels);
00634 
00635    // Double-checking routines, good for after loading.
00636    // Return TRUE if already correct, FALSE if they had to make a correction.
00637    DllExport BOOL CheckOrder (); // Checks for out of order sets or remaps
00638    DllExport BOOL CheckFaces (); // Checks remaps & fCreates for out of bound map vert id's.
00639 };
00640 
00655 class VDataDelta: public MaxHeapOperators {
00656 public:
00657    PerData *out;
00658 
00660    VDataDelta () { out=NULL; }
00662    DllExport ~VDataDelta ();
00671    void SetVNum (int nv, BOOL keep=FALSE) { if (out) out->SetCount(nv,keep); }
00681    DllExport void Activate (int vnum, int vdID);
00691    DllExport void Set (int where, void *data, int num=1);
00692 };
00693 
00694 #pragma warning(push)
00695 #pragma warning(disable:4100)
00696 
00776 class MeshDelta : public BaseInterfaceServer {
00777    DWORD *vlut, *flut;
00778    int vlutSize, flutSize;
00779 
00780    MapDelta hmap[NUM_HIDDENMAPS];
00781    BitArray hmapSupport;
00782 
00783    // Internal methods:
00784    // Parts of Cut:
00785    DWORD FindBestNextFace (Mesh & m, Tab<DWORD> *vfac, Point3 *cpv, DWORD startV, Point3 & svP);
00786    DWORD FindOtherFace (DWORD ff, Tab<DWORD> * vfa, Tab<DWORD> * vfb);
00787 public:
00788    DWORD vnum, fnum;
00789 
00790    Tab<VertMove> vMove; // Ordered list of moves to existing verts
00791    //Tab<Point3> vCreate;  // DO NOT USE!!!!!  Use of this data member was eliminated in 4.0
00792    Tab<VertMove> vClone;   // Creation-order list of cloned points.
00793    BitArray vDelete;
00794 
00795    Tab<FaceCreate> fCreate;         // New faces
00796    Tab<FaceRemap> fRemap;  // existing faces using new verts.  (Ordered list.)
00797    Tab<FaceChange> fChange;   // ordered list of face flag changes
00798    Tab<FaceSmooth> fSmooth;   // ordered list of face smoothing group changes
00799    BitArray fDelete; // Also applies to map faces.
00800 
00801    BitArray vsel, esel, fsel, vhide;   // Based on output mesh indexing.
00802 
00803    MapDelta *map;
00804    BitArray mapSupport;
00805 
00806    VDataDelta *vd;   // Based on output mesh indexing.
00807    BitArray vdSupport;
00808 
00811    DllExport MeshDelta ();
00815    DllExport MeshDelta (const Mesh & m);
00818    DllExport ~MeshDelta ();
00819 
00825    DllExport void InitToMesh (const Mesh & m);
00829    DllExport void ClearAllOps ();
00837    DllExport void SetMapNum (int n, bool keep=TRUE);
00840    int GetMapNum () { return mapSupport.GetSize(); }
00847    MapDelta & Map(int mp) { return (mp<0) ? hmap[-1-mp] : map[mp]; }
00854    bool getMapSupport (int mp) { return ((mp<0) ? hmapSupport[-1-mp] : mapSupport[mp]) ? true : false; }
00861    void setMapSupport (int mp, bool val=true) { if (mp<0) hmapSupport.Set(-1-mp, val); else mapSupport.Set(mp, val); }
00864    bool hasMapSupport () { return !(mapSupport.IsEmpty() && hmapSupport.IsEmpty()); }
00873    DllExport void SetVDataNum (int size, bool keep=TRUE);
00876    int GetVDataNum () { return vdSupport.GetSize(); }
00887    DllExport DWORD PartsChanged ();
00888 
00889    // The main work of a MeshDelta.
00909    DllExport void Apply(Mesh& mesh);
00912    MeshDelta& operator=(MeshDelta& td) { CopyMDChannels (td, MDELTA_ALL); return *this; }
00920    MeshDelta& operator*=(MeshDelta& td) { Compose(td); return *this; }
00928    DllExport void Compose (MeshDelta & td);
00929 
00930    // Following give numbers of clones or deletions, given the input numbers.
00931    // (We can't delete vertex 10 on an 8-vert mesh; this counts the number of valid entries.)
00938    DllExport DWORD NumVMove (DWORD inVNum);
00947    DllExport DWORD NumVClone (DWORD inVNum);
00954    DllExport DWORD NumVDelete (DWORD inVNum);
00961    DllExport DWORD NumFDelete (DWORD inFNum);
00963    int NumFCreate () { return fCreate.Count(); }
00964 
00965    // Sets the size of the input object -- should be used only in multiplying MeshDeltas,
00966    // since it destroys records of changes to out-of-range components.
00967    // MeshDelta may be applied to mesh without using these.
00977    DllExport void SetInFNum (int nface);
00987    DllExport void SetInVNum (int nv);
00988 
00991    int outVNum () { return vnum + vClone.Count() - vDelete.NumberSet(); }
00997    int outVNum (int inVNum) { return inVNum + NumVClone(inVNum) - NumVDelete(inVNum); }
01000    int outFNum () { return fnum + fCreate.Count() - fDelete.NumberSet(); }
01006    int outFNum (int inFNum) { return inFNum + fCreate.Count() - NumFDelete(inFNum); }
01007 
01017    DllExport void FillInFaces (Mesh & m); // Fills in undefined mapping face verts.
01023    DllExport void AddVertexColors ();  // Adds vertex color mapdelta to match this meshdelta.
01035    DllExport void AddMap (int mapID); // Adds mapdelta on specified channel to match this meshdelta.
01045    DllExport void AddVertexData (int vdChan, Mesh *m=NULL);
01046 
01047    // Create lookup tables for fast conversion of pre- and post- vert/face indices.
01060    DllExport void UpdateLUTs (int extraV=0, int extraF=0);
01063    DllExport void ClearLUTs ();
01064 
01065    // Following methods turn output indices to input indices.
01075    DllExport DWORD VLut (DWORD i);
01085    DllExport DWORD FLut (DWORD i);
01086    // Following methods turn input indices to output indices.
01095    DllExport DWORD PostVIndex (DWORD i);
01104    DllExport DWORD PostFIndex (DWORD i);
01105    // Following operate on output indices
01111    bool IsVClone (DWORD i) { int j=VLut(i)-vnum; return ((j>=0) && (j<vClone.Count())); }
01119    DWORD VCloneOf (DWORD i) { int j=VLut(i)-vnum; return ((j>=0) && (j<vClone.Count())) ? vClone[j].vid : UNDEFINED; }
01120    // NOTE: vCreate array no longer used in 3.1!
01129    bool IsVCreate (DWORD i) { return FALSE; }
01135    bool IsFCreate (DWORD i) { int j=FLut(i)-fnum; return ((j>=0) && (j<fCreate.Count())); }
01143    DllExport DWORD MoveID (DWORD i);
01144 
01145    // Basic topological operations:
01146    // Those that accept DWORD indices require post-operation indices.
01163    DllExport DWORD VCreate (Point3 *p, int num=1, BitArray *sel=NULL, BitArray *hide=NULL);
01171    DllExport DWORD VClone (DWORD *v, int num=1);
01181    DllExport DWORD VClone (DWORD *v, Point3 *off, int num=1);
01190    DllExport DWORD VClone (VertMove *vm, int num=1);
01196    DWORD VClone (DWORD v) { return VClone (&v, 1); }
01204    DWORD VClone (DWORD v, Point3 off) { return VClone (&v, &off, 1); }
01213    DllExport Point3 OutVert (Mesh & m, DWORD v);
01221    DllExport void VDelete (DWORD *v, int num=1);
01227    DllExport void VDelete (BitArray & vdel);
01237    DllExport DWORD FCreate (Face *f, int num=1);
01251    DllExport DWORD FCreate (FaceCreate *f, int num=1);
01266    DllExport DWORD FCreateQuad (DWORD *v, DWORD smG=0, MtlID matID=0, int orig=UNDEFINED);
01288    DllExport DWORD FClone (Face & f, DWORD ff, DWORD remapFlags=0, DWORD *v=NULL);
01301    DllExport void CreateDefaultMapFaces (int num=1);
01319    DllExport void FRemap (FaceRemap *f, int num=1);
01344    DllExport void FRemap (DWORD f, DWORD flags, DWORD *v);
01353    DllExport DWORD RemapID (DWORD ff);
01363    DllExport DWORD IsRemapped (DWORD ff, DWORD vid);
01372    DllExport Face OutFace (Mesh & m, DWORD ff);
01381    DllExport void FChange (FaceChange *f, int num=1);
01394    DllExport void FChange (DWORD f, DWORD flags, DWORD dat);
01403    DllExport void FSmooth (FaceSmooth *f, int num=1);
01414    DllExport void FSmooth (DWORD f, DWORD mask, DWORD val);
01423    void SetMatID (DWORD f, MtlID mt) { FChange (f, ATTRIB_MATID, mt<<ATTRIB_MATID_SHIFT); }
01431    void SetSmGroup (DWORD f, DWORD smG) { FSmooth (f, ~DWORD(0), smG); }
01443    void SetEdgeVis (DWORD f, DWORD ed, BOOL vis=TRUE) { FChange (f, (1<<ed), vis?(1<<ed):0); }
01454    DllExport void FDelete (DWORD *f, int num=1);
01460    DllExport void FDelete (BitArray & fdel);
01461 
01462    // Geometric ops:
01471    DllExport void Move (int i, const Point3 & p);
01481    DllExport void Move (BitArray & sel, const Point3 & p);
01492    DllExport void Move (VertMove *vm, int num);
01493 
01494    // FOLLOWING TWO METHODS SHOULD NOT BE USED:
01495    DllExport void GetSavingPermutations (int & numCr, int & numCl, Tab<int> & vPermute, Tab<int> & vPReverse);
01496    DllExport void PermuteClonedVertices (Tab<int> & vPermute);
01497 
01498    // Gotta be able to save and load this complex thing...
01500    DllExport IOResult Save (ISave *isave);
01502    DllExport IOResult Load (ILoad *iload);
01503 
01504    // Handy debugging output
01512    DllExport void MyDebugPrint (bool lut=FALSE, bool mp=FALSE);
01513 
01514    // Backup-relevant characteristics:
01545    DllExport DWORD ChangeFlags (Tab<DWORD> *mChannels=NULL);
01574    DllExport void CopyMDChannels (MeshDelta & from, DWORD channels, Tab<DWORD> *mChannels=NULL);
01575 
01576    // Double-checking routines, good for after loading.
01577    // Returns TRUE if order was already correct, FALSE if it had to make a correction.
01578    DllExport BOOL CheckOrder ();
01579    DllExport BOOL CheckMapFaces ();
01580 
01581    // More complex operations, built on the list above.
01582    // Mesh given is expected to be result of the current MeshDelta.
01583    // Found in MDAppOps.cpp
01601    DllExport void AutoSmooth(Mesh &m, BitArray sel, float angle, AdjFaceList *af=NULL, AdjEdgeList *ae=NULL);
01622    DllExport void Bevel (Mesh & m, BitArray vset, float outline, Tab<Point3> *odir,
01623       float height, Tab<Point3> *hdir);
01639    DllExport DWORD CreatePolygon (Mesh & m, int deg, int *v, DWORD smG=0, MtlID matID=0);
01649    DllExport void DeleteVertSet (Mesh & m, BitArray sel);   // does delete faces
01658    DllExport void DeleteEdgeSet (Mesh & m, BitArray sel);   // doesn't delete verts
01666    DllExport void DeleteFaceSet (Mesh & m, BitArray sel);   // doesn't delete verts.
01674    DllExport void DeleteSelected (Mesh & m);
01680    DllExport void DeleteIsoVerts (Mesh & m);
01689    DllExport void FlipNormal (Mesh & m, DWORD face);
01699    DllExport void MakeSelFacesPlanar (Mesh &m, BitArray sel);
01709    DllExport void MakeSelVertsPlanar (Mesh &m, BitArray sel);
01723    DllExport void MoveVertsToPlane (Mesh & m, BitArray sel, Point3 & N, float offset);
01734    DllExport void RestrictMatIDs (Mesh & m, int numMats);   // like "FitMeshIDsToMaterial".
01753    DllExport void SelectFacesByFlags (Mesh & m, BOOL onoff, DWORD flagmask, DWORD flags);
01754    // if adj is non-NULL, it uses it to set the "other side" visible too.
01755    DllExport void SetSingleEdgeVis (Mesh & m, DWORD ed, BOOL vis, AdjFaceList *adj=NULL);
01756 
01757    // Following will initialize to the mesh given: they can't be used to "add" ops to an existing MeshDelta.
01758    // (To add these ops, make a new MeshDelta, call one of the following, and append it to your previous one with Compose.)
01759    // Found in MDOps.cpp
01771    DllExport void AttachMesh (Mesh & m, Mesh &attachment, Matrix3 & relativeTransform,
01772       int matOffset);
01780    DllExport void BreakVerts (Mesh & m, BitArray vset);
01794    DllExport void ChamferEdges (Mesh & m, BitArray eset, MeshChamferData &mcd, AdjEdgeList *ae=NULL);
01810    DllExport void ChamferMove (Mesh & m, MeshChamferData &mcd, float amount, AdjEdgeList *ae=NULL);
01824    DllExport void ChamferVertices (Mesh & m, BitArray vset, MeshChamferData &mcd, AdjEdgeList *ae=NULL);
01832    DllExport void CloneFaces (Mesh & m, BitArray fset);
01841    DllExport void CloneVerts (Mesh & m, BitArray vset);
01851    DllExport void CollapseEdges(Mesh &m, BitArray ecol, AdjEdgeList *ae=NULL);
01880    DllExport DWORD Cut (Mesh & m, DWORD ed1, float prop1, DWORD ed2, float prop2,
01881       Point3 & norm, bool fixNeighbors=TRUE, bool split=FALSE);
01902    DllExport void Detach (Mesh & m, Mesh *out, BitArray fset, BOOL faces, BOOL del, BOOL elem);
01931    DllExport void DivideEdge (Mesh & m, DWORD ed, float prop=.5f, AdjEdgeList *el=NULL,
01932       bool visDiag1=FALSE, bool fixNeighbors=TRUE, bool visDiag2=FALSE, bool split=FALSE);
01943    DllExport void DivideEdges (Mesh & m, BitArray eset, AdjEdgeList *el=NULL);
01959    DllExport void DivideFace (Mesh & m, DWORD f, float *bary=NULL);
01972    DllExport void DivideFaces (Mesh & m, BitArray fset, MeshOpProgress *mop=NULL);
01995    DllExport void EdgeTessellate(Mesh &m, BitArray fset, float tens,
01996       AdjEdgeList *ae=NULL, AdjFaceList *af=NULL, MeshOpProgress *mop=NULL);
02010    DllExport void ExplodeFaces(Mesh &m, float thresh, bool useFaceSel=FALSE, AdjFaceList *af=NULL);
02024    DllExport void ExtrudeEdges (Mesh & m, BitArray eset, Tab<Point3> *edir=NULL);
02036    DllExport void ExtrudeFaces (Mesh & m, BitArray fset, AdjEdgeList *el=NULL);
02041    DllExport void ResetVertCorners (Mesh & m);  // DO NOT USE.  Not relevant.
02046    DllExport void ResetVertWeights (Mesh & m);
02058    void SetFaceAlpha (Mesh &m, BitArray fset, float alpha, int mp=MAP_ALPHA) { SetFaceColors (m, fset, UVVert(alpha,alpha,alpha), mp); }
02070    void SetVertAlpha (Mesh &m, BitArray vset, float alpha, int mp=MAP_ALPHA) { SetVertColors (m, vset, UVVert(alpha,alpha,alpha),mp); }
02084    DllExport void SetFaceColors (Mesh &m, BitArray fset, VertColor vc, int mp=0);
02098    DllExport void SetVertColors (Mesh &m, BitArray vset, VertColor vc, int mp=0);
02099    DllExport void SetVertCorners (Mesh &m, BitArray vset, float corner);   // DO NOT USE: Not relevant.
02109    DllExport void SetVertWeights (Mesh &m, BitArray vset, float weight);
02122    DllExport DWORD TurnEdge (Mesh & m, DWORD ed, AdjEdgeList *el=NULL);
02134    DllExport BOOL WeldByThreshold (Mesh & m, BitArray vset, float thresh);
02146    DllExport void WeldVertSet (Mesh & m, BitArray vset, Point3 *weldPoint=NULL);
02170    DllExport void PropagateFacing (Mesh & m, BitArray & fset, int face,
02171       AdjFaceList &af, BitArray &done,BOOL bias=1);
02184    DllExport void UnifyNormals (Mesh & m, BitArray fset, AdjFaceList *af=NULL);
02185 
02186    // In slicer.cpp:
02209    DllExport void Slice (Mesh & m, Point3 N, float off, bool sep=FALSE, bool remove=FALSE, BitArray *fslice=NULL, AdjEdgeList *ae=NULL);
02210 };
02211 
02212 // Following classes provide standard interface for modifiers and objects that
02213 // use mesh deltas -- specifically Edit Mesh and Editable Mesh for now.
02214 
02215 enum meshCommandMode { McmCreate, McmAttach, McmExtrude, McmBevel, McmChamfer,
02216       McmSlicePlane, McmCut, McmWeldTarget, McmFlipNormalMode, McmDivide, McmTurnEdge,McmEditSoftSelection };
02217 enum meshButtonOp    { MopHide, MopUnhideAll, MopDelete, MopDetach, MopBreak, MopViewAlign,
02218       MopGridAlign, MopMakePlanar, MopCollapse, MopTessellate, MopExplode, MopSlice, MopWeld,
02219       MopRemoveIsolatedVerts, MopSelectOpenEdges, MopCreateShapeFromEdges, MopShowNormal,
02220       MopFlipNormal, MopUnifyNormal, MopAutoSmooth, MopVisibleEdge, MopInvisibleEdge, MopAutoEdge,
02221       MopAttachList, MopSelectByID, MopSelectBySG, MopClearAllSG, MopSelectByColor,
02222       MopCopyNS, MopPasteNS, MopEditVertColor, MopEditVertIllum };
02223 enum meshUIParam { MuiSelByVert, MuiIgBack, MuiIgnoreVis, MuiSoftSel, MuiSSUseEDist,
02224       MuiSSEDist, MuiSSBack, MuiWeldBoxSize, MuiExtrudeType, MuiShowVNormals,
02225       MuiShowFNormals, MuiSliceSplit, MuiCutRefine, // end of integer values
02226       MuiPolyThresh, MuiFalloff, MuiPinch, MuiBubble, MuiWeldDist, MuiNormalSize,
02227       MuiDeleteIsolatedVerts // MuiDeleteIsolatedVerts is an integer value, but also supports float
02228       };
02229 
02230 #define EM_MESHUIPARAM_LAST_INT MuiShowFNormals // must specify last integer param
02231 #define EM_SL_OBJECT 0
02232 #define EM_SL_VERTEX 1
02233 #define EM_SL_EDGE 2
02234 #define EM_SL_FACE 3
02235 #define EM_SL_POLYGON 4
02236 #define EM_SL_ELEMENT 5
02237 
02245 class MeshDeltaUser : public InterfaceServer {
02246 public:
02255    virtual void LocalDataChanged (DWORD parts)=0;
02256    // start or stop interactive command mode, uses mode enum above
02264    virtual void ToggleCommandMode (meshCommandMode mode)=0;
02265    // perform button op, uses op enum above
02277    virtual void ButtonOp (meshButtonOp opcode)=0;
02278 
02279    // UI controls access
02293    virtual void GetUIParam (meshUIParam uiCode, int & ret) { }
02307    virtual void SetUIParam (meshUIParam uiCode, int val) { }
02321    virtual void GetUIParam (meshUIParam uiCode, float & ret) { }
02335    virtual void SetUIParam (meshUIParam uiCode, float val) { }
02336    virtual void UpdateApproxUI () { }
02337 
02338    // Should work on any local command mode.
02339    virtual void ExitCommandModes ()=0;
02340 
02341    virtual bool Editing () { return FALSE; } // returns TRUE iff between BeginEditParams, EndEditParams
02342    virtual DWORD GetEMeshSelLevel () { return EM_SL_OBJECT; }
02343    virtual void SetEMeshSelLevel (DWORD sl) { }
02344 
02345    // access to EditTriObject method for creating point controllers
02346    virtual void PlugControllersSel(TimeValue t,BitArray &set) { }
02347 };
02348 #pragma warning(pop)
02349 
02358 class MeshDeltaUserData: public MaxHeapOperators {
02359 public:
02377    virtual void ApplyMeshDelta (MeshDelta & md, MeshDeltaUser *mdu, TimeValue t)=0;
02382    virtual MeshDelta *GetCurrentMDState () { return NULL; } // only non-null in Edit Mesh
02383    // functional interface to mesh ops
02384    virtual void MoveSelection(int level, TimeValue t, Matrix3& partm, Matrix3& tmAxis, Point3& val, BOOL localOrigin)=0;
02385    virtual void RotateSelection(int level, TimeValue t, Matrix3& partm, Matrix3& tmAxis, Quat& val, BOOL localOrigin)=0;
02386    virtual void ScaleSelection(int level, TimeValue t, Matrix3& partm, Matrix3& tmAxis, Point3& val, BOOL localOrigin)=0;
02387    virtual void ExtrudeSelection(int level, BitArray* sel, float amount, float bevel, BOOL groupNormal, Point3* direction)=0;
02388 };
02389 
02390 // Constants used in Edit(able) Mesh's shortcut table - THESE MUST BE MATCHED to values in Editable Mesh's resources.
02391 #define EM_SHORTCUT_ID 0x38ba1366
02392 
02393 #define MDUID_EM_SELTYPE                   40001
02394 #define MDUID_EM_SELTYPE_BACK              40002
02395 #define MDUID_EM_SELTYPE_VERTEX            40003
02396 #define MDUID_EM_SELTYPE_EDGE              40004
02397 #define MDUID_EM_SELTYPE_FACE              40005
02398 #define MDUID_EM_SELTYPE_POLYGON           40006
02399 #define MDUID_EM_SELTYPE_ELEMENT           40007
02400 #define MDUID_EM_SELTYPE_OBJ               40008
02401 #define MDUID_EM_AUTOSMOOTH                40009
02402 #define MDUID_EM_ATTACH                    40010
02403 #define MDUID_EM_BREAK                     40011
02404 #define MDUID_EM_IGBACK                    40012
02405 #define MDUID_EM_BEVEL                     40013
02406 #define MDUID_EM_CREATE                    40014
02407 #define MDUID_EM_CUT                       40015
02408 #define MDUID_EM_DIVIDE                    40016
02409 #define MDUID_EM_EXTRUDE                   40017
02410 #define MDUID_EM_FLIPNORM                  40018
02411 #define MDUID_EM_SS_BACKFACE               40019
02412 #define MDUID_EM_UNIFY_NORMALS             40020
02413 #define MDUID_EM_HIDE                      40021
02414 #define MDUID_EM_EDGE_INVIS                40022
02415 #define MDUID_EM_IGNORE_INVIS                 40023
02416 #define MDUID_EM_IGNORE_INVIS              40023
02417 #define MDUID_EM_COLLAPSE                  40024
02418 #define MDUID_EM_SHOWNORMAL                40025
02419 #define MDUID_EM_SELOPEN                   40026
02420 #define MDUID_EM_REMOVE_ISO                40027
02421 #define MDUID_EM_SLICEPLANE                40028
02422 #define MDUID_EM_SOFTSEL                   40029
02423 #define MDUID_EM_SLICE                     40030
02424 #define MDUID_EM_DETACH                    40031
02425 #define MDUID_EM_TURNEDGE                  40032
02426 #define MDUID_EM_UNHIDE                    40033
02427 #define MDUID_EM_EDGE_VIS                  40034
02428 #define MDUID_EM_SELBYVERT                 40035
02429 #define MDUID_EM_AUTOEDGE                  40036
02430 #define MDUID_EM_WELD                      40038
02431 #define MDUID_EM_EXPLODE                   40039
02432 #define MDUID_EM_CHAMFER                   40040
02433 #define MDUID_EM_WELD_TARGET                     40041
02434 #define MDUID_EM_ATTACH_LIST                     40042
02435 #define MDUID_EM_VIEW_ALIGN                         40043
02436 #define MDUID_EM_GRID_ALIGN                      40044
02437 #define MDUID_EM_SPLIT                              40045
02438 #define MDUID_EM_REFINE_CUTENDS                  40046
02439 #define MDUID_EM_COPY_NAMEDSEL                   40047
02440 #define MDUID_EM_PASTE_NAMEDSEL                  40048
02441 #define MDUID_EM_MAKE_PLANAR                     40049
02442 #define MDUID_EM_VERT_COLOR                         40050
02443 #define MDUID_EM_VERT_ILLUM                         40051
02444 #define MDUID_EM_FLIP_NORMAL_MODE                40052
02445 
02471 DllExport void FindTriangulation (Mesh & m, int deg, int *vv, int *tri);
02472 
02473