From c1f3ce8cceb675a9c76b4dc4e7cdfb18b17c4f2f Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 7 Jul 2019 18:36:55 +0200 Subject: implemented CDoor --- src/math/Matrix.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/math/Matrix.h') diff --git a/src/math/Matrix.h b/src/math/Matrix.h index 6e1001cb..5cc7d12f 100644 --- a/src/math/Matrix.h +++ b/src/math/Matrix.h @@ -306,6 +306,15 @@ Multiply3x3(const CMatrix &mat, const CVector &vec) mat.m_matrix.right.z * vec.x + mat.m_matrix.up.z * vec.y + mat.m_matrix.at.z * vec.z); } +inline CVector +Multiply3x3(const CVector &vec, const CMatrix &mat) +{ + return CVector( + mat.m_matrix.right.x * vec.x + mat.m_matrix.right.y * vec.y + mat.m_matrix.right.z * vec.z, + mat.m_matrix.up.x * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.up.z * vec.z, + mat.m_matrix.at.x * vec.x + mat.m_matrix.at.y * vec.y + mat.m_matrix.at.z * vec.z); +} + class CCompressedMatrixNotAligned { CVector m_vecPos; -- cgit v1.2.3 From edf5ac2626ce17b74037281aa3c9730902b4b1d4 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 8 Jul 2019 17:07:34 +0200 Subject: little changes; one more function of CAutomobile --- src/math/Matrix.h | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/math/Matrix.h') diff --git a/src/math/Matrix.h b/src/math/Matrix.h index 5cc7d12f..eda75e4a 100644 --- a/src/math/Matrix.h +++ b/src/math/Matrix.h @@ -78,10 +78,10 @@ public: return *this; } - 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; } + 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; } void SetScale(float s){ m_matrix.right.x = s; m_matrix.right.y = 0.0f; @@ -190,9 +190,9 @@ public: m_matrix.pos.z = 0.0f; } void Reorthogonalise(void){ - CVector &r = *GetRight(); - CVector &f = *GetForward(); - CVector &u = *GetUp(); + CVector &r = GetRight(); + CVector &f = GetForward(); + CVector &u = GetUp(); u = CrossProduct(r, f); u.Normalise(); r = CrossProduct(f, u); @@ -327,24 +327,24 @@ class CCompressedMatrixNotAligned public: void CompressFromFullMatrix(CMatrix &other) { - m_rightX = 127.0f * other.GetRight()->x; - m_rightY = 127.0f * other.GetRight()->y; - m_rightZ = 127.0f * other.GetRight()->z; - m_upX = 127.0f * other.GetForward()->x; - m_upY = 127.0f * other.GetForward()->y; - m_upZ = 127.0f * other.GetForward()->z; - m_vecPos = *other.GetPosition(); + m_rightX = 127.0f * other.GetRight().x; + m_rightY = 127.0f * other.GetRight().y; + m_rightZ = 127.0f * other.GetRight().z; + m_upX = 127.0f * other.GetForward().x; + m_upY = 127.0f * other.GetForward().y; + m_upZ = 127.0f * other.GetForward().z; + m_vecPos = other.GetPosition(); } void DecompressIntoFullMatrix(CMatrix &other) { - other.GetRight()->x = m_rightX / 127.0f; - other.GetRight()->y = m_rightY / 127.0f; - other.GetRight()->z = m_rightZ / 127.0f; - other.GetForward()->x = m_upX / 127.0f; - other.GetForward()->y = m_upY / 127.0f; - other.GetForward()->z = m_upZ / 127.0f; - *other.GetUp() = CrossProduct(*other.GetRight(), *other.GetForward()); - *other.GetPosition() = m_vecPos; + other.GetRight().x = m_rightX / 127.0f; + other.GetRight().y = m_rightY / 127.0f; + other.GetRight().z = m_rightZ / 127.0f; + other.GetForward().x = m_upX / 127.0f; + other.GetForward().y = m_upY / 127.0f; + other.GetForward().z = m_upZ / 127.0f; + other.GetUp() = CrossProduct(other.GetRight(), other.GetForward()); + other.GetPosition() = m_vecPos; other.Reorthogonalise(); } -}; \ No newline at end of file +}; -- cgit v1.2.3 From 2ae112fdf6b90bb4435dba34bcc2a23604e1e158 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 8 Jul 2019 21:37:47 +0200 Subject: more CAutomobile --- src/math/Matrix.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/math/Matrix.h') diff --git a/src/math/Matrix.h b/src/math/Matrix.h index eda75e4a..b7d6c207 100644 --- a/src/math/Matrix.h +++ b/src/math/Matrix.h @@ -82,6 +82,32 @@ public: CVector &GetRight(void) { return *(CVector*)&m_matrix.right; } CVector &GetForward(void) { return *(CVector*)&m_matrix.up; } CVector &GetUp(void) { return *(CVector*)&m_matrix.at; } + + void SetTranslate(float x, float y, float z){ + m_matrix.right.x = 1.0f; + m_matrix.right.y = 0.0f; + m_matrix.right.z = 0.0f; + + m_matrix.up.x = 0.0f; + m_matrix.up.y = 1.0f; + m_matrix.up.z = 0.0f; + + m_matrix.at.x = 0.0f; + m_matrix.at.y = 0.0f; + m_matrix.at.z = 1.0f; + + m_matrix.pos.x = x; + m_matrix.pos.y = y; + m_matrix.pos.z = z; + } + void SetTranslate(const CVector &trans){ SetTranslate(trans.x, trans.y, trans.z); } + void Translate(float x, float y, float z){ + m_matrix.pos.x += x; + m_matrix.pos.y += y; + m_matrix.pos.z += z; + } + void Translate(const CVector &trans){ Translate(trans.x, trans.y, trans.z); } + void SetScale(float s){ m_matrix.right.x = s; m_matrix.right.y = 0.0f; @@ -99,6 +125,7 @@ public: m_matrix.pos.y = 0.0f; m_matrix.pos.z = 0.0f; } + void SetRotateXOnly(float angle){ float c = cos(angle); float s = sin(angle); -- cgit v1.2.3 From 4a36d64f15f898854bb8a76be86ac9a8c536b291 Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 10 Jul 2019 17:18:26 +0200 Subject: added wrappers around math functions --- src/math/Matrix.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/math/Matrix.h') diff --git a/src/math/Matrix.h b/src/math/Matrix.h index b7d6c207..2c0108c1 100644 --- a/src/math/Matrix.h +++ b/src/math/Matrix.h @@ -127,8 +127,8 @@ public: } void SetRotateXOnly(float angle){ - float c = cos(angle); - float s = sin(angle); + float c = Cos(angle); + float s = Sin(angle); m_matrix.right.x = 1.0f; m_matrix.right.y = 0.0f; @@ -149,8 +149,8 @@ public: m_matrix.pos.z = 0.0f; } void SetRotateYOnly(float angle){ - float c = cos(angle); - float s = sin(angle); + float c = Cos(angle); + float s = Sin(angle); m_matrix.right.x = c; m_matrix.right.y = 0.0f; @@ -171,8 +171,8 @@ public: m_matrix.pos.z = 0.0f; } void SetRotateZOnly(float angle){ - float c = cos(angle); - float s = sin(angle); + float c = Cos(angle); + float s = Sin(angle); m_matrix.right.x = c; m_matrix.right.y = s; @@ -193,12 +193,12 @@ public: m_matrix.pos.z = 0.0f; } void SetRotate(float xAngle, float yAngle, float zAngle) { - float cX = cos(xAngle); - float sX = sin(xAngle); - float cY = cos(yAngle); - float sY = sin(yAngle); - float cZ = cos(zAngle); - float sZ = sin(zAngle); + float cX = Cos(xAngle); + float sX = Sin(xAngle); + float cY = Cos(yAngle); + float sY = Sin(yAngle); + float cZ = Cos(zAngle); + float sZ = Sin(zAngle); m_matrix.right.x = cZ * cY - (sZ * sX) * sY; m_matrix.right.y = (cZ * sX) * sY + sZ * cY; -- cgit v1.2.3