afxConstraint.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  2. // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  3. // Copyright (C) 2015 Faust Logic, Inc.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //
  23. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  24. #ifndef _AFX_CONSTRAINT_H_
  25. #define _AFX_CONSTRAINT_H_
  26. #include "core/util/tVector.h"
  27. #include "T3D/shapeBase.h"
  28. #include "afxEffectDefs.h"
  29. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  30. // afxConstraintDef
  31. class afxEffectBaseData;
  32. struct afxConstraintDef : public afxEffectDefs
  33. {
  34. enum DefType
  35. {
  36. CONS_UNDEFINED,
  37. CONS_PREDEFINED,
  38. CONS_SCENE,
  39. CONS_EFFECT,
  40. CONS_GHOST
  41. };
  42. DefType mDef_type;
  43. StringTableEntry mCons_src_name;
  44. StringTableEntry mCons_node_name;
  45. F32 mHistory_time;
  46. U8 mSample_rate;
  47. bool mRuns_on_server;
  48. bool mRuns_on_client;
  49. bool mPos_at_box_center;
  50. bool mTreat_as_camera;
  51. /*C*/ afxConstraintDef();
  52. bool isDefined();
  53. bool isArbitraryObject();
  54. void reset();
  55. bool parseSpec(const char* spec, bool runs_on_server, bool runs_on_client);
  56. static void gather_cons_defs(Vector<afxConstraintDef>& defs, Vector<afxEffectBaseData*>& fx);
  57. static StringTableEntry SCENE_CONS_KEY;
  58. static StringTableEntry EFFECT_CONS_KEY;
  59. static StringTableEntry GHOST_CONS_KEY;
  60. };
  61. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  62. // afxConstraint
  63. // Abstract base-class for a simple constraint mechanism used to constrain
  64. // special effects to spell related objects such as the spellcaster, target,
  65. // projectile, or impact location.
  66. //
  67. // note -- the direction vectors don't really fit... should probably consider separate
  68. // constraint types for position, orientation, and possibly a look-at constraint.
  69. //
  70. class SceneObject;
  71. class afxConstraintMgr;
  72. class afxConstraint : public SimObject, public afxEffectDefs
  73. {
  74. friend class afxConstraintMgr;
  75. typedef SimObject Parent;
  76. protected:
  77. afxConstraintMgr* mMgr;
  78. afxConstraintDef mCons_def;
  79. bool mIs_defined;
  80. bool mIs_valid;
  81. Point3F mLast_pos;
  82. MatrixF mLast_xfm;
  83. F32 mHistory_time;
  84. bool mIs_alive;
  85. bool mGone_missing;
  86. U32 mChange_code;
  87. public:
  88. /*C*/ afxConstraint(afxConstraintMgr*);
  89. virtual ~afxConstraint();
  90. virtual bool getPosition(Point3F& pos, F32 hist=0.0f)
  91. { pos = mLast_pos; return mIs_valid; }
  92. virtual bool getTransform(MatrixF& xfm, F32 hist=0.0f)
  93. { xfm = mLast_xfm; return mIs_valid;}
  94. virtual bool getAltitudes(F32& terrain_alt, F32& interior_alt) { return false; }
  95. virtual bool isDefined() { return mIs_defined; }
  96. virtual bool isValid() { return mIs_valid; }
  97. virtual U32 getChangeCode() { return mChange_code; }
  98. virtual U32 setAnimClip(const char* clip, F32 pos, F32 rate, F32 trans, bool is_death_anim)
  99. { return 0; };
  100. virtual void resetAnimation(U32 tag) { };
  101. virtual U32 lockAnimation() { return 0; }
  102. virtual void unlockAnimation(U32 tag) { }
  103. virtual F32 getAnimClipDuration(const char* clip) { return 0.0f; }
  104. virtual S32 getDamageState() { return -1; }
  105. virtual void setLivingState(bool state) { mIs_alive = state; };
  106. virtual bool getLivingState() { return mIs_alive; };
  107. virtual void sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos)=0;
  108. virtual SceneObject* getSceneObject()=0;
  109. virtual void restoreObject(SceneObject*)=0;
  110. virtual U16 getScopeId()=0;
  111. virtual U32 getTriggers()=0;
  112. virtual void set_scope_id(U16 scope_id) { }
  113. virtual void unset() { }
  114. };
  115. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  116. // afxConstraintMgr
  117. class ShapeBase;
  118. class afxEffectWrapper;
  119. class afxShapeConstraint;
  120. class afxObjectConstraint;
  121. class BitStream;
  122. class NetConnection;
  123. struct afxConstraintID
  124. {
  125. S16 index;
  126. S16 sub_index;
  127. afxConstraintID() { index = -1; sub_index = 0; }
  128. afxConstraintID(S16 idx, S16 sub=0) { index = idx; sub_index = sub; }
  129. bool undefined() const { return (index < 0); }
  130. };
  131. typedef Vector<afxConstraint*> afxConstraintList;
  132. class afxConstraintMgr : public afxEffectDefs
  133. {
  134. typedef SimObject Parent;
  135. struct preDef
  136. {
  137. StringTableEntry name;
  138. U32 type;
  139. };
  140. Vector<afxConstraintList*> mConstraints_v;
  141. Vector<StringTableEntry> mNames_on_server;
  142. Vector<S32> mGhost_ids;
  143. Vector<preDef> mPredefs;
  144. U32 mStartTime;
  145. bool mOn_server;
  146. bool mInitialized;
  147. F32 mScoping_dist_sq;
  148. SceneObject* find_object_from_name(StringTableEntry);
  149. S32 find_cons_idx_from_name(StringTableEntry);
  150. S32 find_effect_cons_idx_from_name(StringTableEntry);
  151. void create_constraint(const afxConstraintDef&);
  152. void set_ref_shape(afxConstraintID which_id, ShapeBase*);
  153. void set_ref_shape(afxConstraintID which_id, U16 scope_id);
  154. public:
  155. /*C*/ afxConstraintMgr();
  156. /*D*/ ~afxConstraintMgr();
  157. void defineConstraint(U32 type, StringTableEntry);
  158. afxConstraintID setReferencePoint(StringTableEntry which, Point3F point);
  159. afxConstraintID setReferencePoint(StringTableEntry which, Point3F point, Point3F vector);
  160. afxConstraintID setReferenceTransform(StringTableEntry which, MatrixF& xfm);
  161. afxConstraintID setReferenceObject(StringTableEntry which, SceneObject*);
  162. afxConstraintID setReferenceObjectByScopeId(StringTableEntry which, U16 scope_id, bool is_shape);
  163. afxConstraintID setReferenceEffect(StringTableEntry which, afxEffectWrapper*);
  164. afxConstraintID createReferenceEffect(StringTableEntry which, afxEffectWrapper*);
  165. void setReferencePoint(afxConstraintID which_id, Point3F point);
  166. void setReferencePoint(afxConstraintID which_id, Point3F point, Point3F vector);
  167. void setReferenceTransform(afxConstraintID which_id, MatrixF& xfm);
  168. void setReferenceObject(afxConstraintID which_id, SceneObject*);
  169. void setReferenceObjectByScopeId(afxConstraintID which_id, U16 scope_id, bool is_shape);
  170. void setReferenceEffect(afxConstraintID which_id, afxEffectWrapper*);
  171. void invalidateReference(afxConstraintID which_id);
  172. afxConstraintID getConstraintId(const afxConstraintDef&);
  173. afxConstraint* getConstraint(afxConstraintID cons_id);
  174. void sample(F32 dt, U32 now, const Point3F* cam_pos=0);
  175. void setStartTime(U32 timestamp) { mStartTime = timestamp; }
  176. void initConstraintDefs(Vector<afxConstraintDef>&, bool on_server, F32 scoping_dist=-1.0f);
  177. void packConstraintNames(NetConnection* conn, BitStream* stream);
  178. void unpackConstraintNames(BitStream* stream);
  179. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
  180. // scope-tracking
  181. private:
  182. Vector<SceneObject*> scopeable_objs;
  183. Vector<U16> scopeable_ids;
  184. Vector<afxConstraint*>* missing_objs;
  185. Vector<afxConstraint*>* missing_objs2;
  186. Vector<afxConstraint*> missing_objs_a;
  187. Vector<afxConstraint*> missing_objs_b;
  188. public:
  189. void addScopeableObject(SceneObject*);
  190. void removeScopeableObject(SceneObject*);
  191. void clearAllScopeableObjs();
  192. void postMissingConstraintObject(afxConstraint*, bool is_deleting=false);
  193. void restoreScopedObject(SceneObject*, afxChoreographer* ch);
  194. void adjustProcessOrdering(afxChoreographer*);
  195. F32 getScopingDistanceSquared() const { return mScoping_dist_sq; }
  196. };
  197. inline afxConstraintID afxConstraintMgr::setReferencePoint(StringTableEntry which, Point3F point)
  198. {
  199. return setReferencePoint(which, point, Point3F(0,0,1));
  200. }
  201. inline void afxConstraintMgr::setReferencePoint(afxConstraintID which, Point3F point)
  202. {
  203. setReferencePoint(which, point, Point3F(0,0,1));
  204. }
  205. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  206. // afxPointConstraint
  207. // This constrains to a specific 3D position such as an impact location.
  208. //
  209. class afxPointConstraint : public afxConstraint
  210. {
  211. typedef afxConstraint Parent;
  212. protected:
  213. Point3F mPoint;
  214. Point3F mVector;
  215. public:
  216. /*C*/ afxPointConstraint(afxConstraintMgr*);
  217. virtual ~afxPointConstraint();
  218. virtual void set(Point3F point, Point3F vector);
  219. virtual void sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos);
  220. virtual SceneObject* getSceneObject() { return 0; }
  221. virtual void restoreObject(SceneObject*) { }
  222. virtual U16 getScopeId() { return 0; }
  223. virtual U32 getTriggers() { return 0; }
  224. virtual void unset() { set(Point3F::Zero, Point3F(0,0,1)); }
  225. };
  226. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  227. // afxTransformConstraint
  228. // This constrains to a specific 3D transformation.
  229. //
  230. class afxTransformConstraint : public afxConstraint
  231. {
  232. typedef afxConstraint Parent;
  233. protected:
  234. MatrixF mXfm;
  235. public:
  236. /*C*/ afxTransformConstraint(afxConstraintMgr*);
  237. virtual ~afxTransformConstraint();
  238. virtual void set(const MatrixF& xfm);
  239. virtual void sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos);
  240. virtual SceneObject* getSceneObject() { return 0; }
  241. virtual void restoreObject(SceneObject*) { }
  242. virtual U16 getScopeId() { return 0; }
  243. virtual U32 getTriggers() { return 0; }
  244. virtual void unset() { set(MatrixF::Identity); }
  245. };
  246. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  247. // afxShapeConstraint
  248. // This constrains to a hierarchical shape (subclasses of ShapeBase), such as a
  249. // Player or a Vehicle. You can also constrain to named sub-nodes of a shape.
  250. class ShapeBase;
  251. class SceneObject;
  252. class afxShapeConstraint : public afxConstraint
  253. {
  254. friend class afxConstraintMgr;
  255. typedef afxConstraint Parent;
  256. protected:
  257. StringTableEntry mArb_name;
  258. ShapeBase* mShape;
  259. U16 mScope_id;
  260. U32 mClip_tag;
  261. U32 mLock_tag;
  262. public:
  263. /*C*/ afxShapeConstraint(afxConstraintMgr*);
  264. /*C*/ afxShapeConstraint(afxConstraintMgr*, StringTableEntry arb_name);
  265. virtual ~afxShapeConstraint();
  266. virtual void set(ShapeBase* shape);
  267. virtual void set_scope_id(U16 scope_id);
  268. virtual void sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos);
  269. virtual U32 setAnimClip(const char* clip, F32 pos, F32 rate, F32 trans, bool is_death_anim);
  270. virtual void resetAnimation(U32 tag);
  271. virtual U32 lockAnimation();
  272. virtual void unlockAnimation(U32 tag);
  273. virtual F32 getAnimClipDuration(const char* clip);
  274. void remapAnimation(U32 tag, ShapeBase* other_shape);
  275. virtual S32 getDamageState();
  276. virtual SceneObject* getSceneObject() { return mShape; }
  277. virtual void restoreObject(SceneObject*);
  278. virtual U16 getScopeId() { return mScope_id; }
  279. virtual U32 getTriggers();
  280. virtual void onDeleteNotify(SimObject*);
  281. virtual void unset() { set(0); }
  282. };
  283. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  284. // afxShapeNodeConstraint
  285. class afxShapeNodeConstraint : public afxShapeConstraint
  286. {
  287. friend class afxConstraintMgr;
  288. typedef afxShapeConstraint Parent;
  289. protected:
  290. StringTableEntry mArb_node;
  291. S32 mShape_node_ID;
  292. public:
  293. /*C*/ afxShapeNodeConstraint(afxConstraintMgr*);
  294. /*C*/ afxShapeNodeConstraint(afxConstraintMgr*, StringTableEntry arb_name, StringTableEntry arb_node);
  295. virtual void set(ShapeBase* shape);
  296. virtual void set_scope_id(U16 scope_id);
  297. virtual void sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos);
  298. virtual void restoreObject(SceneObject*);
  299. S32 getNodeID() const { return mShape_node_ID; }
  300. virtual void onDeleteNotify(SimObject*);
  301. };
  302. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  303. // afxObjectConstraint
  304. // This constrains to a simple 3D object (subclasses of SceneObject), such as an
  305. // afxMagicMissile or a Projectile. You cannot constrain to sub-nodes with an
  306. // afxObjectConstraint, use afxShapeConstraint instead.
  307. class SceneObject;
  308. class afxObjectConstraint : public afxConstraint
  309. {
  310. friend class afxConstraintMgr;
  311. typedef afxConstraint Parent;
  312. protected:
  313. StringTableEntry mArb_name;
  314. SceneObject* mObj;
  315. U16 mScope_id;
  316. bool mIs_camera;
  317. public:
  318. afxObjectConstraint(afxConstraintMgr*);
  319. afxObjectConstraint(afxConstraintMgr*, StringTableEntry arb_name);
  320. virtual ~afxObjectConstraint();
  321. virtual void set(SceneObject* obj);
  322. virtual void set_scope_id(U16 scope_id);
  323. virtual void sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos);
  324. virtual SceneObject* getSceneObject() { return mObj; }
  325. virtual void restoreObject(SceneObject*);
  326. virtual U16 getScopeId() { return mScope_id; }
  327. virtual U32 getTriggers();
  328. virtual void onDeleteNotify(SimObject*);
  329. virtual void unset() { set(0); }
  330. };
  331. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  332. // afxEffectConstraint
  333. // This constrains to a hierarchical shape (subclasses of ShapeBase), such as a
  334. // Player or a Vehicle. You can also constrain to named sub-nodes of a shape.
  335. class afxEffectWrapper;
  336. class afxEffectConstraint : public afxConstraint
  337. {
  338. friend class afxConstraintMgr;
  339. typedef afxConstraint Parent;
  340. protected:
  341. StringTableEntry mEffect_name;
  342. afxEffectWrapper* mEffect;
  343. U32 mClip_tag;
  344. bool mIs_death_clip;
  345. U32 mLock_tag;
  346. public:
  347. /*C*/ afxEffectConstraint(afxConstraintMgr*);
  348. /*C*/ afxEffectConstraint(afxConstraintMgr*, StringTableEntry effect_name);
  349. virtual ~afxEffectConstraint();
  350. virtual bool getPosition(Point3F& pos, F32 hist=0.0f);
  351. virtual bool getTransform(MatrixF& xfm, F32 hist=0.0f);
  352. virtual bool getAltitudes(F32& terrain_alt, F32& interior_alt);
  353. virtual void set(afxEffectWrapper* effect);
  354. virtual void sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos) { }
  355. virtual U32 setAnimClip(const char* clip, F32 pos, F32 rate, F32 trans, bool is_death_anim);
  356. virtual void resetAnimation(U32 tag);
  357. virtual F32 getAnimClipDuration(const char* clip);
  358. virtual SceneObject* getSceneObject() { return 0; }
  359. virtual void restoreObject(SceneObject*) { }
  360. virtual U16 getScopeId() { return 0; }
  361. virtual U32 getTriggers();
  362. virtual void unset() { set(0); }
  363. };
  364. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  365. // afxEffectNodeConstraint
  366. class afxEffectNodeConstraint : public afxEffectConstraint
  367. {
  368. friend class afxConstraintMgr;
  369. typedef afxEffectConstraint Parent;
  370. protected:
  371. StringTableEntry mEffect_node;
  372. S32 mEffect_node_ID;
  373. public:
  374. /*C*/ afxEffectNodeConstraint(afxConstraintMgr*);
  375. /*C*/ afxEffectNodeConstraint(afxConstraintMgr*, StringTableEntry name, StringTableEntry node);
  376. virtual bool getPosition(Point3F& pos, F32 hist=0.0f);
  377. virtual bool getTransform(MatrixF& xfm, F32 hist=0.0f);
  378. virtual void set(afxEffectWrapper* effect);
  379. S32 getNodeID() const { return mEffect_node_ID; }
  380. };
  381. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  382. // afxSampleBuffer
  383. class afxSampleBuffer
  384. {
  385. protected:
  386. U32 mBuffer_sz;
  387. U32 mBuffer_ms;
  388. U32 mMS_per_sample;
  389. U32 mElapsed_ms;
  390. U32 mLast_sample_ms;
  391. U32 mNext_sample_num;
  392. U32 mNum_samples;
  393. virtual void recSample(U32 idx, void* data) = 0;
  394. bool compute_idx_from_lag(F32 lag, U32& idx);
  395. bool compute_idx_from_lag(F32 lag, U32& idx1, U32& idx2, F32& t);
  396. public:
  397. /*C*/ afxSampleBuffer();
  398. virtual ~afxSampleBuffer();
  399. virtual void configHistory(F32 hist_len, U8 sample_rate);
  400. void recordSample(F32 dt, U32 elapsed_ms, void* data);
  401. virtual void getSample(F32 lag, void* data, bool& oob) = 0;
  402. };
  403. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  404. // afxSampleXfmBuffer
  405. class afxSampleXfmBuffer : public afxSampleBuffer
  406. {
  407. typedef afxSampleBuffer Parent;
  408. protected:
  409. MatrixF* mXfm_buffer;
  410. virtual void recSample(U32 idx, void* data);
  411. public:
  412. /*C*/ afxSampleXfmBuffer();
  413. virtual ~afxSampleXfmBuffer();
  414. virtual void configHistory(F32 hist_len, U8 sample_rate);
  415. virtual void getSample(F32 lag, void* data, bool& oob);
  416. };
  417. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  418. // afxPointHistConstraint
  419. // This class extends afxPointConstraint to remember its values for a period of time.
  420. class afxPointHistConstraint : public afxPointConstraint
  421. {
  422. friend class afxConstraintMgr;
  423. typedef afxPointConstraint Parent;
  424. protected:
  425. afxSampleBuffer* mSamples;
  426. public:
  427. /*C*/ afxPointHistConstraint(afxConstraintMgr*);
  428. virtual ~afxPointHistConstraint();
  429. virtual void set(Point3F point, Point3F vector);
  430. virtual void sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos);
  431. virtual bool getPosition(Point3F& pos, F32 hist=0.0f);
  432. virtual bool getTransform(MatrixF& xfm, F32 hist=0.0f);
  433. };
  434. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  435. // afxPointHistConstraint
  436. // This class extends afxTransformConstraint to remember its values for a period of time.
  437. class afxTransformHistConstraint : public afxTransformConstraint
  438. {
  439. friend class afxConstraintMgr;
  440. typedef afxTransformConstraint Parent;
  441. protected:
  442. afxSampleBuffer* mSamples;
  443. public:
  444. /*C*/ afxTransformHistConstraint(afxConstraintMgr*);
  445. virtual ~afxTransformHistConstraint();
  446. virtual void set(const MatrixF& xfm);
  447. virtual void sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos);
  448. virtual bool getPosition(Point3F& pos, F32 hist=0.0f);
  449. virtual bool getTransform(MatrixF& xfm, F32 hist=0.0f);
  450. };
  451. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  452. // afxShapeHistConstraint
  453. // This class extends afxShapeConstraint to remember its values for a period of time.
  454. class afxShapeHistConstraint : public afxShapeConstraint
  455. {
  456. friend class afxConstraintMgr;
  457. typedef afxShapeConstraint Parent;
  458. protected:
  459. afxSampleBuffer* mSamples;
  460. public:
  461. /*C*/ afxShapeHistConstraint(afxConstraintMgr*);
  462. /*C*/ afxShapeHistConstraint(afxConstraintMgr*, StringTableEntry arb_name);
  463. virtual ~afxShapeHistConstraint();
  464. virtual void set(ShapeBase* shape);
  465. virtual void set_scope_id(U16 scope_id);
  466. virtual void sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos);
  467. virtual bool getPosition(Point3F& pos, F32 hist=0.0f);
  468. virtual bool getTransform(MatrixF& xfm, F32 hist=0.0f);
  469. virtual void onDeleteNotify(SimObject*);
  470. };
  471. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  472. // afxShapeNodeHistConstraint
  473. // This class extends afxShapeConstraint to remember its values for a period of time.
  474. class afxShapeNodeHistConstraint : public afxShapeNodeConstraint
  475. {
  476. friend class afxConstraintMgr;
  477. typedef afxShapeNodeConstraint Parent;
  478. protected:
  479. afxSampleBuffer* mSamples;
  480. public:
  481. /*C*/ afxShapeNodeHistConstraint(afxConstraintMgr*);
  482. /*C*/ afxShapeNodeHistConstraint(afxConstraintMgr*, StringTableEntry arb_name, StringTableEntry arb_node);
  483. virtual ~afxShapeNodeHistConstraint();
  484. virtual void set(ShapeBase* shape);
  485. virtual void set_scope_id(U16 scope_id);
  486. virtual void sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos);
  487. virtual bool getPosition(Point3F& pos, F32 hist=0.0f);
  488. virtual bool getTransform(MatrixF& xfm, F32 hist=0.0f);
  489. virtual void onDeleteNotify(SimObject*);
  490. };
  491. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  492. // afxObjectHistConstraint
  493. // This class extends afxObjectConstraint to remember its values for a period of time.
  494. class SceneObject;
  495. class afxObjectHistConstraint : public afxObjectConstraint
  496. {
  497. friend class afxConstraintMgr;
  498. typedef afxObjectConstraint Parent;
  499. protected:
  500. afxSampleBuffer* mSamples;
  501. public:
  502. afxObjectHistConstraint(afxConstraintMgr*);
  503. afxObjectHistConstraint(afxConstraintMgr*, StringTableEntry arb_name);
  504. virtual ~afxObjectHistConstraint();
  505. virtual void set(SceneObject* obj);
  506. virtual void set_scope_id(U16 scope_id);
  507. virtual void sample(F32 dt, U32 elapsed_ms, const Point3F* cam_pos);
  508. virtual bool getPosition(Point3F& pos, F32 hist=0.0f);
  509. virtual bool getTransform(MatrixF& xfm, F32 hist=0.0f);
  510. virtual void onDeleteNotify(SimObject*);
  511. };
  512. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  513. #endif // _AFX_CONSTRAINT_H_