1 | /**********************************************************************
|
---|
2 | *<
|
---|
3 | FILE: SimpObj.h
|
---|
4 |
|
---|
5 | DESCRIPTION: A base class for procedural objects that fit into
|
---|
6 | a standard form.
|
---|
7 |
|
---|
8 | CREATED BY: Rolf Berteig
|
---|
9 |
|
---|
10 | HISTORY: created 10/10/95
|
---|
11 |
|
---|
12 | *> Copyright (c) 1994, All Rights Reserved.
|
---|
13 | **********************************************************************/
|
---|
14 |
|
---|
15 | #ifndef __SIMPOBJ__
|
---|
16 | #define __SIMPOBJ__
|
---|
17 |
|
---|
18 | // ParticleSys lib
|
---|
19 | #include "partclib.h"
|
---|
20 |
|
---|
21 |
|
---|
22 | class SimpleObject : public GeomObject {
|
---|
23 | public:
|
---|
24 | IParamBlock *pblock;
|
---|
25 | Mesh mesh;
|
---|
26 | Interval ivalid;
|
---|
27 |
|
---|
28 | BOOL suspendSnap; // If TRUE, no snapping will occur
|
---|
29 |
|
---|
30 | static SimpleObject *editOb;
|
---|
31 |
|
---|
32 | CoreExport SimpleObject();
|
---|
33 | CoreExport ~SimpleObject();
|
---|
34 |
|
---|
35 | CoreExport void UpdateMesh(TimeValue t);
|
---|
36 | CoreExport void GetBBox(TimeValue t, Matrix3& tm, Box3& box );
|
---|
37 | void MeshInvalid() {ivalid.SetEmpty();}
|
---|
38 |
|
---|
39 | // From BaseObject
|
---|
40 | CoreExport void BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev);
|
---|
41 | CoreExport void EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
|
---|
42 | CoreExport int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
|
---|
43 | CoreExport void Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt);
|
---|
44 | CoreExport int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
|
---|
45 | CoreExport IParamArray *GetParamBlock();
|
---|
46 | CoreExport int GetParamBlockIndex(int id);
|
---|
47 |
|
---|
48 | // From Object
|
---|
49 | CoreExport ObjectState Eval(TimeValue time);
|
---|
50 | void InitNodeName(TSTR& s) {s = GetObjectName();}
|
---|
51 | CoreExport Interval ObjectValidity(TimeValue t);
|
---|
52 | CoreExport int CanConvertToType(Class_ID obtype);
|
---|
53 | CoreExport Object* ConvertToType(TimeValue t, Class_ID obtype);
|
---|
54 |
|
---|
55 | // From GeomObject
|
---|
56 | CoreExport int IntersectRay(TimeValue t, Ray& ray, float& at, Point3& norm);
|
---|
57 | CoreExport void GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box );
|
---|
58 | CoreExport void GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box );
|
---|
59 | CoreExport void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel );
|
---|
60 | CoreExport Mesh* GetRenderMesh(TimeValue t, INode *inode, View &view, BOOL& needDelete);
|
---|
61 |
|
---|
62 | // Animatable methods
|
---|
63 | CoreExport void FreeCaches();
|
---|
64 | void GetClassName(TSTR& s) {s = GetObjectName();}
|
---|
65 | int NumSubs() { return 1; }
|
---|
66 | Animatable* SubAnim(int i) { return pblock; }
|
---|
67 | CoreExport TSTR SubAnimName(int i);
|
---|
68 |
|
---|
69 | // From ref
|
---|
70 | int NumRefs() {return 1;}
|
---|
71 | RefTargetHandle GetReference(int i) {return pblock;}
|
---|
72 | void SetReference(int i, RefTargetHandle rtarg) {pblock=(IParamBlock*)rtarg;}
|
---|
73 | CoreExport RefResult NotifyRefChanged(Interval changeInt,RefTargetHandle hTarget,
|
---|
74 | PartID& partID, RefMessage message);
|
---|
75 |
|
---|
76 |
|
---|
77 | // --- These must be implemented by the derived class ----------------
|
---|
78 | virtual void BuildMesh(TimeValue t)=0;
|
---|
79 | virtual BOOL OKtoDisplay(TimeValue t) {return TRUE;}
|
---|
80 | virtual void InvalidateUI() {}
|
---|
81 | virtual ParamDimension *GetParameterDim(int pbIndex) {return defaultDim;}
|
---|
82 | virtual TSTR GetParameterName(int pbIndex) {return TSTR(_T("Parameter"));}
|
---|
83 | };
|
---|
84 |
|
---|
85 |
|
---|
86 | class SimpleWSMObject : public WSMObject {
|
---|
87 | public:
|
---|
88 | IParamBlock *pblock;
|
---|
89 | Mesh mesh;
|
---|
90 | Interval ivalid;
|
---|
91 |
|
---|
92 | static SimpleWSMObject *editOb;
|
---|
93 |
|
---|
94 | CoreExport SimpleWSMObject();
|
---|
95 | CoreExport ~SimpleWSMObject();
|
---|
96 |
|
---|
97 | CoreExport void UpdateMesh(TimeValue t);
|
---|
98 | CoreExport void GetBBox(TimeValue t, Matrix3& tm, Box3& box );
|
---|
99 | void MeshInvalid() {ivalid.SetEmpty();}
|
---|
100 |
|
---|
101 | // From BaseObject
|
---|
102 | CoreExport void BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev);
|
---|
103 | CoreExport void EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
|
---|
104 | CoreExport int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
|
---|
105 | CoreExport void Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt);
|
---|
106 | CoreExport int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
|
---|
107 | CoreExport IParamArray *GetParamBlock();
|
---|
108 | CoreExport int GetParamBlockIndex(int id);
|
---|
109 |
|
---|
110 | // From Object
|
---|
111 | int DoOwnSelectHilite() {return TRUE;}
|
---|
112 | CoreExport ObjectState Eval(TimeValue time);
|
---|
113 | void InitNodeName(TSTR& s) {s = GetObjectName();}
|
---|
114 | CoreExport Interval ObjectValidity(TimeValue t);
|
---|
115 | CoreExport void GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box );
|
---|
116 | CoreExport void GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box );
|
---|
117 | CoreExport void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel );
|
---|
118 | int IsRenderable() {return FALSE;}
|
---|
119 |
|
---|
120 | // Animatable methods
|
---|
121 | CoreExport void FreeCaches();
|
---|
122 | void GetClassName(TSTR& s) {s = GetObjectName();}
|
---|
123 | int NumSubs() { return 1; }
|
---|
124 | Animatable* SubAnim(int i) { return pblock; }
|
---|
125 | CoreExport TSTR SubAnimName(int i);
|
---|
126 |
|
---|
127 | // From ref
|
---|
128 | int NumRefs() {return 1;}
|
---|
129 | RefTargetHandle GetReference(int i) {return pblock;}
|
---|
130 | void SetReference(int i, RefTargetHandle rtarg) {pblock=(IParamBlock*)rtarg;}
|
---|
131 | CoreExport RefResult NotifyRefChanged(Interval changeInt,RefTargetHandle hTarget,
|
---|
132 | PartID& partID, RefMessage message);
|
---|
133 |
|
---|
134 |
|
---|
135 | // --- These must be implemented by the derived class ----------------
|
---|
136 | virtual void BuildMesh(TimeValue t)=0;
|
---|
137 | virtual BOOL OKtoDisplay(TimeValue t) {return TRUE;}
|
---|
138 | virtual void InvalidateUI() {}
|
---|
139 | virtual ParamDimension *GetParameterDim(int pbIndex) {return defaultDim;}
|
---|
140 | virtual TSTR GetParameterName(int pbIndex) {return TSTR(_T("Parameter"));}
|
---|
141 | };
|
---|
142 |
|
---|
143 |
|
---|
144 | class SimpleParticle : public ParticleObject {
|
---|
145 | public:
|
---|
146 | IParamBlock *pblock;
|
---|
147 | ParticleSys parts;
|
---|
148 | TimeValue tvalid;
|
---|
149 | BOOL valid;
|
---|
150 | Tab<ForceField*> fields;
|
---|
151 | Tab<CollisionObject*> cobjs;
|
---|
152 | Mesh mesh;
|
---|
153 | Interval mvalid;
|
---|
154 |
|
---|
155 | CoreExport static SimpleParticle *editOb;
|
---|
156 | CoreExport static IObjParam *ip;
|
---|
157 |
|
---|
158 | CoreExport SimpleParticle();
|
---|
159 | CoreExport ~SimpleParticle();
|
---|
160 |
|
---|
161 | CoreExport void Update(TimeValue t,INode *node=NULL);
|
---|
162 | CoreExport void UpdateMesh(TimeValue t);
|
---|
163 | CoreExport void GetBBox(TimeValue t, Matrix3& tm, Box3& box);
|
---|
164 | void MeshInvalid() {mvalid.SetEmpty();}
|
---|
165 | void ParticleInvalid() {valid=FALSE;}
|
---|
166 |
|
---|
167 | // From BaseObject
|
---|
168 | CoreExport void BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev);
|
---|
169 | CoreExport void EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
|
---|
170 | CoreExport int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
|
---|
171 | CoreExport int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
|
---|
172 | CoreExport IParamArray *GetParamBlock();
|
---|
173 | CoreExport int GetParamBlockIndex(int id);
|
---|
174 |
|
---|
175 | // From Object
|
---|
176 | int DoOwnSelectHilite() {return TRUE;}
|
---|
177 | CoreExport ObjectState Eval(TimeValue time);
|
---|
178 | void InitNodeName(TSTR& s) {s = GetObjectName();}
|
---|
179 | CoreExport Interval ObjectValidity(TimeValue t);
|
---|
180 | CoreExport int CanConvertToType(Class_ID obtype);
|
---|
181 | CoreExport Object* ConvertToType(TimeValue t, Class_ID obtype);
|
---|
182 | CoreExport Object *MakeShallowCopy(ChannelMask channels);
|
---|
183 | void WSStateInvalidate() {valid = FALSE;}
|
---|
184 | BOOL IsWorldSpaceObject() {return TRUE;}
|
---|
185 |
|
---|
186 | // From GeomObject
|
---|
187 | CoreExport void GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box );
|
---|
188 | CoreExport void GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box );
|
---|
189 | CoreExport void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel );
|
---|
190 |
|
---|
191 | // From ParticleObject
|
---|
192 | CoreExport void ApplyForceField(ForceField *ff);
|
---|
193 | CoreExport BOOL ApplyCollisionObject(CollisionObject *co);
|
---|
194 |
|
---|
195 | // Animatable methods
|
---|
196 | void GetClassName(TSTR& s) {s = GetObjectName();}
|
---|
197 | int NumSubs() {return 1;}
|
---|
198 | Animatable* SubAnim(int i) { return pblock; }
|
---|
199 | CoreExport TSTR SubAnimName(int i);
|
---|
200 | CoreExport void* GetInterface(ULONG id);
|
---|
201 |
|
---|
202 | // From ref
|
---|
203 | int NumRefs() {return 1;}
|
---|
204 | RefTargetHandle GetReference(int i) {return pblock;}
|
---|
205 | void SetReference(int i, RefTargetHandle rtarg) {pblock=(IParamBlock*)rtarg;}
|
---|
206 | CoreExport RefResult NotifyRefChanged(Interval changeInt,RefTargetHandle hTarget,
|
---|
207 | PartID& partID, RefMessage message);
|
---|
208 |
|
---|
209 |
|
---|
210 | // --- These must be implemented by the derived class ----------------
|
---|
211 | virtual void UpdateParticles(TimeValue t,INode *node)=0;
|
---|
212 | virtual void BuildEmitter(TimeValue t, Mesh& amesh)=0;
|
---|
213 | virtual Interval GetValidity(TimeValue t)=0;
|
---|
214 | virtual MarkerType GetMarkerType() {return POINT_MRKR;}
|
---|
215 | virtual BOOL OKtoDisplay(TimeValue t) {return TRUE;}
|
---|
216 | virtual BOOL EmitterVisible() {return TRUE;}
|
---|
217 | virtual void InvalidateUI() {}
|
---|
218 | virtual ParamDimension *GetParameterDim(int pbIndex) {return defaultDim;}
|
---|
219 | virtual TSTR GetParameterName(int pbIndex) {return TSTR(_T("Parameter"));}
|
---|
220 | };
|
---|
221 |
|
---|
222 | class GenBoxObject: public SimpleObject {
|
---|
223 | public:
|
---|
224 | virtual void SetParams(float width, float height, float length, int wsegs=1,int lsegs=1,
|
---|
225 | int hsegs=1, BOOL genUV=TRUE)=0;
|
---|
226 | };
|
---|
227 |
|
---|
228 | class GenCylinder: public SimpleObject {
|
---|
229 | public:
|
---|
230 | virtual void SetParams(float rad, float height, int segs, int sides, int capsegs=1, BOOL smooth=TRUE,
|
---|
231 | BOOL genUV=TRUE, BOOL sliceOn= FALSE, float slice1 = 0.0f, float slice2 = 0.0f)=0;
|
---|
232 | };
|
---|
233 |
|
---|
234 | class GenSphere: public SimpleObject {
|
---|
235 | public:
|
---|
236 | virtual void SetParams(float rad, int segs, BOOL smooth=TRUE, BOOL genUV=TRUE,
|
---|
237 | float hemi=0.0f, BOOL squash=FALSE, BOOL recenter=FALSE)=0;
|
---|
238 | };
|
---|
239 |
|
---|
240 |
|
---|
241 | #endif // __SIMPOBJ__
|
---|