SO3Engine
OgreNewt_Debugger.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_DEBUGGER
13#define _INCLUDE_OGRENEWT_DEBUGGER
14
15
17#include "OgreNewt_Tools.h"
18
19
20namespace Ogre
21{
22 class ManualObject;
23}
24
25namespace OgreNewt
26{
27
28
30
34 class _OgreNewtExport Debugger : public Ogre::Node::Listener
35 {
36
37 public:
38 ~Debugger();
39
41 /*
42 \param smgr pointer to your Ogre::SceneManager
43 */
44 void init(Ogre::SceneManager* smgr);
45
47 void deInit();
48
50 virtual void nodeDestroyed(const Ogre::Node *);
51
53
56 void showDebugInformation();
57
59 void hideDebugInformation();
60
62 void setDefaultColor(Ogre::ColourValue col);
63
65 void setMaterialColor(const MaterialID* mat, Ogre::ColourValue col);
66
68 void startRaycastRecording(bool markhitbodies = false);
69
71 bool isRaycastRecording();
72
74 bool isRaycastRecordingHitBodies();
75
77 void clearRaycastsRecorded();
78
80 void stopRaycastRecording();
81
83 void setRaycastRecordingColor(Ogre::ColourValue rayCol, Ogre::ColourValue convexCol, Ogre::ColourValue hitBodyCol, Ogre::ColourValue prefilterDiscardedBodyCol);
84
86 void addRay(const Ogre::Vector3 &startpt, const Ogre::Vector3 &endpt);
87
89 void addConvexRay(const OgreNewt::ConvexCollisionPtr& col, const Ogre::Vector3 &startpt, const Ogre::Quaternion &colori, const Ogre::Vector3 &endpt);
90
92 void addDiscardedBody(const OgreNewt::Body* body);
93
95 void addHitBody(const OgreNewt::Body* body);
96
97 // utility function to build a visual wire from shape for a collision
98 void buildDebugObjectFromCollision(Ogre::ManualObject* object, Ogre::ColourValue colour, const NewtonCollision* shape) const;
99
100 protected:
101 friend class OgreNewt::World;
103 Debugger(const OgreNewt::World* world);
104
106 Ogre::SceneManager* m_sceneManager;
107 Ogre::SceneNode* m_debugnode;
108 typedef std::map<int, Ogre::ColourValue> MaterialIdColorMap;
110 Ogre::ColourValue m_defaultcolor;
111
112 // raycast-debugging
113 Ogre::SceneNode* m_raycastsnode;
115 Ogre::ColourValue m_raycol, m_convexcol, m_hitbodycol, m_prefilterdiscardedcol;
117
119 {
121#ifdef OGRENEWT_NO_COLLISION_SHAREDPTR
122 m_lastcol(NULL),
123#endif
124 m_node(NULL), m_lines(NULL), m_text(NULL), m_updated(false) {}
126 Ogre::Vector3 m_scale;
127 Ogre::SceneNode* m_node;
128 Ogre::ManualObject* m_lines;
131 };
132 typedef std::map<OgreNewt::Body*, BodyDebugData> BodyDebugDataMap;
134
136 void processBody(Body* body);
137
139 void processJoint(Joint* joint);
140
142 void clearBodyDebugDataCache();
143
144 typedef std::list<Ogre::ManualObject*> ManualObjectList;
146
147
148 private:
150 Debugger() {}
151
153 Debugger(const Debugger&) {}
154
156 const Debugger& operator=(const Debugger& d) { return d; } // actually this implementation must *never* be used!
157
158 static void _CDECL newtonPerPoly( void* userData, int vertexCount, const float* faceVertec, int id );
159
160 static void _CDECL newtonprocessJoints(const NewtonJoint* joint, void* userData);
161 };
162
163} // end namespace OgreNewt
164
165
166#endif // _INCLUDE_OGRENEWT_DEBUGGER
167
main class for all Rigid Bodies in the system.
represents a shape for collision detection
represents a collision shape that is explicitly convex.
For viewing the Newton rigid bodies visually.
MaterialIdColorMap m_materialcolors
Ogre::SceneNode * m_debugnode
BodyDebugDataMap m_cachemap
Ogre::ColourValue m_defaultcolor
Ogre::SceneNode * m_raycastsnode
const OgreNewt::World * m_world
ManualObjectList mRecordedRaycastObjects
std::map< OgreNewt::Body *, BodyDebugData > BodyDebugDataMap
std::map< int, Ogre::ColourValue > MaterialIdColorMap
Ogre::ColourValue m_convexcol
std::list< Ogre::ManualObject * > ManualObjectList
Ogre::SceneManager * m_sceneManager
base class for all joints.
represents a material
represents a physics world.
OgreNewt::OgreAddons::MovableText * m_text