00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #pragma once
00018
00019 #include "maxheap.h"
00020 #include "shphier.h"
00021 #include "spline3d.h"
00022 #include "shpsels.h"
00023 #include "hitdata.h"
00024 #include "TabTypes.h"
00025 #include "GraphicsConstants.h"
00026
00027
00028 class BezierShape;
00029 class ModContext;
00030
00031
00032 #define SHAPE_TRIM 0
00033 #define SHAPE_EXTEND 1
00034
00035
00036 class bindShape: public MaxHeapOperators
00037 {
00038 public:
00039 int pointSplineIndex;
00040 int segSplineIndex;
00041 int seg;
00042 Point3 bindPoint,segPoint;
00043 BOOL isEnd;
00044 };
00045
00046
00062 class ShapeSubHitRec: public MaxHeapOperators {
00063 private:
00064 ShapeSubHitRec *next;
00065 public:
00066 DWORD dist;
00067 BezierShape* shape;
00068 int poly;
00069 int index;
00072 ShapeSubHitRec( DWORD dist, BezierShape *shape, int poly, int index, ShapeSubHitRec *next )
00073 { this->dist = dist; this->shape = shape; this->poly = poly; this->index = index; this->next = next; }
00074
00076 ShapeSubHitRec *Next() { return next; }
00077 };
00078
00084 class SubShapeHitList: public MaxHeapOperators {
00085 private:
00086 ShapeSubHitRec *first;
00087 public:
00089 SubShapeHitList() { first = NULL; }
00091 CoreExport ~SubShapeHitList();
00092
00094 ShapeSubHitRec *First() { return first; }
00108 CoreExport void AddHit( DWORD dist, BezierShape *shape, int poly, int index );
00109 int Count() {
00110 int count = 0;
00111 ShapeSubHitRec *ptr = first;
00112 while(ptr) {
00113 count++;
00114 ptr = ptr->Next();
00115 }
00116 return count;
00117 }
00118 };
00119
00120
00133 class ShapeHitData : public HitData {
00134 public:
00135 BezierShape *shape;
00136 int poly;
00137 int index;
00140 ShapeHitData(BezierShape *shape, int poly, int index)
00141 { this->shape = shape; this->poly = poly; this->index = index; }
00142 ~ShapeHitData() {}
00143 };
00144
00145
00146
00154 class ShapeContextCallback: public MaxHeapOperators {
00155 public:
00165 virtual BezierShape *GetShapeContext(ModContext* context) = 0;
00166 };
00167
00168 class ShapeObject;
00169
00185 class BezierShapeTopology: public MaxHeapOperators {
00186 public:
00187 BOOL ready;
00188 IntTab kcount;
00189 BitArray closed;
00193 BezierShapeTopology() { ready = FALSE; }
00198 CoreExport void Build(BezierShape &shape);
00200 CoreExport int operator==(const BezierShapeTopology& t);
00202 CoreExport IOResult Save(ISave *isave);
00204 CoreExport IOResult Load(ILoad *iload);
00205 };
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 #define BEZIER_SHAPE_INTERFACE_EX41 Interface_ID(0x23526cd1, 0x695d7e4e)
00219 #define GET_BEZIER_SHAPE_INTERFACE_EX41() \
00220 (BezierShapeInterface_Ex41*) GetInterface(BEZIER_SHAPE_INTERFACE_EX41)
00221
00238 class BezierShapeInterface_Ex41 : public BaseInterface
00239 {
00240 public:
00241 BOOL mUseAreaSelect;
00242 float mAreaSelect;
00243
00251 BaseInterface* GetInterface(Interface_ID id) { if (id == BEZIER_SHAPE_INTERFACE_EX41) return (BaseInterface*)this; else return NULL; }
00254 Interface_ID GetID() { return BEZIER_SHAPE_INTERFACE_EX41; }
00257 void DeleteInterface();
00258 };
00259
00260
00307 class BezierShape : public BaseInterfaceServer {
00308 Box3 bdgBox;
00309 static int shapeCount;
00310 PolyShape pShape;
00311 int pShapeSteps;
00312 BOOL pShapeOptimize;
00313 BOOL pShapeCacheValid;
00314 int *vertBase;
00315 int totalShapeVerts;
00316 int *knotBase;
00317 int totalShapeKnots;
00318 BOOL topoCacheValid;
00319 BezierShapeTopology topology;
00320
00321
00322
00323
00324
00325
00326
00327
00328 BOOL UseAreaSelect();
00329 void SetUseAreaSelect( BOOL useAreaSelect );
00330
00331 float AreaSelect();
00332 void SetAreaSelect( float aresSelect );
00333
00334
00335
00336 friend INT_PTR CALLBACK SplineSelectDlgProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam );
00337
00338 public:
00339
00340
00341 PatchCapInfo patchCap;
00342 BOOL patchCapCacheValid;
00343
00344
00345 Spline3D **splines;
00346 int splineCount;
00347
00348 int steps;
00349 BOOL optimize;
00350
00351
00352 ShapeVSel vertSel;
00353 ShapeSSel segSel;
00354 ShapePSel polySel;
00355
00356
00357 int bezVecPoly;
00358 int bezVecVert;
00359
00360
00361 DWORD selLevel;
00362
00363
00364 DWORD dispFlags;
00365
00379 CoreExport BezierShape();
00382 CoreExport BezierShape(BezierShape& fromShape);
00383
00398 CoreExport void Init();
00399
00401 CoreExport ~BezierShape();
00402
00404 CoreExport BezierShape& operator=(BezierShape& fromShape);
00406 CoreExport BezierShape& operator=(PolyShape& fromShape);
00414 CoreExport Point3 GetVert(int poly, int i);
00424 CoreExport void SetVert(int poly, int i, const Point3 &xyz);
00425
00427 CoreExport void Render(GraphicsWindow *gw, Material *ma, RECT *rp, int compFlags, int numMat);
00428 CoreExport void RenderGizmo(GraphicsWindow *gw);
00430 CoreExport BOOL Select(GraphicsWindow *gw, Material *ma, HitRegion *hr, int abortOnHit = FALSE);
00432 CoreExport void Snap(GraphicsWindow *gw, SnapInfo *snap, IPoint2 *p, Matrix3 &tm);
00433
00435 CoreExport void Snap(GraphicsWindow *gw, SnapInfo *snap, IPoint2 *p, Matrix3 &tm, DWORD flags);
00438 CoreExport BOOL SubObjectHitTest(GraphicsWindow *gw, Material *ma, HitRegion *hr,
00439 DWORD flags, SubShapeHitList& hitList );
00440
00444 CoreExport void BuildBoundingBox(void);
00452 CoreExport Box3 GetBoundingBox(Matrix3 *tm=NULL);
00453
00454
00458 CoreExport void InvalidateGeomCache();
00460 CoreExport void InvalidateCapCache();
00461
00462
00464 CoreExport void ShallowCopy(BezierShape *ashape, ChannelMask channels);
00466 CoreExport void DeepCopy(BezierShape *ashape, ChannelMask channels);
00468 CoreExport void NewAndCopyChannels(ChannelMask channels);
00470 CoreExport void FreeChannels(ChannelMask channels, int zeroOthers=1);
00471
00472
00479 CoreExport void SetDispFlag(DWORD f);
00486 CoreExport DWORD GetDispFlag(DWORD f);
00493 CoreExport void ClearDispFlag(DWORD f);
00509 CoreExport BitArray VertexTempSel(int poly, int level = -1);
00510
00511
00512
00513
00545 CoreExport BitArray VertexTempSelAll(int poly = -1, BOOL includeVecs = FALSE, int level = 0, BOOL forceSel = FALSE);
00546
00548
00553 CoreExport BitArray VertexFlagSel(int poly, DWORD flag);
00554
00556 CoreExport IOResult Save(ISave* isave);
00558 CoreExport IOResult Load(ILoad* iload);
00559
00560
00561
00563 inline int SplineCount() { return splineCount; }
00570 CoreExport Spline3D* GetSpline(int index);
00586 CoreExport Spline3D* NewSpline(int itype = KTYPE_CORNER,int dtype = KTYPE_BEZIER,int ptype = PARM_UNIFORM);
00595 CoreExport Spline3D* AddSpline(Spline3D* spline);
00601 CoreExport int DeleteSpline(int index);
00611 CoreExport int InsertSpline(Spline3D* spline, int index);
00613 CoreExport void NewShape();
00616 CoreExport int GetNumVerts();
00619 CoreExport int GetNumSegs();
00632 CoreExport void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel );
00645 CoreExport void UpdateSels(BOOL save=FALSE);
00652 CoreExport void GetClosures(BitArray& array);
00658 CoreExport void SetClosures(BitArray& array);
00681 CoreExport float FindSegmentPoint(int poly, int segment, GraphicsWindow *gw, Material *ma, HitRegion *hr, int ptype = PARAM_SIMPLE);
00692 CoreExport void Reverse(int poly, BOOL keepZero = FALSE);
00705 CoreExport void Reverse(BitArray &reverse, BOOL keepZero = FALSE);
00717 CoreExport ShapeHierarchy &OrganizeCurves(TimeValue t, ShapeHierarchy *hier = NULL);
00727 CoreExport void MakePolyShape(PolyShape &pshp, int steps = -1, BOOL optimize = FALSE);
00736 CoreExport void MakeFirst(int poly, int vertex);
00742 CoreExport void Transform(Matrix3 &tm);
00744 CoreExport BezierShape& operator+=(BezierShape& from);
00756 CoreExport void AddAndWeld(BezierShape &from, float weldThreshold);
00758 CoreExport void ReadyCachedPolyShape();
00769 CoreExport int MakeCap(TimeValue t, MeshCapInfo &capInfo, int capType);
00779 CoreExport int MakeCap(TimeValue t, PatchCapInfo &capInfo);
00787 CoreExport int ReadyPatchCap();
00788
00789
00790
00797 CoreExport void CopyShapeDataFrom(BezierShape &fromShape);
00798
00799
00800
00802 CoreExport void PrepVertBaseIndex();
00811 CoreExport int GetVertIndex(int poly, int vert);
00821 CoreExport void GetPolyAndVert(int index, int &polyOut, int &vertOut);
00823 CoreExport int GetTotalVerts();
00824 CoreExport Point3 GetVert( int index );
00825 CoreExport void SetVert( int index , const Point3 &xyz);
00826
00827
00828
00830 CoreExport void PrepKnotBaseIndex();
00839 CoreExport int GetKnotIndex(int poly, int knot);
00849 CoreExport void GetPolyAndKnot(int index, int &polyOut, int &knotOut);
00851 CoreExport int GetTotalKnots();
00852
00853
00854
00861 CoreExport BOOL DeleteSelVerts(int poly);
00868 CoreExport BOOL DeleteSelSegs(int poly);
00871 CoreExport BOOL DeleteSelectedVerts();
00874 CoreExport BOOL DeleteSelectedSegs();
00877 CoreExport BOOL DeleteSelectedPolys();
00878
00879
00880
00887 CoreExport BOOL CloneSelectedParts(BOOL reverse=FALSE);
00888
00889
00890
00891
00892
00893
00894
00895
00909 CoreExport BOOL RecordTopologyTags(int channel=0);
00910
00911
00927 CoreExport Point3 InterpCurve3D(int poly, float param, int ptype=PARAM_SIMPLE);
00942 CoreExport Point3 TangentCurve3D(int poly, float param, int ptype=PARAM_SIMPLE);
00962 CoreExport Point3 InterpPiece3D(int poly, int piece, float param, int ptype=PARAM_SIMPLE);
00977 CoreExport Point3 TangentPiece3D(int poly, int piece, float param, int ptype=PARAM_SIMPLE);
00987 CoreExport MtlID GetMatID(int poly, int piece);
00992 CoreExport float LengthOfCurve(int poly);
00993
00994
01002 CoreExport void GetTopology(BezierShapeTopology &topo);
01003
01004
01034 CoreExport BOOL PerformTrimOrExtend(IObjParam *ip, ViewExp *vpt, ShapeHitData *hit, IPoint2 &m, ShapeContextCallback &cb, int trimType, int trimInfinite);
01035
01036 CoreExport BOOL SelVertsSameType();
01037 CoreExport BOOL SelSegsSameType();
01038 CoreExport BOOL SelSplinesSameType();
01039
01040
01041
01042 Tab<bindShape> bindList;
01058 CoreExport void BindKnot(BOOL isEnd, int segIndex, int splineSegID, int splinePointID);
01065 CoreExport BOOL UnbindKnot(int splineID, BOOL isEnd);
01081 CoreExport void UpdateBindList(BOOL useGeometricTracking = FALSE);
01084 CoreExport BOOL HideSelectedSegs();
01087 CoreExport BOOL HideSelectedVerts();
01090 CoreExport BOOL HideSelectedSplines();
01093 CoreExport BOOL UnhideSegs();
01094
01095 CoreExport int UnselectHiddenVerts();
01096 CoreExport int UnselectHiddenSegs();
01097 CoreExport int UnselectHiddenSplines();
01098
01099 float * mpVertexWeights;
01100 int numVertexWeights;
01101 int * mpVertexEdgeDists;
01102 float * mpVertexDists;
01103
01104 public:
01105 CoreExport void SetVertexWeightCount( int i );
01106 CoreExport void SetVertexWeight( int i, float w ) { assert( mpVertexWeights ); if ( i >= numVertexWeights ) return; mpVertexWeights[i] = w; }
01107 CoreExport float VertexWeight( int i ) { if ( !mpVertexWeights ) return 0.0f; if ( i >= numVertexWeights ) return 0.0f; return mpVertexWeights[i]; }
01108 CoreExport bool VertexWeightSupport() { if ( mpVertexWeights ) return true; return false; }
01109 CoreExport float *GetVSelectionWeights() { return mpVertexWeights; }
01110 CoreExport void SupportVSelectionWeights();
01111
01112 float mFalloff, mPinch, mBubble;
01113 int mEdgeDist, mUseEdgeDist, mAffectBackface, mUseSoftSelections;
01114
01115 CoreExport int UseEdgeDists( );
01116 CoreExport void SetUseEdgeDists( int edgeDist );
01117
01118 CoreExport int EdgeDist( );
01119 CoreExport void SetEdgeDist( int edgeDist );
01120
01121 CoreExport int UseSoftSelections();
01122 CoreExport void SetUseSoftSelections( int useSoftSelections );
01123
01124 CoreExport int AffectBackface( );
01125 CoreExport void SetAffectBackface( int affectBackface );
01126
01127 CoreExport float Falloff( );
01128 CoreExport void SetFalloff( float falloff );
01129
01130 CoreExport float Pinch( );
01131 CoreExport void SetPinch( float pinch );
01132
01133 CoreExport float Bubble( );
01134 CoreExport void SetBubble( float bubble );
01135
01136 CoreExport void InvalidateVertexWeights();
01137
01138 CoreExport void UpdateVertexDists();
01139 CoreExport void UpdateEdgeDists( );
01140 CoreExport void UpdateVertexWeights();
01141
01143
01149 CoreExport bool DeleteSplines(const unsigned int* indices, unsigned int n);
01150 };
01151