Project

General

Profile

SO3Engine
OgreNewt_Tools.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_TOOLS
13#define _INCLUDE_OGRENEWT_TOOLS
14
15
17#include "OgreNewt_Collision.h"
18
19namespace OgreNewt
20{
21
22
24 namespace Converters
25 {
27
32 _OgreNewtExport void MatrixToQuatPos( const dFloat* matrix, Ogre::Quaternion& quat, Ogre::Vector3 &pos );
33
35
40 _OgreNewtExport void QuatPosToMatrix( const Ogre::Quaternion& quat, const Ogre::Vector3 &pos, dFloat* matrix );
41
43
47 _OgreNewtExport void MatrixToMatrix4( const dFloat* matrix_in, Ogre::Matrix4& matrix_out );
48
50
54 _OgreNewtExport void Matrix4ToMatrix( const Ogre::Matrix4& matrix_in, dFloat* matrix_out );
55
56 _OgreNewtExport Ogre::Quaternion grammSchmidt( const Ogre::Vector3& pin );
57 }
58
60 namespace CollisionTools
61 {
62
64
73 _OgreNewtExport int CollisionPointDistance( const OgreNewt::World* world, const Ogre::Vector3& globalpt,
74 const OgreNewt::CollisionPtr& col, const Ogre::Quaternion& colorient, const Ogre::Vector3& colpos,
75 Ogre::Vector3& retpt, Ogre::Vector3& retnormal, int threadIndex );
76
77
78
80
92 _OgreNewtExport int CollisionClosestPoint( const OgreNewt::World* world, const OgreNewt::CollisionPtr& colA, const Ogre::Quaternion& colOrientA, const Ogre::Vector3& colPosA,
93 const OgreNewt::CollisionPtr& colB, const Ogre::Quaternion& colOrientB, const Ogre::Vector3& colPosB,
94 Ogre::Vector3& retPosA, Ogre::Vector3& retPosB, Ogre::Vector3& retNorm, int threadIndex );
95
96
98
104 _OgreNewtExport Ogre::AxisAlignedBox CollisionCalculateFittingAABB( const OgreNewt::CollisionPtr& col,
105 const Ogre::Quaternion& orient = Ogre::Quaternion::IDENTITY,
106 const Ogre::Vector3& pos = Ogre::Vector3::ZERO );
107
109 _OgreNewtExport Ogre::Vector3 CollisionSupportVertex( const OgreNewt::CollisionPtr& col, const Ogre::Vector3& dir );
110
111 } // end namespace "CollisionTools"
112
113 namespace Springs
114 {
115
116 _OgreNewtExport Ogre::Real calculateSpringDamperAcceleration( Ogre::Real deltaTime, Ogre::Real spingK,
117 Ogre::Real stretchDistance, Ogre::Real springDamping, Ogre::Real dampVelocity );
118
119 } // end namespace SPRINGS
120
121 namespace OgreAddons
122 {
133 class _OgreNewtExport MovableText : public Ogre::MovableObject, public Ogre::Renderable
134 {
135 /******************************** MovableText data ****************************/
136 public:
137 enum HorizontalAlignment {H_LEFT, H_CENTER};
138 enum VerticalAlignment {V_BELOW, V_ABOVE, V_CENTER};
139
140 protected:
141 Ogre::String mFontName;
142 Ogre::String mType;
143 Ogre::String mName;
144 Ogre::String mCaption;
147
148 Ogre::ColourValue mColor;
149 Ogre::RenderOperation mRenderOp;
150 Ogre::AxisAlignedBox mAABB;
151 Ogre::LightList mLList;
152
153 Ogre::Real mCharHeight;
154 Ogre::Real mSpaceWidth;
155
158 bool mOnTop;
159
161 Ogre::Real mRadius;
162
163 Ogre::Vector3 mGlobalTranslation;
164 Ogre::Vector3 mLocalTranslation;
165
166 Ogre::Camera *mpCam;
167 Ogre::RenderWindow *mpWin;
168 Ogre::FontPtr mpFont;
169 Ogre::MaterialPtr mpMaterial;
170 Ogre::MaterialPtr mpBackgroundMaterial;
171
172 /******************************** public methods ******************************/
173 public:
174 MovableText(const Ogre::String &name, const Ogre::String &caption, const Ogre::String &fontName, Ogre::Real charHeight, const Ogre::ColourValue &color = Ogre::ColourValue::White);
175 virtual ~MovableText();
176
177 // Set settings
178 void setFontName(const Ogre::String &fontName);
179 void setCaption(const Ogre::String &caption);
180 void setColor(const Ogre::ColourValue &color);
181 void setCharacterHeight(Ogre::Real height);
182 void setSpaceWidth(Ogre::Real width);
183 void setTextAlignment(const HorizontalAlignment& horizontalAlignment, const VerticalAlignment& verticalAlignment);
184 void setGlobalTranslation( Ogre::Vector3 trans );
185 void setLocalTranslation( Ogre::Vector3 trans );
186 void showOnTop(bool show=true);
187
188 // Get settings
189 const Ogre::String &getFontName() const {return mFontName;}
190 const Ogre::String &getCaption() const {return mCaption;}
191 const Ogre::ColourValue &getColor() const {return mColor;}
192
193 Ogre::Real getCharacterHeight() const {return mCharHeight;}
194 Ogre::Real getSpaceWidth() const {return mSpaceWidth;}
195 Ogre::Vector3 getGlobalTranslation() const {return mGlobalTranslation;}
196 Ogre::Vector3 getLocalTranslation() const {return mLocalTranslation;}
197 bool getShowOnTop() const {return mOnTop;}
198 Ogre::AxisAlignedBox GetAABB(void) { return mAABB; }
199
200 /******************************** protected methods and overload **************/
201 protected:
202
203 // from MovableText, create the object
204 void _setupGeometry();
205 void _updateColors();
206
207 // from MovableObject
208 void getWorldTransforms(Ogre::Matrix4 *xform) const;
209 Ogre::Real getBoundingRadius(void) const {return mRadius;};
210 Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const {return 0;};
211 void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false);
212 const Ogre::Quaternion &getWorldOrientation(void) const;
213 const Ogre::Vector3 &getWorldPosition(void) const;
214 const Ogre::AxisAlignedBox &getBoundingBox(void) const {return mAABB;};
215 const Ogre::String &getName(void) const {return mName;};
216 const Ogre::String &getMovableType(void) const {static Ogre::String movType = "MovableText"; return movType;};
217
218 void _notifyCurrentCamera(Ogre::Camera *cam);
219 void _updateRenderQueue(Ogre::RenderQueue* queue);
220
221 // from renderable
222 void getRenderOperation(Ogre::RenderOperation &op);
223 const Ogre::MaterialPtr &getMaterial(void) const {assert(mpMaterial); return mpMaterial;};
224 const Ogre::LightList &getLights(void) const {return mLList;};
225 };
226
227 }
228
229} // end NAMESPACE OgreNewt
230
231#endif
232
represents a shape for collision detection
const Ogre::String & getMovableType(void) const
Ogre::AxisAlignedBox GetAABB(void)
Ogre::Real getBoundingRadius(void) const
Ogre::Vector3 getLocalTranslation() const
HorizontalAlignment mHorizontalAlignment
const Ogre::ColourValue & getColor() const
const Ogre::MaterialPtr & getMaterial(void) const
const Ogre::String & getCaption() const
Ogre::Vector3 getGlobalTranslation() const
const Ogre::AxisAlignedBox & getBoundingBox(void) const
const Ogre::String & getName(void) const
const Ogre::LightList & getLights(void) const
const Ogre::String & getFontName() const
Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const
represents a physics world.
_OgreNewtExport Ogre::Vector3 CollisionSupportVertex(const OgreNewt::CollisionPtr &col, const Ogre::Vector3 &dir)
Get a vertex of the collision in the given direction.
_OgreNewtExport Ogre::AxisAlignedBox CollisionCalculateFittingAABB(const OgreNewt::CollisionPtr &col, const Ogre::Quaternion &orient=Ogre::Quaternion::IDENTITY, const Ogre::Vector3 &pos=Ogre::Vector3::ZERO)
calculate the AABB of a collision primitive in an arbitrary orientation
_OgreNewtExport int CollisionClosestPoint(const OgreNewt::World *world, const OgreNewt::CollisionPtr &colA, const Ogre::Quaternion &colOrientA, const Ogre::Vector3 &colPosA, const OgreNewt::CollisionPtr &colB, const Ogre::Quaternion &colOrientB, const Ogre::Vector3 &colPosB, Ogre::Vector3 &retPosA, Ogre::Vector3 &retPosB, Ogre::Vector3 &retNorm, int threadIndex)
find the nearest 2 points between 2 collision shapes.
_OgreNewtExport int CollisionPointDistance(const OgreNewt::World *world, const Ogre::Vector3 &globalpt, const OgreNewt::CollisionPtr &col, const Ogre::Quaternion &colorient, const Ogre::Vector3 &colpos, Ogre::Vector3 &retpt, Ogre::Vector3 &retnormal, int threadIndex)
find the point on a collision primitive closest to a global point.
_OgreNewtExport void MatrixToMatrix4(const dFloat *matrix_in, Ogre::Matrix4 &matrix_out)
Take a Newton matrix and make it into an Ogre::Matrix4.
_OgreNewtExport void MatrixToQuatPos(const dFloat *matrix, Ogre::Quaternion &quat, Ogre::Vector3 &pos)
Take a Newton matrix and create a Quaternion + Position_vector.
_OgreNewtExport Ogre::Quaternion grammSchmidt(const Ogre::Vector3 &pin)
_OgreNewtExport void Matrix4ToMatrix(const Ogre::Matrix4 &matrix_in, dFloat *matrix_out)
Take an Ogre::Matrix4 and make it into a Newton-happy matrix.
_OgreNewtExport void QuatPosToMatrix(const Ogre::Quaternion &quat, const Ogre::Vector3 &pos, dFloat *matrix)
Take a Quaternion and Position Matrix and create a Newton-happy float matrix!
_OgreNewtExport Ogre::Real calculateSpringDamperAcceleration(Ogre::Real deltaTime, Ogre::Real spingK, Ogre::Real stretchDistance, Ogre::Real springDamping, Ogre::Real dampVelocity)