-
Notifications
You must be signed in to change notification settings - Fork 0
/
SRotationComponent.h
55 lines (45 loc) · 1.09 KB
/
SRotationComponent.h
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
#ifndef SROTATIONCOMPONENT_H_INCLUDED
#define SROTATIONCOMPONENT_H_INCLUDED
#include <lf/Lightfeather.h>
#include <btBulletDynamicsCommon.h>
#include <entityx.h>
using namespace entityx;
using namespace lf;
struct RotationComponent : Component<RotationComponent>
{
float x,y,z,w;
RotationComponent(float x = 0.0f, float y = 0.0f, float z = 0.0f, float w = 1.0f) : x(x), y(y), z(z), w(w)
{
}
RotationComponent(btQuaternion btquat)
{
setRotation(btquat);
}
RotationComponent(core::quaternion lfquat)
{
setRotation(lfquat);
}
void setRotation(core::quaternion const &lfquat)
{
x = lfquat.X;
y = lfquat.Y;
z = lfquat.Z;
w = lfquat.W;
}
void setRotation(btQuaternion const &btquat )
{
x = btquat.x();
y = btquat.y();
z = btquat.z();
w = btquat.w();
}
core::quaternion getRotationLF()
{
return core::quaternion(x,y,z,w);
}
btQuaternion getRotationBT()
{
return btQuaternion(x,y,z,w);
}
};
#endif // SROTATIONCOMPONENT_H_INCLUDED