Przeglądaj źródła

refactor

develop
Robin Thoni 8 lat temu
rodzic
commit
f4ad09a158

+ 18
- 9
UGameEngine/entities/ugeentity.cpp Wyświetl plik

@@ -123,13 +123,8 @@ void UGEEntity::setColor(const QColor &color)
123 123
 
124 124
 Vector3D UGEEntity::getRealPoint(const Vector3D &pos)
125 125
 {
126
-    Matrix3x3 scale;
127
-    scale.setScalar(0, 0, _scale.getX());
128
-    scale.setScalar(1, 1, _scale.getY());
129
-    scale.setScalar(2, 2, _scale.getZ());
130
-    Vector3D p = scale.multMatrix(pos);
131
-    Matrix3x3 rot = getRotationMatrix(_rotation);
132
-    return (rot.multMatrix(p) + _position);
126
+    Matrix3x3 trans = getTransformationMatrix();
127
+    return (trans.multMatrix(pos) + _position);
133 128
 }
134 129
 
135 130
 ColorVector3D UGEEntity::getRealPoint(const ColorVector3D &pos)
@@ -142,9 +137,23 @@ TextureVector3D UGEEntity::getRealPoint(const TextureVector3D &pos)
142 137
     return TextureVector3D(pos.getTextureCoord(), getRealPoint((ColorVector3D)pos));
143 138
 }
144 139
 
145
-Matrix3x3 UGEEntity::getRotationMatrix(const Vector3D &rotation)
140
+Matrix3x3 UGEEntity::getTransformationMatrix() const
141
+{
142
+    return getRotationMatrix().multMatrix(getScaleMatrix());
143
+}
144
+
145
+Matrix3x3 UGEEntity::getScaleMatrix() const
146
+{
147
+    Matrix3x3 scale;
148
+    scale.setScalar(0, 0, _scale.getX());
149
+    scale.setScalar(1, 1, _scale.getY());
150
+    scale.setScalar(2, 2, _scale.getZ());
151
+    return scale;
152
+}
153
+
154
+Matrix3x3 UGEEntity::getRotationMatrix() const
146 155
 {
147
-    Vector3D r = Tools::degreeToRad(rotation);
156
+    Vector3D r = Tools::degreeToRad(_rotation);
148 157
 
149 158
     Matrix3x3 mx;
150 159
     mx.setToIdentity();

+ 3
- 1
UGameEngine/entities/ugeentity.h Wyświetl plik

@@ -43,7 +43,9 @@ public:
43 43
     ColorVector3D getRealPoint(const ColorVector3D& pos);
44 44
     TextureVector3D getRealPoint(const TextureVector3D& pos);
45 45
 
46
-    Matrix3x3 getRotationMatrix(const Vector3D& rotation);
46
+    Matrix3x3 getTransformationMatrix() const;
47
+    Matrix3x3 getScaleMatrix() const;
48
+    Matrix3x3 getRotationMatrix() const;
47 49
 
48 50
     virtual void drawPoint(AbstractRenderDevice* device, const ColorVector3D& point);
49 51
 

Ładowanie…
Anuluj
Zapisz