-
Notifications
You must be signed in to change notification settings - Fork 0
/
motionstates.cpp
56 lines (45 loc) · 1.2 KB
/
motionstates.cpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "motionstates.h"
GLNodeMotionState::GLNodeMotionState(const btTransform &initialpos, QGLSceneNode *node) :
my_pos(initialpos),
my_node(node)
{
Q_ASSERT(my_node);
setWorldTransform(my_pos);
}
GLNodeMotionState::~GLNodeMotionState()
{
}
void GLNodeMotionState::getWorldTransform(btTransform &worldTrans) const
{
worldTrans = my_pos;
}
void GLNodeMotionState::setWorldTransform(const btTransform &worldTrans)
{
my_pos = worldTrans;
btVector3 pos = worldTrans.getOrigin();
my_node->setPosition(QVector3D(pos.x(),pos.y(),pos.z()));
btQuaternion r = worldTrans.getRotation();
QQuaternion q(r.getW(),r.x(),r.y(),r.z());
QMatrix4x4 rotation;
rotation.rotate(q);
my_node->setLocalTransform(rotation);
}
KinematicMotionState::KinematicMotionState(const btTransform &initialpos) :
my_pos(initialpos)
{
}
KinematicMotionState::~KinematicMotionState()
{
}
void KinematicMotionState::getWorldTransform(btTransform &worldTrans) const
{
worldTrans = my_pos;
}
void KinematicMotionState::setWorldTransform(const btTransform &worldTrans)
{
my_pos = worldTrans;
}
void KinematicMotionState::setTransform(const btTransform &transform)
{
my_pos = transform;
}