NW4F Sys
Loading...
Searching...
No Matches
math_Transform.h
Go to the documentation of this file.
1#ifndef NW_MATH_TRANSFORM_H_
2#define NW_MATH_TRANSFORM_H_
3
4#include <nw/math/math_Config.h>
5#include <nw/math/math_Vector2.h>
6#include <nw/math/math_Vector3.h>
7#include <nw/math/math_Vector4.h>
8
9namespace nw { namespace math {
10
17
24
25struct Transform2 : public Transform2_
26{
27public:
29 typedef f32 value_type;
30public:
32 explicit Transform2(const Transform2_& t)
33 {
34 scale = t.scale;
35 rotate = t.rotate;
36 translate = t.translate;
37 }
38 Transform2(const VEC2& s, const VEC2& r, const VEC2& t)
39 {
40 scale = s;
41 rotate = r;
42 translate = t;
43 }
44
45 bool operator == (const self_type& rhs) const { return ::std::memcmp(this, &rhs, sizeof(Transform2)) == 0; }
46 bool operator != (const self_type& rhs) const { return ::std::memcmp(this, &rhs, sizeof(Transform2)) != 0; }
47};
48
49struct Transform3 : public Transform3_
50{
51public:
53 typedef f32 value_type;
54public:
56 explicit Transform3(const Transform3_& t)
57 {
58 scale = t.scale;
59 rotate = t.rotate;
60 translate = t.translate;
61 }
62 Transform3(const VEC3& s, const VEC3& r, const VEC3& t)
63 {
64 scale = s;
65 rotate = r;
66 translate = t;
67 }
68
69 bool operator == (const self_type& rhs) const { return ::std::memcmp(this, &rhs, sizeof(Transform3)) == 0; }
70 bool operator != (const self_type& rhs) const { return ::std::memcmp(this, &rhs, sizeof(Transform3)) != 0; }
71};
72
73inline Transform2*
75{
76 pOut->scale = VEC2(1.f, 1.f);
77 pOut->rotate = VEC2(0.f, 0.f);
78 pOut->translate = VEC2(0.f, 0.f);
79 return pOut;
80}
81
82inline Transform3*
84{
85 pOut->scale = VEC3(1.f, 1.f, 1.f);
86 pOut->rotate = VEC3(0.f, 0.f, 0.f);
87 pOut->translate = VEC3(0.f, 0.f, 0.f);
88 return pOut;
89}
90
91// NW_MATH_INLINE VEC3* VEC3Transform(VEC3* pOut, const MTX34* pM, const VEC3* pV); <-- Redundant redeclaration
92// NW_MATH_INLINE VEC3* VEC3Transform(VEC3* pOut, const MTX44* pM, const VEC3* pV); <-- Redundant redeclaration
93
94// NW_MATH_INLINE VEC4* VEC3Transform(VEC4* pOut, const MTX44* pM, const VEC3* pV); <-- Redundant redeclaration
95NW_MATH_INLINE VEC3* VEC3TransformArray(VEC3* pOut, const MTX34* pM, const VEC3* pV, s32 count);
96NW_MATH_INLINE VEC4* VEC3TransformArray(VEC4* pOut, const MTX44* pM, const VEC3* pV, u32 count);
97
98NW_MATH_INLINE VEC3* VEC3TransformNormal(VEC3* pOut, const MTX34* pM, const VEC3* pV);
99NW_MATH_INLINE VEC3* VEC3TransformNormalArray(VEC3* pOutArray, const MTX34* pM, const VEC3* pArray, u32 n);
100
101NW_MATH_INLINE VEC3* VEC3TransformCoord(VEC3* pOut, const MTX44* pM, const VEC3* pV);
102NW_MATH_INLINE VEC3* VEC3TransformCoordArray(VEC3* pOut, const MTX44* pM, const VEC3* pV, u32 count);
103
104NW_MATH_INLINE VEC4* VEC4Transform(VEC4* pOut, const MTX44* pM, const VEC4* pV);
105NW_MATH_INLINE VEC4* VEC4TransformArray(VEC4* pOut, const MTX44* pM, const VEC4* pV, u32 n);
106
107NW_MATH_INLINE VEC4* VEC4Transform(VEC4* pOut, const MTX34* pM, const VEC4* pV);
108NW_MATH_INLINE VEC4* VEC4TransformArray(VEC4* pOut, const MTX34* pM, const VEC4* pV, u32 n);
109
110inline VEC3* VEC3Transform(VEC3* pOut, const MTX34& m, const VEC3& v) { return VEC3Transform( pOut, &m, &v ); }
111inline VEC4* VEC3Transform(VEC4* pOut, const MTX44& m, const VEC3& v) { return VEC3Transform( pOut, &m, &v ); }
112inline VEC3* VEC3TransformArray(VEC3* pOutArray, const MTX34& m, const VEC3* pArray, s32 count) { return VEC3TransformArray( pOutArray, &m, pArray, count ); }
113inline VEC4* VEC3TransformArray(VEC4* pOutArray, const MTX44& m, const VEC3* pArray, u32 count) { return VEC3TransformArray( pOutArray, &m, pArray, count ); }
114
115inline VEC3* VEC3TransformNormal(VEC3* pOut, const MTX34& m, const VEC3& v) { return VEC3TransformNormal( pOut, &m, &v ); }
116inline VEC3* VEC3TransformNormalArray(VEC3* pOutArray, const MTX34& m, const VEC3* pArray, u32 n) { return VEC3TransformNormalArray( pOutArray, &m, pArray, n ); }
117
118inline VEC3* VEC3TransformCoord(VEC3* pOut, const MTX44& m, const VEC3& v) { return VEC3TransformCoord( pOut, &m, &v ); }
119inline VEC3* VEC3TransformCoordArray(VEC3* pOutArray, const MTX44& m, const VEC3* pArray, u32 count) { return VEC3TransformCoordArray( pOutArray, &m, pArray, count ); }
120
121inline VEC4* VEC4Transform(VEC4* pOut, const MTX44& m, const VEC4& v) { return VEC4Transform( pOut, &m, &v ); }
122inline VEC4* VEC4TransformArray(VEC4* pOutArray, const MTX44& m, const VEC4* pArray, u32 n) { return VEC4TransformArray( pOutArray, &m, pArray, n ); }
123
125VEC3::SetTransform(const MTX34& mtx, const VEC3& src)
126{
127 return *VEC3Transform(this, &mtx, &src);
128}
129
131VEC3::SetTransform(const MTX44& mtx, const VEC3& src)
132{
133 return *VEC3Transform(this, &mtx, &src);
134}
135
137VEC3::SetTransformNormal(const MTX34& mtx, const VEC3& src)
138{
139 return *VEC3TransformNormal(this, &mtx, &src);
140}
141
142
144VEC4::SetTransform(const MTX34& mtx, const VEC4& src)
145{
146 return *VEC4Transform(this, &mtx, &src);
147}
148
150VEC4::SetTransform(const MTX44& mtx, const VEC4& src)
151{
152 return *VEC4Transform(this, &mtx, &src);
153}
154
155} } // namespace nw::math
156
157#endif // NW_MATH_TRANSFORM_H_
#define NW_MATH_INLINE
Definition math_Config.h:7
Definition math_Constant.cpp:5
VEC3 * VEC3Transform(VEC3 *pOut, const MTX34 &m, const VEC3 &v)
Definition math_Transform.h:110
VEC3 * VEC3TransformNormalArray(VEC3 *pOutArray, const MTX34 &m, const VEC3 *pArray, u32 n)
Definition math_Transform.h:116
VEC4 * VEC4TransformArray(VEC4 *pOutArray, const MTX44 &m, const VEC4 *pArray, u32 n)
Definition math_Transform.h:122
VEC4 * VEC3Transform(VEC4 *pOut, const MTX44 &m, const VEC3 &v)
Definition math_Transform.h:111
VEC4 * VEC3TransformArray(VEC4 *pOutArray, const MTX44 &m, const VEC3 *pArray, u32 count)
Definition math_Transform.h:113
NW_MATH_INLINE VEC4 * VEC3TransformArray(VEC4 *pOut, const MTX44 *pM, const VEC3 *pV, u32 count)
VEC3 * VEC3TransformArray(VEC3 *pOutArray, const MTX34 &m, const VEC3 *pArray, s32 count)
Definition math_Transform.h:112
NW_MATH_INLINE VEC4 * VEC4Transform(VEC4 *pOut, const MTX44 *pM, const VEC4 *pV)
Transform2 * Transform2Identity(Transform2 *pOut)
Definition math_Transform.h:74
Transform3 * Transform3Identity(Transform3 *pOut)
Definition math_Transform.h:83
NW_MATH_INLINE VEC4 * VEC4TransformArray(VEC4 *pOut, const MTX44 *pM, const VEC4 *pV, u32 n)
NW_MATH_INLINE VEC4 * VEC4Transform(VEC4 *pOut, const MTX34 *pM, const VEC4 *pV)
NW_MATH_INLINE VEC3 * VEC3TransformCoordArray(VEC3 *pOut, const MTX44 *pM, const VEC3 *pV, u32 count)
NW_MATH_INLINE VEC3 * VEC3TransformArray(VEC3 *pOut, const MTX34 *pM, const VEC3 *pV, s32 count)
NW_MATH_INLINE VEC3 * VEC3TransformNormal(VEC3 *pOut, const MTX34 *pM, const VEC3 *pV)
VEC3 * VEC3TransformNormal(VEC3 *pOut, const MTX34 &m, const VEC3 &v)
Definition math_Transform.h:115
NW_MATH_INLINE VEC3 * VEC3TransformCoord(VEC3 *pOut, const MTX44 *pM, const VEC3 *pV)
VEC3 * VEC3TransformCoord(VEC3 *pOut, const MTX44 &m, const VEC3 &v)
Definition math_Transform.h:118
VEC3 * VEC3TransformCoordArray(VEC3 *pOutArray, const MTX44 &m, const VEC3 *pArray, u32 count)
Definition math_Transform.h:119
VEC4 * VEC4Transform(VEC4 *pOut, const MTX44 &m, const VEC4 &v)
Definition math_Transform.h:121
NW_MATH_INLINE VEC3 * VEC3TransformNormalArray(VEC3 *pOutArray, const MTX34 *pM, const VEC3 *pArray, u32 n)
NW_MATH_INLINE VEC4 * VEC4TransformArray(VEC4 *pOut, const MTX34 *pM, const VEC4 *pV, u32 n)
Definition math_Constant.cpp:5
Definition math_Matrix34.h:136
Definition math_Matrix44.h:189
Definition math_Transform.h:12
VEC2 translate
Definition math_Transform.h:15
VEC2 scale
Definition math_Transform.h:13
VEC2 rotate
Definition math_Transform.h:14
Definition math_Transform.h:26
Transform2(const VEC2 &s, const VEC2 &r, const VEC2 &t)
Definition math_Transform.h:38
bool operator==(const self_type &rhs) const
Definition math_Transform.h:45
Transform2 self_type
Definition math_Transform.h:28
Transform2(const Transform2_ &t)
Definition math_Transform.h:32
f32 value_type
Definition math_Transform.h:29
Transform2()
Definition math_Transform.h:31
bool operator!=(const self_type &rhs) const
Definition math_Transform.h:46
Definition math_Transform.h:19
VEC3 translate
Definition math_Transform.h:22
VEC3 rotate
Definition math_Transform.h:21
VEC3 scale
Definition math_Transform.h:20
Definition math_Transform.h:50
Transform3 self_type
Definition math_Transform.h:52
bool operator!=(const self_type &rhs) const
Definition math_Transform.h:70
Transform3(const Transform3_ &t)
Definition math_Transform.h:56
bool operator==(const self_type &rhs) const
Definition math_Transform.h:69
f32 value_type
Definition math_Transform.h:53
Transform3()
Definition math_Transform.h:55
Transform3(const VEC3 &s, const VEC3 &r, const VEC3 &t)
Definition math_Transform.h:62
Definition math_Vector2.h:49
Definition math_Vector3.h:62
NW_MATH_INLINE self_type & SetTransformNormal(const MTX34 &pM, const VEC3 &src)
Definition math_Transform.h:137
NW_MATH_INLINE self_type & SetTransform(const MTX44 &pM, const VEC3 &src)
Definition math_Transform.h:131
Definition math_Vector4.h:69