1 #pragma once

    2 #include <Ogre.h>

    3 #include "PhysicsData.h"

    4 #include "Component.h"

    5 #include "Event.h"

    6 

    7 #include <Physics/Dynamics/Entity/hkpRigidBody.h>   

    8 #include <Physics/Dynamics/Collide/hkpCollisionListener.h>

    9 

   10 

   11 enum MotionState

   12 {

   13  MOTIONSTATIC= 0,

   14 MOTIONKEYFRAMED= 1,

   15  MOTIONDYNAMIC= 2,

   16 MOTIONPLAYER= 3

   17 };

   18 

   19 class hkPackfileData;

   20 

   21 // Represents the Havok (Body or phantom or charController)

   22 class PhysicsComponent :

   23     public Component , public hkpCollisionListener

   24 {

   25 public:

   26     /**

   27     * Base physics constructor

   28     * @param data the PhysicsData to populate the initial body / col

   29     */

   30     PhysicsComponent(PhysicsData data);

   31 

   32     /**

   33     * Base destructor

   34     */

   35     virtual ~PhysicsComponent(void);

   36 

   37     /**

   38     * initialization function

   39     */

   40     virtual void init();

   41 

   42     /**

   43     * virtual familyID to represent the component family as a key value in a hash

   44     * @return the family ID, MeshComponent

   45     */

   46     virtual const std::string& familyID();

   47 

   48     void handleEvent(Event* event);

   49 

   50     /**

   51     * Get the physics body

   52     * @return the Havok Rigid Body

   53     */

   54     hkpEntity* getBody();

   55 

   56     virtual void preUpdate(float dt);

   57     virtual void postUpdate(float dt);

   58 

   59     // Called after a contact point was added

   60     virtual void contactPointAddedCallback(    hkpContactPointAddedEvent& event );

   61 

   62     virtual void contactPointConfirmedCallback( hkpContactPointConfirmedEvent& event);

   63 

   64         // Called before a contact point gets removed. We do not implement this for this demo.

   65     virtual void contactPointRemovedCallback( hkpContactPointRemovedEvent& event );

   66 

   67         // Called just before the collisionResult is passed to the constraint system (solved).

   68     virtual void contactProcessCallback( hkpContactProcessEvent& event );

   69 

   70     int getMotionType();

   71 

   72     void setMotionType(int motionType);

   73 

   74 private:

   75     //Uncopyable

   76     /**

   77     * Explicit private copy constructor making class uncopyable

   78     */

   79     explicit PhysicsComponent(const PhysicsComponent& co);

   80     PhysicsComponent& operator=(const PhysicsComponent& co);

   81 

   82 protected:

   83     /**

   84     * Base physics constructor

   85     * @see clone()

   86     */

   87     PhysicsComponent();

   88 

   89 

   90     static std::string mFamilyID;

   91     hkpRigidBody* mBody;

   92     //static,dynamic,keyframed

   93     int mMotionType;

   94 

   95     //keyframe stuff

   96     std::vector<PositionChange> mOffsets;

   97     float mMoveSpeed;

   98     float mWaitTime;

   99     float mCurrentWaitTime;

  100     int mCurrentIndex;

  101     bool mLoaded;

  102     bool mOffsetsAdded;

  103 

  104 };

  105 

  106 

  107