aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/star_control/dmatrix.cpp186
-rw-r--r--engines/titanic/star_control/dmatrix.h8
-rw-r--r--engines/titanic/star_control/dvector.cpp6
-rw-r--r--engines/titanic/star_control/fmatrix.cpp6
-rw-r--r--engines/titanic/star_control/matrix_transform.cpp50
-rw-r--r--engines/titanic/star_control/star_camera.cpp80
6 files changed, 168 insertions, 168 deletions
diff --git a/engines/titanic/star_control/dmatrix.cpp b/engines/titanic/star_control/dmatrix.cpp
index 296851b829..4f9b22d6a5 100644
--- a/engines/titanic/star_control/dmatrix.cpp
+++ b/engines/titanic/star_control/dmatrix.cpp
@@ -29,28 +29,28 @@ namespace Titanic {
DMatrix *DMatrix::_static;
DMatrix::DMatrix() :
- _row1(0.0, 0.0, 0.0), _row2(0.0, 0.0, 0.0), _row3(0.0, 0.0, 0.0) {
+ _col1(0.0, 0.0, 0.0), _col2(0.0, 0.0, 0.0), _col3(0.0, 0.0, 0.0) {
}
DMatrix::DMatrix(int mode, const DVector &src) {
switch (mode) {
case 0:
- _row1._x = 1.0;
- _row2._y = 1.0;
- _row3._z = 1.0;
- _row4 = src;
+ _col1._x = 1.0;
+ _col2._y = 1.0;
+ _col3._z = 1.0;
+ _col4 = src;
break;
case 1:
- _row1._x = src._x;
- _row2._y = src._y;
- _row3._z = src._z;
+ _col1._x = src._x;
+ _col2._y = src._y;
+ _col3._z = src._z;
break;
default:
- _row1._x = 1.0;
- _row2._y = 1.0;
- _row3._z = 1.0;
+ _col1._x = 1.0;
+ _col2._y = 1.0;
+ _col3._z = 1.0;
break;
}
}
@@ -60,9 +60,9 @@ DMatrix::DMatrix(Axis axis, double amount) {
}
DMatrix::DMatrix(const FMatrix &src) {
- _row1 = src._row1;
- _row2 = src._row2;
- _row3 = src._row3;
+ _col1 = src._row1;
+ _col2 = src._row2;
+ _col3 = src._row3;
}
void DMatrix::init() {
@@ -81,27 +81,27 @@ void DMatrix::setRotationMatrix(Axis axis, double amount) {
switch (axis) {
case X_AXIS:
- _row1._x = 1.0;
- _row2._y = cosVal;
- _row2._z = sinVal;
- _row3._y = -sinVal;
- _row3._z = cosVal;
+ _col1._x = 1.0;
+ _col2._y = cosVal;
+ _col2._z = sinVal;
+ _col3._y = -sinVal;
+ _col3._z = cosVal;
break;
case Y_AXIS:
- _row1._x = cosVal;
- _row1._z = sinVal;
- _row2._y = 1.0;
- _row3._x = -sinVal;
- _row3._z = cosVal;
+ _col1._x = cosVal;
+ _col1._z = sinVal;
+ _col2._y = 1.0;
+ _col3._x = -sinVal;
+ _col3._z = cosVal;
break;
case Z_AXIS:
- _row1._x = cosVal;
- _row1._y = sinVal;
- _row2._x = -sinVal;
- _row2._y = cosVal;
- _row3._z = 1.0;
+ _col1._x = cosVal;
+ _col1._y = sinVal;
+ _col2._x = -sinVal;
+ _col2._y = cosVal;
+ _col3._z = 1.0;
break;
default:
@@ -110,7 +110,7 @@ void DMatrix::setRotationMatrix(Axis axis, double amount) {
}
DMatrix DMatrix::fn1() const {
- double val1 = _row1._x * _row3._z * _row2._y;
+ double val1 = _col1._x * _col3._z * _col2._y;
double val2 = 0.0;
double val3 = val1;
@@ -119,29 +119,29 @@ DMatrix DMatrix::fn1() const {
val1 = 0.0;
}
- double val4 = _row3._x * _row1._y * _row2._z;
+ double val4 = _col3._x * _col1._y * _col2._z;
if (val4 < 0.0)
val2 = val2 + val4;
else
val1 = val1 + val4;
- double val5 = _row3._y * _row1._z * _row2._x;
+ double val5 = _col3._y * _col1._z * _col2._x;
if (val5 < 0.0)
val2 = val2 + val5;
else
val1 = val1 + val5;
- if (-(_row3._x * _row2._y * _row1._z) < 0.0)
- val2 = val2 - _row3._x * _row2._y * _row1._z;
+ if (-(_col3._x * _col2._y * _col1._z) < 0.0)
+ val2 = val2 - _col3._x * _col2._y * _col1._z;
else
- val1 = val1 - _row3._x * _row2._y * _row1._z;
- if (-(_row1._y * _row3._z * _row2._x) < 0.0)
- val2 = val2 - _row1._y * _row3._z * _row2._x;
+ val1 = val1 - _col3._x * _col2._y * _col1._z;
+ if (-(_col1._y * _col3._z * _col2._x) < 0.0)
+ val2 = val2 - _col1._y * _col3._z * _col2._x;
else
- val1 = val1 - _row1._y * _row3._z * _row2._x;
+ val1 = val1 - _col1._y * _col3._z * _col2._x;
- val3 = _row3._y * _row2._z;
- double val6 = -(_row1._x * val3);
+ val3 = _col3._y * _col2._z;
+ double val6 = -(_col1._x * val3);
if (val6 < 0.0)
val2 = val2 + val6;
else
@@ -150,26 +150,26 @@ DMatrix DMatrix::fn1() const {
double val7 = val2 + val1;
assert(!(val7 == 0.0 || fabs(val7 / (val1 - val2)) < 1.0e-10));
- double val8 = _row3._z * _row2._y;
+ double val8 = _col3._z * _col2._y;
double val9 = 1.0 / val7;
DMatrix m;
- m._row1._x = (val8 - val3) * val9;
- m._row2._x = -((_row3._z * _row2._x - _row3._x * _row2._z) * val9);
- m._row3._x = (_row3._y * _row2._x - _row3._x * _row2._y) * val9;
- m._row1._y = -((_row1._y * _row3._z - _row3._y * _row1._z) * val9);
- m._row2._y = (_row1._x * _row3._z - _row3._x * _row1._z) * val9;
- m._row3._y = -((_row1._x * _row3._y - _row3._x * _row1._y) * val9);
- m._row1._z = (_row1._y * _row2._z - _row2._y * _row1._z) * val9;
- m._row2._z = -((_row1._x * _row2._z - _row1._z * _row2._x) * val9);
- m._row3._z = (_row1._x * _row2._y - _row1._y * _row2._x) * val9;
-
- m._row4._x = -(m._row1._x * _row4._x + _row4._y * m._row2._x
- + _row4._z * m._row3._x);
- m._row4._y = -(_row4._z * m._row3._y + _row4._y * m._row2._y
- + _row4._x * m._row1._y);
- m._row4._z = -(_row4._z * m._row3._z + _row4._x * m._row1._z
- + _row4._y * m._row2._z);
+ m._col1._x = (val8 - val3) * val9;
+ m._col2._x = -((_col3._z * _col2._x - _col3._x * _col2._z) * val9);
+ m._col3._x = (_col3._y * _col2._x - _col3._x * _col2._y) * val9;
+ m._col1._y = -((_col1._y * _col3._z - _col3._y * _col1._z) * val9);
+ m._col2._y = (_col1._x * _col3._z - _col3._x * _col1._z) * val9;
+ m._col3._y = -((_col1._x * _col3._y - _col3._x * _col1._y) * val9);
+ m._col1._z = (_col1._y * _col2._z - _col2._y * _col1._z) * val9;
+ m._col2._z = -((_col1._x * _col2._z - _col1._z * _col2._x) * val9);
+ m._col3._z = (_col1._x * _col2._y - _col1._y * _col2._x) * val9;
+
+ m._col4._x = -(m._col1._x * _col4._x + _col4._y * m._col2._x
+ + _col4._z * m._col3._x);
+ m._col4._y = -(_col4._z * m._col3._y + _col4._y * m._col2._y
+ + _col4._x * m._col1._y);
+ m._col4._z = -(_col4._z * m._col3._z + _col4._x * m._col1._z
+ + _col4._y * m._col2._z);
return m;
}
@@ -187,46 +187,46 @@ void DMatrix::loadTransform(const CMatrixTransform &src) {
double val5 = temp1V._y * src._field0;
double val6 = temp1V._z * src._field0;
- _row1._x = 1.0 - (temp2V._z + temp2V._y);
- _row1._y = val1 + val6;
- _row1._z = val2 - val5;
- _row2._x = val1 - val6;
- _row2._y = 1.0 - (temp2V._z + temp2V._x);
- _row2._z = val3 + val4;
- _row3._x = val2 + val5;
- _row3._y = val3 - val4;
- _row3._z = 1.0 - (temp2V._y + temp2V._x);
- _row4._x = 0;
- _row4._y = 0;
- _row4._z = 0;
+ _col1._x = 1.0 - (temp2V._z + temp2V._y);
+ _col1._y = val1 + val6;
+ _col1._z = val2 - val5;
+ _col2._x = val1 - val6;
+ _col2._y = 1.0 - (temp2V._z + temp2V._x);
+ _col2._z = val3 + val4;
+ _col3._x = val2 + val5;
+ _col3._y = val3 - val4;
+ _col3._z = 1.0 - (temp2V._y + temp2V._x);
+ _col4._x = 0;
+ _col4._y = 0;
+ _col4._z = 0;
}
DMatrix DMatrix::fn4(const DMatrix &m) {
DMatrix dm;
- dm._row1._x = m._row3._x * _row1._z + m._row2._x * _row1._y
- + m._row1._x * _row1._x;
- dm._row1._y = _row1._x * m._row1._y + m._row3._y * _row1._z
- + m._row2._y * _row1._y;
- dm._row1._z = _row1._x * m._row1._z + m._row3._z * _row1._z
- + m._row2._z * _row1._y;
- dm._row2._x = m._row1._x * _row2._x + _row2._y * m._row2._x
- + _row2._z * m._row3._x;
- dm._row2._y = _row2._y * m._row2._y + _row2._z * m._row3._y
- + m._row1._y * _row2._x;
- dm._row2._z = m._row1._z * _row2._x + _row2._y * m._row2._z
- + _row2._z * m._row3._z;
- dm._row3._x = m._row1._x * _row3._x + _row3._y * m._row2._x
- + _row3._z * m._row3._x;
- dm._row3._y = _row3._y * m._row2._y + _row3._z * m._row3._y
- + m._row1._y * _row3._x;
- dm._row3._z = m._row2._z * _row3._y + m._row3._z * _row3._z
- + m._row1._z * _row3._x;
- dm._row4._x = m._row1._x * _row4._x + _row4._y * m._row2._x
- + _row4._z * m._row3._x + m._row4._x;
- dm._row4._y = _row4._z * m._row3._y + _row4._y * m._row2._y
- + _row4._x * m._row1._y + m._row4._y;
- dm._row4._z = _row4._y * m._row2._z + _row4._x * m._row1._z
- + _row4._z * m._row3._z + m._row4._z;
+ dm._col1._x = m._col3._x * _col1._z + m._col2._x * _col1._y
+ + m._col1._x * _col1._x;
+ dm._col1._y = _col1._x * m._col1._y + m._col3._y * _col1._z
+ + m._col2._y * _col1._y;
+ dm._col1._z = _col1._x * m._col1._z + m._col3._z * _col1._z
+ + m._col2._z * _col1._y;
+ dm._col2._x = m._col1._x * _col2._x + _col2._y * m._col2._x
+ + _col2._z * m._col3._x;
+ dm._col2._y = _col2._y * m._col2._y + _col2._z * m._col3._y
+ + m._col1._y * _col2._x;
+ dm._col2._z = m._col1._z * _col2._x + _col2._y * m._col2._z
+ + _col2._z * m._col3._z;
+ dm._col3._x = m._col1._x * _col3._x + _col3._y * m._col2._x
+ + _col3._z * m._col3._x;
+ dm._col3._y = _col3._y * m._col2._y + _col3._z * m._col3._y
+ + m._col1._y * _col3._x;
+ dm._col3._z = m._col2._z * _col3._y + m._col3._z * _col3._z
+ + m._col1._z * _col3._x;
+ dm._col4._x = m._col1._x * _col4._x + _col4._y * m._col2._x
+ + _col4._z * m._col3._x + m._col4._x;
+ dm._col4._y = _col4._z * m._col3._y + _col4._y * m._col2._y
+ + _col4._x * m._col1._y + m._col4._y;
+ dm._col4._z = _col4._y * m._col2._z + _col4._x * m._col1._z
+ + _col4._z * m._col3._z + m._col4._z;
return dm;
}
diff --git a/engines/titanic/star_control/dmatrix.h b/engines/titanic/star_control/dmatrix.h
index 1cc36167df..45837ce19a 100644
--- a/engines/titanic/star_control/dmatrix.h
+++ b/engines/titanic/star_control/dmatrix.h
@@ -39,10 +39,10 @@ class DMatrix {
private:
static DMatrix *_static;
public:
- DVector _row1;
- DVector _row2;
- DVector _row3;
- DVector _row4;
+ DVector _col1;
+ DVector _col2;
+ DVector _col3;
+ DVector _col4;
public:
static void init();
static void deinit();
diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp
index 23d601eca9..3f09b12500 100644
--- a/engines/titanic/star_control/dvector.cpp
+++ b/engines/titanic/star_control/dvector.cpp
@@ -42,9 +42,9 @@ double DVector::getDistance(const DVector &src) {
DVector DVector::fn1(const DMatrix &m) {
DVector dest;
- dest._x = m._row3._x * _z + m._row2._x * _y + m._row1._x * _x + m._row4._x;
- dest._y = m._row2._y * _y + m._row3._y * _z + m._row1._y * _x + m._row4._y;
- dest._z = m._row3._z * _z + m._row2._z * _y + m._row1._z * _x + m._row4._z;
+ dest._x = m._col3._x * _z + m._col2._x * _y + m._col1._x * _x + m._col4._x;
+ dest._y = m._col2._y * _y + m._col3._y * _z + m._col1._y * _x + m._col4._y;
+ dest._z = m._col3._z * _z + m._col2._z * _y + m._col1._z * _x + m._col4._z;
return dest;
}
diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp
index ca351972e8..bf5754af91 100644
--- a/engines/titanic/star_control/fmatrix.cpp
+++ b/engines/titanic/star_control/fmatrix.cpp
@@ -40,9 +40,9 @@ FMatrix::FMatrix(const FMatrix &src) {
}
void FMatrix::copyFrom(const DMatrix &src) {
- _row1 = src._row1;
- _row2 = src._row2;
- _row3 = src._row3;
+ _row1 = src._col1;
+ _row2 = src._col2;
+ _row3 = src._col3;
}
void FMatrix::load(SimpleFile *file, int param) {
diff --git a/engines/titanic/star_control/matrix_transform.cpp b/engines/titanic/star_control/matrix_transform.cpp
index 9de21e42aa..20cadd580f 100644
--- a/engines/titanic/star_control/matrix_transform.cpp
+++ b/engines/titanic/star_control/matrix_transform.cpp
@@ -55,46 +55,46 @@ CMatrixTransform CMatrixTransform::resize(double factor) const {
}
void CMatrixTransform::fn4(const DMatrix &m) {
- double total = m._row1._x + m._row3._z + m._row2._y + 1.0;
+ double total = m._col1._x + m._col3._z + m._col2._y + 1.0;
if (total <= 0.00001) {
- total = m._row3._z;
+ total = m._col3._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 (m._col1._x <= m._col3._z) {
+ if (m._col2._y > total)
+ total = m._col2._y;
+ } else if (m._col1._x > total) {
+ total = m._col1._x;
}
- if (total == m._row1._x) {
- double val1 = sqrt(m._row1._x - -1.0 - m._row2._y - m._row3._z);
+ if (total == m._col1._x) {
+ double val1 = sqrt(m._col1._x - -1.0 - m._col2._y - m._col3._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);
+ _field0 = (m._col2._z - m._col3._y) * val2;
+ _vector._y = (m._col2._x + m._col1._y) * val2;
+ _vector._z = (m._col3._x + m._col1._z) * val2;
+ } else if (total == m._col2._y) {
+ double val1 = sqrt(m._col2._y - -1.0 - m._col3._z - m._col1._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);
+ _field0 = (m._col3._x - m._col1._z) * val2;
+ _vector._z = (m._col3._y + m._col2._z) * val2;
+ _vector._x = (m._col2._x + m._col1._y) * val2;
+ } else if (total == m._col3._z) {
+ double val1 = sqrt(m._col3._z - -1.0 - m._col1._x - m._col2._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;
+ _field0 = (m._col1._y - m._col2._x) * val2;
+ _vector._x = (m._col3._x + m._col1._z) * val2;
+ _vector._y = (m._col3._y + m._col2._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;
+ _vector._x = (m._col2._z - m._col3._y) * val1;
+ _vector._y = (m._col3._x - m._col1._z) * val1;
+ _vector._z = (m._col1._y - m._col2._x) * val1;
}
}
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index c715daf356..d3487e2f65 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -465,10 +465,10 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
DVector tempV2 = _viewport._position;
DMatrix m4;
- m4._row1 = viewport->_position;
- m4._row2 = DVector(0.0, 0.0, 0.0);
- m4._row3 = DVector(0.0, 0.0, 0.0);
- m4._row4 = DVector(0.0, 0.0, 0.0);
+ m4._col1 = viewport->_position;
+ m4._col2 = DVector(0.0, 0.0, 0.0);
+ m4._col3 = DVector(0.0, 0.0, 0.0);
+ m4._col4 = DVector(0.0, 0.0, 0.0);
FMatrix m5 = viewport->getOrientation();
double yVal1 = m5._row1._y * 1000000.0;
@@ -476,39 +476,39 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
double xVal1 = m5._row2._x * 1000000.0;
double yVal2 = m5._row2._y * 1000000.0;
double zVal2 = m5._row2._z * 1000000.0;
- double zVal3 = zVal1 + m4._row1._z;
- double yVal3 = yVal1 + m4._row1._y;
- double xVal2 = m5._row1._x * 1000000.0 + m4._row1._x;
- double zVal4 = zVal2 + m4._row1._z;
- double yVal4 = yVal2 + m4._row1._y;
- double xVal3 = xVal1 + m4._row1._x;
+ double zVal3 = zVal1 + m4._col1._z;
+ double yVal3 = yVal1 + m4._col1._y;
+ double xVal2 = m5._row1._x * 1000000.0 + m4._col1._x;
+ double zVal4 = zVal2 + m4._col1._z;
+ double yVal4 = yVal2 + m4._col1._y;
+ double xVal3 = xVal1 + m4._col1._x;
DVector tempV4(xVal2, yVal3, zVal3);
DVector tempV3(xVal3, yVal4, zVal4);
- m4._row3 = tempV4;
+ m4._col3 = tempV4;
FVector tempV5;
tempV5._x = m5._row3._x * 1000000.0;
tempV5._y = m5._row3._y * 1000000.0;
- m4._row2 = tempV3;
+ m4._col2 = tempV3;
- tempV3._x = tempV5._x + m4._row1._x;
- tempV3._y = tempV5._y + m4._row1._y;
- tempV3._z = m5._row3._z * 1000000.0 + m4._row1._z;
- m4._row4 = tempV3;
+ tempV3._x = tempV5._x + m4._col1._x;
+ tempV3._y = tempV5._y + m4._col1._y;
+ tempV3._z = m5._row3._z * 1000000.0 + m4._col1._z;
+ m4._col4 = tempV3;
tempV2 = tempV2.fn1(m2);
- m4._row1 = m4._row1.fn1(m2);
- m4._row3 = m4._row3.fn1(m2);
- m4._row2 = m4._row2.fn1(m2);
- m4._row4 = m4._row4.fn1(m2);
+ m4._col1 = m4._col1.fn1(m2);
+ m4._col3 = m4._col3.fn1(m2);
+ m4._col2 = m4._col2.fn1(m2);
+ m4._col4 = m4._col4.fn1(m2);
// Find the angle that gives the minimum distance
DVector tempPos;
double minDistance = 1.0e20;
int minDegree = 0;
for (int degree = 0; degree < 360; ++degree) {
- tempPos = m4._row1;
+ tempPos = m4._col1;
tempPos.fn2((double)degree);
double distance = tempV2.getDistance(tempPos);
@@ -518,25 +518,25 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
}
}
- m4._row1.fn2((double)minDegree);
- m4._row2.fn2((double)minDegree);
- m4._row3.fn2((double)minDegree);
- m4._row4.fn2((double)minDegree);
- m4._row1 = m4._row1.fn1(m1);
- m4._row2 = m4._row2.fn1(m1);
- m4._row3 = m4._row3.fn1(m1);
- m4._row4 = m4._row4.fn1(m1);
-
- m4._row3 -= m4._row1;
- m4._row2 -= m4._row1;
- m4._row4 -= m4._row1;
-
- m4._row3.normalize();
- m4._row2.normalize();
- m4._row4.normalize();
- m5.set(m4._row3, m4._row2, m4._row4);
-
- FVector newPos = m4._row1;
+ m4._col1.fn2((double)minDegree);
+ m4._col2.fn2((double)minDegree);
+ m4._col3.fn2((double)minDegree);
+ m4._col4.fn2((double)minDegree);
+ m4._col1 = m4._col1.fn1(m1);
+ m4._col2 = m4._col2.fn1(m1);
+ m4._col3 = m4._col3.fn1(m1);
+ m4._col4 = m4._col4.fn1(m1);
+
+ m4._col3 -= m4._col1;
+ m4._col2 -= m4._col1;
+ m4._col4 -= m4._col1;
+
+ m4._col3.normalize();
+ m4._col2.normalize();
+ m4._col4.normalize();
+ m5.set(m4._col3, m4._col2, m4._col4);
+
+ FVector newPos = m4._col1;
FMatrix m6 = _viewport.getOrientation();
_mover->proc8(_viewport._position, newPos, m6, m5);