SO3Engine
OgreNewt_RayCastVehicle.h
Go to the documentation of this file.
1/*
2 OgreNewt Library
3
4 Ogre implementation of Newton Game Dynamics SDK
5
6 OgreNewt basically has no license, you may use any or all of the library however you desire... I hope it can help you in any way.
7
8 by Walaber
9 some changes by melven
10
11*/
12#ifndef _INCLUDE_OGRENEWT_RAYCASTVEHICLE
13#define _INCLUDE_OGRENEWT_RAYCASTVEHICLE
14
15#include <CustomDGRayCastCar.h>
17#include "OgreNewt_Joint.h"
18
19
20namespace OgreNewt
21{
22 class RaycastVehicle: public CustomDGRayCastCar
23 {
24 class Tire
25 {
26 public:
28 /*
29 this is the all-important constructor.
30 \param RaycastVehicle the parent vehicle to which you want to add this tire.
31 \param ogre node
32 \param susShock spring damper coefficient
33 \param susSpring spring strength
34 \param susLength spring length
35 \param colID collision ID used to determine collision in material callbacks.
36 */
37 Tire(RaycastVehicle* vehicle, Ogre::Node* node, const bool steer, const bool driving, const int id);
38
40 virtual ~Tire();
41 bool isSteer(){return m_steer;}
42 bool isDriving(){return m_driving;}
43
45 const int getId() const {return m_tireId;}
46
47 const Ogre::Node* getNode() const {return m_node;}
48
50 RaycastVehicle* getVehicle() const {return m_vehicle;}
51
52 void getTireMatrix(dMatrix &matrix);
53
54 void updateNodePosition();
55
56 void showDebug(Ogre::SceneNode* debugRootNode);
57
58 protected:
59 RaycastVehicle* m_vehicle;
60 int m_tireId;
61 Ogre::Node* m_node;
62 bool m_steer;
63 bool m_driving;
64
65 private:
67 struct DebugInfo
68 {
69 Ogre::SceneNode* m_node;
70 Ogre::ManualObject* m_visualDebug;
71 };
72
73 DebugInfo m_debug;
74 };
75
76 private:
77 std::vector<Tire*> m_lTires;
78 OgreNewt::Body* m_body;
79
80 void setTireTransformCallback(OgreNewt::Body* carBody);
81
82 public:
83
85 RaycastVehicle(const dMatrix carMatrix, OgreNewt::Body* carBody);
86
88 virtual ~RaycastVehicle();
89
91 void ApplyTorque(dFloat torque);
92 void ApplySteering(dFloat angle);
93 void ApplyBrake(dFloat brakeTorque);
94
95 void getTireMatrix(unsigned int index, dMatrix &outMatrix);
96 bool getTireOnAir(unsigned int index);
97 Ogre::Real getTireAngularVelocity(unsigned int index);
98 int getTireIndexByNode(Ogre::Node* node);
99
100 void addTire(Ogre::Node* node, const Ogre::Real mass, const Ogre::Real radius, const Ogre::Real width, const Ogre::Real friction, const Ogre::Real susLength, const Ogre::Real susSpring, const Ogre::Real susShock, const bool steer, const bool driving);
101
102 RaycastVehicle::Tire* getTire(unsigned int index);
103
105
109 void showDebugData(Ogre::SceneNode* debugRootNode);
110
111 /*virtual void SubmitConstraints(dFloat timestep, int threadIndex);
112 virtual void GetInfo(NewtonJointRecord* info) const;
113 */
114 };
115} // end NAMESPACE OgreNewt
116
117#endif
main class for all Rigid Bodies in the system.
RaycastVehicle::Tire * getTire(unsigned int index)
void getTireMatrix(unsigned int index, dMatrix &outMatrix)
void addTire(Ogre::Node *node, const Ogre::Real mass, const Ogre::Real radius, const Ogre::Real width, const Ogre::Real friction, const Ogre::Real susLength, const Ogre::Real susSpring, const Ogre::Real susShock, const bool steer, const bool driving)
Ogre::Real getTireAngularVelocity(unsigned int index)
void ApplyBrake(dFloat brakeTorque)
int getTireIndexByNode(Ogre::Node *node)
bool getTireOnAir(unsigned int index)
void showDebugData(Ogre::SceneNode *debugRootNode)
show joint visual debugging data