home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / game / AF.h < prev    next >
C/C++ Source or Header  |  2005-11-14  |  4KB  |  98 lines

  1.  
  2. #ifndef __GAME_AF_H__
  3. #define __GAME_AF_H__
  4.  
  5.  
  6. /*
  7. ===============================================================================
  8.  
  9.   Articulated figure controller.
  10.  
  11. ===============================================================================
  12. */
  13.  
  14. typedef struct jointConversion_s {
  15.     int                        bodyId;                // id of the body
  16.     jointHandle_t            jointHandle;        // handle of joint this body modifies
  17.     AFJointModType_t        jointMod;            // modify joint axis, origin or both
  18.     idVec3                    jointBodyOrigin;    // origin of body relative to joint
  19.     idMat3                    jointBodyAxis;        // axis of body relative to joint
  20. } jointConversion_t;
  21.  
  22. typedef struct afTouch_s {
  23.     idEntity *                touchedEnt;
  24.     idClipModel *            touchedClipModel;
  25.     idAFBody *                touchedByBody;
  26. } afTouch_t;
  27.  
  28. class idAF {
  29. public:
  30.                             idAF( void );
  31.                             ~idAF( void );
  32.  
  33.     void                    Save( idSaveGame *savefile ) const;
  34.     void                    Restore( idRestoreGame *savefile );
  35.  
  36.     void                    SetAnimator( idAnimator *a ) { animator = a; }
  37. // RAVEN BEGIN
  38. // ddynerman: purge constraints/joints before loading a new one
  39.     bool                    Load( idEntity *ent, const char *fileName, bool purgeAF = false );
  40. // RAVEN END
  41.     bool                    IsLoaded( void ) const { return isLoaded && self != NULL; }
  42.     const char *            GetName( void ) const { return name.c_str(); }
  43.     void                    SetupPose( idEntity *ent, int time );
  44.     void                    ChangePose( idEntity *ent, int time );
  45.     int                        EntitiesTouchingAF( afTouch_t touchList[ MAX_GENTITIES ] ) const;
  46.     void                    Start( void );
  47.     void                    StartFromCurrentPose( int inheritVelocityTime );
  48.     void                    Stop( void );
  49.     void                    Rest( void );
  50.     bool                    IsActive( void ) const { return isActive; }
  51.     void                    SetConstraintPosition( const char *name, const idVec3 &pos );
  52.  
  53.     idPhysics_AF *            GetPhysics( void ) { return &physicsObj; }
  54.     const idPhysics_AF *    GetPhysics( void ) const { return &physicsObj; }
  55.     idBounds                GetBounds( void ) const;
  56.     bool                    UpdateAnimation( void );
  57.  
  58.     void                    GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis ) const;
  59.     void                    GetImpactInfo( idEntity *ent, int id, const idVec3 &point, impactInfo_t *info );
  60.     void                    ApplyImpulse( idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse );
  61.     void                    AddForce( idEntity *ent, int id, const idVec3 &point, const idVec3 &force );
  62.     int                        BodyForClipModelId( int id ) const;
  63.  
  64.     void                    SaveState( idDict &args ) const;
  65.     void                    LoadState( const idDict &args );
  66.  
  67.     void                    AddBindConstraints( void );
  68.     void                    RemoveBindConstraints( void );
  69.  
  70.     idPhysics_AF            physicsObj;            // articulated figure physics
  71.     bool                    TestSolid( void ) const;
  72.  
  73. protected:
  74.     idStr                    name;                // name of the loaded .af file
  75.     idEntity *                self;                // entity using the animated model
  76.     idAnimator *            animator;            // animator on entity
  77.     int                        modifiedAnim;        // anim to modify
  78.     idVec3                    baseOrigin;            // offset of base body relative to skeletal model origin
  79.     idMat3                    baseAxis;            // axis of base body relative to skeletal model origin
  80.     idList<jointConversion_t>jointMods;            // list with transforms from skeletal model joints to articulated figure bodies
  81.     idList<int>                jointBody;            // table to find the nearest articulated figure body for a joint of the skeletal model
  82.     int                        poseTime;            // last time the articulated figure was transformed to reflect the current animation pose
  83.     int                        restStartTime;        // time the articulated figure came to rest
  84.     bool                    isLoaded;            // true when the articulated figure is properly loaded
  85.     bool                    isActive;            // true if the articulated figure physics is active
  86.     bool                    hasBindConstraints;    // true if the bind constraints have been added
  87.  
  88. protected:
  89.     void                    SetBase( idAFBody *body, const idJointMat *joints );
  90.     void                    AddBody( idAFBody *body, const idJointMat *joints, const char *jointName, const AFJointModType_t mod );
  91.  
  92.     bool                    LoadBody( const idDeclAF_Body *fb, const idJointMat *joints );
  93.     bool                    LoadConstraint( const idDeclAF_Constraint *fc );
  94.  
  95. };
  96.  
  97. #endif /* !__GAME_AF_H__ */
  98.