diff options
author | Paul Gilbert | 2016-07-16 08:50:42 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-17 13:09:46 -0400 |
commit | e1695101bc464fe1a4917f7cd25db38854c923e0 (patch) | |
tree | 49ff507aa4e625f576846f100c72ef76aa29a676 | |
parent | 7553b81d8694fe05b5ba29893f3578b3d43aed68 (diff) | |
download | scummvm-rg350-e1695101bc464fe1a4917f7cd25db38854c923e0.tar.gz scummvm-rg350-e1695101bc464fe1a4917f7cd25db38854c923e0.tar.bz2 scummvm-rg350-e1695101bc464fe1a4917f7cd25db38854c923e0.zip |
TITANIC: Beginnings of matrix and vector classes
14 files changed, 304 insertions, 84 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index de82f1d968..9dfbc92986 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -417,10 +417,15 @@ MODULE_OBJS := \ sound/water_lapping_sounds.o \ sound/wave_file.o \ star_control/star_control.o \ - star_control/star_control_sub1.o \ - star_control/star_control_sub2.o \ star_control/base_star.o \ + star_control/dmatrix.o \ + star_control/dvector.o \ + star_control/fmatrix.o \ + star_control/fpoint.o \ + star_control/fvector.o \ star_control/star_array.o \ + star_control/star_control_sub1.o \ + star_control/star_control_sub2.o \ star_control/star_control_sub4.o \ star_control/star_control_sub5.o \ star_control/star_control_sub6.o \ @@ -430,8 +435,6 @@ MODULE_OBJS := \ star_control/star_view.o \ star_control/star_control_sub12.o \ star_control/star_control_sub13.o \ - star_control/star_control_sub14.o \ - star_control/star_control_sub15.o \ star_control/star_control_sub20.o \ star_control/star_control_sub21.o \ star_control/star_control_sub22.o \ diff --git a/engines/titanic/star_control/star_control_sub15.cpp b/engines/titanic/star_control/dmatrix.cpp index a6eb2e88fa..160dccafe1 100644 --- a/engines/titanic/star_control/star_control_sub15.cpp +++ b/engines/titanic/star_control/dmatrix.cpp @@ -20,17 +20,14 @@ * */ -#include "titanic/star_control/star_control_sub15.h" +#include "titanic/star_control/dmatrix.h" namespace Titanic { -CStarControlSub15::CStarControlSub15() : - _field0(1.875), _field8(0), _fieldC(0), - _field10(0), _field14(0), _field18(0.0), _field1C(0), - _field20(1.875), _field28(0), _field2C(0), - _field30(0), _field38(0), _field3C(0), - _field40(1.875), _field48(0), _field4C(0), - _field50(0), _field54(0), _field58(0), _field5C(0) { +DMatrix::DMatrix() : + _row1(1.0, 0.0, 0.0), _row2(0.0, 1.0, 0.0), _row3(0.0, 0.0, 1.0), + _row4(0.0, 0.0, 0.0) { } + } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub15.h b/engines/titanic/star_control/dmatrix.h index faf68f1b87..8c5eeeb584 100644 --- a/engines/titanic/star_control/star_control_sub15.h +++ b/engines/titanic/star_control/dmatrix.h @@ -20,38 +20,23 @@ * */ -#ifndef TITANIC_STAR_CONTROL_SUB15_H -#define TITANIC_STAR_CONTROL_SUB15_H +#ifndef TITANIC_DMATRIX_H +#define TITANIC_DMATRIX_H + +#include "titanic/star_control/dvector.h" namespace Titanic { -class CStarControlSub15 { +class DMatrix { private: - double _field0; - int _field8; - int _fieldC; - int _field10; - int _field14; - double _field18; - int _field1C; - double _field20; - int _field24; - int _field28; - int _field2C; - double _field30; - int _field38; - int _field3C; - double _field40; - int _field48; - int _field4C; - int _field50; - int _field54; - int _field58; - int _field5C; + DVector _row1; + DVector _row2; + DVector _row3; + DVector _row4; public: - CStarControlSub15(); + DMatrix(); }; } // End of namespace Titanic -#endif /* TITANIC_STAR_CONTROL_SUB15_H */ +#endif /* TITANIC_DMATRIX_H */ diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp new file mode 100644 index 0000000000..8e071cf0ab --- /dev/null +++ b/engines/titanic/star_control/dvector.cpp @@ -0,0 +1,28 @@ +/* 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/dvector.h" + +namespace Titanic { + + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub14.cpp b/engines/titanic/star_control/dvector.h index 75e7c68d8e..32d2bdd229 100644 --- a/engines/titanic/star_control/star_control_sub14.cpp +++ b/engines/titanic/star_control/dvector.h @@ -20,31 +20,19 @@ * */ -#include "titanic/star_control/star_control_sub14.h" +#ifndef TITANIC_DVECTOR_H +#define TITANIC_DVECTOR_H namespace Titanic { -CStarControlSub14::CStarControlSub14() : - _field0(0x3F800000), _field4(0), _field8(0), _fieldC(0), - _field10(0x3F800000), _field14(0), _field18(0), _field1C(0), - _field20(0x3F800000) { -} - -void CStarControlSub14::load(SimpleFile *file, int param) { - _field0 = file->readFloat(); - _field4 = file->readFloat(); - _field8 = file->readFloat(); - _fieldC = file->readFloat(); - _field10 = file->readFloat(); - _field14 = file->readFloat(); - _field18 = file->readFloat(); - _field1C = file->readFloat(); - _field20 = file->readFloat(); -} - -void CStarControlSub14::save(SimpleFile *file, int indent) { - -} - +class DVector { +public: + double _x, _y, _z; +public: + DVector() : _x(0), _y(0), _z(0) {} + DVector(double x, double y, double z) : _x(x), _y(y), _z(z) {} +}; } // End of namespace Titanic + +#endif /* TITANIC_DVECTOR_H */ diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp new file mode 100644 index 0000000000..52fc2bfd86 --- /dev/null +++ b/engines/titanic/star_control/fmatrix.cpp @@ -0,0 +1,75 @@ +/* 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/fmatrix.h" + +namespace Titanic { + +FMatrix::FMatrix() : + _row1(1.0, 0.0, 0.0), _row2(0.0, 1.0, 0.0), _row3(0.0, 0.0, 1.0) { +} + +FMatrix::FMatrix(DMatrix *src) { + copyFrom(src); +} + +void FMatrix::copyFrom(const DMatrix *src) { + // TODO +} + +void FMatrix::load(SimpleFile *file, int param) { + _row1._x = file->readFloat(); + _row1._y = file->readFloat(); + _row1._z = file->readFloat(); + _row2._x = file->readFloat(); + _row2._y = file->readFloat(); + _row2._z = file->readFloat(); + _row3._x = file->readFloat(); + _row3._y = file->readFloat(); + _row3._z = file->readFloat(); +} + +void FMatrix::save(SimpleFile *file, int indent) { + file->writeFloatLine(_row1._x, indent); + file->writeFloatLine(_row1._y, indent); + file->writeFloatLine(_row1._z, indent); + file->writeFloatLine(_row2._x, indent); + file->writeFloatLine(_row2._y, indent); + file->writeFloatLine(_row2._z, indent); + file->writeFloatLine(_row3._x, indent); + file->writeFloatLine(_row3._y, indent); + file->writeFloatLine(_row3._z, indent); +} + +void FMatrix::clear() { + _row1 = FVector(1.0, 0.0, 0.0); + _row2 = FVector(0.0, 1.0, 0.0); + _row3 = FVector(0.0, 0.0, 1.0); +} + +void FMatrix::set(FVector *row1, FVector *row2, FVector *row3) { + _row1 = *row1; + _row2 = *row2; + _row3 = *row3; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub14.h b/engines/titanic/star_control/fmatrix.h index 0b1d4e3b08..e98b160f01 100644 --- a/engines/titanic/star_control/star_control_sub14.h +++ b/engines/titanic/star_control/fmatrix.h @@ -20,26 +20,29 @@ * */ -#ifndef TITANIC_STAR_CONTROL_SUB14_H -#define TITANIC_STAR_CONTROL_SUB14_H +#ifndef TITANIC_FMATRIX_H +#define TITANIC_FMATRIX_H #include "titanic/support/simple_file.h" +#include "titanic/star_control/fvector.h" namespace Titanic { -class CStarControlSub14 { +class DMatrix; + +class FMatrix { +private: + FVector _row1; + FVector _row2; + FVector _row3; private: - double _field0; - double _field4; - double _field8; - double _fieldC; - double _field10; - double _field14; - double _field18; - double _field1C; - double _field20; + /** + * Copys data from a given source + */ + void copyFrom(const DMatrix *src); public: - CStarControlSub14(); + FMatrix(); + FMatrix(DMatrix *src); /** * Load the data for the class from file @@ -51,8 +54,17 @@ public: */ void save(SimpleFile *file, int indent); + /** + * Clears the matrix + */ + void clear(); + + /** + * Sets the data for the matrix + */ + void set(FVector *row1, FVector *row2, FVector *row3); }; } // End of namespace Titanic -#endif /* TITANIC_STAR_CONTROL_SUB13_H */ +#endif /* TITANIC_MATRIX3_H */ diff --git a/engines/titanic/star_control/fpoint.cpp b/engines/titanic/star_control/fpoint.cpp new file mode 100644 index 0000000000..f3d7008324 --- /dev/null +++ b/engines/titanic/star_control/fpoint.cpp @@ -0,0 +1,28 @@ +/* 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/fpoint.h" + +namespace Titanic { + + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/fpoint.h b/engines/titanic/star_control/fpoint.h new file mode 100644 index 0000000000..5329ecb9e3 --- /dev/null +++ b/engines/titanic/star_control/fpoint.h @@ -0,0 +1,38 @@ +/* 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. + * + */ + +#ifndef TITANIC_FPOINT_H +#define TITANIC_FPOINT_H + +namespace Titanic { + +class FVector { +public: + double _x, _y; +public: + FVector() : _x(0), _y(0) {} + FVector(double x, double y) : _x(x), _y(y) {} +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FPOINT_H */ diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp new file mode 100644 index 0000000000..39d303c4dc --- /dev/null +++ b/engines/titanic/star_control/fvector.cpp @@ -0,0 +1,28 @@ +/* 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/fvector.h" + +namespace Titanic { + + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h new file mode 100644 index 0000000000..86e6e384ac --- /dev/null +++ b/engines/titanic/star_control/fvector.h @@ -0,0 +1,38 @@ +/* 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. + * + */ + +#ifndef TITANIC_FVECTOR_H +#define TITANIC_FVECTOR_H + +namespace Titanic { + +class FVector { +public: + double _x, _y, _z; +public: + FVector() : _x(0), _y(0), _z(0) {} + FVector(double x, double y, double z) : _x(x), _y(y), _z(z) {} +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FVECTOR_H */ diff --git a/engines/titanic/star_control/star_control_sub13.cpp b/engines/titanic/star_control/star_control_sub13.cpp index f22a22a6e9..fd67c19785 100644 --- a/engines/titanic/star_control/star_control_sub13.cpp +++ b/engines/titanic/star_control/star_control_sub13.cpp @@ -63,12 +63,12 @@ void CStarControlSub13::load(SimpleFile *file, int param) { for (int idx = 0; idx < 5; ++idx) _valArray[idx] = file->readFloat(); - _sub14.load(file, param); + _matrix.load(file, param); _fieldD4 = 0; } void CStarControlSub13::save(SimpleFile *file, int indent) { - _sub14.save(file, indent); + _matrix.save(file, indent); } diff --git a/engines/titanic/star_control/star_control_sub13.h b/engines/titanic/star_control/star_control_sub13.h index e1b54775ce..37ffe1bdb9 100644 --- a/engines/titanic/star_control/star_control_sub13.h +++ b/engines/titanic/star_control/star_control_sub13.h @@ -25,7 +25,7 @@ #include "titanic/support/simple_file.h" #include "titanic/star_control/star_control_sub6.h" -#include "titanic/star_control/star_control_sub14.h" +#include "titanic/star_control/fmatrix.h" namespace Titanic { @@ -43,7 +43,7 @@ private: int _field22; int _field24; double _valArray[5]; - CStarControlSub14 _sub14; + FMatrix _matrix; CStarControlSub6 _sub1; CStarControlSub6 _sub2; int _fieldC0; diff --git a/engines/titanic/star_control/star_control_sub25.h b/engines/titanic/star_control/star_control_sub25.h index 81b5bb0f54..e943782e37 100644 --- a/engines/titanic/star_control/star_control_sub25.h +++ b/engines/titanic/star_control/star_control_sub25.h @@ -23,17 +23,17 @@ #ifndef TITANIC_STAR_CONTROL_SUB25_H #define TITANIC_STAR_CONTROL_SUB25_H -#include "titanic/star_control/star_control_sub14.h" +#include "titanic/star_control/fmatrix.h" #include "titanic/star_control/star_control_sub26.h" namespace Titanic { class CStarControlSub25 { public: - CStarControlSub14 _sub1; - CStarControlSub14 _sub2; - CStarControlSub26 _sub3; - CStarControlSub26 _sub4; + FMatrix _matrix1; + FMatrix _matrix2; + CStarControlSub26 _sub1; + CStarControlSub26 _sub2; public: }; |