soui
5.0.0.1
Soui5 Doc
Loading...
Searching...
No Matches
STransformation.cpp
1
2
#include <souistd.h>
3
#include <animation/STransformation.h>
4
5
SNSBEGIN
6
7
bool
STransformation::isIdentity
()
const
8
{
9
return
getTransformationType
() == TYPE_IDENTITY;
10
}
11
12
bool
STransformation::hasMatrix
()
const
13
{
14
return
(
getTransformationType
() & TYPE_MATRIX) == TYPE_MATRIX;
15
}
16
17
bool
STransformation::hasAlpha
()
const
18
{
19
return
(
getTransformationType
() & TYPE_ALPHA) == TYPE_ALPHA;
20
}
21
22
BYTE
STransformation::GetAlpha
()
const
23
{
24
return
mAlpha
;
25
}
26
27
void
STransformation::updateMatrixType
()
28
{
29
if
(
mMatrix
.isIdentity())
30
mTransformationType
&= ~TYPE_MATRIX;
31
else
32
mTransformationType
|= TYPE_MATRIX;
33
}
34
35
void
STransformation::SetAlpha
(BYTE alpha)
36
{
37
mAlpha
= alpha;
38
mTransformationType
|= TYPE_ALPHA;
39
}
40
41
void
STransformation::setMatrix
(
const
SMatrix
&mtx)
42
{
43
mMatrix
= mtx;
44
updateMatrixType
();
45
}
46
47
SMatrix
&
STransformation::getMatrix
()
48
{
49
return
mMatrix
;
50
}
51
52
const
SMatrix
&
STransformation::getMatrix
()
const
53
{
54
return
mMatrix
;
55
}
56
57
void
STransformation::postCompose
(
STransformation
t)
58
{
59
if
(t.
hasAlpha
())
60
{
61
mAlpha
= (BYTE)((
int
)
mAlpha
* t.
GetAlpha
() / 255);
62
mTransformationType
|= TYPE_ALPHA;
63
}
64
if
(t.
hasMatrix
())
65
{
66
mMatrix
*= t.
getMatrix
();
67
updateMatrixType
();
68
}
69
}
70
71
void
STransformation::Compose
(
const
ITransformation *t)
72
{
73
const
STransformation
&t2 = *(
const
STransformation
*)t;
74
compose
(t2);
75
}
76
77
void
STransformation::compose
(
const
STransformation
&t)
78
{
79
if
(t.
hasAlpha
())
80
{
81
mAlpha
= (BYTE)((
int
)
mAlpha
* t.
GetAlpha
() / 255);
82
mTransformationType
|= TYPE_ALPHA;
83
}
84
if
(t.
hasMatrix
())
85
{
86
mMatrix
= t.
getMatrix
() *
mMatrix
;
87
updateMatrixType
();
88
}
89
}
90
91
void
STransformation::set
(
STransformation
t)
92
{
93
mAlpha
= t.
GetAlpha
();
94
mMatrix
= t.
getMatrix
();
95
96
mTransformationType
= t.
getTransformationType
();
97
}
98
99
void
STransformation::SetTransformationType
(
int
type)
100
{
101
mTransformationType
= type;
102
}
103
104
int
STransformation::getTransformationType
()
const
105
{
106
return
mTransformationType
;
107
}
108
109
void
STransformation::Clear
()
110
{
111
mMatrix
.reset();
112
mAlpha
= 255;
113
mTransformationType
= TYPE_IDENTITY;
114
}
115
116
STransformation::STransformation
()
117
{
118
Clear
();
119
}
120
121
IMatrix *
STransformation::GetMatrix
()
122
{
123
return
&
mMatrix
;
124
}
125
126
SNSEND
SMatrix
The SMatrix class holds a 3x3 matrix for transforming coordinates. SMatrix does not have a constructo...
Definition
SMatrix.h:22
STransformation::set
void set(STransformation t)
Clones the specified transformation.
Definition
STransformation.cpp:91
STransformation::updateMatrixType
void updateMatrixType()
Updates the transformation type based on the current matrix and alpha.
Definition
STransformation.cpp:27
STransformation::Clear
void Clear() OVERRIDE
Clears the transformation to the identity matrix and alpha to 1.
Definition
STransformation.cpp:109
STransformation::GetMatrix
IMatrix * GetMatrix() OVERRIDE
Gets the matrix representing the transformation.
Definition
STransformation.cpp:121
STransformation::hasMatrix
bool hasMatrix() const
Checks if the transformation affects the matrix property.
Definition
STransformation.cpp:12
STransformation::mTransformationType
int mTransformationType
Indicates the nature of this transformation.
Definition
STransformation.h:24
STransformation::Compose
void Compose(const ITransformation *t) OVERRIDE
Composes this transformation with another transformation.
Definition
STransformation.cpp:71
STransformation::compose
void compose(const STransformation &t)
Applies this STransformation to an existing STransformation.
Definition
STransformation.cpp:77
STransformation::GetAlpha
BYTE GetAlpha() SCONST OVERRIDE
Gets the degree of transparency.
Definition
STransformation.cpp:22
STransformation::SetTransformationType
void SetTransformationType(int type) OVERRIDE
Sets the type of transformation.
Definition
STransformation.cpp:99
STransformation::postCompose
void postCompose(STransformation t)
Composes this transformation with another transformation using postConcat.
Definition
STransformation.cpp:57
STransformation::isIdentity
bool isIdentity() const
Checks if the transformation is the identity transformation.
Definition
STransformation.cpp:7
STransformation::mAlpha
BYTE mAlpha
The degree of transparency (255 means fully opaque, 0 means fully transparent).
Definition
STransformation.h:23
STransformation::SetAlpha
void SetAlpha(BYTE alpha) OVERRIDE
Sets the degree of transparency.
Definition
STransformation.cpp:35
STransformation::STransformation
STransformation()
Creates a new transformation with alpha = 1 and the identity matrix.
Definition
STransformation.cpp:116
STransformation::getMatrix
const SMatrix & getMatrix() const
Gets the 3x3 matrix representing the transformation.
Definition
STransformation.cpp:52
STransformation::hasAlpha
bool hasAlpha() const
Checks if the transformation affects the alpha property.
Definition
STransformation.cpp:17
STransformation::mMatrix
SMatrix mMatrix
The 3x3 matrix representing the transformation.
Definition
STransformation.h:22
STransformation::setMatrix
void setMatrix(const SMatrix &mtx)
Sets the matrix representing the transformation.
Definition
STransformation.cpp:41
STransformation::getTransformationType
int getTransformationType() const
Indicates the nature of this transformation.
Definition
STransformation.cpp:104
SOUI
src
animation
STransformation.cpp
Generated by
1.13.2