1 | /**********************************************************************
|
---|
2 | *<
|
---|
3 | FILE: triobj.h
|
---|
4 |
|
---|
5 | DESCRIPTION: Defines Triangle Mesh Object
|
---|
6 |
|
---|
7 | CREATED BY: Dan Silva
|
---|
8 |
|
---|
9 | HISTORY: created 9 September 1994
|
---|
10 |
|
---|
11 | *> Copyright (c) 1994, All Rights Reserved.
|
---|
12 | **********************************************************************/
|
---|
13 |
|
---|
14 | #ifndef __TRIOBJ__
|
---|
15 |
|
---|
16 | #define __TRIOBJ__
|
---|
17 |
|
---|
18 | #include "meshlib.h"
|
---|
19 | #include "snap.h"
|
---|
20 |
|
---|
21 | #define TRI_MULTI_PROCESSING TRUE
|
---|
22 |
|
---|
23 | extern CoreExport Class_ID triObjectClassID;
|
---|
24 |
|
---|
25 | class TriObject: public GeomObject {
|
---|
26 | Interval geomValid;
|
---|
27 | Interval topoValid;
|
---|
28 | Interval texmapValid;
|
---|
29 | Interval selectValid;
|
---|
30 | DWORD validBits; // for the remaining constant channels
|
---|
31 | CoreExport void CopyValidity(TriObject *fromOb, ChannelMask channels);
|
---|
32 | #if TRI_MULTI_PROCESSING
|
---|
33 | static int refCount;
|
---|
34 | static HANDLE defThread;
|
---|
35 | static HANDLE defMutex;
|
---|
36 | static HANDLE defStartEvent;
|
---|
37 | static HANDLE defEndEvent;
|
---|
38 | friend DWORD WINAPI defFunc(LPVOID ptr);
|
---|
39 | #endif
|
---|
40 |
|
---|
41 | protected:
|
---|
42 | // inherited virtual methods for Reference-management
|
---|
43 | CoreExport RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message );
|
---|
44 | public:
|
---|
45 | Mesh mesh;
|
---|
46 |
|
---|
47 | CoreExport TriObject();
|
---|
48 | CoreExport ~TriObject();
|
---|
49 |
|
---|
50 | // inherited virtual methods:
|
---|
51 |
|
---|
52 | // From BaseObject
|
---|
53 | CoreExport int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
|
---|
54 | CoreExport int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
|
---|
55 | CoreExport void Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt);
|
---|
56 | CoreExport CreateMouseCallBack* GetCreateMouseCallBack();
|
---|
57 | CoreExport RefTargetHandle Clone(RemapDir& remap = NoRemap());
|
---|
58 |
|
---|
59 | // From Object
|
---|
60 | CoreExport ObjectState Eval(TimeValue time);
|
---|
61 | CoreExport Interval ObjectValidity(TimeValue t);
|
---|
62 |
|
---|
63 | // get and set the validity interval for the nth channel
|
---|
64 | CoreExport Interval ChannelValidity(TimeValue t, int nchan);
|
---|
65 | CoreExport void SetChannelValidity(int i, Interval v);
|
---|
66 | CoreExport void InvalidateChannels(ChannelMask channels);
|
---|
67 |
|
---|
68 | // Convert-to-type validity
|
---|
69 | CoreExport Interval ConvertValidity(TimeValue t);
|
---|
70 |
|
---|
71 | // Deformable object procs
|
---|
72 | int IsDeformable() { return 1; }
|
---|
73 | int NumPoints() { return mesh.getNumVerts(); }
|
---|
74 | Point3 GetPoint(int i) { return mesh.getVert(i); }
|
---|
75 | void SetPoint(int i, const Point3& p) { mesh.setVert(i,p); }
|
---|
76 |
|
---|
77 | // Mappable object procs
|
---|
78 | int IsMappable() { return 1; }
|
---|
79 | void ApplyUVWMap(int type, float utile, float vtile, float wtile,
|
---|
80 | int uflip, int vflip, int wflip, int cap,const Matrix3 &tm) {
|
---|
81 | mesh.ApplyUVWMap(type,utile,vtile,wtile,uflip,vflip,wflip,cap,tm); }
|
---|
82 |
|
---|
83 | void PointsWereChanged(){ mesh.InvalidateGeomCache(); }
|
---|
84 | CoreExport void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm=NULL,BOOL useSel=FALSE );
|
---|
85 | CoreExport void Deform(Deformer *defProc, int useSel);
|
---|
86 | CoreExport int PointLogicallySelected(int i) ;
|
---|
87 |
|
---|
88 | CoreExport int CanConvertToType(Class_ID obtype);
|
---|
89 | CoreExport Object* ConvertToType(TimeValue t, Class_ID obtype);
|
---|
90 | CoreExport void FreeChannels(ChannelMask chan);
|
---|
91 | CoreExport Object *MakeShallowCopy(ChannelMask channels);
|
---|
92 | CoreExport void ShallowCopy(Object* fromOb, ChannelMask channels);
|
---|
93 | CoreExport void NewAndCopyChannels(ChannelMask channels);
|
---|
94 |
|
---|
95 | CoreExport DWORD GetSubselState();
|
---|
96 | CoreExport void SetSubSelState(DWORD s);
|
---|
97 |
|
---|
98 | CoreExport BOOL CheckObjectIntegrity();
|
---|
99 |
|
---|
100 | // From GeomObject
|
---|
101 | CoreExport int IntersectRay(TimeValue t, Ray& ray, float& at, Point3& norm);
|
---|
102 | CoreExport ObjectHandle CreateTriObjRep(TimeValue t); // for rendering, also for deformation
|
---|
103 | CoreExport void GetWorldBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& box );
|
---|
104 | CoreExport void GetLocalBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& box );
|
---|
105 | CoreExport Mesh* GetRenderMesh(TimeValue t, INode *inode, View &view, BOOL& needDelete);
|
---|
106 |
|
---|
107 | Mesh& Mesh() { return mesh; }
|
---|
108 |
|
---|
109 | // Animatable methods
|
---|
110 |
|
---|
111 | void DeleteThis() { delete this; }
|
---|
112 | void FreeCaches() {mesh.InvalidateGeomCache(); }
|
---|
113 | Class_ID ClassID() { return Class_ID(TRIOBJ_CLASS_ID,0); }
|
---|
114 | void GetClassName(TSTR& s) { s = TSTR(_T("TriObject")); }
|
---|
115 | void NotifyMe(Animatable *subAnim, int message) {}
|
---|
116 | int IsKeyable() { return 0;}
|
---|
117 | int Update(TimeValue t) { return 0; }
|
---|
118 | BOOL BypassTreeView() { return TRUE; }
|
---|
119 | // This is the name that will appear in the history browser.
|
---|
120 | TCHAR *GetObjectName() { return _T("Mesh"); }
|
---|
121 |
|
---|
122 | // IO
|
---|
123 | CoreExport IOResult Save(ISave *isave);
|
---|
124 | CoreExport IOResult Load(ILoad *iload);
|
---|
125 |
|
---|
126 | // TriObject-specific methods
|
---|
127 |
|
---|
128 |
|
---|
129 | };
|
---|
130 |
|
---|
131 | // Regular TriObject
|
---|
132 | CoreExport ClassDesc* GetTriObjDescriptor();
|
---|
133 |
|
---|
134 | // A new decsriptor can be registered to replace the default
|
---|
135 | // tri object descriptor. This new descriptor will then
|
---|
136 | // be used to create tri objects.
|
---|
137 |
|
---|
138 | CoreExport void RegisterEditTriObjDesc(ClassDesc* desc);
|
---|
139 | CoreExport ClassDesc* GetEditTriObjDesc(); // Returns default of none have been registered
|
---|
140 |
|
---|
141 | // Use this instead of new TriObject. It will use the registered descriptor
|
---|
142 | // if one is registered, otherwise you'll get a default tri-object.
|
---|
143 | CoreExport TriObject *CreateNewTriObject();
|
---|
144 |
|
---|
145 |
|
---|
146 | #endif
|
---|