diff options
author | Paul Gilbert | 2017-03-22 20:52:33 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-03-22 20:52:33 -0400 |
commit | 530aa6c9a04e2b14fda0538fc094028dec6a6d6e (patch) | |
tree | a414f7eb27e50864d055ad54fbb483682be1295a /engines/titanic | |
parent | 710b48a6ff43da0546a824dc38fb77c6c9c5b576 (diff) | |
download | scummvm-rg350-530aa6c9a04e2b14fda0538fc094028dec6a6d6e.tar.gz scummvm-rg350-530aa6c9a04e2b14fda0538fc094028dec6a6d6e.tar.bz2 scummvm-rg350-530aa6c9a04e2b14fda0538fc094028dec6a6d6e.zip |
TITANIC: Finished CStarControlSub24 class
Diffstat (limited to 'engines/titanic')
19 files changed, 189 insertions, 48 deletions
diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp index 6efd09cdb7..54e674cad8 100644 --- a/engines/titanic/star_control/fmatrix.cpp +++ b/engines/titanic/star_control/fmatrix.cpp @@ -100,13 +100,13 @@ void FMatrix::fn1(const FVector &v) { _row2._y = tempVector._y; _row2._z = tempVector._z; - _row3.crossProduct(&tempVector, &_row2); + _row3.crossProduct(tempVector, _row2); _row1._x = _row2._x; _row1._y = _row2._y; _row1._z = _row2._z; _row1.normalize(); - _row3.crossProduct(&tempVector, &_row1); + _row3.crossProduct(tempVector, _row1); _row2._x = _row1._x; _row2._y = _row1._y; _row2._z = _row1._z; diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp index 91f358f3fc..666b22eb3a 100644 --- a/engines/titanic/star_control/fvector.cpp +++ b/engines/titanic/star_control/fvector.cpp @@ -38,10 +38,10 @@ void FVector::fn1(FVector *v) { v->_z = _z; } -void FVector::crossProduct(FVector *dest, const FVector *src) { - dest->_x = (src->_z * _y) - (_z * src->_y); - dest->_y = (src->_x * _z) - (_x * src->_z); - dest->_z = (src->_y * _x) - (_y * src->_x); +void FVector::crossProduct(FVector &dest, const FVector &src) { + dest._x = (src._z * _y) - (_z * src._y); + dest._y = (src._x * _z) - (_x * src._z); + dest._z = (src._y * _x) - (_y * src._x); } double FVector::normalize() { @@ -54,17 +54,18 @@ double FVector::normalize() { return hyp; } -void FVector::addAndNormalize(FVector *dest, const FVector *v1, const FVector *v2) { - FVector tempVector(v1->_x + v2->_x, v1->_y + v2->_y, v1->_z + v2->_z); +const FVector *FVector::addAndNormalize(FVector &dest, const FVector &v1, const FVector &v2) { + FVector tempVector(v1._x + v2._x, v1._y + v2._y, v1._z + v2._z); tempVector.normalize(); - *dest = tempVector; + dest = tempVector; + return &dest; } -double FVector::getDistance(const FVector *src) const { - double xd = src->_x - _x; - double yd = src->_y - _y; - double zd = src->_z - _z; +double FVector::getDistance(const FVector &src) const { + double xd = src._x - _x; + double yd = src._y - _y; + double zd = src._z - _z; return sqrt(xd * xd + yd * yd + zd * zd); } diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h index 79ddf7509a..67eba6b5c9 100644 --- a/engines/titanic/star_control/fvector.h +++ b/engines/titanic/star_control/fvector.h @@ -56,7 +56,7 @@ public: /** * Calculates the cross-product between this matrix and a passed one */ - void crossProduct(FVector *dest, const FVector *src); + void crossProduct(FVector &dest, const FVector &src); /** * Normalizes the vector so the length from origin equals 1.0 @@ -66,12 +66,12 @@ public: /** * Adds two vectors together and then normalizes the result */ - static void addAndNormalize(FVector *dest, const FVector *v1, const FVector *v2); + static const FVector *addAndNormalize(FVector &dest, const FVector &v1, const FVector &v2); /** * Returns the distance between a specified point and this one */ - double getDistance(const FVector *src) const; + double getDistance(const FVector &src) const; FVector fn5(const CStarControlSub6 *sub6) const; @@ -97,6 +97,10 @@ public: return FVector(_x - delta._x, _y - delta._y, _z - delta._z); } + const FVector operator*(double right) const { + return FVector(_x * right, _y * right, _z * right); + } + void operator+=(const FVector &delta) { _x += delta._x; _y += delta._y; diff --git a/engines/titanic/star_control/star_control_sub20.cpp b/engines/titanic/star_control/star_control_sub20.cpp index 955a855841..fd12573fac 100644 --- a/engines/titanic/star_control/star_control_sub20.cpp +++ b/engines/titanic/star_control/star_control_sub20.cpp @@ -90,7 +90,7 @@ void CStarControlSub20::proc7() { } } -void CStarControlSub20::proc11(CErrorCode &errorCode, FVector &v, const FMatrix &m) { +void CStarControlSub20::proc11(CErrorCode &errorCode, FVector &v, FMatrix &m) { if (_size > 0.0) { v._x += m._row3._x * _size; v._y += m._row3._y * _size; diff --git a/engines/titanic/star_control/star_control_sub20.h b/engines/titanic/star_control/star_control_sub20.h index 5d7e8c0009..eed5e94ad1 100644 --- a/engines/titanic/star_control/star_control_sub20.h +++ b/engines/titanic/star_control/star_control_sub20.h @@ -58,7 +58,7 @@ public: virtual void proc8(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2) {} virtual void proc9(FVector &v1, FVector &v2, FMatrix &matrix) {} virtual void proc10(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m) {} - virtual void proc11(CErrorCode &errorCode, FVector &v, const FMatrix &m); + virtual void proc11(CErrorCode &errorCode, FVector &v, FMatrix &m); virtual void setVector(CStarVector *sv); /** diff --git a/engines/titanic/star_control/star_control_sub21.cpp b/engines/titanic/star_control/star_control_sub21.cpp index c81d5911db..a70460aa53 100644 --- a/engines/titanic/star_control/star_control_sub21.cpp +++ b/engines/titanic/star_control/star_control_sub21.cpp @@ -53,7 +53,7 @@ void CStarControlSub21::proc10(const FVector &v1, const FVector &v2, const FVect incLockCount(); } -void CStarControlSub21::proc11(CErrorCode &errorCode, FVector &v, const FMatrix &m) { +void CStarControlSub21::proc11(CErrorCode &errorCode, FVector &v, FMatrix &m) { if (_sub24.get8()) { decLockCount(); int val = _sub24.proc5(errorCode, v, m); diff --git a/engines/titanic/star_control/star_control_sub21.h b/engines/titanic/star_control/star_control_sub21.h index 66ce535993..17e0a427a6 100644 --- a/engines/titanic/star_control/star_control_sub21.h +++ b/engines/titanic/star_control/star_control_sub21.h @@ -37,7 +37,7 @@ public: virtual void proc9(FVector &v1, FVector &v2, FMatrix &matrix); virtual void proc10(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m); - virtual void proc11(CErrorCode &errorCode, FVector &v, const FMatrix &m); + virtual void proc11(CErrorCode &errorCode, FVector &v, FMatrix &m); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub22.cpp b/engines/titanic/star_control/star_control_sub22.cpp index b5962bc225..68681c0a6f 100644 --- a/engines/titanic/star_control/star_control_sub22.cpp +++ b/engines/titanic/star_control/star_control_sub22.cpp @@ -37,7 +37,7 @@ void CStarControlSub22::proc8(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2 incLockCount(); } -void CStarControlSub22::proc11(CErrorCode &errorCode, FVector &v, const FMatrix &m) { +void CStarControlSub22::proc11(CErrorCode &errorCode, FVector &v, FMatrix &m) { if (_sub27.get8()) { decLockCount(); int val = _sub27.proc5(errorCode, v, m); diff --git a/engines/titanic/star_control/star_control_sub22.h b/engines/titanic/star_control/star_control_sub22.h index 61f60b10f1..704cfa7d6c 100644 --- a/engines/titanic/star_control/star_control_sub22.h +++ b/engines/titanic/star_control/star_control_sub22.h @@ -36,7 +36,7 @@ public: virtual ~CStarControlSub22() {} virtual void proc8(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2); - virtual void proc11(CErrorCode &errorCode, FVector &v, const FMatrix &m); + virtual void proc11(CErrorCode &errorCode, FVector &v, FMatrix &m); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub23.cpp b/engines/titanic/star_control/star_control_sub23.cpp index 4587fd3e27..ad4cb65f8a 100644 --- a/engines/titanic/star_control/star_control_sub23.cpp +++ b/engines/titanic/star_control/star_control_sub23.cpp @@ -37,10 +37,8 @@ CStarControlSub23::CStarControlSub23() : _row1(0.0, 1000000.0, 0.0) { _field48 = 0; _field4C = 0; _field54 = 0; - _field58 = 0; - _field5C = 0; - _field60 = 0; - _field64 = 0; + _field58 = 0.0; + _field60 = 0.0; } void CStarControlSub23::proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2) { @@ -52,7 +50,7 @@ void CStarControlSub23::proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2 _field58 = 0; _field8 = 0; _field34 = 0; - _field5C = 1.875; + _field58 = 1.0; _field40 = -1; _field44 = -1; _field48 = -1; @@ -62,11 +60,10 @@ void CStarControlSub23::proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2 void CStarControlSub23::proc3(const FMatrix &m1, const FMatrix &m2) { _row1.clear(); _row2.clear(); - _field58 = 0; + _field58 = 1.0; _field24 = 0.0; _field8 = 0; _field34 = 0; - _field5C = 1.875; } void CStarControlSub23::proc4(FVector &v1, FVector &v2, FMatrix &m) { @@ -82,8 +79,7 @@ void CStarControlSub23::proc4(FVector &v1, FVector &v2, FMatrix &m) { _field44 = -1; _field48 = -1; _field4C = -1; - _field58 = 0; - _field5C = 1.875; + _field58 = 1.0; } void CStarControlSub23::proc6(int val1, int val2, float val) { diff --git a/engines/titanic/star_control/star_control_sub23.h b/engines/titanic/star_control/star_control_sub23.h index 9e90e021a2..d8233ec91d 100644 --- a/engines/titanic/star_control/star_control_sub23.h +++ b/engines/titanic/star_control/star_control_sub23.h @@ -46,10 +46,8 @@ protected: int _field4C; Common::Array<double> _powers; int _field54; - int _field58; - double _field5C; + double _field58; double _field60; - double _field64; CStarControlSub25 _sub25; public: CStarControlSub23(); diff --git a/engines/titanic/star_control/star_control_sub24.cpp b/engines/titanic/star_control/star_control_sub24.cpp index 27f29b41ca..28b69f71a7 100644 --- a/engines/titanic/star_control/star_control_sub24.cpp +++ b/engines/titanic/star_control/star_control_sub24.cpp @@ -26,18 +26,142 @@ namespace Titanic { void CStarControlSub24::proc3(const FMatrix &m1, const FMatrix &m2) { - + CStarControlSub23::proc3(m1, m2); + _sub25.fn1(m1, m2); + _field60 = 0.1; + _field58 = 0.0; + _field40 = _field44 = _field48 = -1; + _field8 = 1; } void CStarControlSub24::proc4(FVector &v1, FVector &v2, FMatrix &m) { CStarControlSub23::proc4(v1, v2, m); - // TODO + if (_field24 > 8000.0) { + _field8 = 1; + _field34 = 1; + proc6(120, 4, _field24 - 8000.0); + } + + FVector row3 = m._row3; + double mult = _row3._x * row3._x + _row3._y * row3._y+ _row3._z * row3._z; + _field58 = 1.0; + + bool flag = false; + if (mult < 1.0) { + if (mult >= 1.0 - 1.0e-10) + flag = true; + } else { + if (mult <= 1.0 + 1.0e-10) + flag = true; + } + + if (!flag) { + const FVector *tv; + FVector tempV1, tempV2; + FVector::addAndNormalize(tempV1, row3, _row3); + tv = FVector::addAndNormalize(tempV2, row3, tempV1); + tempV1 = *tv; + + tv = FVector::addAndNormalize(tempV2, row3, tempV1); + tempV1 = *tv; + + tv = FVector::addAndNormalize(tempV2, row3, tempV1); + tempV1 = *tv; + + FMatrix m1; + m1.fn1(tempV1); + _sub25.fn1(m, m1); + + _field58 = 0.0; + _field60 = 0.1; + _field8 = 1; + } } -int CStarControlSub24::proc5(CErrorCode &errorCode, FVector &v, const FMatrix &m) { - // TODO - return 0; +int CStarControlSub24::proc5(CErrorCode &errorCode, FVector &v, FMatrix &m) { + FVector v1, v2, v3, v4; + const FVector *tv; + + if (_field8) + return 0; + + if (_field58 < 1.0) { + _sub25.fn2(_field60 + _field58, m); + errorCode.set(); + return 1; + } + + if (!_field34) { + _field8 = 0; + return 2; + } + + v2 = m._row3; + v3 = _row2 - v; + v3.normalize(); + + double val = m._row3._x * v3._x + m._row3._y * v3._y + m._row3._z * v3._z; + bool flag = false; + if (val > 1.0) { + if (val >= 1.0 - 1.0e-10) + flag = true; + } else { + if (val <= 1.0 + 1.0e-10) + flag = true; + } + + if (!flag) { + v2.addAndNormalize(v1, v2, v3); + tv = v2.addAndNormalize(v4, v2, v1); + v1 = *tv; + tv = v2.addAndNormalize(v4, v2, v1); + v1 = *tv; + tv = v2.addAndNormalize(v4, v2, v1); + v1 = *tv; + + m.fn1(v1); + v2 = v1; + } + + if (_field40 >= 0) { + double powVal = _powers[_field40]; + v1 = v2 * powVal; + v += v1; + + --_field40; + errorCode.set(); + return 1; + } + + if (_field44 > 0) { + v1._z = v2._z * _field38; + v1._x = v2._x * _field38; + v._x = v1._x + v._x; + v._y = v2._y * _field38 + v._y; + v._z = v1._z + v._z; + + --_field44; + errorCode.set(); + return 1; + } + + if (_field48 >= 0) { + double powVal = _powers[31 - _field48]; + v1._y = v2._y * powVal; + v1._z = v2._z * powVal; + v1._x = v2._x * powVal; + v._y = v1._y + v._y; + v._z = v1._z + v._z; + v._x = v._x + v1._x; + + --_field48; + errorCode.set(); + return 1; + } + + _field8 = 0; + return 2; } } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub24.h b/engines/titanic/star_control/star_control_sub24.h index 34b9cf4eac..16f53610ec 100644 --- a/engines/titanic/star_control/star_control_sub24.h +++ b/engines/titanic/star_control/star_control_sub24.h @@ -33,7 +33,7 @@ public: virtual void proc3(const FMatrix &m1, const FMatrix &m2); virtual void proc4(FVector &v1, FVector &v2, FMatrix &m); - virtual int proc5(CErrorCode &errorCode, FVector &v, const FMatrix &m); + virtual int proc5(CErrorCode &errorCode, FVector &v, FMatrix &m); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub25.cpp b/engines/titanic/star_control/star_control_sub25.cpp index 73c72e6a77..a8e13473f2 100644 --- a/engines/titanic/star_control/star_control_sub25.cpp +++ b/engines/titanic/star_control/star_control_sub25.cpp @@ -21,7 +21,7 @@ */ #include "titanic/star_control/star_control_sub25.h" -#include "common/textconsole.h" +#include "titanic/star_control/dmatrix.h" namespace Titanic { @@ -31,4 +31,19 @@ void CStarControlSub25::fn1(const FMatrix &m1, const FMatrix &m2) { } +void CStarControlSub25::fn2(double val, FMatrix &m) { + if (val < 0.0) { + m = _matrix1; + } else if (val > 1.0) { + m = _matrix2; + } else { + CStarControlSub26 sub26; + sub26.fn5(val, &_sub2, &sub26); + + DMatrix m1; + m1.fn3(&sub26); + m = m1; + } +} + } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub25.h b/engines/titanic/star_control/star_control_sub25.h index 85692cf62d..cb7d61023e 100644 --- a/engines/titanic/star_control/star_control_sub25.h +++ b/engines/titanic/star_control/star_control_sub25.h @@ -36,6 +36,7 @@ public: CStarControlSub26 _sub2; public: void fn1(const FMatrix &m1, const FMatrix &m2); + void fn2(double val, FMatrix &m); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub26.cpp b/engines/titanic/star_control/star_control_sub26.cpp index 546a3e9fae..91dd1576f9 100644 --- a/engines/titanic/star_control/star_control_sub26.cpp +++ b/engines/titanic/star_control/star_control_sub26.cpp @@ -42,4 +42,8 @@ void CStarControlSub26::copyFrom(const CStarControlSub26 *src) { _sub = src->_sub; } +void CStarControlSub26::fn5(double val, CStarControlSub26 *s1, CStarControlSub26 *s2) { + // TODO +} + } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub26.h b/engines/titanic/star_control/star_control_sub26.h index 9023da906c..670007efa8 100644 --- a/engines/titanic/star_control/star_control_sub26.h +++ b/engines/titanic/star_control/star_control_sub26.h @@ -50,7 +50,7 @@ public: void copyFrom(const CStarControlSub26 *src); double fn1() const; - + void fn5(double val, CStarControlSub26 *s1, CStarControlSub26 *s2); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub27.cpp b/engines/titanic/star_control/star_control_sub27.cpp index 706e947a05..e9559b250b 100644 --- a/engines/titanic/star_control/star_control_sub27.cpp +++ b/engines/titanic/star_control/star_control_sub27.cpp @@ -37,12 +37,10 @@ void CStarControlSub27::proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2 if (m1 != m2) { _sub25.fn1(m1, m2); - _field58 = 0; - _field5C = 0.0; + _field58 = 0.0; if (_field4C == 0) { - _field60 = -1.5881868e-23; - _field64 = 1.4499999; + _field60 = 0.1; _field8 = 1; } else { _field60 = 1.0 / (double)v24; @@ -51,7 +49,7 @@ void CStarControlSub27::proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2 } } -int CStarControlSub27::proc5(CErrorCode &errorCode, FVector &v, const FMatrix &m) { +int CStarControlSub27::proc5(CErrorCode &errorCode, FVector &v, FMatrix &m) { // TODO return 0; } diff --git a/engines/titanic/star_control/star_control_sub27.h b/engines/titanic/star_control/star_control_sub27.h index 801591294e..f8aa3d6ce7 100644 --- a/engines/titanic/star_control/star_control_sub27.h +++ b/engines/titanic/star_control/star_control_sub27.h @@ -32,7 +32,7 @@ public: virtual ~CStarControlSub27() {} virtual void proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2); - virtual int proc5(CErrorCode &errorCode, FVector &v, const FMatrix &m); + virtual int proc5(CErrorCode &errorCode, FVector &v, FMatrix &m); }; } // End of namespace Titanic |