aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2017-05-22 19:58:49 -0400
committerPaul Gilbert2017-05-22 19:58:49 -0400
commit9c28bcf04391456a5a2147a587cac2ea2b8fda66 (patch)
treea529e0ff0355e90af4cf7df2a1b76f573060d139 /engines/titanic
parent44bd75c368814e71666c6054b6600626d2650fa4 (diff)
downloadscummvm-rg350-9c28bcf04391456a5a2147a587cac2ea2b8fda66.tar.gz
scummvm-rg350-9c28bcf04391456a5a2147a587cac2ea2b8fda66.tar.bz2
scummvm-rg350-9c28bcf04391456a5a2147a587cac2ea2b8fda66.zip
TITANIC: Renamed CStarControlSub26 to CMatrixTransform
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/module.mk2
-rw-r--r--engines/titanic/star_control/dmatrix.cpp28
-rw-r--r--engines/titanic/star_control/dmatrix.h4
-rw-r--r--engines/titanic/star_control/matrix_transform.cpp146
-rw-r--r--engines/titanic/star_control/matrix_transform.h (renamed from engines/titanic/star_control/star_control_sub26.h)29
-rw-r--r--engines/titanic/star_control/orientation_changer.cpp4
-rw-r--r--engines/titanic/star_control/orientation_changer.h6
-rw-r--r--engines/titanic/star_control/star_control_sub26.cpp144
8 files changed, 179 insertions, 184 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index e003d48e24..2e53070a8c 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -441,6 +441,7 @@ MODULE_OBJS := \
star_control/frange.o \
star_control/frect.o \
star_control/fvector.o \
+ star_control/matrix_transform.o \
star_control/orientation_changer.o \
star_control/star_camera.o \
star_control/star_closeup.o \
@@ -451,7 +452,6 @@ MODULE_OBJS := \
star_control/star_control_sub22.o \
star_control/star_control_sub23.o \
star_control/star_control_sub24.o \
- star_control/star_control_sub26.o \
star_control/star_control_sub27.o \
star_control/star_field.o \
star_control/star_points1.o \
diff --git a/engines/titanic/star_control/dmatrix.cpp b/engines/titanic/star_control/dmatrix.cpp
index b7ebbc718a..547758a4b7 100644
--- a/engines/titanic/star_control/dmatrix.cpp
+++ b/engines/titanic/star_control/dmatrix.cpp
@@ -22,7 +22,7 @@
#include "titanic/star_control/dmatrix.h"
#include "titanic/star_control/fmatrix.h"
-#include "titanic/star_control/star_control_sub26.h"
+#include "titanic/star_control/matrix_transform.h"
namespace Titanic {
@@ -174,31 +174,31 @@ DMatrix DMatrix::fn1() const {
return m;
}
-void DMatrix::fn3(CStarControlSub26 *sub26) {
+void DMatrix::fn3(const CMatrixTransform &src) {
double v3, v4, v5, v6, v7, v8, v9, v10;
double v11, v12, v13, v14, v15, v16, v17, v18, v19, v20;
- v3 = sub26->fn1();
+ v3 = src.fn1();
if (v3 <= 0.0)
v20 = 0.0;
else
v20 = 2.0 / v3;
- v4 = v20 * sub26->_sub._v1;
- v5 = v20 * sub26->_sub._v2;
- v6 = v20 * sub26->_sub._v3;
- v7 = v4 * sub26->_sub._v1;
+ v4 = v20 * src._vector._x;
+ v5 = v20 * src._vector._y;
+ v6 = v20 * src._vector._z;
+ v7 = v4 * src._vector._x;
v8 = v4;
v9 = v5;
- v10 = v5 * sub26->_sub._v1;
- v11 = v5 * sub26->_sub._v2;
+ v10 = v5 * src._vector._x;
+ v11 = v5 * src._vector._y;
v12 = v6;
- v13 = v8 * sub26->_field0;
+ v13 = v8 * src._field0;
v14 = v12 + v11;
- v15 = v6 * sub26->_sub._v2;
- v16 = v6 * sub26->_field0;
+ v15 = v6 * src._vector._y;
+ v16 = v6 * src._field0;
v17 = v11 + v7;
- v18 = v6 * sub26->_sub._v1;
- v19 = v9 * sub26->_field0;
+ v18 = v6 * src._vector._x;
+ v19 = v9 * src._field0;
_row1._x = 1.0 - v14;
_row1._y = v10 + v16;
_row1._z = v18 - v19;
diff --git a/engines/titanic/star_control/dmatrix.h b/engines/titanic/star_control/dmatrix.h
index cc14c5ebbf..a41fc86ce7 100644
--- a/engines/titanic/star_control/dmatrix.h
+++ b/engines/titanic/star_control/dmatrix.h
@@ -29,7 +29,7 @@
namespace Titanic {
class FMatrix;
-class CStarControlSub26;
+class CMatrixTransform;
/**
* Double based matrix class.
@@ -58,7 +58,7 @@ public:
void setRotationMatrix(Axis axis, double amount);
DMatrix fn1() const;
- void fn3(CStarControlSub26 *sub26);
+ void fn3(const CMatrixTransform &src);
DMatrix fn4(const DMatrix &m);
};
diff --git a/engines/titanic/star_control/matrix_transform.cpp b/engines/titanic/star_control/matrix_transform.cpp
new file mode 100644
index 0000000000..f51b73439d
--- /dev/null
+++ b/engines/titanic/star_control/matrix_transform.cpp
@@ -0,0 +1,146 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/star_control/matrix_transform.h"
+#include "common/textconsole.h"
+
+namespace Titanic {
+
+void CMatrixTransform::setup(double val1, double x, double y, double z) {
+ _field0 = val1;
+ _vector._x = x;
+ _vector._y = y;
+ _vector._z = z;
+}
+
+void CMatrixTransform::copyFrom(const CMatrixTransform &src) {
+ _field0 = src._field0;
+ _vector = src._vector;
+}
+
+double CMatrixTransform::fn1() const {
+ return _vector._x * _vector._x + _vector._y * _vector._y +
+ _vector._z * _vector._z + _field0 * _field0;
+}
+
+double CMatrixTransform::fn2(const CMatrixTransform &src) {
+ return _field0 * src._field0 + _vector._x * src._vector._x
+ + _vector._y * src._vector._y + _vector._z * src._vector._z;
+}
+
+CMatrixTransform CMatrixTransform::resize(double factor) const {
+ CMatrixTransform dest;
+ dest.setup(_field0 * factor, _vector._x * factor, _vector._y * factor,
+ _vector._z * factor);
+ return dest;
+}
+
+void CMatrixTransform::fn4(const DMatrix &m) {
+ double total = m._row1._x + m._row3._z + m._row2._y + 1.0;
+
+ if (total <= 0.00001) {
+ total = m._row3._z;
+
+ if (m._row1._x <= m._row3._z) {
+ if (m._row2._y > total)
+ total = m._row2._y;
+ } else if (m._row1._x > total) {
+ total = m._row1._x;
+ }
+
+ if (total == m._row1._x) {
+ double val1 = sqrt(m._row1._x - -1.0 - m._row2._y - m._row3._z);
+ double val2 = 0.5 / val1;
+ _vector._x = val1 * 0.5;
+ _field0 = (m._row2._z - m._row3._y) * val2;
+ _vector._y = (m._row2._x + m._row1._y) * val2;
+ _vector._z = (m._row3._x + m._row1._z) * val2;
+ } else if (total == m._row2._y) {
+ double val1 = sqrt(m._row2._y - -1.0 - m._row3._z - m._row1._x);
+ double val2 = 0.5 / val1;
+ _vector._y = val1 * 0.5;
+ _field0 = (m._row3._x - m._row1._z) * val2;
+ _vector._z = (m._row3._y + m._row2._z) * val2;
+ _vector._x = (m._row2._x + m._row1._y) * val2;
+ } else if (total == m._row3._z) {
+ double val1 = sqrt(m._row3._z - -1.0 - m._row1._x - m._row2._y);
+ double val2 = 0.5 / val1;
+ _vector._z = val1 * 0.5;
+ _field0 = (m._row1._y - m._row2._x) * val2;
+ _vector._x = (m._row3._x + m._row1._z) * val2;
+ _vector._y = (m._row3._y + m._row2._z) * val2;
+ }
+ } else {
+ double val1 = 0.5 / sqrt(total);
+ _field0 = sqrt(total) * 0.5;
+ _vector._x = (m._row2._z - m._row3._y) * val1;
+ _vector._y = (m._row3._x - m._row1._z) * val1;
+ _vector._z = (m._row1._y - m._row2._x) * val1;
+ }
+}
+
+CMatrixTransform CMatrixTransform::fn5(double percent, const CMatrixTransform &src) {
+ CMatrixTransform sub1 = *this;
+ CMatrixTransform sub2, sub4;
+ CMatrixTransform dest;
+ double val1 = sub1.fn2(src);
+
+ if (val1 < 0.0) {
+ val1 = -val1;
+ sub2.setup(-sub1._field0, -sub1._vector._x, -sub1._vector._y, -sub1._vector._z);
+ sub1 = sub2;
+ }
+
+ if (val1 + 1.0 <= 0.00001) {
+ dest._vector._x = -sub1._vector._y;
+ dest._vector._y = sub1._vector._x;
+ dest._vector._z = -sub1._field0;
+ dest._field0 = sub1._vector._z;
+
+ double sin1 = sin(percent * M_PI);
+ double sin2 = sin((0.5 - percent) * M_PI);
+ dest._vector._x = sin1 * dest._vector._x + sub1._vector._x * sin2;
+ dest._vector._y = sub1._vector._y * sin2 + sub1._vector._x * sin1;
+ dest._vector._z = sin1 * -sub1._field0 + sub1._vector._z * sin2;
+ return dest;
+ }
+
+ CMatrixTransform t1, t2;
+ double val2;
+
+ if (1.0 - val1 <= 0.00001) {
+ val2 = 1.0 - percent;
+ t1 = src.resize(percent);
+ } else {
+ double cosVal = acos(val1);
+ double sinVal = sin(cosVal);
+ val2 = sin((1.0 - percent) * cosVal) / sinVal;
+ t2 = src.resize(sin(cosVal * percent) / sinVal);
+ }
+
+ t2 = sub1.resize(val2);
+ dest.setup(t2._field0 + t1._field0, t1._vector._x + t2._vector._x,
+ t1._vector._y + t2._vector._y, t1._vector._z + t2._vector._z);
+ return dest;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub26.h b/engines/titanic/star_control/matrix_transform.h
index 690a274583..fb7bfd3cc6 100644
--- a/engines/titanic/star_control/star_control_sub26.h
+++ b/engines/titanic/star_control/matrix_transform.h
@@ -20,45 +20,38 @@
*
*/
-#ifndef TITANIC_STAR_CONTROL_SUB26_H
-#define TITANIC_STAR_CONTROL_SUB26_H
+#ifndef TITANIC_MATRIX_TRANSFORM_H
+#define TITANIC_MATRIX_TRANSFORM_H
#include "titanic/star_control/dmatrix.h"
namespace Titanic {
-class CStarControlSub26 {
- struct Sub {
- double _v1;
- double _v2;
- double _v3;
-
- Sub() : _v1(0.0), _v2(0.0), _v3(0.0) {}
- };
+class CMatrixTransform {
private:
- double fn2(const CStarControlSub26 *src);
- const CStarControlSub26 *fn3(const CStarControlSub26 *src, double val);
+ double fn2(const CMatrixTransform &src);
+ CMatrixTransform resize(double factor) const;
public:
double _field0;
- Sub _sub;
+ DVector _vector;
public:
- CStarControlSub26() : _field0(1.0) {}
+ CMatrixTransform() : _field0(1.0) {}
/**
* Sets the field values
*/
- void setup(double val1, double val2, double val3, double val4);
+ void setup(double val1, double x, double y, double z);
/**
* Copies from another instance
*/
- void copyFrom(const CStarControlSub26 *src);
+ void copyFrom(const CMatrixTransform &src);
double fn1() const;
void fn4(const DMatrix &m);
- CStarControlSub26 fn5(double percent, CStarControlSub26 *src);
+ CMatrixTransform fn5(double percent, const CMatrixTransform &src);
};
} // End of namespace Titanic
-#endif /* TITANIC_STAR_CONTROL_SUB26_H */
+#endif /* TITANIC_MATRIX_TRANSFORM_H */
diff --git a/engines/titanic/star_control/orientation_changer.cpp b/engines/titanic/star_control/orientation_changer.cpp
index decbd6b74b..b71ad07b8e 100644
--- a/engines/titanic/star_control/orientation_changer.cpp
+++ b/engines/titanic/star_control/orientation_changer.cpp
@@ -39,10 +39,10 @@ FMatrix COrientationChanger::getOrientation(double percent) {
} else if (percent > 1.0) {
return _maxOrient;
} else {
- CStarControlSub26 sub26 = _sub1.fn5(percent, &_sub2);
+ CMatrixTransform tfm = _sub1.fn5(percent, _sub2);
DMatrix m1;
- m1.fn3(&sub26);
+ m1.fn3(tfm);
return m1;
}
}
diff --git a/engines/titanic/star_control/orientation_changer.h b/engines/titanic/star_control/orientation_changer.h
index fc1a132e9a..a59cb30cc4 100644
--- a/engines/titanic/star_control/orientation_changer.h
+++ b/engines/titanic/star_control/orientation_changer.h
@@ -24,7 +24,7 @@
#define TITANIC_ORIENTATION_CHANGER_H
#include "titanic/star_control/fmatrix.h"
-#include "titanic/star_control/star_control_sub26.h"
+#include "titanic/star_control/matrix_transform.h"
namespace Titanic {
@@ -32,8 +32,8 @@ class COrientationChanger {
public:
FMatrix _minOrient;
FMatrix _maxOrient;
- CStarControlSub26 _sub1;
- CStarControlSub26 _sub2;
+ CMatrixTransform _sub1;
+ CMatrixTransform _sub2;
public:
/**
* Loads the constraints for the minimum and maximum orientation
diff --git a/engines/titanic/star_control/star_control_sub26.cpp b/engines/titanic/star_control/star_control_sub26.cpp
deleted file mode 100644
index 5625457f2a..0000000000
--- a/engines/titanic/star_control/star_control_sub26.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "titanic/star_control/star_control_sub26.h"
-#include "common/textconsole.h"
-
-namespace Titanic {
-
-void CStarControlSub26::setup(double val1, double val2, double val3, double val4) {
- _field0 = val1;
- _sub._v1 = val2;
- _sub._v2 = val3;
- _sub._v3 = val4;
-}
-
-void CStarControlSub26::copyFrom(const CStarControlSub26 *src) {
- _field0 = src->_field0;
- _sub = src->_sub;
-}
-
-double CStarControlSub26::fn1() const {
- return _sub._v1 * _sub._v1 + _sub._v2 * _sub._v2 +
- _sub._v3 * _sub._v3 + _field0 * _field0;
-}
-
-double CStarControlSub26::fn2(const CStarControlSub26 *src) {
- return _field0 * src->_field0 + _sub._v1 * src->_sub._v1
- + _sub._v2 * src->_sub._v2 + _sub._v3 * src->_sub._v3;
-}
-
-const CStarControlSub26 *CStarControlSub26::fn3(const CStarControlSub26 *src, double val) {
- CStarControlSub26::setup(_field0 * val, _sub._v1 * val, _sub._v2 * val, _sub._v3 * val);
- return src;
-}
-
-void CStarControlSub26::fn4(const DMatrix &m) {
- double total = m._row1._x + m._row3._z + m._row2._y + 1.0;
-
- if (total <= 0.00001) {
- total = m._row3._z;
-
- if (m._row1._x <= m._row3._z) {
- if (m._row2._y > total)
- total = m._row2._y;
- } else if (m._row1._x > total) {
- total = m._row1._x;
- }
-
- if (total == m._row1._x) {
- double val1 = sqrt(m._row1._x - -1.0 - m._row2._y - m._row3._z);
- double val2 = 0.5 / val1;
- _sub._v1 = val1 * 0.5;
- _field0 = (m._row2._z - m._row3._y) * val2;
- _sub._v2 = (m._row2._x + m._row1._y) * val2;
- _sub._v3 = (m._row3._x + m._row1._z) * val2;
- } else if (total == m._row2._y) {
- double val1 = sqrt(m._row2._y - -1.0 - m._row3._z - m._row1._x);
- double val2 = 0.5 / val1;
- _sub._v2 = val1 * 0.5;
- _field0 = (m._row3._x - m._row1._z) * val2;
- _sub._v3 = (m._row3._y + m._row2._z) * val2;
- _sub._v1 = (m._row2._x + m._row1._y) * val2;
- } else if (total == m._row3._z) {
- double val1 = sqrt(m._row3._z - -1.0 - m._row1._x - m._row2._y);
- double val2 = 0.5 / val1;
- _sub._v3 = val1 * 0.5;
- _field0 = (m._row1._y - m._row2._x) * val2;
- _sub._v1 = (m._row3._x + m._row1._z) * val2;
- _sub._v2 = (m._row3._y + m._row2._z) * val2;
- }
- } else {
- double val1 = 0.5 / sqrt(total);
- _field0 = sqrt(total) * 0.5;
- _sub._v1 = (m._row2._z - m._row3._y) * val1;
- _sub._v2 = (m._row3._x - m._row1._z) * val1;
- _sub._v3 = (m._row1._y - m._row2._x) * val1;
- }
-}
-
-CStarControlSub26 CStarControlSub26::fn5(double percent, CStarControlSub26 *src) {
- CStarControlSub26 sub1 = *this;
- CStarControlSub26 sub2, sub3, sub4;
- CStarControlSub26 dest;
- double val1 = sub1.fn2(src);
-
- if (val1 < 0.0) {
- val1 = -val1;
- sub2.setup(-sub1._field0, -sub1._sub._v1, -sub1._sub._v2, -sub1._sub._v3);
- sub1 = sub2;
- }
-
- if (val1 + 1.0 <= 0.00001) {
- dest._sub._v1 = -sub1._sub._v2;
- dest._sub._v2 = sub1._sub._v1;
- dest._sub._v3 = -sub1._field0;
- dest._field0 = sub1._sub._v3;
-
- double sin1 = sin(percent * M_PI);
- double sin2 = sin((0.5 - percent) * M_PI);
- dest._sub._v1 = sin1 * dest._sub._v1 + sub1._sub._v1 * sin2;
- dest._sub._v2 = sub1._sub._v2 * sin2 + sub1._sub._v1 * sin1;
- dest._sub._v3 = sin1 * -sub1._field0 + sub1._sub._v3 * sin2;
- return dest;
- } else {
- const CStarControlSub26 *sp;
- double val2;
-
- if (1.0 - val1 <= 0.00001) {
- val2 = 1.0 - percent;
- sp = src->fn3(&sub3, percent);
- } else {
- double cosVal = acos(val1);
- double sinVal = sin(cosVal);
- val2 = sin((1.0 - percent) * cosVal) / sinVal;
- sp = src->fn3(&sub3, sin(cosVal * percent) / sinVal);
- }
-
- const CStarControlSub26 *sp2 = sub1.fn3(&sub4, val2);
- dest.setup(sp2->_field0 + sp->_field0, sp->_sub._v1 + sp2->_sub._v1,
- sp->_sub._v2 + sp2->_sub._v2, sp->_sub._v3 + sp2->_sub._v3);
- return dest;
- }
-}
-
-} // End of namespace Titanic