[Scummvm-git-logs] scummvm master -> f435a1592c1ea4b830e0d8809971097bacbd7c2a
dreammaster
paulfgilbert at gmail.com
Mon Jan 13 01:17:30 UTC 2020
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:
f435a1592c TITANIC: Rename CCStarCamera class to CCamera
Commit: f435a1592c1ea4b830e0d8809971097bacbd7c2a
https://github.com/scummvm/scummvm/commit/f435a1592c1ea4b830e0d8809971097bacbd7c2a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-01-12T17:17:10-08:00
Commit Message:
TITANIC: Rename CCStarCamera class to CCamera
Changed paths:
A engines/titanic/star_control/camera.cpp
A engines/titanic/star_control/camera.h
R engines/titanic/star_control/star_camera.cpp
R engines/titanic/star_control/star_camera.h
engines/titanic/module.mk
engines/titanic/star_control/base_stars.cpp
engines/titanic/star_control/base_stars.h
engines/titanic/star_control/camera_mover.cpp
engines/titanic/star_control/camera_mover.h
engines/titanic/star_control/const_boundaries.cpp
engines/titanic/star_control/const_boundaries.h
engines/titanic/star_control/constellations.cpp
engines/titanic/star_control/constellations.h
engines/titanic/star_control/star_closeup.cpp
engines/titanic/star_control/star_closeup.h
engines/titanic/star_control/star_control.cpp
engines/titanic/star_control/star_crosshairs.cpp
engines/titanic/star_control/star_crosshairs.h
engines/titanic/star_control/star_field.cpp
engines/titanic/star_control/star_field.h
engines/titanic/star_control/star_field_base.cpp
engines/titanic/star_control/star_field_base.h
engines/titanic/star_control/star_markers.cpp
engines/titanic/star_control/star_markers.h
engines/titanic/star_control/star_ref.cpp
engines/titanic/star_control/star_ref.h
engines/titanic/star_control/star_view.cpp
engines/titanic/star_control/star_view.h
engines/titanic/star_control/viewport.cpp
engines/titanic/star_control/viewport.h
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 5a18f42..73517d7 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -432,6 +432,7 @@ MODULE_OBJS := \
sound/wave_file.o \
star_control/star_control.o \
star_control/base_stars.o \
+ star_control/camera.o \
star_control/camera_auto_mover.o \
star_control/camera_mover.o \
star_control/const_boundaries.o \
@@ -446,7 +447,6 @@ MODULE_OBJS := \
star_control/marked_camera_mover.o \
star_control/matrix_transform.o \
star_control/orientation_changer.o \
- star_control/star_camera.o \
star_control/star_closeup.o \
star_control/star_crosshairs.o \
star_control/star_field_base.o \
diff --git a/engines/titanic/star_control/base_stars.cpp b/engines/titanic/star_control/base_stars.cpp
index 00206b1..8475b1e 100644
--- a/engines/titanic/star_control/base_stars.cpp
+++ b/engines/titanic/star_control/base_stars.cpp
@@ -21,7 +21,7 @@
*/
#include "titanic/star_control/base_stars.h"
-#include "titanic/star_control/star_camera.h"
+#include "titanic/star_control/camera.h"
#include "titanic/star_control/star_closeup.h"
#include "titanic/star_control/star_ref.h"
#include "titanic/support/files_manager.h"
@@ -126,7 +126,7 @@ void CBaseStars::resetEntry(CBaseStarEntry &entry) {
entry._data[idx] = 0;
}
-void CBaseStars::draw(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup) {
+void CBaseStars::draw(CSurfaceArea *surfaceArea, CCamera *camera, CStarCloseup *closeup) {
if (!_data.empty()) {
switch (camera->getStarColor()) {
case WHITE: // draw white, green, and red stars (mostly white)
@@ -161,7 +161,7 @@ void CBaseStars::draw(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarClose
}
}
-void CBaseStars::draw1(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup) {
+void CBaseStars::draw1(CSurfaceArea *surfaceArea, CCamera *camera, CStarCloseup *closeup) {
FPose pose = camera->getPose();
camera->getRelativeXCenterPixels(&_value1, &_value2, &_value3, &_value4);
@@ -246,7 +246,7 @@ void CBaseStars::draw1(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarClos
}
}
-void CBaseStars::draw2(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup) {
+void CBaseStars::draw2(CSurfaceArea *surfaceArea, CCamera *camera, CStarCloseup *closeup) {
FPose pose = camera->getPose();
camera->getRelativeXCenterPixels(&_value1, &_value2, &_value3, &_value4);
@@ -332,7 +332,7 @@ void CBaseStars::draw2(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarClos
}
}
-void CBaseStars::draw3(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup) {
+void CBaseStars::draw3(CSurfaceArea *surfaceArea, CCamera *camera, CStarCloseup *closeup) {
FPose pose = camera->getPose();
camera->getRelativeXCenterPixels(&_value1, &_value2, &_value3, &_value4);
@@ -439,7 +439,7 @@ void CBaseStars::draw3(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarClos
}
}
-void CBaseStars::draw4(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup) {
+void CBaseStars::draw4(CSurfaceArea *surfaceArea, CCamera *camera, CStarCloseup *closeup) {
FPose pose = camera->getPose();
camera->getRelativeXCenterPixels(&_value1, &_value2, &_value3, &_value4);
@@ -547,14 +547,14 @@ void CBaseStars::draw4(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarClos
}
}
-int CBaseStars::findStar(CSurfaceArea *surfaceArea, CStarCamera *camera,
+int CBaseStars::findStar(CSurfaceArea *surfaceArea, CCamera *camera,
const Common::Point &pt) {
CStarRef1 ref(this, pt);
ref.process(surfaceArea, camera);
return ref._index;
}
-int CBaseStars::baseFn2(CSurfaceArea *surfaceArea, CStarCamera *camera) {
+int CBaseStars::baseFn2(CSurfaceArea *surfaceArea, CCamera *camera) {
CStarRef3 ref(this);
ref.process(surfaceArea, camera);
return ref._index;
diff --git a/engines/titanic/star_control/base_stars.h b/engines/titanic/star_control/base_stars.h
index aa6ce5e..1bf9c71 100644
--- a/engines/titanic/star_control/base_stars.h
+++ b/engines/titanic/star_control/base_stars.h
@@ -34,7 +34,7 @@ namespace Titanic {
enum StarMode { MODE_STARFIELD = 0, MODE_PHOTO = 1 };
-class CStarCamera;
+class CCamera;
class CStarCloseup;
class CString;
class CSurfaceArea;
@@ -74,10 +74,10 @@ struct CStarPosition : public Common::Point {
*/
class CBaseStars {
private:
- void draw1(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup);
- void draw2(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup);
- void draw3(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup);
- void draw4(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup);
+ void draw1(CSurfaceArea *surfaceArea, CCamera *camera, CStarCloseup *closeup);
+ void draw2(CSurfaceArea *surfaceArea, CCamera *camera, CStarCloseup *closeup);
+ void draw3(CSurfaceArea *surfaceArea, CCamera *camera, CStarCloseup *closeup);
+ void draw4(CSurfaceArea *surfaceArea, CCamera *camera, CStarCloseup *closeup);
protected:
FRange _minMax;
double _minVal;
@@ -109,14 +109,14 @@ public:
/**
* Draw the item
*/
- virtual void draw(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup);
+ virtual void draw(CSurfaceArea *surfaceArea, CCamera *camera, CStarCloseup *closeup);
virtual bool loadYale(int v1) { return true; }
/**
* Selects a star
*/
- virtual bool selectStar(CSurfaceArea *surfaceArea, CStarCamera *camera,
+ virtual bool selectStar(CSurfaceArea *surfaceArea, CCamera *camera,
const Common::Point &pt, void *handler = nullptr) { return false; }
/**
@@ -154,18 +154,18 @@ public:
* Checks for the presence of a star at a given position on the
* screen given the specified camera view, and returns it's index
*/
- int findStar(CSurfaceArea *surfaceArea, CStarCamera *camera,
+ int findStar(CSurfaceArea *surfaceArea, CCamera *camera,
const Common::Point &pt);
- int baseFn2(CSurfaceArea *surfaceArea, CStarCamera *camera);
+ int baseFn2(CSurfaceArea *surfaceArea, CCamera *camera);
};
class CStarVector {
private:
- CStarCamera *_owner;
+ CCamera *_owner;
FVector _vector;
public:
- CStarVector(CStarCamera *owner, const FVector &v) : _owner(owner), _vector(v) {}
+ CStarVector(CCamera *owner, const FVector &v) : _owner(owner), _vector(v) {}
/**
* Applies the saved vector
diff --git a/engines/titanic/star_control/camera.cpp b/engines/titanic/star_control/camera.cpp
new file mode 100644
index 0000000..8c79ead
--- /dev/null
+++ b/engines/titanic/star_control/camera.cpp
@@ -0,0 +1,649 @@
+/* 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/camera.h"
+#include "titanic/debugger.h"
+#include "titanic/star_control/camera_mover.h"
+#include "titanic/star_control/fmatrix.h"
+#include "titanic/star_control/fpoint.h"
+#include "titanic/star_control/marked_camera_mover.h"
+#include "titanic/star_control/unmarked_camera_mover.h"
+#include "titanic/star_control/error_code.h"
+#include "titanic/support/simple_file.h"
+#include "titanic/titanic.h"
+
+namespace Titanic {
+
+const double rowScale1 = 100000.0;
+const double rowScale2 = 1000000.0;
+
+FMatrix *CCamera::_priorOrientation;
+FMatrix *CCamera::_newOrientation;
+
+CCamera::CCamera(const CNavigationInfo *data) :
+ _starLockState(ZERO_LOCKED), _mover(nullptr), _isMoved(false), _isInLockingProcess(false) {
+ setMoverType(data);
+}
+
+CCamera::CCamera(CViewport *src) :
+ _starLockState(ZERO_LOCKED), _mover(nullptr), _isMoved(false), _isInLockingProcess(false), _viewport(src) {
+}
+
+void CCamera::init() {
+ _priorOrientation = nullptr;
+ _newOrientation = nullptr;
+}
+
+void CCamera::deinit() {
+ delete _priorOrientation;
+ delete _newOrientation;
+ _priorOrientation = nullptr;
+ _newOrientation = nullptr;
+}
+
+bool CCamera::isLocked() {
+ return _mover->isLocked();
+}
+
+bool CCamera::isNotInLockingProcess() {
+ return !_isInLockingProcess;
+}
+
+CCamera::~CCamera() {
+ removeMover();
+}
+
+void CCamera::proc2(const CViewport *src) {
+ _viewport.copyFrom(src);
+}
+
+void CCamera::proc3(const CNavigationInfo *src) {
+ _mover->copyFrom(src);
+}
+
+void CCamera::setPosition(const FVector &v) {
+ if (!isLocked()) {
+ _viewport.setPosition(v);
+ setIsMoved();
+ }
+}
+
+void CCamera::setOrientation(const FVector &v) {
+ if (!isLocked())
+ _viewport.setOrientation(v);
+}
+
+// This never gets called
+void CCamera::proc6(int v) {
+ if (!isLocked())
+ _viewport.setC(v);
+}
+
+// This never gets called
+void CCamera::proc7(int v) {
+ if (!isLocked())
+ _viewport.set10(v);
+}
+
+// This never gets called
+void CCamera::proc8(int v) {
+ if (!isLocked())
+ _viewport.set14(v);
+}
+
+// This never gets called
+void CCamera::setCenterYAngle(int v) {
+ if (!isLocked())
+ _viewport.setCenterYAngle(v);
+}
+
+// This never gets called
+void CCamera::setCenterZAngle(int v) {
+ if (!isLocked())
+ _viewport.setCenterZAngle(v);
+}
+
+void CCamera::randomizeOrientation() {
+ if (!isLocked())
+ _viewport.randomizeOrientation();
+}
+
+void CCamera::setFields(StarMode mode, double val) {
+ if (!isLocked())
+ _viewport.changeStarColorPixel(mode, val);
+}
+
+void CCamera::proc13(CViewport *dest) {
+ *dest = _viewport;
+}
+
+void CCamera::setDestination(const FVector &v) {
+ FMatrix orientation = _viewport.getOrientation();
+ FVector oldPos = _viewport._position;
+
+ _mover->moveTo(oldPos, v, orientation);
+}
+
+void CCamera::updatePosition(CErrorCode *errorCode) {
+ if (!_priorOrientation)
+ _priorOrientation = new FMatrix();
+ if (!_newOrientation)
+ _newOrientation = new FMatrix();
+
+ *_priorOrientation = _viewport.getOrientation();
+ *_newOrientation = *_priorOrientation;
+
+ FVector priorPos = _viewport._position;
+ FVector newPos = _viewport._position;
+ _mover->updatePosition(*errorCode, newPos, *_newOrientation);
+
+ if (newPos != priorPos) {
+ _viewport.setPosition(newPos);
+ setIsMoved();
+ }
+
+ if (*_priorOrientation != *_newOrientation) {
+ _viewport.setOrientation(*_newOrientation);
+ }
+}
+
+void CCamera::accelerate() {
+ _mover->accelerate();
+}
+
+void CCamera::deccelerate() {
+ _mover->deccelerate();
+}
+
+void CCamera::fullSpeed() {
+ _mover->fullSpeed();
+}
+
+void CCamera::stop() {
+ _mover->stop();
+}
+
+void CCamera::reposition(double factor) {
+ if (!isLocked())
+ _viewport.reposition(factor);
+}
+
+void CCamera::setPosition(const FPose &pose) {
+ if (!isLocked()) {
+ _viewport.setPosition(pose);
+ setIsMoved();
+ }
+}
+
+void CCamera::changeOrientation(FMatrix &m) {
+ if (!isLocked())
+ _viewport.changeOrientation(m);
+}
+
+FPose CCamera::getPose() {
+ return _viewport.getPose();
+}
+
+FPose CCamera::getRawPose() {
+ return _viewport.getRawPose();
+}
+
+double CCamera::getThreshold() const {
+ return _viewport._field10;
+}
+
+double CCamera::proc26() const {
+ return _viewport._field14;
+}
+
+StarColor CCamera::getStarColor() const {
+ return _viewport._starColor;
+}
+
+FVector CCamera::getRelativePos(int index, const FVector &src) {
+ FVector dest;
+
+ double val;
+ if (index == 2) {
+ val = _viewport._isZero;
+ } else {
+ val = _viewport._valArray[index];
+ }
+
+ dest._x = ((val + src._x) * _viewport._centerVector._x)
+ / (_viewport._centerVector._y * src._z);
+ dest._y = src._y * _viewport._centerVector._x / (_viewport._centerVector._z * src._z);
+ dest._z = src._z;
+ return dest;
+}
+
+FVector CCamera::getRelativePosNoCentering(int index, const FVector &src) {
+ return _viewport.getRelativePosNoCentering(index, src);
+}
+
+FVector CCamera::proc30(int index, const FVector &v) {
+ return _viewport.getRelativePosCentering(index, v);
+}
+
+FVector CCamera::proc31(int index, const FVector &v) {
+ return _viewport.getRelativePosCenteringRaw(index, v);
+}
+
+void CCamera::setViewportAngle(const FPoint &angles) {
+ debug(DEBUG_DETAILED, "setViewportAngle %f %f", angles._x, angles._y);
+
+ if (isLocked())
+ return;
+
+ switch(_starLockState) {
+ case ZERO_LOCKED: {
+ FPose subX(X_AXIS, angles._y);
+ FPose subY(Y_AXIS, -angles._x); // needs to be negative or looking left will cause the view to go right
+ FPose sub(subX, subY);
+ changeOrientation(sub);
+ break;
+ }
+
+ case ONE_LOCKED: {
+ FVector row1 = _lockedStarsPos._row1;
+ FPose poseX(X_AXIS, angles._y);
+ FPose poseY(Y_AXIS, -angles._x); // needs to be negative or looking left will cause the view to go right
+ FPose pose(poseX, poseY);
+
+ FMatrix m1 = _viewport.getOrientation();
+ FVector tempV1 = _viewport._position;
+ FVector tempV2 = m1._row1 * rowScale1;
+ FVector tempV3 = tempV2 + tempV1;
+ FVector tempV4 = tempV3;
+
+ tempV2 = m1._row2 * rowScale1;
+ FVector tempV5 = m1._row3 * rowScale1;
+ FVector tempV6 = tempV2 + tempV1;
+
+ FVector tempV7 = tempV5 + tempV1;
+ tempV5 = tempV6;
+ tempV6 = tempV7;
+
+ tempV1 -= row1;
+ tempV4 -= row1;
+ tempV5 -= row1;
+ tempV6 -= row1;
+
+ tempV1 = tempV1.matProdRowVect(pose);
+ tempV4 = tempV4.matProdRowVect(pose);
+ tempV5 = tempV5.matProdRowVect(pose);
+ tempV6 = tempV6.matProdRowVect(pose);
+
+ tempV4 -= tempV1;
+ tempV5 -= tempV1;
+ tempV6 -= tempV1;
+
+ float unusedScale = 0.0;
+ if (!tempV4.normalize(unusedScale) ||
+ !tempV5.normalize(unusedScale) ||
+ !tempV6.normalize(unusedScale)) {
+ // Do the normalization, put the scale amount in unusedScale,
+ // but if it is unsuccessful, crash
+ assert(unusedScale);
+ }
+
+ tempV1 += row1;
+ m1.set(tempV4, tempV5, tempV6);
+ _viewport.setOrientation(m1);
+ _viewport.setPosition(tempV1);
+ break;
+ }
+
+ case TWO_LOCKED: {
+ FVector tempV2;
+ FPose m1;
+ FVector mrow1, mrow2, mrow3;
+ FVector tempV1, diffV, multV, multV2, tempV3, tempV7;
+
+ FPose subX(0, _lockedStarsPos._row1);
+ FPose subY(Y_AXIS, angles._y);
+
+ tempV1 = _lockedStarsPos._row2 - _lockedStarsPos._row1;
+ diffV = tempV1;
+ m1 = diffV.formRotXY();
+ FPose m11;
+ fposeProd(m1, subX, m11);
+
+ subX = m11.inverseTransform();
+ FPose m12;
+ fposeProd(subX, subY, m12);
+
+ FMatrix m3 = _viewport.getOrientation();
+ tempV2 = _viewport._position;
+ multV._x = m3._row1._x * rowScale2;
+ multV._y = m3._row1._y * rowScale2;
+ multV._z = m3._row1._z * rowScale2;
+ tempV3._x = tempV2._x;
+ tempV3._y = tempV2._y;
+ tempV3._z = tempV2._z;
+ multV2._z = m3._row2._z * rowScale2;
+
+ 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 * rowScale2;
+ multV2._y = m3._row2._y * rowScale2;
+ mrow1 = tempV1;
+ multV = multV2 + tempV3;
+ mrow2 = multV;
+
+ tempV7._z = m3._row3._z * rowScale2 + tempV3._z;
+ tempV7._y = m3._row3._y * rowScale2 + tempV3._y;
+ tempV7._x = m3._row3._x * rowScale2 + tempV3._x;
+
+ mrow3 = tempV7;
+ tempV3 = tempV3.matProdRowVect(m12);
+ mrow1 = mrow1.matProdRowVect(m12);
+ mrow2 = mrow2.matProdRowVect(m12);
+ mrow3 = mrow3.matProdRowVect(m12);
+
+ tempV3 = tempV3.matProdRowVect(m11);
+ mrow1 = mrow1.matProdRowVect(m11);
+ mrow2 = mrow2.matProdRowVect(m11);
+ mrow3 = mrow3.matProdRowVect(m11);
+
+ mrow1 -= tempV3;
+ mrow2 -= tempV3;
+ mrow3 -= tempV3;
+
+ float unusedScale=0.0;
+ if (!mrow1.normalize(unusedScale) ||
+ !mrow2.normalize(unusedScale) ||
+ !mrow3.normalize(unusedScale)) {
+ // Do the normalization, put the scale amount in unusedScale,
+ // but if it is unsuccessful, crash
+ assert(unusedScale);
+ }
+
+ m3.set(mrow1, mrow2, mrow3);
+ _viewport.setOrientation(m3);
+ _viewport.setPosition(tempV3);
+ break;
+ }
+
+ // All three stars are locked on in this case so the camera does not move
+ // in response to the users mouse movements
+ case THREE_LOCKED:
+ default:
+ break;
+ }
+}
+
+bool CCamera::addLockedStar(const FVector v) {
+ if (_starLockState == THREE_LOCKED)
+ return false;
+
+ CNavigationInfo data;
+ _mover->copyTo(&data);
+ removeMover();
+
+ FVector &row = _lockedStarsPos[(int)_starLockState];
+ _starLockState = StarLockState((int)_starLockState + 1);
+ row = v;
+ setMoverType(&data);
+ return true;
+}
+
+bool CCamera::removeLockedStar() {
+ if (_starLockState == ZERO_LOCKED)
+ return false;
+
+ CNavigationInfo data;
+ _mover->copyTo(&data);
+ removeMover();
+
+ _starLockState = StarLockState((int)_starLockState - 1);
+ setMoverType(&data);
+ return true;
+}
+
+void CCamera::getRelativeXCenterPixels(double *v1, double *v2, double *v3, double *v4) {
+ _viewport.getRelativeXCenterPixels(v1, v2, v3, v4);
+}
+
+void CCamera::load(SimpleFile *file, int param) {
+ _viewport.load(file, param);
+}
+
+void CCamera::save(SimpleFile *file, int indent) {
+ _viewport.save(file, indent);
+}
+
+bool CCamera::setMoverType(const CNavigationInfo *src) {
+ CCameraMover *mover = nullptr;
+
+ switch (_starLockState) {
+ case ZERO_LOCKED:
+ mover = new CUnmarkedCameraMover(src);
+ break;
+
+ case ONE_LOCKED:
+ case TWO_LOCKED:
+ case THREE_LOCKED:
+ mover = new CMarkedCameraMover(src);
+ break;
+
+ default:
+ break;
+ }
+
+ if (mover) {
+ assert(!_mover); // removeMover() is usually called before this function so _mover is null
+ _mover = mover;
+ return true;
+ } else {
+ return false;
+ }
+}
+
+void CCamera::removeMover() {
+ if (_mover) {
+ delete _mover;
+ _mover = nullptr;
+ _isInLockingProcess = false;
+ }
+}
+
+bool CCamera::lockMarker1(FVector v1, FVector firstStarPosition, FVector v3) {
+ if (_starLockState != ZERO_LOCKED)
+ return true;
+
+ _isInLockingProcess = true;
+ FVector tempV;
+ double val1, val2, val3, val4, val5;
+ double val6, val7, val8, val9;
+
+ val1 = _viewport._centerVector._y * v1._x;
+ tempV._z = _viewport._field10;
+ val2 = _viewport._centerVector._y * tempV._z * v3._x;
+ val3 = _viewport._centerVector._z * v1._y;
+ val4 = _viewport._centerVector._z * tempV._z;
+ val5 = val1 * v1._z / _viewport._centerVector._x;
+ v3._z = v1._z;
+ val6 = val4 * v3._y;
+ val7 = val3 * v1._z / _viewport._centerVector._x;
+ val8 = val6 / _viewport._centerVector._x;
+ val9 = val2 / _viewport._centerVector._x;
+ v3._x = val5 - _viewport._isZero; // TODO: _viewport._isZero is always zero
+ v3._y = val7;
+ tempV._x = val9 - _viewport._isZero; // TODO: _viewport._isZero is always zero
+ tempV._y = val8;
+
+ float unusedScale = 0.0;
+ if (!v3.normalize(unusedScale) || !tempV.normalize(unusedScale)) {
+ // Do the normalization, put the scale amount in unusedScale,
+ // but if it is unsuccessful, crash
+ assert(unusedScale);
+ }
+
+ FMatrix matrix = _viewport.getOrientation();
+ const FVector &pos = _viewport._position;
+ _mover->transitionBetweenOrientations(v3, tempV, pos, matrix); // TODO: pos does not get used in this function,
+ // i.e., _mover has CUnmarkedCameraMover handle which means
+ // CUnmarkedCameraMover::transitionBetweenOrientations gets called
+
+ CStarVector *sv = new CStarVector(this, firstStarPosition);
+ _mover->setVector(sv);
+
+ return true;
+}
+
+bool CCamera::lockMarker2(CViewport *viewport, const FVector &secondStarPosition) {
+ if (_starLockState != ONE_LOCKED)
+ return true;
+
+ _isInLockingProcess = true;
+ FVector firstStarPosition = _lockedStarsPos._row1;
+ FPose m3(0, firstStarPosition); // Identity matrix and row4 as the 1st stars position
+ FVector starDelta = secondStarPosition - firstStarPosition;
+ FPose m10 = starDelta.formRotXY();
+ FPose m11;
+ fposeProd(m10, m3, m11);
+
+ m10 = m11.inverseTransform();
+
+ FVector oldPos = _viewport._position;
+
+ FPose m4;
+ m4._row1 = viewport->_position;
+ m4._row2 = FVector(0.0, 0.0, 0.0);
+ m4._row3 = FVector(0.0, 0.0, 0.0);
+ m4._vector = FVector(0.0, 0.0, 0.0);
+
+ FMatrix newOr = viewport->getOrientation();
+ float yVal1 = newOr._row1._y * rowScale2;
+ float zVal1 = newOr._row1._z * rowScale2;
+ float xVal1 = newOr._row2._x * rowScale2;
+ float yVal2 = newOr._row2._y * rowScale2;
+ float zVal2 = newOr._row2._z * rowScale2;
+ float zVal3 = zVal1 + m4._row1._z;
+ float yVal3 = yVal1 + m4._row1._y;
+ float xVal2 = newOr._row1._x * rowScale2 + m4._row1._x;
+ float zVal4 = zVal2 + m4._row1._z;
+ float yVal4 = yVal2 + m4._row1._y;
+ float xVal3 = xVal1 + m4._row1._x;
+
+ FVector tempV4(xVal2, yVal3, zVal3);
+ FVector tempV3(xVal3, yVal4, zVal4);
+ m4._row3 = tempV4;
+
+ FVector tempV5;
+ tempV5._x = newOr._row3._x * rowScale2;
+ tempV5._y = newOr._row3._y * rowScale2;
+ m4._row2 = tempV3;
+
+ tempV3._x = tempV5._x + m4._row1._x;
+ tempV3._y = tempV5._y + m4._row1._y;
+ tempV3._z = newOr._row3._z * rowScale2 + m4._row1._z;
+ m4._vector = tempV3;
+
+
+ FVector viewPosition2 = oldPos.matProdRowVect(m10);
+ m3 = m4.compose2(m10);
+
+ float minDistance;
+ FVector x1(viewPosition2);
+ FVector x2(m3._row1);
+ // Find the angle of rotation for m4._row1 that gives the minimum distance to viewPosition
+ float minDegree = calcAngleForMinDist(x1, x2, minDistance);
+
+ m3.rotVectAxisY((double)minDegree);
+ FPose m13;
+ m13 = m3.compose2(m11);
+
+ m13._row3 -= m13._row1;
+ m13._row2 -= m13._row1;
+ m13._vector -= m13._row1;
+
+
+
+ float unusedScale=0.0;
+ if (!m13._row2.normalize(unusedScale) ||
+ !m13._row3.normalize(unusedScale) ||
+ !m13._vector.normalize(unusedScale) ) {
+ // Do the normalizations, put the scale amount in unusedScale,
+ // but if any of the normalizations are unsuccessful, crash
+ assert(unusedScale);
+ }
+
+ newOr.set(m13._row3, m13._row2, m13._vector);
+
+ FVector newPos = m13._row1;
+ FMatrix oldOr = _viewport.getOrientation();
+
+ // WORKAROUND: set old position to new position (1st argument), this prevents
+ // locking issues when locking the 2nd star. Fixes #9961.
+ _mover->transitionBetweenPosOrients(newPos, newPos, oldOr, newOr);
+ CStarVector *sv = new CStarVector(this, secondStarPosition);
+ _mover->setVector(sv);
+
+ return true;
+}
+
+bool CCamera::lockMarker3(CViewport *viewport, const FVector &thirdStarPosition) {
+ if (_starLockState != TWO_LOCKED)
+ return true;
+
+ _isInLockingProcess = true;
+ FMatrix newOr = viewport->getOrientation();
+ FMatrix oldOr = _viewport.getOrientation();
+ FVector newPos = viewport->_position;
+ //FVector oldPos = _viewport._position;
+
+ // WORKAROUND: set old position to new position (1st argument), this prevents
+ // locking issues when locking the 3rd star. Fixes #9961.
+ _mover->transitionBetweenPosOrients(newPos, newPos, oldOr, newOr);
+
+ CStarVector *sv = new CStarVector(this, thirdStarPosition);
+ _mover->setVector(sv);
+
+ return true;
+}
+
+float CCamera::calcAngleForMinDist(FVector &x, FVector &y, float &minDistance) {
+ FVector tempPos;
+ minDistance = (float)1.0e20;
+ float minDegree = 0.0;
+ float degInc = 1.0; // one degree steps
+ int nDegrees = floor(360.0/degInc);
+ for (int i = 0; i < nDegrees; ++i) {
+ tempPos = y;
+ tempPos.rotVectAxisY((float)degInc*i);
+ float distance = x.getDistance(tempPos);
+
+ if (distance < minDistance) {
+ minDistance = distance;
+ minDegree = (float) degInc*i;
+ }
+ }
+ return minDegree;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/camera.h b/engines/titanic/star_control/camera.h
new file mode 100644
index 0000000..06b1957
--- /dev/null
+++ b/engines/titanic/star_control/camera.h
@@ -0,0 +1,251 @@
+/* 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_CAMERA_H
+#define TITANIC_CAMERA_H
+
+#include "titanic/star_control/fmatrix.h"
+#include "titanic/star_control/base_stars.h"
+#include "titanic/star_control/viewport.h"
+
+namespace Titanic {
+
+class CCameraMover;
+class CErrorCode;
+struct CNavigationInfo;
+class FPoint;
+class SimpleFile;
+
+enum StarLockState { ZERO_LOCKED=0, ONE_LOCKED=1, TWO_LOCKED=2, THREE_LOCKED=3 };
+
+/**
+ * Implements a reference point from which the starmap can be viewed
+ */
+class CCamera {
+private:
+ static FMatrix *_priorOrientation;
+ static FMatrix *_newOrientation;
+private:
+ StarLockState _starLockState;
+ FMatrix _lockedStarsPos; // Each row represents the location of a locked star
+ CCameraMover *_mover; // A marked or unmarked camera mover, contains an automover
+ CViewport _viewport;
+ bool _isMoved; // Used in CPetStarfield to determine if a star destination can be set
+ bool _isInLockingProcess; // The mover/view is homing in on a new star
+private:
+ /**
+ * Set Mover type to be unmarked or marked camera mover based on
+ * the number of stars currently locked (_starLockState)
+ * The CNavigationInfo data is used to initialize the mover
+ */
+ bool setMoverType(const CNavigationInfo *src);
+
+ /**
+ * Deletes the previous mover handle
+ */
+ void removeMover();
+
+ /**
+ * Return whether the handler is locked
+ */
+ bool isLocked();
+public:
+ static void init();
+ static void deinit();
+public:
+ CCamera(const CNavigationInfo *data);
+ CCamera(CViewport *src);
+ virtual ~CCamera();
+
+ virtual void proc2(const CViewport *src);
+ virtual void proc3(const CNavigationInfo *src);
+
+ /**
+ * The mover/view is not currently homing in on a new star
+ * This can mean it is unmarked, or that it is fully locked
+ * onto one star or more (but not in the process of doing so)
+ */
+ bool isNotInLockingProcess();
+
+ /**
+ * Set the camera position
+ */
+ virtual void setPosition(const FVector &v);
+
+ /**
+ * Sets the camera orientation
+ */
+ virtual void setOrientation(const FVector &v);
+
+ virtual void proc6(int v);
+ virtual void proc7(int v);
+ virtual void proc8(int v);
+ virtual void setCenterYAngle(int v);
+ virtual void setCenterZAngle(int v);
+ virtual void randomizeOrientation();
+ virtual void setFields(StarMode mode, double val);
+ virtual void proc13(CViewport *dest);
+
+ /**
+ * Sets the destination to move the camera to
+ */
+ virtual void setDestination(const FVector &v);
+
+ /**
+ * Updates the camera position
+ */
+ virtual void updatePosition(CErrorCode *errorCode);
+
+ /**
+ * Increases movement speed in forward direction
+ */
+ virtual void accelerate();
+
+ /**
+ * Increases movement speed in backward direction
+ */
+ virtual void deccelerate();
+
+ /**
+ * Increase to full speed
+ */
+ virtual void fullSpeed();
+
+ /**
+ * Completely stop
+ */
+ virtual void stop();
+
+ virtual void reposition(double factor);
+
+ /**
+ * Set the camera position
+ */
+ virtual void setPosition(const FPose &pose);
+
+ virtual void changeOrientation(FMatrix &m);
+
+ /**
+ * Get the position and direction of the camera
+ */
+ virtual FPose getPose();
+
+ virtual FPose getRawPose();
+ virtual double getThreshold() const;
+
+ virtual double proc26() const;
+ virtual StarColor getStarColor() const;
+
+ /**
+ * Return the passed vector relative to the center of the viewpoint
+ */
+ virtual FVector getRelativePos(int index, const FVector &src);
+
+ virtual FVector getRelativePosNoCentering(int index, const FVector &src);
+ virtual FVector proc30(int index, const FVector &v);
+ virtual FVector proc31(int index, const FVector &v);
+
+ /**
+ * Sets the viewport position within the starfield
+ */
+ virtual void setViewportAngle(const FPoint &angles);
+
+ /**
+ * How many stars are currently locked onto
+ */
+ virtual StarLockState getStarLockState() const { return _starLockState; }
+
+ /**
+ * Adds the row for a locked in marker/star
+ * @remarks This can't be a pass-by-reference, since adding
+ * the vector for the star destroys the calling star vector
+ */
+ virtual bool addLockedStar(const FVector v);
+
+ /**
+ * Removes the most recent locked in marker/star
+ * @remarks This can't be a pass-by-reference, since adding
+ * the vector for the star destroys the calling star vector
+ */
+ virtual bool removeLockedStar();
+
+ /**
+ * All arguments are return values
+ * First is the x center coordinate relative to y
+ * Second is the x center coordinate relative to z
+ * Third is the first x center pixel offset
+ * Fourth is the second x center pixel offset
+ */
+ virtual void getRelativeXCenterPixels(double *v1, double *v2, double *v3, double *v4);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file, int param);
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Calculates the angle of rotation of y that achieves
+ * the minimum distance to x.
+ * The angle is in degrees.
+ * Also returns the minimum distance calculated
+ */
+ float calcAngleForMinDist(FVector &x, FVector &y, float &minDistance);
+
+ /**
+ * Returns true for whether the camera has been moved
+ */
+ bool isMoved() const { return _isMoved; }
+
+ /**
+ * Sets the camera as having been moved
+ */
+ void setIsMoved() { _isMoved = true; }
+
+ /**
+ * Resets the flag for whether the camera has moved
+ */
+ void clearIsMoved() { _isMoved = false; }
+
+ /**
+ * Lock in the first matched star marker
+ */
+ bool lockMarker1(FVector v1, FVector v2, FVector v3);
+
+ /**
+ * Lock in the second matched star marker
+ */
+ bool lockMarker2(CViewport *viewport, const FVector &v);
+
+ /**
+ * Lock in the third and final matched star marker
+ */
+ bool lockMarker3(CViewport *viewport, const FVector &v);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_CAMERA_H */
diff --git a/engines/titanic/star_control/camera_mover.cpp b/engines/titanic/star_control/camera_mover.cpp
index 4340eb8..13fd673 100644
--- a/engines/titanic/star_control/camera_mover.cpp
+++ b/engines/titanic/star_control/camera_mover.cpp
@@ -88,14 +88,14 @@ void CCameraMover::copyTo(CNavigationInfo *dest) {
dest->_unusedZ = _unusedZ;
}
-void CCameraMover::increaseForwardSpeed() {
+void CCameraMover::accelerate() {
if (!isLocked() && _speed < _maxSpeed) {
_speedChangeCtr += _speedChangeInc;
_speed += ABS(_speedChangeCtr);
}
}
-void CCameraMover::increaseBackwardSpeed() {
+void CCameraMover::deccelerate() {
if (!isLocked() && _speed > -_maxSpeed) {
_speedChangeCtr -= _speedChangeInc;
_speed -= ABS(_speedChangeCtr);
diff --git a/engines/titanic/star_control/camera_mover.h b/engines/titanic/star_control/camera_mover.h
index 3d72e01..2f01eaf 100644
--- a/engines/titanic/star_control/camera_mover.h
+++ b/engines/titanic/star_control/camera_mover.h
@@ -69,12 +69,12 @@ public:
/**
* Increases movement speed in forward direction
*/
- virtual void increaseForwardSpeed();
+ virtual void accelerate();
/**
* Decreases movement speed in backward direction
*/
- virtual void increaseBackwardSpeed();
+ virtual void deccelerate();
/**
* Increase to full speed
diff --git a/engines/titanic/star_control/const_boundaries.cpp b/engines/titanic/star_control/const_boundaries.cpp
index 101a6ba..3761973 100644
--- a/engines/titanic/star_control/const_boundaries.cpp
+++ b/engines/titanic/star_control/const_boundaries.cpp
@@ -21,7 +21,7 @@
*/
#include "titanic/star_control/const_boundaries.h"
-#include "titanic/star_control/star_camera.h"
+#include "titanic/star_control/camera.h"
#include "titanic/star_control/star_field.h"
#include "titanic/star_control/surface_area.h"
#include "titanic/support/files_manager.h"
@@ -68,7 +68,7 @@ bool CConstBoundaries::initialize() {
return true;
}
-void CConstBoundaries::draw(CSurfaceArea *surface, CStarCamera *camera) {
+void CConstBoundaries::draw(CSurfaceArea *surface, CCamera *camera) {
if (_data.empty())
return;
diff --git a/engines/titanic/star_control/const_boundaries.h b/engines/titanic/star_control/const_boundaries.h
index 75b292f..9e4b718 100644
--- a/engines/titanic/star_control/const_boundaries.h
+++ b/engines/titanic/star_control/const_boundaries.h
@@ -28,7 +28,7 @@
namespace Titanic {
-class CStarCamera;
+class CCamera;
class CSurfaceArea;
class CConstBoundaries {
@@ -49,7 +49,7 @@ public:
/**
* Draw the boundary structure
*/
- void draw(CSurfaceArea *surface, CStarCamera *camera);
+ void draw(CSurfaceArea *surface, CCamera *camera);
};
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/constellations.cpp b/engines/titanic/star_control/constellations.cpp
index 6693970..4d422fc 100644
--- a/engines/titanic/star_control/constellations.cpp
+++ b/engines/titanic/star_control/constellations.cpp
@@ -21,7 +21,7 @@
*/
#include "titanic/star_control/constellations.h"
-#include "titanic/star_control/star_camera.h"
+#include "titanic/star_control/camera.h"
#include "titanic/star_control/star_field.h"
#include "titanic/star_control/surface_area.h"
#include "titanic/support/files_manager.h"
@@ -70,7 +70,7 @@ bool CConstellations::initialize() {
return true;
}
-void CConstellations::draw(CSurfaceArea *surface, CStarCamera *camera) {
+void CConstellations::draw(CSurfaceArea *surface, CCamera *camera) {
if (_data.empty())
return;
diff --git a/engines/titanic/star_control/constellations.h b/engines/titanic/star_control/constellations.h
index 1f4cfac..54269c8 100644
--- a/engines/titanic/star_control/constellations.h
+++ b/engines/titanic/star_control/constellations.h
@@ -28,7 +28,7 @@
namespace Titanic {
-class CStarCamera;
+class CCamera;
class CSurfaceArea;
class CConstellations {
@@ -47,7 +47,7 @@ public:
/**
* Draw the starfield points
*/
- void draw(CSurfaceArea *surface, CStarCamera *camera);
+ void draw(CSurfaceArea *surface, CCamera *camera);
};
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
deleted file mode 100644
index aa60bda..0000000
--- a/engines/titanic/star_control/star_camera.cpp
+++ /dev/null
@@ -1,649 +0,0 @@
-/* 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/star_camera.h"
-#include "titanic/debugger.h"
-#include "titanic/star_control/camera_mover.h"
-#include "titanic/star_control/fmatrix.h"
-#include "titanic/star_control/fpoint.h"
-#include "titanic/star_control/marked_camera_mover.h"
-#include "titanic/star_control/unmarked_camera_mover.h"
-#include "titanic/star_control/error_code.h"
-#include "titanic/support/simple_file.h"
-#include "titanic/titanic.h"
-
-namespace Titanic {
-
-const double rowScale1 = 100000.0;
-const double rowScale2 = 1000000.0;
-
-FMatrix *CStarCamera::_priorOrientation;
-FMatrix *CStarCamera::_newOrientation;
-
-CStarCamera::CStarCamera(const CNavigationInfo *data) :
- _starLockState(ZERO_LOCKED), _mover(nullptr), _isMoved(false), _isInLockingProcess(false) {
- setMoverType(data);
-}
-
-CStarCamera::CStarCamera(CViewport *src) :
- _starLockState(ZERO_LOCKED), _mover(nullptr), _isMoved(false), _isInLockingProcess(false), _viewport(src) {
-}
-
-void CStarCamera::init() {
- _priorOrientation = nullptr;
- _newOrientation = nullptr;
-}
-
-void CStarCamera::deinit() {
- delete _priorOrientation;
- delete _newOrientation;
- _priorOrientation = nullptr;
- _newOrientation = nullptr;
-}
-
-bool CStarCamera::isLocked() {
- return _mover->isLocked();
-}
-
-bool CStarCamera::isNotInLockingProcess() {
- return !_isInLockingProcess;
-}
-
-CStarCamera::~CStarCamera() {
- removeMover();
-}
-
-void CStarCamera::proc2(const CViewport *src) {
- _viewport.copyFrom(src);
-}
-
-void CStarCamera::proc3(const CNavigationInfo *src) {
- _mover->copyFrom(src);
-}
-
-void CStarCamera::setPosition(const FVector &v) {
- if (!isLocked()) {
- _viewport.setPosition(v);
- setIsMoved();
- }
-}
-
-void CStarCamera::setOrientation(const FVector &v) {
- if (!isLocked())
- _viewport.setOrientation(v);
-}
-
-// This never gets called
-void CStarCamera::proc6(int v) {
- if (!isLocked())
- _viewport.setC(v);
-}
-
-// This never gets called
-void CStarCamera::proc7(int v) {
- if (!isLocked())
- _viewport.set10(v);
-}
-
-// This never gets called
-void CStarCamera::proc8(int v) {
- if (!isLocked())
- _viewport.set14(v);
-}
-
-// This never gets called
-void CStarCamera::setCenterYAngle(int v) {
- if (!isLocked())
- _viewport.setCenterYAngle(v);
-}
-
-// This never gets called
-void CStarCamera::setCenterZAngle(int v) {
- if (!isLocked())
- _viewport.setCenterZAngle(v);
-}
-
-void CStarCamera::randomizeOrientation() {
- if (!isLocked())
- _viewport.randomizeOrientation();
-}
-
-void CStarCamera::setFields(StarMode mode, double val) {
- if (!isLocked())
- _viewport.changeStarColorPixel(mode, val);
-}
-
-void CStarCamera::proc13(CViewport *dest) {
- *dest = _viewport;
-}
-
-void CStarCamera::setDestination(const FVector &v) {
- FMatrix orientation = _viewport.getOrientation();
- FVector oldPos = _viewport._position;
-
- _mover->moveTo(oldPos, v, orientation);
-}
-
-void CStarCamera::updatePosition(CErrorCode *errorCode) {
- if (!_priorOrientation)
- _priorOrientation = new FMatrix();
- if (!_newOrientation)
- _newOrientation = new FMatrix();
-
- *_priorOrientation = _viewport.getOrientation();
- *_newOrientation = *_priorOrientation;
-
- FVector priorPos = _viewport._position;
- FVector newPos = _viewport._position;
- _mover->updatePosition(*errorCode, newPos, *_newOrientation);
-
- if (newPos != priorPos) {
- _viewport.setPosition(newPos);
- setIsMoved();
- }
-
- if (*_priorOrientation != *_newOrientation) {
- _viewport.setOrientation(*_newOrientation);
- }
-}
-
-void CStarCamera::increaseForwardSpeed() {
- _mover->increaseForwardSpeed();
-}
-
-void CStarCamera::increaseBackwardSpeed() {
- _mover->increaseBackwardSpeed();
-}
-
-void CStarCamera::fullSpeed() {
- _mover->fullSpeed();
-}
-
-void CStarCamera::stop() {
- _mover->stop();
-}
-
-void CStarCamera::reposition(double factor) {
- if (!isLocked())
- _viewport.reposition(factor);
-}
-
-void CStarCamera::setPosition(const FPose &pose) {
- if (!isLocked()) {
- _viewport.setPosition(pose);
- setIsMoved();
- }
-}
-
-void CStarCamera::changeOrientation(FMatrix &m) {
- if (!isLocked())
- _viewport.changeOrientation(m);
-}
-
-FPose CStarCamera::getPose() {
- return _viewport.getPose();
-}
-
-FPose CStarCamera::getRawPose() {
- return _viewport.getRawPose();
-}
-
-double CStarCamera::getThreshold() const {
- return _viewport._field10;
-}
-
-double CStarCamera::proc26() const {
- return _viewport._field14;
-}
-
-StarColor CStarCamera::getStarColor() const {
- return _viewport._starColor;
-}
-
-FVector CStarCamera::getRelativePos(int index, const FVector &src) {
- FVector dest;
-
- double val;
- if (index == 2) {
- val = _viewport._isZero;
- } else {
- val = _viewport._valArray[index];
- }
-
- dest._x = ((val + src._x) * _viewport._centerVector._x)
- / (_viewport._centerVector._y * src._z);
- dest._y = src._y * _viewport._centerVector._x / (_viewport._centerVector._z * src._z);
- dest._z = src._z;
- return dest;
-}
-
-FVector CStarCamera::getRelativePosNoCentering(int index, const FVector &src) {
- return _viewport.getRelativePosNoCentering(index, src);
-}
-
-FVector CStarCamera::proc30(int index, const FVector &v) {
- return _viewport.getRelativePosCentering(index, v);
-}
-
-FVector CStarCamera::proc31(int index, const FVector &v) {
- return _viewport.getRelativePosCenteringRaw(index, v);
-}
-
-void CStarCamera::setViewportAngle(const FPoint &angles) {
- debug(DEBUG_DETAILED, "setViewportAngle %f %f", angles._x, angles._y);
-
- if (isLocked())
- return;
-
- switch(_starLockState) {
- case ZERO_LOCKED: {
- FPose subX(X_AXIS, angles._y);
- FPose subY(Y_AXIS, -angles._x); // needs to be negative or looking left will cause the view to go right
- FPose sub(subX, subY);
- changeOrientation(sub);
- break;
- }
-
- case ONE_LOCKED: {
- FVector row1 = _lockedStarsPos._row1;
- FPose poseX(X_AXIS, angles._y);
- FPose poseY(Y_AXIS, -angles._x); // needs to be negative or looking left will cause the view to go right
- FPose pose(poseX, poseY);
-
- FMatrix m1 = _viewport.getOrientation();
- FVector tempV1 = _viewport._position;
- FVector tempV2 = m1._row1 * rowScale1;
- FVector tempV3 = tempV2 + tempV1;
- FVector tempV4 = tempV3;
-
- tempV2 = m1._row2 * rowScale1;
- FVector tempV5 = m1._row3 * rowScale1;
- FVector tempV6 = tempV2 + tempV1;
-
- FVector tempV7 = tempV5 + tempV1;
- tempV5 = tempV6;
- tempV6 = tempV7;
-
- tempV1 -= row1;
- tempV4 -= row1;
- tempV5 -= row1;
- tempV6 -= row1;
-
- tempV1 = tempV1.matProdRowVect(pose);
- tempV4 = tempV4.matProdRowVect(pose);
- tempV5 = tempV5.matProdRowVect(pose);
- tempV6 = tempV6.matProdRowVect(pose);
-
- tempV4 -= tempV1;
- tempV5 -= tempV1;
- tempV6 -= tempV1;
-
- float unusedScale = 0.0;
- if (!tempV4.normalize(unusedScale) ||
- !tempV5.normalize(unusedScale) ||
- !tempV6.normalize(unusedScale)) {
- // Do the normalization, put the scale amount in unusedScale,
- // but if it is unsuccessful, crash
- assert(unusedScale);
- }
-
- tempV1 += row1;
- m1.set(tempV4, tempV5, tempV6);
- _viewport.setOrientation(m1);
- _viewport.setPosition(tempV1);
- break;
- }
-
- case TWO_LOCKED: {
- FVector tempV2;
- FPose m1;
- FVector mrow1, mrow2, mrow3;
- FVector tempV1, diffV, multV, multV2, tempV3, tempV7;
-
- FPose subX(0, _lockedStarsPos._row1);
- FPose subY(Y_AXIS, angles._y);
-
- tempV1 = _lockedStarsPos._row2 - _lockedStarsPos._row1;
- diffV = tempV1;
- m1 = diffV.formRotXY();
- FPose m11;
- fposeProd(m1, subX, m11);
-
- subX = m11.inverseTransform();
- FPose m12;
- fposeProd(subX, subY, m12);
-
- FMatrix m3 = _viewport.getOrientation();
- tempV2 = _viewport._position;
- multV._x = m3._row1._x * rowScale2;
- multV._y = m3._row1._y * rowScale2;
- multV._z = m3._row1._z * rowScale2;
- tempV3._x = tempV2._x;
- tempV3._y = tempV2._y;
- tempV3._z = tempV2._z;
- multV2._z = m3._row2._z * rowScale2;
-
- 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 * rowScale2;
- multV2._y = m3._row2._y * rowScale2;
- mrow1 = tempV1;
- multV = multV2 + tempV3;
- mrow2 = multV;
-
- tempV7._z = m3._row3._z * rowScale2 + tempV3._z;
- tempV7._y = m3._row3._y * rowScale2 + tempV3._y;
- tempV7._x = m3._row3._x * rowScale2 + tempV3._x;
-
- mrow3 = tempV7;
- tempV3 = tempV3.matProdRowVect(m12);
- mrow1 = mrow1.matProdRowVect(m12);
- mrow2 = mrow2.matProdRowVect(m12);
- mrow3 = mrow3.matProdRowVect(m12);
-
- tempV3 = tempV3.matProdRowVect(m11);
- mrow1 = mrow1.matProdRowVect(m11);
- mrow2 = mrow2.matProdRowVect(m11);
- mrow3 = mrow3.matProdRowVect(m11);
-
- mrow1 -= tempV3;
- mrow2 -= tempV3;
- mrow3 -= tempV3;
-
- float unusedScale=0.0;
- if (!mrow1.normalize(unusedScale) ||
- !mrow2.normalize(unusedScale) ||
- !mrow3.normalize(unusedScale)) {
- // Do the normalization, put the scale amount in unusedScale,
- // but if it is unsuccessful, crash
- assert(unusedScale);
- }
-
- m3.set(mrow1, mrow2, mrow3);
- _viewport.setOrientation(m3);
- _viewport.setPosition(tempV3);
- break;
- }
-
- // All three stars are locked on in this case so the camera does not move
- // in response to the users mouse movements
- case THREE_LOCKED:
- default:
- break;
- }
-}
-
-bool CStarCamera::addLockedStar(const FVector v) {
- if (_starLockState == THREE_LOCKED)
- return false;
-
- CNavigationInfo data;
- _mover->copyTo(&data);
- removeMover();
-
- FVector &row = _lockedStarsPos[(int)_starLockState];
- _starLockState = StarLockState((int)_starLockState + 1);
- row = v;
- setMoverType(&data);
- return true;
-}
-
-bool CStarCamera::removeLockedStar() {
- if (_starLockState == ZERO_LOCKED)
- return false;
-
- CNavigationInfo data;
- _mover->copyTo(&data);
- removeMover();
-
- _starLockState = StarLockState((int)_starLockState - 1);
- setMoverType(&data);
- return true;
-}
-
-void CStarCamera::getRelativeXCenterPixels(double *v1, double *v2, double *v3, double *v4) {
- _viewport.getRelativeXCenterPixels(v1, v2, v3, v4);
-}
-
-void CStarCamera::load(SimpleFile *file, int param) {
- _viewport.load(file, param);
-}
-
-void CStarCamera::save(SimpleFile *file, int indent) {
- _viewport.save(file, indent);
-}
-
-bool CStarCamera::setMoverType(const CNavigationInfo *src) {
- CCameraMover *mover = nullptr;
-
- switch (_starLockState) {
- case ZERO_LOCKED:
- mover = new CUnmarkedCameraMover(src);
- break;
-
- case ONE_LOCKED:
- case TWO_LOCKED:
- case THREE_LOCKED:
- mover = new CMarkedCameraMover(src);
- break;
-
- default:
- break;
- }
-
- if (mover) {
- assert(!_mover); // removeMover() is usually called before this function so _mover is null
- _mover = mover;
- return true;
- } else {
- return false;
- }
-}
-
-void CStarCamera::removeMover() {
- if (_mover) {
- delete _mover;
- _mover = nullptr;
- _isInLockingProcess = false;
- }
-}
-
-bool CStarCamera::lockMarker1(FVector v1, FVector firstStarPosition, FVector v3) {
- if (_starLockState != ZERO_LOCKED)
- return true;
-
- _isInLockingProcess = true;
- FVector tempV;
- double val1, val2, val3, val4, val5;
- double val6, val7, val8, val9;
-
- val1 = _viewport._centerVector._y * v1._x;
- tempV._z = _viewport._field10;
- val2 = _viewport._centerVector._y * tempV._z * v3._x;
- val3 = _viewport._centerVector._z * v1._y;
- val4 = _viewport._centerVector._z * tempV._z;
- val5 = val1 * v1._z / _viewport._centerVector._x;
- v3._z = v1._z;
- val6 = val4 * v3._y;
- val7 = val3 * v1._z / _viewport._centerVector._x;
- val8 = val6 / _viewport._centerVector._x;
- val9 = val2 / _viewport._centerVector._x;
- v3._x = val5 - _viewport._isZero; // TODO: _viewport._isZero is always zero
- v3._y = val7;
- tempV._x = val9 - _viewport._isZero; // TODO: _viewport._isZero is always zero
- tempV._y = val8;
-
- float unusedScale = 0.0;
- if (!v3.normalize(unusedScale) || !tempV.normalize(unusedScale)) {
- // Do the normalization, put the scale amount in unusedScale,
- // but if it is unsuccessful, crash
- assert(unusedScale);
- }
-
- FMatrix matrix = _viewport.getOrientation();
- const FVector &pos = _viewport._position;
- _mover->transitionBetweenOrientations(v3, tempV, pos, matrix); // TODO: pos does not get used in this function,
- // i.e., _mover has CUnmarkedCameraMover handle which means
- // CUnmarkedCameraMover::transitionBetweenOrientations gets called
-
- CStarVector *sv = new CStarVector(this, firstStarPosition);
- _mover->setVector(sv);
-
- return true;
-}
-
-bool CStarCamera::lockMarker2(CViewport *viewport, const FVector &secondStarPosition) {
- if (_starLockState != ONE_LOCKED)
- return true;
-
- _isInLockingProcess = true;
- FVector firstStarPosition = _lockedStarsPos._row1;
- FPose m3(0, firstStarPosition); // Identity matrix and row4 as the 1st stars position
- FVector starDelta = secondStarPosition - firstStarPosition;
- FPose m10 = starDelta.formRotXY();
- FPose m11;
- fposeProd(m10, m3, m11);
-
- m10 = m11.inverseTransform();
-
- FVector oldPos = _viewport._position;
-
- FPose m4;
- m4._row1 = viewport->_position;
- m4._row2 = FVector(0.0, 0.0, 0.0);
- m4._row3 = FVector(0.0, 0.0, 0.0);
- m4._vector = FVector(0.0, 0.0, 0.0);
-
- FMatrix newOr = viewport->getOrientation();
- float yVal1 = newOr._row1._y * rowScale2;
- float zVal1 = newOr._row1._z * rowScale2;
- float xVal1 = newOr._row2._x * rowScale2;
- float yVal2 = newOr._row2._y * rowScale2;
- float zVal2 = newOr._row2._z * rowScale2;
- float zVal3 = zVal1 + m4._row1._z;
- float yVal3 = yVal1 + m4._row1._y;
- float xVal2 = newOr._row1._x * rowScale2 + m4._row1._x;
- float zVal4 = zVal2 + m4._row1._z;
- float yVal4 = yVal2 + m4._row1._y;
- float xVal3 = xVal1 + m4._row1._x;
-
- FVector tempV4(xVal2, yVal3, zVal3);
- FVector tempV3(xVal3, yVal4, zVal4);
- m4._row3 = tempV4;
-
- FVector tempV5;
- tempV5._x = newOr._row3._x * rowScale2;
- tempV5._y = newOr._row3._y * rowScale2;
- m4._row2 = tempV3;
-
- tempV3._x = tempV5._x + m4._row1._x;
- tempV3._y = tempV5._y + m4._row1._y;
- tempV3._z = newOr._row3._z * rowScale2 + m4._row1._z;
- m4._vector = tempV3;
-
-
- FVector viewPosition2 = oldPos.matProdRowVect(m10);
- m3 = m4.compose2(m10);
-
- float minDistance;
- FVector x1(viewPosition2);
- FVector x2(m3._row1);
- // Find the angle of rotation for m4._row1 that gives the minimum distance to viewPosition
- float minDegree = calcAngleForMinDist(x1, x2, minDistance);
-
- m3.rotVectAxisY((double)minDegree);
- FPose m13;
- m13 = m3.compose2(m11);
-
- m13._row3 -= m13._row1;
- m13._row2 -= m13._row1;
- m13._vector -= m13._row1;
-
-
-
- float unusedScale=0.0;
- if (!m13._row2.normalize(unusedScale) ||
- !m13._row3.normalize(unusedScale) ||
- !m13._vector.normalize(unusedScale) ) {
- // Do the normalizations, put the scale amount in unusedScale,
- // but if any of the normalizations are unsuccessful, crash
- assert(unusedScale);
- }
-
- newOr.set(m13._row3, m13._row2, m13._vector);
-
- FVector newPos = m13._row1;
- FMatrix oldOr = _viewport.getOrientation();
-
- // WORKAROUND: set old position to new position (1st argument), this prevents
- // locking issues when locking the 2nd star. Fixes #9961.
- _mover->transitionBetweenPosOrients(newPos, newPos, oldOr, newOr);
- CStarVector *sv = new CStarVector(this, secondStarPosition);
- _mover->setVector(sv);
-
- return true;
-}
-
-bool CStarCamera::lockMarker3(CViewport *viewport, const FVector &thirdStarPosition) {
- if (_starLockState != TWO_LOCKED)
- return true;
-
- _isInLockingProcess = true;
- FMatrix newOr = viewport->getOrientation();
- FMatrix oldOr = _viewport.getOrientation();
- FVector newPos = viewport->_position;
- //FVector oldPos = _viewport._position;
-
- // WORKAROUND: set old position to new position (1st argument), this prevents
- // locking issues when locking the 3rd star. Fixes #9961.
- _mover->transitionBetweenPosOrients(newPos, newPos, oldOr, newOr);
-
- CStarVector *sv = new CStarVector(this, thirdStarPosition);
- _mover->setVector(sv);
-
- return true;
-}
-
-float CStarCamera::calcAngleForMinDist(FVector &x, FVector &y, float &minDistance) {
- FVector tempPos;
- minDistance = (float)1.0e20;
- float minDegree = 0.0;
- float degInc = 1.0; // one degree steps
- int nDegrees = floor(360.0/degInc);
- for (int i = 0; i < nDegrees; ++i) {
- tempPos = y;
- tempPos.rotVectAxisY((float)degInc*i);
- float distance = x.getDistance(tempPos);
-
- if (distance < minDistance) {
- minDistance = distance;
- minDegree = (float) degInc*i;
- }
- }
- return minDegree;
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_camera.h b/engines/titanic/star_control/star_camera.h
deleted file mode 100644
index 678f7b0..0000000
--- a/engines/titanic/star_control/star_camera.h
+++ /dev/null
@@ -1,251 +0,0 @@
-/* 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_STAR_CAMERA_H
-#define TITANIC_STAR_CAMERA_H
-
-#include "titanic/star_control/fmatrix.h"
-#include "titanic/star_control/base_stars.h"
-#include "titanic/star_control/viewport.h"
-
-namespace Titanic {
-
-class CCameraMover;
-class CErrorCode;
-struct CNavigationInfo;
-class FPoint;
-class SimpleFile;
-
-enum StarLockState { ZERO_LOCKED=0, ONE_LOCKED=1, TWO_LOCKED=2, THREE_LOCKED=3 };
-
-/**
- * Implements a reference point from which the starmap can be viewed
- */
-class CStarCamera {
-private:
- static FMatrix *_priorOrientation;
- static FMatrix *_newOrientation;
-private:
- StarLockState _starLockState;
- FMatrix _lockedStarsPos; // Each row represents the location of a locked star
- CCameraMover *_mover; // A marked or unmarked camera mover, contains an automover
- CViewport _viewport;
- bool _isMoved; // Used in CPetStarfield to determine if a star destination can be set
- bool _isInLockingProcess; // The mover/view is homing in on a new star
-private:
- /**
- * Set Mover type to be unmarked or marked camera mover based on
- * the number of stars currently locked (_starLockState)
- * The CNavigationInfo data is used to initialize the mover
- */
- bool setMoverType(const CNavigationInfo *src);
-
- /**
- * Deletes the previous mover handle
- */
- void removeMover();
-
- /**
- * Return whether the handler is locked
- */
- bool isLocked();
-public:
- static void init();
- static void deinit();
-public:
- CStarCamera(const CNavigationInfo *data);
- CStarCamera(CViewport *src);
- virtual ~CStarCamera();
-
- virtual void proc2(const CViewport *src);
- virtual void proc3(const CNavigationInfo *src);
-
- /**
- * The mover/view is not currently homing in on a new star
- * This can mean it is unmarked, or that it is fully locked
- * onto one star or more (but not in the process of doing so)
- */
- bool isNotInLockingProcess();
-
- /**
- * Set the camera position
- */
- virtual void setPosition(const FVector &v);
-
- /**
- * Sets the camera orientation
- */
- virtual void setOrientation(const FVector &v);
-
- virtual void proc6(int v);
- virtual void proc7(int v);
- virtual void proc8(int v);
- virtual void setCenterYAngle(int v);
- virtual void setCenterZAngle(int v);
- virtual void randomizeOrientation();
- virtual void setFields(StarMode mode, double val);
- virtual void proc13(CViewport *dest);
-
- /**
- * Sets the destination to move the camera to
- */
- virtual void setDestination(const FVector &v);
-
- /**
- * Updates the camera position
- */
- virtual void updatePosition(CErrorCode *errorCode);
-
- /**
- * Increases movement speed in forward direction
- */
- virtual void increaseForwardSpeed();
-
- /**
- * Increases movement speed in backward direction
- */
- virtual void increaseBackwardSpeed();
-
- /**
- * Increase to full speed
- */
- virtual void fullSpeed();
-
- /**
- * Completely stop
- */
- virtual void stop();
-
- virtual void reposition(double factor);
-
- /**
- * Set the camera position
- */
- virtual void setPosition(const FPose &pose);
-
- virtual void changeOrientation(FMatrix &m);
-
- /**
- * Get the position and direction of the camera
- */
- virtual FPose getPose();
-
- virtual FPose getRawPose();
- virtual double getThreshold() const;
-
- virtual double proc26() const;
- virtual StarColor getStarColor() const;
-
- /**
- * Return the passed vector relative to the center of the viewpoint
- */
- virtual FVector getRelativePos(int index, const FVector &src);
-
- virtual FVector getRelativePosNoCentering(int index, const FVector &src);
- virtual FVector proc30(int index, const FVector &v);
- virtual FVector proc31(int index, const FVector &v);
-
- /**
- * Sets the viewport position within the starfield
- */
- virtual void setViewportAngle(const FPoint &angles);
-
- /**
- * How many stars are currently locked onto
- */
- virtual StarLockState getStarLockState() const { return _starLockState; }
-
- /**
- * Adds the row for a locked in marker/star
- * @remarks This can't be a pass-by-reference, since adding
- * the vector for the star destroys the calling star vector
- */
- virtual bool addLockedStar(const FVector v);
-
- /**
- * Removes the most recent locked in marker/star
- * @remarks This can't be a pass-by-reference, since adding
- * the vector for the star destroys the calling star vector
- */
- virtual bool removeLockedStar();
-
- /**
- * All arguments are return values
- * First is the x center coordinate relative to y
- * Second is the x center coordinate relative to z
- * Third is the first x center pixel offset
- * Fourth is the second x center pixel offset
- */
- virtual void getRelativeXCenterPixels(double *v1, double *v2, double *v3, double *v4);
-
- /**
- * Load the data for the class from file
- */
- virtual void load(SimpleFile *file, int param);
-
- /**
- * Save the data for the class to file
- */
- virtual void save(SimpleFile *file, int indent);
-
- /**
- * Calculates the angle of rotation of y that achieves
- * the minimum distance to x.
- * The angle is in degrees.
- * Also returns the minimum distance calculated
- */
- float calcAngleForMinDist(FVector &x, FVector &y, float &minDistance);
-
- /**
- * Returns true for whether the camera has been moved
- */
- bool isMoved() const { return _isMoved; }
-
- /**
- * Sets the camera as having been moved
- */
- void setIsMoved() { _isMoved = true; }
-
- /**
- * Resets the flag for whether the camera has moved
- */
- void clearIsMoved() { _isMoved = false; }
-
- /**
- * Lock in the first matched star marker
- */
- bool lockMarker1(FVector v1, FVector v2, FVector v3);
-
- /**
- * Lock in the second matched star marker
- */
- bool lockMarker2(CViewport *viewport, const FVector &v);
-
- /**
- * Lock in the third and final matched star marker
- */
- bool lockMarker3(CViewport *viewport, const FVector &v);
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_STAR_CAMERA_H */
diff --git a/engines/titanic/star_control/star_closeup.cpp b/engines/titanic/star_control/star_closeup.cpp
index 04b4c86..766445b 100644
--- a/engines/titanic/star_control/star_closeup.cpp
+++ b/engines/titanic/star_control/star_closeup.cpp
@@ -22,7 +22,7 @@
#include "titanic/star_control/star_closeup.h"
#include "titanic/star_control/error_code.h"
-#include "titanic/star_control/star_camera.h"
+#include "titanic/star_control/camera.h"
#include "titanic/star_control/surface_area.h"
#include "titanic/titanic.h"
@@ -192,7 +192,7 @@ bool CStarCloseup::setup2(int val1, int val2) {
}
void CStarCloseup::draw(const FPose &pose, const FVector &vector, const FVector &vector2,
- CSurfaceArea *surfaceArea, CStarCamera *camera) {
+ CSurfaceArea *surfaceArea, CCamera *camera) {
const int VALUES[] = { 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4 };
float val1 = camera->getThreshold();
StarColor starColor = camera->getStarColor();
diff --git a/engines/titanic/star_control/star_closeup.h b/engines/titanic/star_control/star_closeup.h
index 04962e6..346fa43 100644
--- a/engines/titanic/star_control/star_closeup.h
+++ b/engines/titanic/star_control/star_closeup.h
@@ -31,7 +31,7 @@
namespace Titanic {
class CErrorCode;
-class CStarCamera;
+class CCamera;
class CSurfaceArea;
/**
@@ -125,7 +125,7 @@ public:
* Draws the star globe
*/
virtual void draw(const FPose &pose, const FVector &vector, const FVector &vector2,
- CSurfaceArea *surfaceArea, CStarCamera *camera);
+ CSurfaceArea *surfaceArea, CCamera *camera);
virtual void proc3(CErrorCode *errorCode);
diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp
index f8c9096..fe63936 100644
--- a/engines/titanic/star_control/star_control.cpp
+++ b/engines/titanic/star_control/star_control.cpp
@@ -41,11 +41,11 @@ END_MESSAGE_MAP()
CStarControl::CStarControl() : _enabled(false), _petControl(nullptr),
_starRect(20, 10, 620, 350) {
- CStarCamera::init();
+ CCamera::init();
}
CStarControl::~CStarControl() {
- CStarCamera::deinit();
+ CCamera::deinit();
}
void CStarControl::save(SimpleFile *file, int indent) {
diff --git a/engines/titanic/star_control/star_crosshairs.cpp b/engines/titanic/star_control/star_crosshairs.cpp
index 2da83b9..e3edd1b 100644
--- a/engines/titanic/star_control/star_crosshairs.cpp
+++ b/engines/titanic/star_control/star_crosshairs.cpp
@@ -22,7 +22,7 @@
#include "titanic/star_control/star_crosshairs.h"
#include "titanic/star_control/star_markers.h"
-#include "titanic/star_control/star_camera.h"
+#include "titanic/star_control/camera.h"
#include "titanic/star_control/star_field.h"
#include "titanic/star_control/star_ref.h"
#include "titanic/support/simple_file.h"
@@ -135,7 +135,7 @@ void CStarCrosshairs::selectStar(int index, CVideoSurface *surface,
}
}
-bool CStarCrosshairs::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarCamera *camera) {
+bool CStarCrosshairs::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CCamera *camera) {
int count = starField->baseFn2(surfaceArea, camera);
if (count > 0) {
diff --git a/engines/titanic/star_control/star_crosshairs.h b/engines/titanic/star_control/star_crosshairs.h
index e30572a..bcfdeea 100644
--- a/engines/titanic/star_control/star_crosshairs.h
+++ b/engines/titanic/star_control/star_crosshairs.h
@@ -34,7 +34,7 @@ namespace Titanic {
class CStarField;
class CStarMarkers;
-class CStarCamera;
+class CCamera;
class SimpleFile;
class CStarCrosshairs {
@@ -78,7 +78,7 @@ public:
void draw(CSurfaceArea *surfaceArea);
- bool fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarCamera *camera);
+ bool fn1(CStarField *starField, CSurfaceArea *surfaceArea, CCamera *camera);
/**
* Increments the number of matches
diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp
index b4b1cad..fb05474 100644
--- a/engines/titanic/star_control/star_field.cpp
+++ b/engines/titanic/star_control/star_field.cpp
@@ -22,7 +22,7 @@
#include "titanic/star_control/star_field.h"
#include "titanic/star_control/surface_area.h"
-#include "titanic/star_control/star_camera.h"
+#include "titanic/star_control/camera.h"
#include "titanic/titanic.h"
namespace Titanic {
@@ -61,7 +61,7 @@ bool CStarField::initDocument() {
return valid;
}
-void CStarField::render(CVideoSurface *surface, CStarCamera *camera) {
+void CStarField::render(CVideoSurface *surface, CCamera *camera) {
CSurfaceArea surfaceArea(surface);
draw(&surfaceArea, camera, &_starCloseup);
if (_showBox)
@@ -175,7 +175,7 @@ void CStarField::drawBox(CSurfaceArea *surfaceArea) {
surfaceArea->setColorFromPixel();
}
-void CStarField::renderLockLine(CSurfaceArea *surfaceArea, CStarCamera *camera) {
+void CStarField::renderLockLine(CSurfaceArea *surfaceArea, CCamera *camera) {
FVector screenCoord, worldCoord, photoPos;
_closeToMarker = false;
@@ -188,7 +188,7 @@ void CStarField::renderLockLine(CSurfaceArea *surfaceArea, CStarCamera *camera)
}
}
-double CStarField::lockDistance(CSurfaceArea *surfaceArea, CStarCamera *camera,
+double CStarField::lockDistance(CSurfaceArea *surfaceArea, CCamera *camera,
FVector &screenCoord, FVector &worldCoord, FVector &photoPos) {
if (_crosshairs.isEmpty())
// No crosshairs selection yet
@@ -223,7 +223,7 @@ double CStarField::lockDistance(CSurfaceArea *surfaceArea, CStarCamera *camera,
return incr;
}
-void CStarField::fn6(CVideoSurface *surface, CStarCamera *camera) {
+void CStarField::fn6(CVideoSurface *surface, CCamera *camera) {
CSurfaceArea surfaceArea(surface);
_crosshairs.fn1(this, &surfaceArea, camera);
}
@@ -238,7 +238,7 @@ void CStarField::decLockLevel(CVideoSurface *surface) {
setSolved();
}
-bool CStarField::mouseButtonDown(CVideoSurface *surface, CStarCamera *camera,
+bool CStarField::mouseButtonDown(CVideoSurface *surface, CCamera *camera,
int flags, const Common::Point &pt) {
if (_mode == MODE_STARFIELD) {
CSurfaceArea surfaceArea(surface);
diff --git a/engines/titanic/star_control/star_field.h b/engines/titanic/star_control/star_field.h
index b2e6bee..2367e8d 100644
--- a/engines/titanic/star_control/star_field.h
+++ b/engines/titanic/star_control/star_field.h
@@ -58,7 +58,7 @@ private:
* If the player's home photo has a selected star, and the starfield view
* is close enough to it, draw a lock line
*/
- void renderLockLine(CSurfaceArea *surfaceArea, CStarCamera *camera);
+ void renderLockLine(CSurfaceArea *surfaceArea, CCamera *camera);
public:
CStarField();
@@ -77,7 +77,7 @@ public:
/**
* Renders the contents of the starfield
*/
- void render(CVideoSurface *surface, CStarCamera *camera);
+ void render(CVideoSurface *surface, CCamera *camera);
bool getBoundaryState() const;
@@ -152,10 +152,10 @@ public:
/**
* Gets the lock distance to a star
*/
- double lockDistance(CSurfaceArea *surfaceArea, CStarCamera *camera,
+ double lockDistance(CSurfaceArea *surfaceArea, CCamera *camera,
FVector &screenCoord, FVector &worldCoord, FVector &photoPos);
- void fn6(CVideoSurface *surface, CStarCamera *camera);
+ void fn6(CVideoSurface *surface, CCamera *camera);
/**
* Increments the number of matched markers
@@ -172,7 +172,7 @@ public:
/**
* Called when the starfield is clicked
*/
- bool mouseButtonDown(CVideoSurface *surface, CStarCamera *camera,
+ bool mouseButtonDown(CVideoSurface *surface, CCamera *camera,
int flags, const Common::Point &pt);
/**
diff --git a/engines/titanic/star_control/star_field_base.cpp b/engines/titanic/star_control/star_field_base.cpp
index 101180d..c8eabe4 100644
--- a/engines/titanic/star_control/star_field_base.cpp
+++ b/engines/titanic/star_control/star_field_base.cpp
@@ -22,7 +22,7 @@
#include "titanic/star_control/star_field_base.h"
#include "titanic/debugger.h"
-#include "titanic/star_control/star_camera.h"
+#include "titanic/star_control/camera.h"
#include "titanic/support/simple_file.h"
namespace Titanic {
@@ -39,7 +39,7 @@ bool CStarFieldBase::loadYale(int v1) {
}
bool CStarFieldBase::selectStar(CSurfaceArea *surfaceArea,
- CStarCamera *camera, const Common::Point &pt, void *handler) {
+ CCamera *camera, const Common::Point &pt, void *handler) {
int index = findStar(surfaceArea, camera, pt);
if (index == -1) {
return false;
diff --git a/engines/titanic/star_control/star_field_base.h b/engines/titanic/star_control/star_field_base.h
index 2df2ccb..12b4bcd 100644
--- a/engines/titanic/star_control/star_field_base.h
+++ b/engines/titanic/star_control/star_field_base.h
@@ -36,7 +36,7 @@ public:
/**
* Selects a star
*/
- virtual bool selectStar(CSurfaceArea *surfaceArea, CStarCamera *camera,
+ virtual bool selectStar(CSurfaceArea *surfaceArea, CCamera *camera,
const Common::Point &pt, void *handler = nullptr);
virtual bool loadStar();
diff --git a/engines/titanic/star_control/star_markers.cpp b/engines/titanic/star_control/star_markers.cpp
index 61c0c5b..6c2a484 100644
--- a/engines/titanic/star_control/star_markers.cpp
+++ b/engines/titanic/star_control/star_markers.cpp
@@ -21,12 +21,12 @@
*/
#include "titanic/star_control/star_markers.h"
-#include "titanic/star_control/star_camera.h"
+#include "titanic/star_control/camera.h"
#include "titanic/star_control/surface_area.h"
namespace Titanic {
-void CStarMarkers::draw(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup) {
+void CStarMarkers::draw(CSurfaceArea *surfaceArea, CCamera *camera, CStarCloseup *closeup) {
if (_data.empty())
return;
diff --git a/engines/titanic/star_control/star_markers.h b/engines/titanic/star_control/star_markers.h
index 7699e47..1d568de 100644
--- a/engines/titanic/star_control/star_markers.h
+++ b/engines/titanic/star_control/star_markers.h
@@ -34,7 +34,7 @@ public:
/**
* Draw the item
*/
- virtual void draw(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup);
+ virtual void draw(CSurfaceArea *surfaceArea, CCamera *camera, CStarCloseup *closeup);
/**
* Adds a new star, or removes one if already present at the given co-ordinates
diff --git a/engines/titanic/star_control/star_ref.cpp b/engines/titanic/star_control/star_ref.cpp
index f7e71d8..6ba7d07 100644
--- a/engines/titanic/star_control/star_ref.cpp
+++ b/engines/titanic/star_control/star_ref.cpp
@@ -21,12 +21,12 @@
*/
#include "titanic/star_control/star_ref.h"
-#include "titanic/star_control/star_camera.h"
+#include "titanic/star_control/camera.h"
#include "titanic/star_control/surface_area.h"
namespace Titanic {
-void CBaseStarRef::process(CSurfaceArea *surface, CStarCamera *camera) {
+void CBaseStarRef::process(CSurfaceArea *surface, CCamera *camera) {
if (_stars->_data.empty())
return;
diff --git a/engines/titanic/star_control/star_ref.h b/engines/titanic/star_control/star_ref.h
index dd71bf8..b2cc4b6 100644
--- a/engines/titanic/star_control/star_ref.h
+++ b/engines/titanic/star_control/star_ref.h
@@ -28,7 +28,7 @@
namespace Titanic {
-class CStarCamera;
+class CCamera;
class CSurfaceArea;
class CBaseStarRef {
@@ -39,7 +39,7 @@ public:
CBaseStarRef() : _stars(nullptr) {}
virtual ~CBaseStarRef() {}
- void process(CSurfaceArea *surface, CStarCamera *camera);
+ void process(CSurfaceArea *surface, CCamera *camera);
virtual bool check(const Common::Point &pt, int index) { return false; }
};
diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp
index 5e06533..68d54c2 100644
--- a/engines/titanic/star_control/star_view.cpp
+++ b/engines/titanic/star_control/star_view.cpp
@@ -80,7 +80,7 @@ void CStarView::setup(CScreenManager *screenManager, CStarField *starField, CSta
void CStarView::takeCurrentHomePhoto() {
if (_lensValid) {
- CStarCamera camera(&_photoViewport);
+ CCamera camera(&_photoViewport);
takeHomePhotoHelper(&camera);
}
}
@@ -157,7 +157,7 @@ bool CStarView::MouseMoveMsg(int unused, const Point &pt) {
bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
FPose pose;
- int matchedIndex = _starField ? _starField->getMatchedIndex() : -1;
+ int lockLevel = _starField ? _starField->getMatchedIndex() : -1;
switch (tolower(key)) {
case Common::KEYCODE_TAB:
@@ -186,7 +186,7 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
}
case Common::KEYCODE_z:
- if (matchedIndex == -1) {
+ if (lockLevel == -1) {
pose.setRotationMatrix(Y_AXIS, -1.0);
_camera.changeOrientation(pose);
_camera.updatePosition(errorCode);
@@ -195,23 +195,23 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
break;
case Common::KEYCODE_SEMICOLON:
- if (matchedIndex == -1) {
- _camera.increaseForwardSpeed();
+ if (lockLevel == -1) {
+ _camera.accelerate();
errorCode->set();
return true;
}
break;
case Common::KEYCODE_PERIOD:
- if (matchedIndex == -1) {
- _camera.increaseBackwardSpeed();
+ if (lockLevel == -1) {
+ _camera.deccelerate();
errorCode->set();
return true;
}
break;
case Common::KEYCODE_SPACE:
- if (matchedIndex == -1) {
+ if (lockLevel == -1) {
_camera.stop();
errorCode->set();
return true;
@@ -219,7 +219,7 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
break;
case Common::KEYCODE_x:
- if (matchedIndex == -1) {
+ if (lockLevel == -1) {
pose.setRotationMatrix(Y_AXIS, 1.0);
_camera.changeOrientation(pose);
_camera.updatePosition(errorCode);
@@ -228,7 +228,7 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
break;
case Common::KEYCODE_QUOTE:
- if (matchedIndex == -1) {
+ if (lockLevel == -1) {
pose.setRotationMatrix(X_AXIS, 1.0);
_camera.changeOrientation(pose);
_camera.updatePosition(errorCode);
@@ -237,7 +237,7 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
break;
case Common::KEYCODE_SLASH:
- if (matchedIndex == -1) {
+ if (lockLevel == -1) {
pose.setRotationMatrix(X_AXIS, -1.0);
_camera.changeOrientation(pose);
_camera.updatePosition(errorCode);
@@ -460,7 +460,7 @@ void CStarView::unlockStar() {
}
}
-void CStarView::takeHomePhotoHelper(CStarCamera *camera) {
+void CStarView::takeHomePhotoHelper(CCamera *camera) {
if (_starField) {
if (!_photoSurface) {
CScreenManager *scrManager = CScreenManager::setCurrent();
diff --git a/engines/titanic/star_control/star_view.h b/engines/titanic/star_control/star_view.h
index 9e56e95..3ed7d32 100644
--- a/engines/titanic/star_control/star_view.h
+++ b/engines/titanic/star_control/star_view.h
@@ -23,7 +23,7 @@
#ifndef TITANIC_STAR_VIEW_H
#define TITANIC_STAR_VIEW_H
-#include "titanic/star_control/star_camera.h"
+#include "titanic/star_control/camera.h"
#include "titanic/star_control/surface_fader.h"
#include "titanic/star_control/viewport.h"
#include "titanic/support/rect.h"
@@ -42,7 +42,7 @@ private:
CStarControl *_owner;
CStarField *_starField;
CVideoSurface *_videoSurface;
- CStarCamera _camera;
+ CCamera _camera;
bool _lensValid;
CViewport _photoViewport;
CSurfaceFader _fader;
@@ -54,7 +54,7 @@ private:
/**
* Take a photograph of a view specified by the camera
*/
- void takeHomePhotoHelper(CStarCamera *camera);
+ void takeHomePhotoHelper(CCamera *camera);
/**
* View a specified star
diff --git a/engines/titanic/star_control/viewport.cpp b/engines/titanic/star_control/viewport.cpp
index dcd8d78..59ada40 100644
--- a/engines/titanic/star_control/viewport.cpp
+++ b/engines/titanic/star_control/viewport.cpp
@@ -231,7 +231,7 @@ FPose CViewport::getRawPose() {
// TODO: should index be used here like
// getRelativePosCentering/getRelativePosCentering2?
-// CStarCamera::getRelativePosCentering is calling this with an index of
+// CCamera::getRelativePosCentering is calling this with an index of
// 2 which corresponds to _isZero which has value 0.
FVector CViewport::getRelativePosNoCentering(int index, const FVector &src) {
FPose current_pose = getPose();
diff --git a/engines/titanic/star_control/viewport.h b/engines/titanic/star_control/viewport.h
index ae42e84..df82620 100644
--- a/engines/titanic/star_control/viewport.h
+++ b/engines/titanic/star_control/viewport.h
@@ -40,7 +40,7 @@ enum StarColor { WHITE = 0, PINK = 2 };
/**
* Implements the viewport functionality for viewing the star field in
* a given position and orientation.
- * CStarCamera is a big user of this class
+ * CCamera is a big user of this class
*/
class CViewport {
private:
More information about the Scummvm-git-logs
mailing list