20 #ifndef HEADER_MOVEABLE_HPP
21 #define HEADER_MOVEABLE_HPP
25 namespace scene {
class IMesh;
class IMeshSceneNode;
class ISceneNode; }
28 #include "btBulletDynamicsCommon.h"
31 #include "physics/kart_motion_state.hpp"
32 #include "physics/user_pointer.hpp"
33 #include "utils/no_copy.hpp"
34 #include "utils/vec3.hpp"
59 scene::ISceneNode *m_node;
60 std::unique_ptr<btRigidBody> m_body;
61 std::unique_ptr<KartMotionState> m_motion_state;
63 void updateSmoothedGraphics(
float dt);
65 virtual void updateGraphics(
const Vec3& off_xyz =
Vec3(0.0f, 0.0f, 0.0f),
66 const btQuaternion& off_rotation =
67 btQuaternion(0.0f, 0.0f, 0.0f, 1.0f));
75 void setNode(scene::ISceneNode *n);
76 virtual const btVector3
77 &
getVelocity()
const {
return m_body->getLinearVelocity();}
79 &getVelocityLC()
const {
return m_velocityLC; }
80 virtual void setVelocity(
const btVector3& v) {m_body->setLinearVelocity(v); }
81 const Vec3& getXYZ()
const {
return (
Vec3&)m_transform.getOrigin();}
89 getRotation()
const {
return m_transform.getRotation(); }
93 virtual void flyDown();
94 virtual void stopFlying();
99 m_transform.setOrigin(a);
101 m_motion_state->setWorldTransform(m_transform);
107 m_transform.setBasis(m);
109 m_motion_state->setWorldTransform(m_transform);
115 m_transform.setRotation(q);
117 m_motion_state->setWorldTransform(m_transform);
120 virtual void reset();
121 virtual void update(
int ticks) ;
122 btRigidBody *getBody()
const {
return m_body.get(); }
123 void createBody(
float mass, btTransform& trans,
124 btCollisionShape *shape,
127 &getTrans()
const {
return m_transform;}
128 void setTrans(
const btTransform& t);
129 void updatePosition();
137 void prepareSmoothing()
139 SmoothNetworkBody::prepareSmoothing(m_transform,
getVelocity());
142 void checkSmoothing()
147 const btTransform &getSmoothedTrans()
const
148 {
return SmoothNetworkBody::getSmoothedTrans(); }
150 const Vec3& getSmoothedXYZ()
const
151 {
return (
Vec3&)SmoothNetworkBody::getSmoothedTrans().getOrigin(); }
153 virtual const std::string& getIdent()
const
155 static std::string unused(
"unused");
Definition: material.hpp:48
Definition: moveable.hpp:46
float getHeading() const
Returns the heading between -pi and pi.
Definition: moveable.hpp:83
float m_pitch
The pitch between -90 and 90 degrees.
Definition: moveable.hpp:52
scene::ISceneNode * getNode() const
Returns the scene node of this moveable.
Definition: moveable.hpp:74
float m_heading
The 'real' heading between -180 to 180 degrees.
Definition: moveable.hpp:50
float getRoll() const
Returns the roll of the kart between -pi and pi.
Definition: moveable.hpp:87
virtual void updateGraphics(float dt)=0
Called once per rendered frame.
Vec3 m_velocityLC
Velocity in kart coordinates.
Definition: moveable.hpp:48
void setRotation(const btQuaternion &q)
Sets the rotation of the physical body this moveable.
Definition: moveable.hpp:113
virtual void setXYZ(const Vec3 &a)
Sets the XYZ coordinates of the moveable.
Definition: moveable.hpp:97
btTransform m_transform
The bullet transform of this rigid body.
Definition: moveable.hpp:57
float getPitch() const
Returns the pitch of the kart, restricted to between -pi/2 and pi/2.
Definition: moveable.hpp:85
float m_roll
The roll between -180 and 180 degrees.
Definition: moveable.hpp:54
void setRotation(const btMatrix3x3 &m)
Sets the rotation of the physical body this moveable.
Definition: moveable.hpp:105
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Definition: smooth_network_body.hpp:39
void checkSmoothing(const btTransform ¤t_transform, const Vec3 ¤t_velocity)
Adds a new error between graphical and physical position/rotation.
Definition: smooth_network_body.cpp:57
A UserPointer is stored as a user pointer in all bullet bodies.
Definition: user_pointer.hpp:36
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
void setVelocity(int idKart, SimpleVec3 *position)
Sets the kart's velocity to the specified value.
Definition: script_kart.cpp:118
SimpleVec3 getVelocity(int idKart)
Gets the kart's velocity.
Definition: script_kart.cpp:129
This class help to smooth the graphicial transformation of network controlled object....