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);
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();}
80 virtual void setVelocity(
const btVector3& v) {m_body->setLinearVelocity(v); }
89 getRotation()
const {
return m_transform.getRotation(); }
93 virtual void flyDown();
94 virtual void stopFlying();
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,
128 void setTrans(
const btTransform& t);
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
void createBody(float mass, btTransform &trans, btCollisionShape *shape, float restitution)
Creates the bullet rigid body for this moveable.
Definition: moveable.cpp:184
float getHeading() const
Returns the heading between -pi and pi.
Definition: moveable.hpp:83
virtual void flyUp()
Enter flying mode.
Definition: moveable.cpp:130
float m_pitch
The pitch between -90 and 90 degrees.
Definition: moveable.hpp:52
void updatePosition()
Updates the current position and rotation.
Definition: moveable.cpp:165
float m_heading
The 'real' heading between -180 to 180 degrees.
Definition: moveable.hpp:50
scene::ISceneNode * getNode() const
Returns the scene node of this moveable.
Definition: moveable.hpp:74
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.
virtual void updateGraphics(const Vec3 &off_xyz=Vec3(0.0f, 0.0f, 0.0f), const btQuaternion &off_rotation=btQuaternion(0.0f, 0.0f, 0.0f, 1.0f))
Updates the graphics model.
Definition: moveable.cpp:83
Vec3 m_velocityLC
Velocity in kart coordinates.
Definition: moveable.hpp:48
virtual void update(int ticks)
Updates the current position and rotation from the corresponding physics body, and then calls updateG...
Definition: moveable.cpp:153
void setRotation(const btQuaternion &q)
Sets the rotation of the physical body this moveable.
Definition: moveable.hpp:113
void setTrans(const btTransform &t)
Places this moveable at a certain location and stores this transform in this Moveable,...
Definition: moveable.cpp:221
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
virtual void reset()
The reset position must be set before calling reset.
Definition: moveable.cpp:104
void setRotation(const btMatrix3x3 &m)
Sets the rotation of the physical body this moveable.
Definition: moveable.hpp:105
void setNode(scene::ISceneNode *n)
Sets the mesh for this model.
Definition: moveable.cpp:51
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
This class help to smooth the graphicial transformation of network controlled object....