TITANIC: Added remaining CStarField methods

This commit is contained in:
Paul Gilbert 2017-03-05 14:20:54 -05:00
parent bfcfc54b04
commit 7e418108f6
5 changed files with 103 additions and 47 deletions

View File

@ -63,6 +63,26 @@ public:
bool operator!=(const FVector &src) const {
return !operator==(src);
}
FVector operator+(const FVector &delta) const {
return FVector(_x + delta._x, _y + delta._y, _z + delta._z);
}
FVector operator-(const FVector &delta) const {
return FVector(_x - delta._x, _y - delta._y, _z - delta._z);
}
void operator+=(const FVector &delta) {
_x += delta._x;
_y += delta._y;
_z += delta._z;
}
void operator-=(const FVector &delta) {
_x -= delta._x;
_y -= delta._y;
_z -= delta._z;
}
};
} // End of namespace Titanic

View File

@ -23,6 +23,7 @@
#include "titanic/star_control/star_field.h"
#include "titanic/star_control/surface_area.h"
#include "titanic/star_control/star_control_sub12.h"
#include "titanic/titanic.h"
namespace Titanic {
@ -211,8 +212,8 @@ double CStarField::fn5(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
}
void CStarField::fn6(CVideoSurface *surface, CStarControlSub12 *sub12) {
CSurfaceArea surfaceArea(surface);
// TODO
CSurfaceArea surfaceArea(surface);
_sub8.fn1(this, &surfaceArea, sub12);
}
void CStarField::fn7() {
@ -241,4 +242,15 @@ bool CStarField::mouseButtonDown(CVideoSurface *surface, CStarControlSub12 *sub1
}
}
const CBaseStarEntry *CStarField::getRandomStar() const {
if (_data.empty())
return nullptr;
return getDataPtr(g_vm->getRandomNumber(_data.size() - 1));
}
const CBaseStarEntry *CStarField::getStar(int index) const {
return (index < 0 || index >= (int)_data.size()) ? nullptr : getDataPtr(index);
}
} // End of namespace Titanic

View File

@ -117,6 +117,16 @@ public:
*/
bool mouseButtonDown(CVideoSurface *surface, CStarControlSub12 *sub12,
int flags, const Common::Point &pt);
/**
* Gets a random star
*/
const CBaseStarEntry *getRandomStar() const;
/**
* Gets a specified star
*/
const CBaseStarEntry *getStar(int index) const;
};
} // End of namespace Titanic

View File

@ -282,7 +282,7 @@ void CStarView::fn3(bool fadeIn) {
void CStarView::fn4() {
FVector v1, v2;
randomizeVectors2(&v1, &v2);
randomizeVectors2(v1, v2);
_sub12.setPosition(v1);
_sub12.proc5(v2);
}
@ -296,7 +296,25 @@ void CStarView::fn6() {
}
void CStarView::fn7() {
// TODO
const CBaseStarEntry *star = _starField->getRandomStar();
if (star) {
FVector v1, v2;
randomizeVectors3(v1, v2);
v2 += star->_position;
_sub12.setPosition(v2);
_sub12.proc5(v1);
}
}
void CStarView::fn19(int index) {
const CBaseStarEntry *star = _starField->getStar(index);
if (star) {
FVector v1, v2;
randomizeVectors3(v1, v2);
v1 += star->_position;
_sub12.setPosition(v1);
_sub12.proc5(v2);
}
}
void CStarView::fn8() {
@ -342,7 +360,7 @@ void CStarView::fn14() {
void CStarView::setHasReference() {
FVector v1, v2;
randomizeVectors1(&v1, &v2);
randomizeVectors1(v1, v2);
_sub13.setPosition(v1);
_sub13.fn11(v2);
@ -388,60 +406,56 @@ void CStarView::fn18(CStarControlSub12 *sub12) {
}
}
void CStarView::fn19(int v) {
// TODO
}
void CStarView::randomizeVectors1(FVector *v1, FVector *v2) {
v1->_x = g_vm->getRandomFloat() * -4096.0 - 3072.0;
v1->_y = g_vm->getRandomFloat() * -4096.0 - 3072.0;
v1->_z = g_vm->getRandomFloat() * -4096.0 - 3072.0;
void CStarView::randomizeVectors1(FVector &v1, FVector &v2) {
v1._x = g_vm->getRandomFloat() * -4096.0 - 3072.0;
v1._y = g_vm->getRandomFloat() * -4096.0 - 3072.0;
v1._z = g_vm->getRandomFloat() * -4096.0 - 3072.0;
double vx = g_vm->getRandomFloat() * 8192.0;
double vy = g_vm->getRandomFloat() * 1024.0;
vx -= v1->_x;
vy -= v1->_y;
vx -= v1._x;
vy -= v1._y;
v2->_x = vx;
v2->_y = vy;
v2->_z = -v1->_z;
v2->fn3();
v2._x = vx;
v2._y = vy;
v2._z = -v1._z;
v2.fn3();
}
void CStarView::randomizeVectors2(FVector *v1, FVector *v2) {
v1->_x = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1->_y = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1->_z = 3072.0 - g_vm->getRandomFloat() * -4096.0;
void CStarView::randomizeVectors2(FVector &v1, FVector &v2) {
v1._x = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1._y = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1._z = 3072.0 - g_vm->getRandomFloat() * -4096.0;
// TODO: Doublecheck
v2->_x = -v1->_x;
v2->_y = -v1->_y;
v2->_z = -v1->_z;
v2->fn3();
v2._x = -v1._x;
v2._y = -v1._y;
v2._z = -v1._z;
v2.fn3();
}
void CStarView::randomizeVectors3(FVector *v1, FVector *v2) {
v1->_x = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1->_y = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1->_z = 3072.0 - g_vm->getRandomFloat() * -4096.0;
void CStarView::randomizeVectors3(FVector &v1, FVector &v2) {
v1._x = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1._y = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1._z = 3072.0 - g_vm->getRandomFloat() * -4096.0;
// TODO: Doublecheck
v2->_x = -v1->_x;
v2->_y = -v1->_y;
v2->_z = -v1->_z;
v2->fn3();
v2._x = -v1._x;
v2._y = -v1._y;
v2._z = -v1._z;
v2.fn3();
}
void CStarView::randomizeVectors4(FVector *v1, FVector *v2) {
v1->_x = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1->_y = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1->_z = 3072.0 - g_vm->getRandomFloat() * -4096.0;
void CStarView::randomizeVectors4(FVector &v1, FVector &v2) {
v1._x = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1._y = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1._z = 3072.0 - g_vm->getRandomFloat() * -4096.0;
// TODO: Doublecheck
v2->_x = -v1->_x;
v2->_y = -v1->_y;
v2->_z = -v1->_z;
v2->fn3();
v2._x = -v1._x;
v2._y = -v1._y;
v2._z = -v1._z;
v2.fn3();
}
void CStarView::resizeSurface(CScreenManager *scrManager, int width, int height,
CVideoSurface **surface) {

View File

@ -57,10 +57,10 @@ private:
void fn18(CStarControlSub12 *sub12);
void fn19(int v);
void randomizeVectors1(FVector *v1, FVector *v2);
void randomizeVectors2(FVector *v1, FVector *v2);
void randomizeVectors3(FVector *v1, FVector *v2);
void randomizeVectors4(FVector *v1, FVector *v2);
void randomizeVectors1(FVector &v1, FVector &v2);
void randomizeVectors2(FVector &v1, FVector &v2);
void randomizeVectors3(FVector &v1, FVector &v2);
void randomizeVectors4(FVector &v1, FVector &v2);
/**
* Handles resizing the surface