summaryrefslogtreecommitdiffstats
path: root/src/math/Matrix.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/Matrix.h')
-rw-r--r--src/math/Matrix.h34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/math/Matrix.h b/src/math/Matrix.h
index d8f6388d..bf811af7 100644
--- a/src/math/Matrix.h
+++ b/src/math/Matrix.h
@@ -23,9 +23,19 @@ public:
void UpdateRW(void);
void operator=(CMatrix const &rhs);
CMatrix &operator+=(CMatrix const &rhs);
+#ifdef RWCORE_H
+ operator RwMatrix (void) const {
+ return m_matrix;
+ }
+
+ operator RwMatrix *(void) {
+ return &m_matrix;
+ }
+#endif
CMatrix &operator*=(CMatrix const &rhs);
- CVector &GetPosition(void){ return *(CVector*)&m_matrix.pos; }
+ const CVector &GetPosition(void) const { return *(CVector*)&m_matrix.pos; }
+ CVector& GetPosition(void) { return *(CVector*)&m_matrix.pos; }
CVector &GetRight(void) { return *(CVector*)&m_matrix.right; }
CVector &GetForward(void) { return *(CVector*)&m_matrix.up; }
CVector &GetUp(void) { return *(CVector*)&m_matrix.at; }
@@ -44,13 +54,18 @@ public:
{
float *pFloatMatrix = (float*)&m_matrix;
for (int i = 0; i < 3; i++)
-#ifdef FIX_BUGS // BUGFIX from VC
for (int j = 0; j < 3; j++)
-#else
- for (int j = 0; j < 4; j++)
-#endif
pFloatMatrix[i * 4 + j] *= scale;
}
+ void Scale(float sx, float sy, float sz)
+ {
+ float *pFloatMatrix = (float*)&m_matrix;
+ for (int i = 0; i < 3; i++){
+ pFloatMatrix[i * 4 + 0] *= sx;
+ pFloatMatrix[i * 4 + 1] *= sy;
+ pFloatMatrix[i * 4 + 2] *= sz;
+ }
+ }
void SetRotateXOnly(float angle);
@@ -85,6 +100,15 @@ public:
void CopyOnlyMatrix(CMatrix *other);
void SetUnity(void);
void ResetOrientation(void);
+ void CopyRwMatrix(RwMatrix *matrix){
+ m_matrix = *matrix;
+ }
+
+ void CopyToRwMatrix(RwMatrix *matrix){
+ *matrix = m_matrix;
+ RwMatrixUpdate(matrix);
+ }
+
void SetTranslateOnly(float x, float y, float z) {
m_matrix.pos.x = x;
m_matrix.pos.y = y;