Skip to content
Permalink
Browse files

TITANIC: Finished CStarControlSub24 class

  • Loading branch information
dreammaster committed Mar 23, 2017
1 parent 710b48a commit 530aa6c9a04e2b14fda0538fc094028dec6a6d6e
@@ -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;
@@ -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);
}
@@ -56,7 +56,7 @@ class FVector {
/**
* 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 @@ class FVector {
/**
* 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 @@ class FVector {
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;
@@ -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;
@@ -58,7 +58,7 @@ class CStarControlSub20 : public CStar20Data {
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);

/**
@@ -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);
@@ -37,7 +37,7 @@ class CStarControlSub21 : public CStarControlSub20 {

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
@@ -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);
@@ -36,7 +36,7 @@ class CStarControlSub22 : public CStarControlSub20 {
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
@@ -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) {
@@ -46,10 +46,8 @@ class CStarControlSub23 {
int _field4C;
Common::Array<double> _powers;
int _field54;
int _field58;
double _field5C;
double _field58;
double _field60;
double _field64;
CStarControlSub25 _sub25;
public:
CStarControlSub23();
@@ -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
@@ -33,7 +33,7 @@ class CStarControlSub24 : public CStarControlSub23 {

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
@@ -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
@@ -36,6 +36,7 @@ class CStarControlSub25 {
CStarControlSub26 _sub2;
public:
void fn1(const FMatrix &m1, const FMatrix &m2);
void fn2(double val, FMatrix &m);
};

} // End of namespace Titanic

0 comments on commit 530aa6c

Please sign in to comment.
You can’t perform that action at this time.