Skip to content
Permalink
Browse files

TITANIC: Implementing CStarControlSub12 class

  • Loading branch information
dreammaster committed Mar 19, 2017
1 parent 26eb320 commit 2a76819b0fe1ccea9ba8093dc900490576dbe1fc
@@ -78,10 +78,10 @@ void FMatrix::identity() {
_row3 = FVector(0.0, 0.0, 1.0);
}

void FMatrix::set(FVector *row1, FVector *row2, FVector *row3) {
_row1 = *row1;
_row2 = *row2;
_row3 = *row3;
void FMatrix::set(const FVector &row1, const FVector &row2, const FVector &row3) {
_row1 = row1;
_row2 = row2;
_row3 = row3;
}

void FMatrix::fn1(const FVector &v) {
@@ -72,7 +72,7 @@ class FMatrix {
/**
* Sets the data for the matrix
*/
void set(FVector *row1, FVector *row2, FVector *row3);
void set(const FVector &row1, const FVector &row2, const FVector &row3);

void fn1(const FVector &v);
void fn2(const FMatrix &m);
@@ -65,7 +65,7 @@ double FVector::getDistance(const FVector *src) const {
return sqrt(xd * xd + yd * yd + zd * zd);
}

void FVector::fn5(FVector *dest, const CStarControlSub6 *sub6) const {
FVector FVector::fn5(const CStarControlSub6 *sub6) const {
error("TODO: FVector::fn5");
}

@@ -71,7 +71,7 @@ class FVector {
*/
double getDistance(const FVector *src) const;

void fn5(FVector *dest, const CStarControlSub6 *sub6) const;
FVector fn5(const CStarControlSub6 *sub6) const;

/**
* Returns true if the passed vector equals this one
@@ -215,8 +215,103 @@ FVector CStarControlSub12::proc31(int index, const FVector &v) {
return _sub13.fn18(index, v);
}

void CStarControlSub12::setViewportPosition(const FPoint &pt) {
// TODO
void CStarControlSub12::setViewportPosition(const FPoint &angles) {
if (isLocked())
return;

if (_currentIndex == -1) {
CStarControlSub6 subX(X_AXIS, angles._x);
CStarControlSub6 subY(Y_AXIS, angles._y);
CStarControlSub6 sub(&subX, &subY);
subY.copyFrom(&sub);
proc22(subY);
} else if (_currentIndex == 0) {
FVector row1 = _matrix._row1;
CStarControlSub6 subX(X_AXIS, angles._x);
CStarControlSub6 subY(Y_AXIS, angles._y);
CStarControlSub6 sub(&subX, &subY);
subX.copyFrom(&sub);

FMatrix m1 = _sub13.getMatrix();
FVector tempV1 = _sub13._position;
FVector tempV2, tempV3, tempV4, tempV5, tempV6;
tempV2._y = m1._row1._y * 100000.0;
tempV2._z = m1._row1._z * 100000.0;
tempV3._x = m1._row1._x * 100000.0 + tempV1._x;
tempV4._x = tempV3._x;
tempV3._y = tempV2._y + tempV1._y;
tempV4._y = tempV3._y;
tempV3._z = tempV2._z + tempV1._z;
tempV4._z = tempV3._z;
tempV2._x = m1._row2._x * 100000.0;
tempV2._y = m1._row2._y * 100000.0;
tempV2._z = m1._row2._z * 100000.0;
tempV2._x = m1._row3._x * 100000.0;
tempV2._y = m1._row3._y * 100000.0;
tempV2._z = m1._row3._z * 100000.0;
tempV2._x = tempV2._x + tempV1._x;
tempV2._y = tempV2._y + tempV1._y;
tempV2._z = tempV2._z + tempV1._z;
tempV3._x = tempV2._x + tempV1._x;
tempV3._y = tempV2._y + tempV1._y;
tempV5._x = tempV2._x;
tempV5._y = tempV2._y;
tempV3._z = tempV2._z + tempV1._z;
tempV5._z = tempV2._z;
tempV6._x = tempV3._x;
tempV6._y = tempV3._y;
tempV6._z = tempV3._z;
tempV1._x = tempV1._x - row1._x;
tempV1._y = tempV1._y - row1._y;
tempV1._z = tempV1._z - row1._z;
tempV4._x = tempV3._x - row1._x;
tempV4._y = tempV4._y - row1._y;
tempV4._z = tempV4._z - row1._z;
tempV5._x = tempV2._x - row1._x;

tempV5._y = tempV5._y - row1._y;
tempV5._z = tempV5._z - row1._z;
tempV6._x = tempV3._x - row1._x;
tempV6._y = tempV6._y - row1._y;
tempV6._z = tempV6._z - row1._z;

FVector modV1 = tempV1.fn5(&subX);
FVector modV2 = tempV4.fn5(&subX);
FVector modV3 = tempV5.fn5(&subX);
FVector modV4 = tempV6.fn5(&subX);
tempV1 = modV1;
tempV4 = modV2;
tempV5 = modV3;
tempV4 = modV4;

tempV2._x = tempV4._x - tempV1._x;
tempV2._y = tempV4._y - tempV1._y;
tempV2._z = tempV4._z - tempV1._z;
tempV4._x = tempV2._x;
tempV4._y = tempV2._y;
tempV2._x = tempV5._x - tempV1._x;
tempV4._z = tempV2._z;
tempV5._x = tempV2._x;
tempV2._y = tempV5._y - tempV1._y;
tempV5._y = tempV2._y;
tempV2._z = tempV5._z - tempV1._z;
tempV5._z = tempV2._z;
tempV2._x = tempV6._x - tempV1._x;
tempV2._y = tempV6._y - tempV1._y;
tempV2._z = tempV6._z - tempV1._z;
tempV6 = tempV2;

tempV4.normalize();
tempV5.normalize();
tempV6.normalize();
tempV1 += row1;

m1.set(tempV4, tempV5, tempV6);
_sub13.setMatrix(m1);
_sub13.setPosition(tempV1);
} else if (_currentIndex == 1) {
// TODO
}
}

bool CStarControlSub12::setArrayVector(const FVector &v) {
@@ -39,7 +39,7 @@ class CStarControlSub12 {
static FMatrix *_matrix2;
private:
int _currentIndex;
FVector _array[3];
FMatrix _matrix;
CStarControlSub20 *_handlerP;
CStarControlSub13 _sub13;
int _field108;
@@ -100,7 +100,7 @@ class CStarControlSub12 {
/**
* Sets the viewport position within the starfield
*/
virtual void setViewportPosition(const FPoint &pt);
virtual void setViewportPosition(const FPoint &angles);

virtual int getCurrentIndex() const { return _currentIndex; }
virtual bool setArrayVector(const FVector &v);
@@ -116,8 +116,7 @@ void CStarControlSub13::setPosition(const FVector &v) {
}

void CStarControlSub13::setPosition(const CStarControlSub6 *sub6) {
FVector vector;
_position.fn5(&vector, sub6);
_position.fn5(sub6);
_position = sub6->_row1;
_flag = false;
}
@@ -163,12 +162,10 @@ void CStarControlSub13::fn12() {
CStarControlSub6 m2(Y_AXIS, g_vm->getRandomNumber(359));
CStarControlSub6 m3(Z_AXIS, g_vm->getRandomNumber(359));

CStarControlSub6 s1, s2;
CStarControlSub6 *s;
s = CStarControlSub6::setup(&s1, &m1, &m2);
s = CStarControlSub6::setup(&s2, s, &m3);
CStarControlSub6 s1(&m1, &m2);
CStarControlSub6 s2(&s1, &m3);

m1.copyFrom(*s);
m1.copyFrom(s2);
_matrix.fn2(m1);
_flag = false;
}
@@ -225,9 +222,8 @@ void CStarControlSub13::fn16(int index, const FVector &src, FVector &dest) {

FVector CStarControlSub13::fn17(int index, const FVector &src) {
FVector dest;
FVector tv;
CStarControlSub6 sub6 = getSub1();
src.fn5(&tv, &sub6);
FVector tv = src.fn5(&sub6);

dest._x = (_valArray[index] + tv._x)
* _fieldC8 / (_fieldCC * tv._z);
@@ -238,9 +234,8 @@ FVector CStarControlSub13::fn17(int index, const FVector &src) {

FVector CStarControlSub13::fn18(int index, const FVector &src) {
FVector dest;
FVector tv;
CStarControlSub6 sub6 = getSub2();
src.fn5(&tv, &sub6);
FVector tv = src.fn5(&sub6);

dest._x = (_valArray[index] + tv._x)
* _fieldC8 / (_fieldCC * tv._z);
@@ -38,6 +38,48 @@ CStarControlSub6::CStarControlSub6(const CStarControlSub6 *src) {
copyFrom(src);
}

CStarControlSub6::CStarControlSub6(const CStarControlSub6 *s1, const CStarControlSub6 *s2) {
_row1._x = s2->_row1._x * s1->_row1._x
+ s1->_row1._z * s2->_row3._x
+ s1->_row1._y * s2->_row2._x;
_row1._y = s1->_row1._x * s2->_row1._y
+ s2->_row3._y * s1->_row1._z
+ s2->_row2._y * s1->_row1._y;
_row1._z = s1->_row1._x * s2->_row1._z
+ s2->_row3._z * s1->_row1._z
+ s2->_row2._z * s1->_row1._y;
_row2._x = s2->_row1._x * s1->_row2._x
+ s1->_row2._y * s2->_row2._x
+ s1->_row2._z * s2->_row3._x;
_row2._y = s1->_row2._y * s2->_row2._y
+ s1->_row2._z * s2->_row3._y
+ s2->_row1._y * s1->_row2._x;
_row2._z = s2->_row1._z * s1->_row2._x
+ s1->_row2._y * s2->_row2._z
+ s1->_row2._z * s2->_row3._z;
_row3._x = s2->_row1._x * s1->_row3._x
+ s1->_row3._y * s2->_row2._x
+ s1->_row3._z * s2->_row3._x;
_row3._y = s1->_row3._z * s2->_row3._y
+ s1->_row3._y * s2->_row2._y
+ s2->_row1._y * s1->_row3._x;
_row3._z = s2->_row3._z * s1->_row3._z
+ s2->_row2._z * s1->_row3._y
+ s2->_row1._z * s1->_row3._x;
_vector._x = s2->_row1._x * s1->_vector._x
+ s1->_vector._y * s2->_row2._x
+ s1->_vector._z * s2->_row3._x
+ s2->_vector._x;
_vector._y = s1->_vector._z * s2->_row3._y
+ s1->_vector._y * s2->_row2._y
+ s1->_vector._x * s2->_row1._y
+ s2->_vector._y;
_vector._z = s1->_vector._y * s2->_row2._z
+ s1->_vector._z * s2->_row3._z
+ s1->_vector._x * s2->_row1._z
+ s2->_vector._z;
}

void CStarControlSub6::init() {
_static = nullptr;
}
@@ -114,51 +156,6 @@ void CStarControlSub6::copyFrom(const FMatrix &src) {
_row3 = src._row3;
}

CStarControlSub6 *CStarControlSub6::setup(CStarControlSub6 *dest, const CStarControlSub6 *s2, const CStarControlSub6 *s3) {
CStarControlSub6 &d = *dest;

d._row1._x = s3->_row1._x * s2->_row1._x
+ s2->_row1._z * s3->_row3._x
+ s2->_row1._y * s3->_row2._x;
d._row1._y = s2->_row1._x * s3->_row1._y
+ s3->_row3._y * s2->_row1._z
+ s3->_row2._y * s2->_row1._y;
d._row1._z = s2->_row1._x * s3->_row1._z
+ s3->_row3._z * s2->_row1._z
+ s3->_row2._z * s2->_row1._y;
d._row2._x = s3->_row1._x * s2->_row2._x
+ s2->_row2._y * s3->_row2._x
+ s2->_row2._z * s3->_row3._x;
d._row2._y = s2->_row2._y * s3->_row2._y
+ s2->_row2._z * s3->_row3._y
+ s3->_row1._y * s2->_row2._x;
d._row2._z = s3->_row1._z * s2->_row2._x
+ s2->_row2._y * s3->_row2._z
+ s2->_row2._z * s3->_row3._z;
d._row3._x = s3->_row1._x * s2->_row3._x
+ s2->_row3._y * s3->_row2._x
+ s2->_row3._z * s3->_row3._x;
d._row3._y = s2->_row3._z * s3->_row3._y
+ s2->_row3._y * s3->_row2._y
+ s3->_row1._y * s2->_row3._x;
d._row3._z = s3->_row3._z * s2->_row3._z
+ s3->_row2._z * s2->_row3._y
+ s3->_row1._z * s2->_row3._x;
d._vector._x = s3->_row1._x * s2->_vector._x
+ s2->_vector._y * s3->_row2._x
+ s2->_vector._z * s3->_row3._x
+ s3->_vector._x;
d._vector._y = s2->_vector._z * s3->_row3._y
+ s2->_vector._y * s3->_row2._y
+ s2->_vector._x * s3->_row1._y
+ s3->_vector._y;
d._vector._z = s2->_vector._y * s3->_row2._z
+ s2->_vector._z * s3->_row3._z
+ s2->_vector._x * s3->_row1._z
+ s3->_vector._z;
return dest;
}

void CStarControlSub6::fn4(CStarControlSub6 *sub6) {
double v2, v3, v6, v7, v8, v9, v10, v11;
double v12, v13, v14, v15, v16, v17, v18;
@@ -39,17 +39,13 @@ class CStarControlSub6 : public FMatrix {
CStarControlSub6();
CStarControlSub6(Axis axis, double amount);
CStarControlSub6(const CStarControlSub6 *src);
CStarControlSub6(const CStarControlSub6 *s1, const CStarControlSub6 *s2);

/**
* Sets an identity matrix
*/
void identity();

/**
* Sets up a passed instance from the specified two other ones
*/
static CStarControlSub6 *setup(CStarControlSub6 *dest, const CStarControlSub6 *s2, const CStarControlSub6 *s3);

/**
* Sets a rotation matrix for the given axis for the given amount
*/

0 comments on commit 2a76819

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