diff options
author | Paul Gilbert | 2017-03-18 23:40:24 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-03-18 23:40:24 -0400 |
commit | 2a76819b0fe1ccea9ba8093dc900490576dbe1fc (patch) | |
tree | 4c770230471668f428eb9b0152d284584f96ec5f /engines | |
parent | 26eb320b717bcf0aebdbe79651330d0de31c6fce (diff) | |
download | scummvm-rg350-2a76819b0fe1ccea9ba8093dc900490576dbe1fc.tar.gz scummvm-rg350-2a76819b0fe1ccea9ba8093dc900490576dbe1fc.tar.bz2 scummvm-rg350-2a76819b0fe1ccea9ba8093dc900490576dbe1fc.zip |
TITANIC: Implementing CStarControlSub12 class
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/star_control/fmatrix.cpp | 8 | ||||
-rw-r--r-- | engines/titanic/star_control/fmatrix.h | 2 | ||||
-rw-r--r-- | engines/titanic/star_control/fvector.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/star_control/fvector.h | 2 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub12.cpp | 99 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub12.h | 4 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub13.cpp | 17 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub6.cpp | 87 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub6.h | 6 |
9 files changed, 155 insertions, 72 deletions
diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp index e0c270ba7d..02da11576c 100644 --- a/engines/titanic/star_control/fmatrix.cpp +++ b/engines/titanic/star_control/fmatrix.cpp @@ -78,10 +78,10 @@ void FMatrix::identity() { _row3 = FVector(0.0, 0.0, 1.0); } -void FMatrix::set(FVector *row1, FVector *row2, FVector *row3) { - _row1 = *row1; - _row2 = *row2; - _row3 = *row3; +void FMatrix::set(const FVector &row1, const FVector &row2, const FVector &row3) { + _row1 = row1; + _row2 = row2; + _row3 = row3; } void FMatrix::fn1(const FVector &v) { diff --git a/engines/titanic/star_control/fmatrix.h b/engines/titanic/star_control/fmatrix.h index 7ab90fb7e1..6fa847f950 100644 --- a/engines/titanic/star_control/fmatrix.h +++ b/engines/titanic/star_control/fmatrix.h @@ -72,7 +72,7 @@ public: /** * Sets the data for the matrix */ - void set(FVector *row1, FVector *row2, FVector *row3); + void set(const FVector &row1, const FVector &row2, const FVector &row3); void fn1(const FVector &v); void fn2(const FMatrix &m); diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp index b0667c532b..92c17a09b4 100644 --- a/engines/titanic/star_control/fvector.cpp +++ b/engines/titanic/star_control/fvector.cpp @@ -65,7 +65,7 @@ double FVector::getDistance(const FVector *src) const { return sqrt(xd * xd + yd * yd + zd * zd); } -void FVector::fn5(FVector *dest, const CStarControlSub6 *sub6) const { +FVector FVector::fn5(const CStarControlSub6 *sub6) const { error("TODO: FVector::fn5"); } diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h index bf446fc640..4582072f50 100644 --- a/engines/titanic/star_control/fvector.h +++ b/engines/titanic/star_control/fvector.h @@ -71,7 +71,7 @@ public: */ double getDistance(const FVector *src) const; - void fn5(FVector *dest, const CStarControlSub6 *sub6) const; + FVector fn5(const CStarControlSub6 *sub6) const; /** * Returns true if the passed vector equals this one diff --git a/engines/titanic/star_control/star_control_sub12.cpp b/engines/titanic/star_control/star_control_sub12.cpp index 7ed65357d3..4e6a6bc0f2 100644 --- a/engines/titanic/star_control/star_control_sub12.cpp +++ b/engines/titanic/star_control/star_control_sub12.cpp @@ -215,8 +215,103 @@ FVector CStarControlSub12::proc31(int index, const FVector &v) { return _sub13.fn18(index, v); } -void CStarControlSub12::setViewportPosition(const FPoint &pt) { - // TODO +void CStarControlSub12::setViewportPosition(const FPoint &angles) { + if (isLocked()) + return; + + if (_currentIndex == -1) { + CStarControlSub6 subX(X_AXIS, angles._x); + CStarControlSub6 subY(Y_AXIS, angles._y); + CStarControlSub6 sub(&subX, &subY); + subY.copyFrom(&sub); + proc22(subY); + } else if (_currentIndex == 0) { + FVector row1 = _matrix._row1; + CStarControlSub6 subX(X_AXIS, angles._x); + CStarControlSub6 subY(Y_AXIS, angles._y); + CStarControlSub6 sub(&subX, &subY); + subX.copyFrom(&sub); + + FMatrix m1 = _sub13.getMatrix(); + FVector tempV1 = _sub13._position; + FVector tempV2, tempV3, tempV4, tempV5, tempV6; + tempV2._y = m1._row1._y * 100000.0; + tempV2._z = m1._row1._z * 100000.0; + tempV3._x = m1._row1._x * 100000.0 + tempV1._x; + tempV4._x = tempV3._x; + tempV3._y = tempV2._y + tempV1._y; + tempV4._y = tempV3._y; + tempV3._z = tempV2._z + tempV1._z; + tempV4._z = tempV3._z; + tempV2._x = m1._row2._x * 100000.0; + tempV2._y = m1._row2._y * 100000.0; + tempV2._z = m1._row2._z * 100000.0; + tempV2._x = m1._row3._x * 100000.0; + tempV2._y = m1._row3._y * 100000.0; + tempV2._z = m1._row3._z * 100000.0; + tempV2._x = tempV2._x + tempV1._x; + tempV2._y = tempV2._y + tempV1._y; + tempV2._z = tempV2._z + tempV1._z; + tempV3._x = tempV2._x + tempV1._x; + tempV3._y = tempV2._y + tempV1._y; + tempV5._x = tempV2._x; + tempV5._y = tempV2._y; + tempV3._z = tempV2._z + tempV1._z; + tempV5._z = tempV2._z; + tempV6._x = tempV3._x; + tempV6._y = tempV3._y; + tempV6._z = tempV3._z; + tempV1._x = tempV1._x - row1._x; + tempV1._y = tempV1._y - row1._y; + tempV1._z = tempV1._z - row1._z; + tempV4._x = tempV3._x - row1._x; + tempV4._y = tempV4._y - row1._y; + tempV4._z = tempV4._z - row1._z; + tempV5._x = tempV2._x - row1._x; + + tempV5._y = tempV5._y - row1._y; + tempV5._z = tempV5._z - row1._z; + tempV6._x = tempV3._x - row1._x; + tempV6._y = tempV6._y - row1._y; + tempV6._z = tempV6._z - row1._z; + + FVector modV1 = tempV1.fn5(&subX); + FVector modV2 = tempV4.fn5(&subX); + FVector modV3 = tempV5.fn5(&subX); + FVector modV4 = tempV6.fn5(&subX); + tempV1 = modV1; + tempV4 = modV2; + tempV5 = modV3; + tempV4 = modV4; + + tempV2._x = tempV4._x - tempV1._x; + tempV2._y = tempV4._y - tempV1._y; + tempV2._z = tempV4._z - tempV1._z; + tempV4._x = tempV2._x; + tempV4._y = tempV2._y; + tempV2._x = tempV5._x - tempV1._x; + tempV4._z = tempV2._z; + tempV5._x = tempV2._x; + tempV2._y = tempV5._y - tempV1._y; + tempV5._y = tempV2._y; + tempV2._z = tempV5._z - tempV1._z; + tempV5._z = tempV2._z; + tempV2._x = tempV6._x - tempV1._x; + tempV2._y = tempV6._y - tempV1._y; + tempV2._z = tempV6._z - tempV1._z; + tempV6 = tempV2; + + tempV4.normalize(); + tempV5.normalize(); + tempV6.normalize(); + tempV1 += row1; + + m1.set(tempV4, tempV5, tempV6); + _sub13.setMatrix(m1); + _sub13.setPosition(tempV1); + } else if (_currentIndex == 1) { + // TODO + } } bool CStarControlSub12::setArrayVector(const FVector &v) { diff --git a/engines/titanic/star_control/star_control_sub12.h b/engines/titanic/star_control/star_control_sub12.h index fbd7b88f9d..b1a25682d7 100644 --- a/engines/titanic/star_control/star_control_sub12.h +++ b/engines/titanic/star_control/star_control_sub12.h @@ -39,7 +39,7 @@ private: static FMatrix *_matrix2; private: int _currentIndex; - FVector _array[3]; + FMatrix _matrix; CStarControlSub20 *_handlerP; CStarControlSub13 _sub13; int _field108; @@ -100,7 +100,7 @@ public: /** * Sets the viewport position within the starfield */ - virtual void setViewportPosition(const FPoint &pt); + virtual void setViewportPosition(const FPoint &angles); virtual int getCurrentIndex() const { return _currentIndex; } virtual bool setArrayVector(const FVector &v); diff --git a/engines/titanic/star_control/star_control_sub13.cpp b/engines/titanic/star_control/star_control_sub13.cpp index 2b5776cefd..6512d12232 100644 --- a/engines/titanic/star_control/star_control_sub13.cpp +++ b/engines/titanic/star_control/star_control_sub13.cpp @@ -116,8 +116,7 @@ void CStarControlSub13::setPosition(const FVector &v) { } void CStarControlSub13::setPosition(const CStarControlSub6 *sub6) { - FVector vector; - _position.fn5(&vector, sub6); + _position.fn5(sub6); _position = sub6->_row1; _flag = false; } @@ -163,12 +162,10 @@ void CStarControlSub13::fn12() { CStarControlSub6 m2(Y_AXIS, g_vm->getRandomNumber(359)); CStarControlSub6 m3(Z_AXIS, g_vm->getRandomNumber(359)); - CStarControlSub6 s1, s2; - CStarControlSub6 *s; - s = CStarControlSub6::setup(&s1, &m1, &m2); - s = CStarControlSub6::setup(&s2, s, &m3); + CStarControlSub6 s1(&m1, &m2); + CStarControlSub6 s2(&s1, &m3); - m1.copyFrom(*s); + m1.copyFrom(s2); _matrix.fn2(m1); _flag = false; } @@ -225,9 +222,8 @@ void CStarControlSub13::fn16(int index, const FVector &src, FVector &dest) { FVector CStarControlSub13::fn17(int index, const FVector &src) { FVector dest; - FVector tv; CStarControlSub6 sub6 = getSub1(); - src.fn5(&tv, &sub6); + FVector tv = src.fn5(&sub6); dest._x = (_valArray[index] + tv._x) * _fieldC8 / (_fieldCC * tv._z); @@ -238,9 +234,8 @@ FVector CStarControlSub13::fn17(int index, const FVector &src) { FVector CStarControlSub13::fn18(int index, const FVector &src) { FVector dest; - FVector tv; CStarControlSub6 sub6 = getSub2(); - src.fn5(&tv, &sub6); + FVector tv = src.fn5(&sub6); dest._x = (_valArray[index] + tv._x) * _fieldC8 / (_fieldCC * tv._z); diff --git a/engines/titanic/star_control/star_control_sub6.cpp b/engines/titanic/star_control/star_control_sub6.cpp index 21fb42c1da..0ced3df9fe 100644 --- a/engines/titanic/star_control/star_control_sub6.cpp +++ b/engines/titanic/star_control/star_control_sub6.cpp @@ -38,6 +38,48 @@ CStarControlSub6::CStarControlSub6(const CStarControlSub6 *src) { copyFrom(src); } +CStarControlSub6::CStarControlSub6(const CStarControlSub6 *s1, const CStarControlSub6 *s2) { + _row1._x = s2->_row1._x * s1->_row1._x + + s1->_row1._z * s2->_row3._x + + s1->_row1._y * s2->_row2._x; + _row1._y = s1->_row1._x * s2->_row1._y + + s2->_row3._y * s1->_row1._z + + s2->_row2._y * s1->_row1._y; + _row1._z = s1->_row1._x * s2->_row1._z + + s2->_row3._z * s1->_row1._z + + s2->_row2._z * s1->_row1._y; + _row2._x = s2->_row1._x * s1->_row2._x + + s1->_row2._y * s2->_row2._x + + s1->_row2._z * s2->_row3._x; + _row2._y = s1->_row2._y * s2->_row2._y + + s1->_row2._z * s2->_row3._y + + s2->_row1._y * s1->_row2._x; + _row2._z = s2->_row1._z * s1->_row2._x + + s1->_row2._y * s2->_row2._z + + s1->_row2._z * s2->_row3._z; + _row3._x = s2->_row1._x * s1->_row3._x + + s1->_row3._y * s2->_row2._x + + s1->_row3._z * s2->_row3._x; + _row3._y = s1->_row3._z * s2->_row3._y + + s1->_row3._y * s2->_row2._y + + s2->_row1._y * s1->_row3._x; + _row3._z = s2->_row3._z * s1->_row3._z + + s2->_row2._z * s1->_row3._y + + s2->_row1._z * s1->_row3._x; + _vector._x = s2->_row1._x * s1->_vector._x + + s1->_vector._y * s2->_row2._x + + s1->_vector._z * s2->_row3._x + + s2->_vector._x; + _vector._y = s1->_vector._z * s2->_row3._y + + s1->_vector._y * s2->_row2._y + + s1->_vector._x * s2->_row1._y + + s2->_vector._y; + _vector._z = s1->_vector._y * s2->_row2._z + + s1->_vector._z * s2->_row3._z + + s1->_vector._x * s2->_row1._z + + s2->_vector._z; +} + void CStarControlSub6::init() { _static = nullptr; } @@ -114,51 +156,6 @@ void CStarControlSub6::copyFrom(const FMatrix &src) { _row3 = src._row3; } -CStarControlSub6 *CStarControlSub6::setup(CStarControlSub6 *dest, const CStarControlSub6 *s2, const CStarControlSub6 *s3) { - CStarControlSub6 &d = *dest; - - d._row1._x = s3->_row1._x * s2->_row1._x - + s2->_row1._z * s3->_row3._x - + s2->_row1._y * s3->_row2._x; - d._row1._y = s2->_row1._x * s3->_row1._y - + s3->_row3._y * s2->_row1._z - + s3->_row2._y * s2->_row1._y; - d._row1._z = s2->_row1._x * s3->_row1._z - + s3->_row3._z * s2->_row1._z - + s3->_row2._z * s2->_row1._y; - d._row2._x = s3->_row1._x * s2->_row2._x - + s2->_row2._y * s3->_row2._x - + s2->_row2._z * s3->_row3._x; - d._row2._y = s2->_row2._y * s3->_row2._y - + s2->_row2._z * s3->_row3._y - + s3->_row1._y * s2->_row2._x; - d._row2._z = s3->_row1._z * s2->_row2._x - + s2->_row2._y * s3->_row2._z - + s2->_row2._z * s3->_row3._z; - d._row3._x = s3->_row1._x * s2->_row3._x - + s2->_row3._y * s3->_row2._x - + s2->_row3._z * s3->_row3._x; - d._row3._y = s2->_row3._z * s3->_row3._y - + s2->_row3._y * s3->_row2._y - + s3->_row1._y * s2->_row3._x; - d._row3._z = s3->_row3._z * s2->_row3._z - + s3->_row2._z * s2->_row3._y - + s3->_row1._z * s2->_row3._x; - d._vector._x = s3->_row1._x * s2->_vector._x - + s2->_vector._y * s3->_row2._x - + s2->_vector._z * s3->_row3._x - + s3->_vector._x; - d._vector._y = s2->_vector._z * s3->_row3._y - + s2->_vector._y * s3->_row2._y - + s2->_vector._x * s3->_row1._y - + s3->_vector._y; - d._vector._z = s2->_vector._y * s3->_row2._z - + s2->_vector._z * s3->_row3._z - + s2->_vector._x * s3->_row1._z - + s3->_vector._z; - return dest; -} - void CStarControlSub6::fn4(CStarControlSub6 *sub6) { double v2, v3, v6, v7, v8, v9, v10, v11; double v12, v13, v14, v15, v16, v17, v18; diff --git a/engines/titanic/star_control/star_control_sub6.h b/engines/titanic/star_control/star_control_sub6.h index 61548d11a7..91def29973 100644 --- a/engines/titanic/star_control/star_control_sub6.h +++ b/engines/titanic/star_control/star_control_sub6.h @@ -39,6 +39,7 @@ public: CStarControlSub6(); CStarControlSub6(Axis axis, double amount); CStarControlSub6(const CStarControlSub6 *src); + CStarControlSub6(const CStarControlSub6 *s1, const CStarControlSub6 *s2); /** * Sets an identity matrix @@ -46,11 +47,6 @@ public: void identity(); /** - * Sets up a passed instance from the specified two other ones - */ - static CStarControlSub6 *setup(CStarControlSub6 *dest, const CStarControlSub6 *s2, const CStarControlSub6 *s3); - - /** * Sets a rotation matrix for the given axis for the given amount */ void setRotationMatrix(Axis axis, double val); |