simpobj.h 9.5 KB

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