aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/zvision/render_manager.cpp44
-rw-r--r--engines/zvision/render_manager.h10
-rw-r--r--engines/zvision/zvision.cpp2
3 files changed, 53 insertions, 3 deletions
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 6d3f7c6fc1..2a8ed1274e 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -24,6 +24,7 @@
#include "common/file.h"
#include "common/system.h"
+#include "common/rect.h"
#include "graphics/decoders/tga.h"
@@ -32,7 +33,12 @@
namespace ZVision {
-RenderManager::RenderManager(OSystem *system) : _system(system) {}
+RenderManager::RenderManager(OSystem *system, const int width, const int height)
+ : _system(system),
+ _width(width),
+ _height(height),
+ _renderTable(width, height) {
+}
void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y) {
Common::File file;
@@ -80,4 +86,40 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 x
_needsScreenUpdate = true;
}
+void RenderManager::generatePanoramaLookupTable() {
+ float fieldOfView = _panoramaOptions.fieldOfView;
+ float scale = _panoramaOptions.linearScale;
+ _renderTable.clear();
+
+ double halfWidth = (double)_width / 2.0;
+ double halfHeight = (double)_height / 2.0;
+
+ double fovRadians = (fieldOfView * 3.14159265 / 180.0);
+ double halfHeightOverTan = halfHeight / tan(fovRadians);
+ double tanOverHalfHeight = tan(fovRadians) / halfHeight;
+
+ for (int32 x = 0; x < _width; x++) {
+ // Add an offset of 0.01 to overcome zero tan/atan issue (vertical line on half of screen)
+ double xPos = (double)x - halfWidth + 0.01;
+
+ double tempX = atan(xPos*tanOverHalfHeight);
+ double scaledX = scale * halfHeightOverTan * tempX;
+ double nn = cos(tempX);
+ double newHalfWidth = halfHeight * nn * halfHeightOverTan * tanOverHalfHeight*2.0;
+
+ int32 newX = floor(scaledX);// + half_w);
+
+ double yScale = newHalfWidth / (double)_height;
+ double et2 = ((double)_height - newHalfWidth) / 2.0;
+
+ for (int32 y = 0; y < _height; y++) {
+ double et1 = (double)y*yScale;
+
+ _renderTable(x, y).x = newX; //pixel index
+
+ int32 newY = floor(et2 + et1);
+ _renderTable(x, y).y = newY; //pixel index
+ }
+ }
+}
} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 137ec51d5a..e481c26666 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -25,17 +25,20 @@
#include "common/types.h"
+#include "zvision/dense_2d_array.h"
+
class OSystem;
namespace Common {
class String;
+class Point;
}
namespace ZVision {
class RenderManager {
public:
- RenderManager(OSystem *system);
+ RenderManager(OSystem *system, const int width, const int height);
public:
enum RenderState {
@@ -46,6 +49,8 @@ public:
private:
OSystem *_system;
+ const int _width;
+ const int _height;
RenderState _renderState;
struct {
@@ -59,10 +64,13 @@ private:
uint16 linearScale;
} _tiltOptions;
+ Dense2DArray<Common::Point> _renderTable;
+
bool _needsScreenUpdate;
public:
void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y);
+ void generatePanoramaLookupTable();
};
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 0e2e02788f..57c9dea211 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -74,7 +74,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
// Create managers
_scriptManager = new ScriptManager(this);
- _renderManager = new RenderManager(_system);
+ _renderManager = new RenderManager(_system, _width, _height);
debug("ZVision::ZVision");
}