[Scummvm-git-logs] scummvm master -> 2bdc93cb11ae97ddd3b001afe1cf99e17509e488

dreammaster paulfgilbert at gmail.com
Sun Jan 12 22:26:45 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:
2bdc93cb11 TITANIC: Properly implement and hookup constellation map


Commit: 2bdc93cb11ae97ddd3b001afe1cf99e17509e488
    https://github.com/scummvm/scummvm/commit/2bdc93cb11ae97ddd3b001afe1cf99e17509e488
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-01-12T14:26:17-08:00

Commit Message:
TITANIC: Properly implement and hookup constellation map

The original also had a cool sphere showing stick-line constellations,
but it wasn't ever shown. This fixes the display and adds c as a
toggle for it when viewing the starmap

Changed paths:
    README.md
    engines/titanic/star_control/const_boundaries.cpp
    engines/titanic/star_control/constellations.cpp
    engines/titanic/star_control/constellations.h
    engines/titanic/star_control/star_view.cpp


diff --git a/README.md b/README.md
index e839842..499be63 100644
--- a/README.md
+++ b/README.md
@@ -1751,6 +1751,7 @@ games and other games.
     l                      - starmap lock coordinate
     d                      - starmap unlock coordinate
 	b                      - starmap show boundary sphere
+	c                      - starmap show constellations 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 eb1e7bb..101a6ba 100644
--- a/engines/titanic/star_control/const_boundaries.cpp
+++ b/engines/titanic/star_control/const_boundaries.cpp
@@ -97,9 +97,9 @@ void CConstBoundaries::draw(CSurfaceArea *surface, CStarCamera *camera) {
 	for (uint idx = 1; idx < _data.size(); ++idx) {
 		// 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;
+		ec1._z = wc._x * pose._row1._z + wc._y * pose._row2._z + wc._z * pose._row3._z + pose._vector._z;
 
 		// Is this connected to the previous point?
 		if (_data[idx]._isDrawn) {
diff --git a/engines/titanic/star_control/constellations.cpp b/engines/titanic/star_control/constellations.cpp
index 4608074..6693970 100644
--- a/engines/titanic/star_control/constellations.cpp
+++ b/engines/titanic/star_control/constellations.cpp
@@ -22,6 +22,7 @@
 
 #include "titanic/star_control/constellations.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"
@@ -30,34 +31,37 @@
 
 namespace Titanic {
 
-#define ARRAY_COUNT 80
+#define TOTAL_CONSTELLATIONS 80
 
 bool CConstellations::initialize() {
+	double ra, dec, phi, theta;
+
 	// Get a reference to the starfield points resource
 	Common::SeekableReadStream *stream = g_vm->_filesManager->getResource("STARFIELD/POINTS2");
 
-	_data.resize(ARRAY_COUNT);
-	for (int rootCtr = 0; rootCtr < ARRAY_COUNT; ++rootCtr) {
-		// Get the number of sub-entries for this entry
+	_data.resize(TOTAL_CONSTELLATIONS);
+	for (int rootCtr = 0; rootCtr < TOTAL_CONSTELLATIONS; ++rootCtr) {
+		// Get the number of points in the constellation
 		int count = stream->readUint32LE();
-		double v1, v2;
 
-		// Read in the sub-entries
-		RootEntry &rootEntry = _data[rootCtr];
+		// Read in the points
+		Constellation &rootEntry = _data[rootCtr];
 		rootEntry.resize(count);
 		for (int idx = 0; idx < count; ++idx) {
-			CStarPointEntry &se = rootEntry[idx];
-			FVector *vectors[2] = { &se._v1, &se._v2 };
+			ConstellationLine &cl = rootEntry[idx];
+			FVector *vectors[2] = { &cl._start, &cl._end};
 
 			for (int fctr = 0; fctr < 2; ++fctr) {
-				v1 = stream->readSint32LE();
-				v2 = stream->readSint32LE();
-				v1 *= Common::deg2rad<double>(0.015);
-				v2 *= Common::deg2rad<double>(0.01);
-
-				vectors[fctr]->_x = cos(v1) * 3000000.0 * cos(v2);
-				vectors[fctr]->_y = sin(v1) * 3000000.0 * cos(v2);
-				vectors[fctr]->_z = sin(v2) * 3000000.0;
+				ra = (double)stream->readSint32LE() * 360.0f / 24000.0f;
+				dec = (double)stream->readSint32LE() / 100.0f;
+
+				// Work the polar coordinates
+				phi = Common::deg2rad<double>(ra);
+				theta = Common::deg2rad<double>(dec);
+
+				vectors[fctr]->_x = UNIVERSE_SCALE * cos(theta) * cos(phi);
+				vectors[fctr]->_y = UNIVERSE_SCALE * cos(theta) * sin(phi);
+				vectors[fctr]->_z = UNIVERSE_SCALE * sin(theta);
 			}
 		}
 	}
@@ -72,49 +76,45 @@ void CConstellations::draw(CSurfaceArea *surface, CStarCamera *camera) {
 
 	FPose pose = camera->getPose();
 	double threshold = camera->getThreshold();
-	FVector vector1, vector2, vector3, vector4;
-	double vWidth2 = (double)surface->_width * 0.5;
-	double vHeight2 = (double)surface->_height * 0.5;
-	FRect r;
+	double centerX = (double)surface->_width / 2.0F;
+	double centerY = (double)surface->_height / 2.0F;
+	FVector ec0, ec1;
+	FVector sc0, sc1;
 
+	// Set the drawing mode, saving the old mode
 	surface->_pixel = 0xffff00;
 	uint oldPixel = surface->_pixel;
 	surface->setColorFromPixel();
 	SurfaceAreaMode oldMode = surface->setMode(SA_SOLID);
 
-	for (uint rootCtr = 0; rootCtr < _data.size(); ++rootCtr) {
-		const RootEntry &re = _data[rootCtr];
-		if (!re._visible || re.empty())
+	// Iterate through the constellations
+	for (uint conCtr = 0; conCtr < _data.size(); ++conCtr) {
+		const Constellation &con = _data[conCtr];
+		if (con.empty())
 			continue;
 
-		for (uint idx = 0; idx < re.size(); ++idx) {
-			const CStarPointEntry &se = re[idx];
-			vector1._z = pose._row2._z * se._v1._y + pose._row3._z * se._v1._z
-				+ pose._row1._z * se._v1._x + pose._vector._z;
-			vector1._x = pose._row2._x * se._v1._y + pose._row3._x * se._v1._z
-				+ pose._row1._x * se._v1._x + pose._vector._x;
-			vector1._y = pose._row2._y * se._v1._y + pose._row3._y * se._v1._z
-				+ pose._row1._y * se._v1._x + pose._vector._y;
-			vector3._z = pose._row2._z * se._v2._y + pose._row2._x * se._v2._z
-				+ pose._row1._z * se._v2._x + pose._vector._y;
-			vector3._x = pose._row3._z * se._v2._y + pose._row3._x * se._v2._z
-				+ pose._row1._x * se._v2._x + pose._vector._y;
-			vector3._y = pose._row2._y * se._v2._y + pose._row3._y * se._v2._z
-				+ pose._row1._y * se._v2._x + pose._vector._y;
-
-			if (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);
+		for (uint idx = 0; idx < con.size(); ++idx) {
+			const FVector &ps = con[idx]._start;
+			ec0._x = ps._x * pose._row1._x + ps._y * pose._row2._x + ps._z * pose._row3._x + pose._vector._x;
+			ec0._y = ps._x * pose._row1._y + ps._y * pose._row2._y + ps._z * pose._row3._y + pose._vector._y;
+			ec0._z = ps._x * pose._row1._z + ps._y * pose._row2._z + ps._z * pose._row3._z + pose._vector._z;
+
+			const FVector &pe = con[idx]._end;
+			ec1._x = pe._x * pose._row1._x + pe._y * pose._row2._x + pe._z * pose._row3._x + pose._vector._x;
+			ec1._y = pe._x * pose._row1._y + pe._y * pose._row2._y + pe._z * pose._row3._y + pose._vector._y;
+			ec1._z = pe._x * pose._row1._z + pe._y * pose._row2._z + pe._z * pose._row3._z + pose._vector._z;
+
+			// Draw if the constellation line is visible
+			if (ec0._z > threshold && ec1._z > threshold) {
+				sc0 = camera->getRelativePos(2, ec0);
+				sc1 = camera->getRelativePos(2, ec1);
+				surface->drawLine(Point(sc0._x + centerX, sc0._y + centerY),
+					Point(sc1._x + centerX, sc1._y + centerY));
 			}
 		}
 	}
 
+	// Restore the old state
 	surface->_pixel = oldPixel;
 	surface->setColorFromPixel();
 	surface->setMode(oldMode);
diff --git a/engines/titanic/star_control/constellations.h b/engines/titanic/star_control/constellations.h
index a5a2788..1f4cfac 100644
--- a/engines/titanic/star_control/constellations.h
+++ b/engines/titanic/star_control/constellations.h
@@ -20,8 +20,8 @@
  *
  */
 
-#ifndef TITANIC_STAR_POINTS2_H
-#define TITANIC_STAR_POINTS2_H
+#ifndef TITANIC_CONSTELLATIONS_H
+#define TITANIC_CONSTELLATIONS_H
 
 #include "titanic/star_control/fvector.h"
 #include "common/array.h"
@@ -32,16 +32,12 @@ class CStarCamera;
 class CSurfaceArea;
 
 class CConstellations {
-	struct CStarPointEntry {
-		FVector _v1, _v2;
-	};
-	class RootEntry : public Common::Array<CStarPointEntry> {
-	public:
-		bool _visible;
-		RootEntry() : _visible(false) {}
+	struct ConstellationLine {
+		FVector _start, _end;
 	};
+	typedef Common::Array<ConstellationLine> Constellation;
 private:
-	Common::Array<RootEntry> _data;
+	Common::Array<Constellation> _data;
 public:
 	/**
 	 * Initializes the data
@@ -56,4 +52,4 @@ public:
 
 } // End of namespace Titanic
 
-#endif /* TITANIC_STAR_POINTS2_H */
+#endif /* TITANIC_CONSTELLATIONS_H */
diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp
index 64beb62..5e06533 100644
--- a/engines/titanic/star_control/star_view.cpp
+++ b/engines/titanic/star_control/star_view.cpp
@@ -245,12 +245,18 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
 		}
 		break;
 
-	// New for ScummVM to show the boundaries code the original implemented,
+	// New for ScummVM to show the boundaries sphere code the original implemented,
 	// but wasn't actually hooked up to any player action
 	case Common::KEYCODE_b:
 		viewBoundaries();
 		return true;
 
+	// New for ScummVM to show the constellations sphere code the original implemented,
+	// but wasn't actually hooked up to any player action
+	case Common::KEYCODE_c:
+		viewConstellations();
+		return true;
+
 	default:
 		break;
 	}




More information about the Scummvm-git-logs mailing list