[Scummvm-git-logs] scummvm master -> 5a44168de6550e10df18b24beec98bf4e1aebf93

dreammaster dreammaster at scummvm.org
Mon Mar 20 04:25:57 CET 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5a44168de6 TITANIC: Finished CStarControlSub12 setViewportPosition


Commit: 5a44168de6550e10df18b24beec98bf4e1aebf93
    https://github.com/scummvm/scummvm/commit/5a44168de6550e10df18b24beec98bf4e1aebf93
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-03-19T23:25:47-04:00

Commit Message:
TITANIC: Finished CStarControlSub12 setViewportPosition

Changed paths:
    engines/titanic/star_control/dvector.cpp
    engines/titanic/star_control/dvector.h
    engines/titanic/star_control/fmatrix.cpp
    engines/titanic/star_control/fmatrix.h
    engines/titanic/star_control/fvector.cpp
    engines/titanic/star_control/fvector.h
    engines/titanic/star_control/star_control_sub12.cpp


diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp
index dc13765..9cd610f 100644
--- a/engines/titanic/star_control/dvector.cpp
+++ b/engines/titanic/star_control/dvector.cpp
@@ -38,8 +38,9 @@ double DVector::getDistance(const DVector &src) {
 	return sqrt((src._x - _x) * (src._x - _x) + (src._y - _y) * (src._y - _y) + (src._z - _z) * (src._z - _z));
 }
 
