-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOgreMotionState.h
More file actions
41 lines (35 loc) · 1.13 KB
/
OgreMotionState.h
File metadata and controls
41 lines (35 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef __OgreMotionState_h_
#define __OgreMotionState_h_
#include <btBulletDynamicsCommon.h>
#include <Ogre.h>
class OgreMotionState : public btMotionState {
protected:
Ogre::SceneNode* mVisibleobj;
btTransform mPos1;
public:
OgreMotionState(const btTransform& initialpos, Ogre::SceneNode* node) {
mVisibleobj = node;
mPos1 = initialpos;
}
virtual ~OgreMotionState() {}
void setNode(Ogre::SceneNode* node) {
mVisibleobj = node;
}
void updateTransform(btTransform& newpos) {
mPos1 = newpos;
}
virtual void getWorldTransform(btTransform& worldTrans) const {
worldTrans = mPos1;
}
virtual void setWorldTransform(const btTransform& worldTrans) {
if(NULL == mVisibleobj)
return; // silently return before we set a node
btQuaternion rot = worldTrans.getRotation();
mVisibleobj->setOrientation(rot.w(), rot.x(), rot.y(), rot.z());
btVector3 pos = worldTrans.getOrigin();
mVisibleobj->setPosition(pos.x(), pos.y(), pos.z());
}
};
//---------------------------------------------------------------------------
#endif // #ifndef __OgreMotionState_h_
//---------------------------------------------------------------------------