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