[Scummvm-git-logs] scummvm master -> 2925cfd0329ea755dbac649fc449548aecbe08bb
dreammaster
paulfgilbert at gmail.com
Sun Jan 12 21:21:28 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
bd6e14193d TITANIC: Cleanup of CStarField
2925cfd032 TITANIC: Properly implement and hookup the CConstBoundaries
Commit: bd6e14193d2a3801f958754c41906bc3b82447d3
https://github.com/scummvm/scummvm/commit/bd6e14193d2a3801f958754c41906bc3b82447d3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-01-12T13:21:09-08:00
Commit Message:
TITANIC: Cleanup of CStarField
Changed paths:
engines/titanic/star_control/star_field.cpp
engines/titanic/star_control/star_field.h
diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp
index 483dc37..dfd0490 100644
--- a/engines/titanic/star_control/star_field.cpp
+++ b/engines/titanic/star_control/star_field.cpp
@@ -77,7 +77,7 @@ void CStarField::render(CVideoSurface *surface, CStarCamera *camera) {
if (_renderBoundaries)
_constBounds.draw(&surfaceArea, camera);
- fn4(&surfaceArea, camera);
+ renderLockLine(&surfaceArea, camera);
}
bool CStarField::getBoundaryState() const {
@@ -177,7 +177,7 @@ void CStarField::drawBox(CSurfaceArea *surfaceArea) {
surfaceArea->setColorFromPixel();
}
-void CStarField::fn4(CSurfaceArea *surfaceArea, CStarCamera *camera) {
+void CStarField::renderLockLine(CSurfaceArea *surfaceArea, CStarCamera *camera) {
FVector screenCoord, worldCoord, photoPos;
_closeToMarker = false;
@@ -201,7 +201,7 @@ double CStarField::lockDistance(CSurfaceArea *surfaceArea, CStarCamera *camera,
const CBaseStarEntry *dataP = _markers.getDataPtr(_crosshairs._entryIndex);
worldCoord = dataP->_position;
- FVector tv = camera->getRelativePosNoCentering(2, worldCoord); // First argument is not getting used in CViewport::fn16
+ FVector tv = camera->getRelativePosNoCentering(2, worldCoord);
if (camera->getThreshold() >= tv._z)
return -1.0;
diff --git a/engines/titanic/star_control/star_field.h b/engines/titanic/star_control/star_field.h
index 9450a13..a12fec8 100644
--- a/engines/titanic/star_control/star_field.h
+++ b/engines/titanic/star_control/star_field.h
@@ -53,7 +53,11 @@ private:
*/
void drawBox(CSurfaceArea *surfaceArea);
- void fn4(CSurfaceArea *surfaceArea, CStarCamera *camera);
+ /**
+ * 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);
public:
CStarField();
Commit: 2925cfd0329ea755dbac649fc449548aecbe08bb
https://github.com/scummvm/scummvm/commit/2925cfd0329ea755dbac649fc449548aecbe08bb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-01-12T13:21:09-08:00
Commit Message:
TITANIC: Properly implement and hookup the CConstBoundaries
The original had a pretty cool patchwork boundary area sphere
display option for the starmap puzzle, but didn't actually hook
it up. I've now bound it to the B key, and fixed bugs in it's display
Changed paths:
README.md
engines/titanic/star_control/const_boundaries.cpp
engines/titanic/star_control/const_boundaries.h
engines/titanic/star_control/star_field.cpp
engines/titanic/star_control/star_field.h
engines/titanic/star_control/star_view.cpp
diff --git a/README.md b/README.md
index fc2c01b..e839842 100644
--- a/README.md
+++ b/README.md
@@ -1750,6 +1750,7 @@ games and other games.
Period (.) - starmap move backward
l - starmap lock coordinate
d - starmap unlock coordinate
+ b - starmap show boundary sphere
The Feeble Files:
Ctrl-d - Starts the debugger
diff --git a/engines/titanic/star_control/const_boundaries.cpp b/engines/titanic/star_control/const_boundaries.cpp
index 0aa5b71..eb1e7bb 100644
--- a/engines/titanic/star_control/const_boundaries.cpp
+++ b/engines/titanic/star_control/const_boundaries.cpp
@@ -22,6 +22,7 @@
#include "titanic/star_control/const_boundaries.h"
#include "titanic/star_control/star_camera.h"
+#include "titanic/star_control/star_field.h"
#include "titanic/star_control/surface_area.h"
#include "titanic/support/files_manager.h"
#include "titanic/titanic.h"
@@ -36,25 +37,31 @@ CConstBoundaries::CConstBoundaries() {
}
bool CConstBoundaries::initialize() {
+ double y, z, ra, dec, phi, theta;
+
// Get a reference to the starfield points resource
Common::SeekableReadStream *stream = g_vm->_filesManager->getResource("STARFIELD/POINTS");
assert(stream && stream->size() == (12 * ARRAY_COUNT));
_data.resize(ARRAY_COUNT);
for (int idx = 0; idx < ARRAY_COUNT; ++idx) {
- CStarPointEntry &entry = _data[idx];
+ CBoundaryVector &entry = _data[idx];
// Get the next set of values
- double v1 = stream->readSint32LE();
- double v2 = stream->readSint32LE();
- entry._flag = stream->readUint32LE() != 0;
+ entry._isDrawn = (idx == 0) ? 0 : stream->readUint32LE() != 0;
+ y = stream->readSint32LE();
+ z = stream->readSint32LE();
+
+ ra = y * 360.0F / 24000.0F;
+ dec = z / 100.0F;
- v1 *= Common::deg2rad<double>(0.015);
- v2 *= Common::deg2rad<double>(0.0099999998);
+ // Work the polar coordinates
+ phi = Common::deg2rad<double>(ra);
+ theta = Common::deg2rad<double>(dec);
- entry._x = cos(v2) * 3000000.0 * cos(v1);
- entry._y = sin(v1) * 3000000.0 * cos(v2);
- entry._z = sin(v2) * 3000000.0;
+ entry._x = UNIVERSE_SCALE * cos(theta) * cos(phi);
+ entry._y = UNIVERSE_SCALE * cos(theta) * sin(phi);
+ entry._z = UNIVERSE_SCALE * sin(theta);
}
delete stream;
@@ -65,46 +72,50 @@ void CConstBoundaries::draw(CSurfaceArea *surface, CStarCamera *camera) {
if (_data.empty())
return;
+ // get the current camera transform.
FPose pose = camera->getPose();
- double threshold = camera->getThreshold();
- FVector vector1, vector2, vector3, vector4;
- FVector vTemp = _data[0];
- double vWidth2 = (double)surface->_width * 0.5;
- double vHeight2 = (double)surface->_height * 0.5;
- FRect r;
+ float threshold = camera->getThreshold();
+ float centerX = (float)surface->_width / 2.0f;
+ float centerY = (float)surface->_height / 2.0f;
+
+ FVector ec0, ec1, wc;
+ FVector sc0, sc1;
+ // Get the starting point
+ wc = _data[0];
+ ec0._x = wc._x * pose._row1._x + wc._y * pose._row2._x + wc._z * pose._row3._x + pose._vector._x;
+ ec0._y = wc._x * pose._row1._y + wc._y * pose._row2._y + wc._z * pose._row3._y + pose._vector._y;
+ ec0._z = wc._x * pose._row1._z + wc._y * pose._row2._z + wc._z * pose._row3._z + pose._vector._z;
+
+ // Set the drawing mode and color
surface->_pixel = 0xff0000;
uint oldPixel = surface->_pixel;
surface->setColorFromPixel();
SurfaceAreaMode oldMode = surface->setMode(SA_SOLID);
- vector1._z = vTemp._x * pose._row1._z + vTemp._y * pose._row2._z + vTemp._z * pose._row3._z + pose._vector._z;
- vector1._x = vTemp._x * pose._row1._x + vTemp._y * pose._row2._x + vTemp._z * pose._row3._x + pose._vector._x;
- vector1._y = vTemp._x * pose._row1._y + vTemp._y * pose._row2._y + vTemp._z * pose._row3._y + pose._vector._y;
-
+ // Iterate through each remaining point
for (uint idx = 1; idx < _data.size(); ++idx) {
- const FVector &sv = _data[idx];
- bool flag = _data[idx - 1]._flag;
- vTemp = sv;
-
- vector3._x = vTemp._x * pose._row1._x + vTemp._y * pose._row2._x + vTemp._z * pose._row3._x * pose._vector._x;
- vector3._y = vTemp._x * pose._row1._y + vTemp._y * pose._row2._y + vTemp._z * pose._row3._y * pose._vector._y;
- vector3._z = vTemp._x * pose._row1._z + vTemp._y * pose._row2._z + vTemp._z * pose._row3._z + pose._vector._z;
-
- if (flag && vector1._z > threshold && vector3._z > threshold) {
- vector2 = camera->getRelativePos(2, vector1);
- vector4 = camera->getRelativePos(2, vector3);
-
- r.bottom = vector4._y + vHeight2;
- r.right = vector4._x + vWidth2;
- r.top = vector2._y + vHeight2;
- r.left = vector2._x + vWidth2;
- surface->drawLine(r);
+ // Process the next point
+ wc = _data[idx];
+ ec1._z = wc._x * pose._row1._z + wc._y * pose._row2._z + wc._z * pose._row3._z + pose._vector._z;
+ ec1._x = wc._x * pose._row1._x + wc._y * pose._row2._x + wc._z * pose._row3._x + pose._vector._x;
+ ec1._y = wc._x * pose._row1._y + wc._y * pose._row2._y + wc._z * pose._row3._y + pose._vector._y;
+
+ // Is this connected to the previous point?
+ if (_data[idx]._isDrawn) {
+ if (ec0._z > threshold && ec1._z > threshold) {
+ // Render the line
+ sc0 = camera->getRelativePos(2, ec0);
+ sc1 = camera->getRelativePos(2, ec1);
+ surface->drawLine(FPoint(sc0._x + centerX, sc0._y + centerY),
+ FPoint(sc1._x + centerX, sc1._y + centerY));
+ }
}
- vector1 = vector3;
+ ec0 = ec1;
}
+ // Reset back to previous
surface->_pixel = oldPixel;
surface->setColorFromPixel();
surface->setMode(oldMode);
diff --git a/engines/titanic/star_control/const_boundaries.h b/engines/titanic/star_control/const_boundaries.h
index 5dece0d..75b292f 100644
--- a/engines/titanic/star_control/const_boundaries.h
+++ b/engines/titanic/star_control/const_boundaries.h
@@ -32,12 +32,12 @@ class CStarCamera;
class CSurfaceArea;
class CConstBoundaries {
- struct CStarPointEntry : public FVector {
- bool _flag;
- CStarPointEntry() : FVector(), _flag(false) {}
+ struct CBoundaryVector : public FVector {
+ bool _isDrawn; // Line is drawn to previous point
+ CBoundaryVector() : FVector(), _isDrawn(false) {}
};
private:
- Common::Array<CStarPointEntry> _data;
+ Common::Array<CBoundaryVector> _data;
public:
CConstBoundaries();
@@ -47,11 +47,11 @@ public:
bool initialize();
/**
- * Draw the starfield points
+ * Draw the boundary structure
*/
void draw(CSurfaceArea *surface, CStarCamera *camera);
};
} // End of namespace Titanic
-#endif /* TITANIC_STAR_POINTS1_H */
+#endif /* TITANIC_CONST_BOUNDARIES_H */
diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp
index dfd0490..b4b1cad 100644
--- a/engines/titanic/star_control/star_field.cpp
+++ b/engines/titanic/star_control/star_field.cpp
@@ -56,8 +56,6 @@ bool CStarField::initDocument() {
if (valid)
valid = _starCloseup.setup();
if (valid)
- valid = _constBounds.initialize();
- if (valid)
valid = _constMap.initialize();
return valid;
diff --git a/engines/titanic/star_control/star_field.h b/engines/titanic/star_control/star_field.h
index a12fec8..b2e6bee 100644
--- a/engines/titanic/star_control/star_field.h
+++ b/engines/titanic/star_control/star_field.h
@@ -33,6 +33,7 @@
namespace Titanic {
#define STAR_SCALE 1024.0F
+#define UNIVERSE_SCALE 3000000.0f
class CStarField : public CStarFieldBase {
private:
diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp
index 563c874..64beb62 100644
--- a/engines/titanic/star_control/star_view.cpp
+++ b/engines/titanic/star_control/star_view.cpp
@@ -245,6 +245,12 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
}
break;
+ // New for ScummVM to show the boundaries code the original implemented,
+ // but wasn't actually hooked up to any player action
+ case Common::KEYCODE_b:
+ viewBoundaries();
+ return true;
+
default:
break;
}
More information about the Scummvm-git-logs
mailing list