00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #pragma once
00013
00014 #include "maxheap.h"
00015 #include "triobj.h"
00016 #include "polyobj.h"
00017 #include "meshadj.h"
00018 #include "patchobj.h"
00019
00020 class HitListWrapper;
00021
00022
00023
00024
00025
00026
00028 struct GenFace: public MaxHeapOperators {
00030 unsigned short numVerts;
00032 DWORD* verts;
00033 };
00034
00036 struct GenEdge: public MaxHeapOperators {
00038 DWORD f[2];
00040 DWORD v[2];
00041 };
00042
00044 struct GenSoftSelData: public MaxHeapOperators {
00046 BOOL useSoftSel;
00048 BOOL useEdgeDist;
00049
00055 int edgeIts;
00056
00059 BOOL ignoreBack;
00060
00062 float falloff;
00065 float pinch;
00068 float bubble;
00069
00070
00072 CoreExport GenSoftSelData();
00073 };
00074
00076 BOOL operator==(GenSoftSelData& a, GenSoftSelData& b);
00077
00078
00079
00080
00081
00106
00107 class ObjectWrapper: public MaxHeapOperators {
00108 protected:
00109 TimeValue t;
00110
00111
00112 union {
00113 Mesh* mesh;
00114 MNMesh* poly;
00115 PatchMesh* patch;
00116 };
00117 union {
00118 MeshTempData* meshTempData;
00119 MNTempData* polyTempData;
00120 };
00121 BOOL isCopy;
00122
00123 Point3* verts;
00124 GenFace* faces;
00125 GenEdge* edges;
00126 GeomObject* collapsedObj;
00127
00128 BitArray faceSel, vertSel;
00129 GenSoftSelData softSelData;
00130
00131 int invalidMask;
00132
00133 public:
00134
00136 enum { empty=0, triObject, polyObject, patchObject } type;
00137 enum { noneEnable=0, triEnable=1, polyEnable=2, patchEnable=4, allEnable=0x7 };
00138
00140 CoreExport ObjectWrapper();
00142 CoreExport ~ObjectWrapper() {Release();}
00144 CoreExport void Zero();
00145
00161 CoreExport BOOL Init( TimeValue t, ObjectState& os, BOOL copy=FALSE, int enable=allEnable, int nativeType=polyObject );
00162
00167 CoreExport void Release();
00168
00171 CoreExport BOOL IsEmpty() {return type==empty;}
00172
00175 CoreExport int Type() {return type;}
00176
00178 CoreExport Mesh* GetTriMesh() {return type==triObject? mesh:NULL;}
00180 CoreExport MNMesh* GetPolyMesh() {return type==polyObject? poly:NULL;}
00182 CoreExport PatchMesh* GetPatchMesh() {return type==patchObject? patch:NULL;}
00183
00184 enum { iv_none=0x000, iv_verts=0x001, iv_faces=0x002, iv_edges=0x004 };
00195 CoreExport void Invalidate( int iInvalid );
00196
00198 CoreExport void InvalidateGeomCache();
00199
00200
00201
00203 CoreExport int NumVerts();
00205 CoreExport int NumFaces();
00207 CoreExport int NumEdges();
00208
00212 CoreExport Point3* Verts();
00217 CoreExport GenFace* Faces();
00222 CoreExport GenEdge* Edges();
00223
00226 CoreExport Point3* GetVert( int index );
00230 CoreExport void SetVert( int index, Point3 &p );
00233 CoreExport void SetNumVerts( int num );
00234
00237 CoreExport GenFace GetFace( int index );
00241 CoreExport void SetFace( int index, GenFace &face );
00244 CoreExport void SetNumFaces( int num );
00245
00248 CoreExport GenEdge GetEdge( int index );
00251 CoreExport int NumFaceEdges( int faceIndex );
00255 CoreExport int GetFaceEdgeIndex( int faceIndex, int edgeIndex );
00256
00260 CoreExport void GetVertexSpace( int index, Matrix3 & tm );
00263 CoreExport Point3* GetVertexNormal( int index );
00264
00265 CoreExport BOOL GetFaceHidden( int faceIndex );
00266 CoreExport void SetFaceHidden( int faceIndex, BOOL hidden );
00267
00268
00269
00273 CoreExport BOOL GetChannelSupport( int mapChannel );
00278 CoreExport void SetChannelSupport( int mapChannel, BOOL b );
00279
00282 CoreExport int NumMapVerts( int channel );
00286 CoreExport void SetNumMapVerts( int channel, int num );
00287
00291 CoreExport Point3* GetMapVert( int channel, int index );
00296 CoreExport void SetMapVert( int channel, int index, Point3 &p );
00297
00302 CoreExport GenFace GetMapFace( int channel, int index );
00308 CoreExport void SetMapFace( int channel, int index, GenFace &face );
00309
00310
00313 CoreExport MtlID GetMtlID( int index );
00317 CoreExport void SetMtlID( int index, MtlID mtlID );
00318
00319
00320
00323 CoreExport DWORD GetSmoothingGroup( int index );
00327 CoreExport void SetSmoothingGroup( int index, DWORD smGrp );
00328
00329
00330
00332 enum {
00334 SEL_OBJECT,
00336 SEL_VERT,
00338 SEL_FACE,
00340 SEL_ELEM
00341 };
00342
00345 CoreExport int GetSelLevel();
00348 CoreExport void SetSelLevel(int selLevel);
00349
00351 CoreExport BitArray& GetVertSel();
00354 CoreExport void SetVertSel( BitArray& );
00355
00357 CoreExport BitArray& GetFaceSel();
00360 CoreExport void SetFaceSel( BitArray& sel );
00361
00365 CoreExport BitArray& GetElemSel();
00366
00371 CoreExport void SetElemSel( BitArray& sel );
00372
00375 CoreExport BitArray* GetSel( int selLevel );
00379 CoreExport void SetSel( int selLevel, BitArray& sel );
00380
00388 CoreExport void FaceToElemSel( BitArray& elemSel, BitArray& faceSel );
00389
00390
00391
00397 CoreExport void GrowSelection( int selLevel, BitArray& newSel );
00398
00404 CoreExport void ShrinkSelection( int selLevel, BitArray& newSel );
00405
00406
00407
00411 CoreExport void GetSoftSel( GenSoftSelData& softSelData );
00415 CoreExport void SetSoftSel( GenSoftSelData& softSelData );
00417 CoreExport void UpdateSoftSel();
00418
00421 CoreExport float* SoftSelWeights();
00424 CoreExport Point3 SoftSelColor( float f );
00425
00426
00427 enum { SUBHIT_IGNOREBACKFACING=(1<<5) };
00428
00438 CoreExport BOOL SubObjectHitTest(
00439 int selLevel, GraphicsWindow* gw, Material* ma, HitRegion *hr,
00440 DWORD flags, HitListWrapper& hitList, int numMat=1, Matrix3 *mat = NULL );
00441
00449 CoreExport int IntersectRay( Ray& ray, float& intersectAt, Point3& norm, int& fi, FloatTab& bary );
00450
00457 CoreExport void Render(GraphicsWindow *gw, Material *ma, RECT *rp, int compFlags, int numMat = 1);
00458
00459
00460
00464 CoreExport int SelLevel( int selLevel );
00468 CoreExport int HitLevel( int selLevel );
00469
00470 };
00471
00472
00473
00474
00475
00476 class HitListWrapper: public MaxHeapOperators {
00477 protected:
00478 friend class ObjectWrapper;
00479 union {
00480 SubObjHitList* meshHitList;
00481 SubObjHitList* polyHitList;
00482 SubPatchHitList* patchHitList;
00483 };
00484 union {
00485 MeshSubHitRec* curMeshHitRec;
00486 MeshSubHitRec* curPolyHitRec;
00487 PatchSubHitRec* curPatchHitRec;
00488 };
00489
00490 public:
00494 enum { empty=0, triObject, polyObject, patchObject } type;
00495
00497 CoreExport HitListWrapper() {type=empty;}
00499 CoreExport ~HitListWrapper();
00500
00503 CoreExport bool GoToFirst();
00506 CoreExport bool GoToNext();
00507
00512 CoreExport DWORD GetDist();
00513
00517 CoreExport int GetIndex();
00518
00523 CoreExport void Init( int type );
00525 CoreExport void Release();
00526 };
00527
00528