2021-01-24 22:55:36 -06:00
|
|
|
#ifndef RIGIDBODY_H
|
|
|
|
#define RIGIDBODY_H
|
|
|
|
|
|
|
|
#include <btBulletDynamicsCommon.h>
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
#include "Spatial.h"
|
2021-01-25 15:17:32 -06:00
|
|
|
#include "CollisionShape.h"
|
2021-01-24 22:55:36 -06:00
|
|
|
|
|
|
|
class Rigidbody : public Spatial {
|
|
|
|
public:
|
|
|
|
Rigidbody();
|
|
|
|
virtual Rigidbody *Create();
|
|
|
|
virtual Rigidbody *Duplicate();
|
|
|
|
virtual Rigidbody *Instance();
|
2021-01-25 15:17:32 -06:00
|
|
|
|
|
|
|
void SetCollisionShape(CollisionShape collisionShape);
|
2021-01-24 22:55:36 -06:00
|
|
|
cfloat mass = 1.0f;
|
2021-01-25 15:17:32 -06:00
|
|
|
|
|
|
|
void ApplyImpulse(Vector3 impulse);
|
|
|
|
void ApplyForce(Vector3 force);
|
|
|
|
|
|
|
|
void SetCharacter(bool character);
|
2021-01-24 22:55:36 -06:00
|
|
|
private:
|
2021-01-25 15:17:32 -06:00
|
|
|
bool character = false;
|
2021-01-24 22:55:36 -06:00
|
|
|
btRigidBody *btBody;
|
|
|
|
btCollisionShape *collisionShape;
|
|
|
|
friend class World;
|
|
|
|
};
|
|
|
|
|
|
|
|
class RigidbodyMotionState : public btMotionState {
|
|
|
|
public:
|
|
|
|
RigidbodyMotionState(Rigidbody *rigidbody);
|
|
|
|
virtual void getWorldTransform(btTransform &worldTrans) const;
|
|
|
|
virtual void setWorldTransform(const btTransform &worldTrans);
|
|
|
|
private:
|
|
|
|
Rigidbody *rigidbody;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* RIGIDBODY_H */
|