-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransformState.cpp
55 lines (44 loc) · 1.26 KB
/
TransformState.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
#include "TransformState.h"
TransformState::TransformState()
{
mScale.SetOne();
mTranslation.SetZero();
mRotation.SetZero();
mScaleXfm.SetScale( mScale );
mTranslationXfm.SetTranslation( mTranslation );
mRotationXfm.SetRotation( mRotation );
ComputeXfm();
}
void TransformState::SetScale( const Vector3f& scale )
{
mScale = scale;
mScaleXfm.SetScale( mScale );
ComputeXfm();
}
void TransformState::SetTranslation( const Vector3f& translation )
{
mTranslation = translation;
mTranslationXfm.SetTranslation( mTranslation );
ComputeXfm();
}
void TransformState::SetRotation( const Vector3f& rotation )
{
mRotation = rotation;
mRotationXfm.SetRotation( mRotation );
ComputeXfm();
}
void TransformState::ComputeXfm()
{
mXfm = mTranslationXfm * mRotationXfm * mScaleXfm;
}
std::ostream& operator<< ( std::ostream &out, const TransformState &xfm )
{
out << "Scale " << xfm.mScale << std::endl;
out << "Trans " << xfm.mTranslation << std::endl;
out << "Rotat " << xfm.mRotation << std::endl;
out << "Scale" << std::endl << xfm.mScaleXfm;
out << "Translation" << std::endl << xfm.mTranslationXfm;
out << "Rotation" << std::endl << xfm.mRotationXfm;
out << "Composition" << std::endl << xfm.mXfm;
return out;
}