-void DVector::fn1(DVector &dest, const DMatrix &m) {
+DVector *DVector::fn1(DVector &dest, const DMatrix &m) {
 	// TODO
+	return nullptr;
 }
 
 void DVector::fn2(double val) {
diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h
index a216be1..a447f25 100644
--- a/engines/titanic/star_control/dvector.h
+++ b/engines/titanic/star_control/dvector.h
@@ -48,11 +48,45 @@ public:
 	 */
 	double getDistance(const DVector &src);
 
-	void fn1(DVector &dest, const DMatrix &m);
+	DVector *fn1(DVector &dest, const DMatrix &m);
 	void fn2(double val);
 	void fn3(DVector &dest);
 	const DMatrix *fn4(const DVector &v, DMatrix &m);
 	void fn5(DMatrix &dest);
+
+	/**
+	 * Returns true if the passed vector equals this one
+	 */
+	bool operator==(const DVector &src) const {
+		return _x != src._x || _y != src._y || _z != src._z;
+	}
+
+	/**
+	 * Returns true if the passed vector does not equal this one
+	 */
+	bool operator!=(const DVector &src) const {
+		return !operator==(src);
+	}
+
+	DVector operator+(const DVector &delta) const {
+		return DVector(_x + delta._x, _y + delta._y, _z + delta._z);
+	}
+
+	DVector operator-(const DVector &delta) const {
+		return DVector(_x - delta._x, _y - delta._y, _z - delta._z);
+	}
+
+	void operator+=(const DVector &delta) {
+		_x += delta._x;
+		_y += delta._y;
+		_z += delta._z;
+	}
+
+	void operator-=(const DVector &delta) {
+		_x -= delta._x;
+		_y -= delta._y;
+		_z -= delta._z;
+	}
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp
index 02da115..6efd09c 100644
--- a/engines/titanic/star_control/fmatrix.cpp
+++ b/engines/titanic/star_control/fmatrix.cpp
@@ -84,6 +84,12 @@ void FMatrix::set(const FVector &row1, const FVector &row2, const FVector &row3)
 	_row3 = row3;
 }
 
+void FMatrix::set(const DVector &row1, const DVector &row2, const DVector &row3) {
+	_row1 = row1;
+	_row2 = row2;
+	_row3 = row3;
+}
+
 void FMatrix::fn1(const FVector &v) {
 	_row3._x = v._x;
 
diff --git a/engines/titanic/star_control/fmatrix.h b/engines/titanic/star_control/fmatrix.h
index 6fa847f..d4a5a33 100644
--- a/engines/titanic/star_control/fmatrix.h
+++ b/engines/titanic/star_control/fmatrix.h
@@ -29,6 +29,7 @@
 namespace Titanic {
 
 class DMatrix;
+class DVector;
 
 /**
  * Floating point matrix class.
@@ -74,6 +75,11 @@ public:
 	 */
 	void set(const FVector &row1, const FVector &row2, const FVector &row3);
 
+	/**
+	 * Sets the data for the matrix
+	 */
+	void set(const DVector &row1, const DVector &row2, const DVector &row3);
+
 	void fn1(const FVector &v);
 	void fn2(const FMatrix &m);
 	void fn3(const FMatrix &m);
diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp
index 92c17a0..91f358f 100644
--- a/engines/titanic/star_control/fvector.cpp
+++ b/engines/titanic/star_control/fvector.cpp
@@ -21,12 +21,16 @@
  */
 
 #include "titanic/star_control/fvector.h"
+#include "titanic/star_control/dvector.h"
 #include "titanic/star_control/star_control_sub6.h"
 #include "common/algorithm.h"
 #include "common/textconsole.h"
 
 namespace Titanic {
 
+FVector::FVector(const DVector &src) : _x(src._x), _y(src._y), _z(src._z) {
+}
+
 void FVector::fn1(FVector *v) {
 	v->_x = (ABS(_x - _y) < 0.00001 && ABS(_y - _z) < 0.00001 &&
 		ABS(_x - _z) < 0.00001) ? -_x : _x;
diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h
index 4582072..79ddf75 100644
--- a/engines/titanic/star_control/fvector.h
+++ b/engines/titanic/star_control/fvector.h
@@ -30,6 +30,7 @@ namespace Titanic {
 enum Axis { X_AXIS, Y_AXIS, Z_AXIS };
 
 class CStarControlSub6;
+class DVector;
 
 /**
  * Floating point vector class.
@@ -41,6 +42,7 @@ public:
 public:
 	FVector() : _x(0), _y(0), _z(0) {}
 	FVector(double x, double y, double z) : _x(x), _y(y), _z(z) {}
+	FVector(const DVector &src);
 
 	/**
 	 * Clears the vector
diff --git a/engines/titanic/star_control/star_control_sub12.cpp b/engines/titanic/star_control/star_control_sub12.cpp
index 4e6a6bc..254b2a8 100644
--- a/engines/titanic/star_control/star_control_sub12.cpp
+++ b/engines/titanic/star_control/star_control_sub12.cpp
@@ -23,6 +23,8 @@
 #include "titanic/star_control/star_control_sub12.h"
 #include "titanic/star_control/star_control_sub21.h"
 #include "titanic/star_control/star_control_sub22.h"
+#include "titanic/star_control/dmatrix.h"
+#include "titanic/star_control/fmatrix.h"
 
 namespace Titanic {
 
@@ -310,7 +312,81 @@ void CStarControlSub12::setViewportPosition(const FPoint &angles) {
 		_sub13.setMatrix(m1);
 		_sub13.setPosition(tempV1);
 	} else if (_currentIndex == 1) {
-		// TODO
+		FVector tempV2;
+		DMatrix m1, m2, sub;
+		DVector mrow1, mrow2, mrow3;
+		DVector tempV1, diffV, multV, multV2, tempV3, tempV4, tempV5, tempV6, tempV7;
+		DVector tempV8, tempV9, tempV10, tempV11, tempV12;
+		DVector tempV13, tempV14, tempV15, tempV16;
+
+		DMatrix subX(0, _matrix._row1);
+		DMatrix subY(Y_AXIS, angles._x);
+
+		tempV1 = _matrix._row2 - _matrix._row1;
+		diffV = tempV1;
+		diffV.fn5(m1);
+		sub.fn4(sub, m1, subX);
+		m1 = sub;
+		m1.fn1(subX);
+		subX.fn4(m2, subX, subY);
+		subX = m2;
+
+		FMatrix m3 = _sub13.getMatrix();
+		tempV2 = _sub13._position;
+		multV._x = m3._row1._x * 1000000.0;
+		multV._y = m3._row1._y * 1000000.0;
+		multV._z = m3._row1._z * 1000000.0;
+		tempV3._x = tempV2._x;
+		tempV3._y = tempV2._y;
+		tempV3._z = tempV2._z;
+		multV2._z = m3._row2._z * 1000000.0;
+
+		tempV1._x = multV._x + tempV3._x;
+		tempV1._y = multV._y + tempV3._y;
+		tempV1._z = multV._z + tempV3._z;
+		mrow3._z = 0.0;
+		mrow3._y = 0.0;
+		mrow3._x = 0.0;
+		multV2._x = m3._row2._x * 1000000.0;
+		multV2._y = m3._row2._y * 1000000.0;
+		mrow1 = tempV1;
+		multV = multV2 + tempV3;
+		mrow2 = multV;
+
+		tempV7._z = m3._row3._z * 1000000.0 + tempV3._z;
+		tempV7._y = m3._row3._y * 1000000.0 + tempV3._y;
+		tempV7._x = m3._row3._x * 1000000.0 + tempV3._x;
+
+		mrow3 = tempV8;
+		DVector *v = tempV3.fn1(tempV9, subX);
+		tempV3 = *v;
+		v = mrow1.fn1(tempV10, subX);
+		mrow1 = *v;
+		v = mrow2.fn1(tempV11, subX);
+		mrow2 = *v;
+		v = mrow3.fn1(tempV12, subX);
+		mrow3 = *v;
+
+		v = tempV3.fn1(tempV13, m1);
+		tempV3 = *v;
+		v = mrow1.fn1(tempV14, m1);
+		mrow1 = *v;
+		v = mrow2.fn1(tempV15, m1);
+		mrow2 = *v;
+		v = mrow3.fn1(tempV16, m1);
+		mrow3 = *v;
+
+		mrow1 -= tempV3;
+		mrow2 -= tempV3;
+		mrow3 -= tempV3;
+		mrow1.normalize();
+		mrow2.normalize();
+		mrow3.normalize();
+		tempV16 = tempV3;
+
+		m3.set(mrow1, mrow2, mrow3);
+		_sub13.setMatrix(m3);
+		_sub13.setPosition(tempV16);
 	}
 }
 





More information about the Scummvm-git-logs mailing list