ZVISION: Create methods for converting screen coords to image coords

This commit is contained in:
richiesams 2013-08-11 13:44:23 -05:00
parent b76927ab4e
commit a3315037ff
4 changed files with 35 additions and 1 deletions

View File

@ -80,6 +80,8 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin
destRect.moveTo((_width - subRectangle.width()) / 2, (_height - subRectangle.height()) / 2);
}
_backgroundOffset = Common::Point(destRect.left, destRect.top);
if (_renderTable.getRenderState() == RenderTable::FLAT) {
_system->copyRectToScreen(buffer + subRectangle.top * horizontalPitch + subRectangle.left, horizontalPitch, destRect.left, destRect.top, destRect.width(), destRect.height());
} else {
@ -139,7 +141,17 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
tga.destroy();
}
}
const Common::Point RenderManager::convertToImageCoords(const Common::Point &point) {
Common::Point newPoint(point);
if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
newPoint = _renderTable.convertWarpedPointToFlatCoords(newPoint);
}
newPoint -= _backgroundOffset;
return newPoint;
}
RenderTable *RenderManager::getRenderTable() {

View File

@ -53,6 +53,7 @@ private:
RenderTable _renderTable;
Common::SeekableReadStream *_currentBackground;
Common::Point _backgroundOffset;
Video::VideoDecoder *_currentVideo;
byte *_scaledVideoFrameBuffer;
@ -90,8 +91,9 @@ public:
*/
void setBackgroundImage(const Common::String &fileName);
RenderTable *getRenderTable();
const Common::Point convertToImageCoords(const Common::Point &point);
RenderTable *getRenderTable();
private:
void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter);

View File

@ -60,6 +60,16 @@ void RenderTable::setRenderState(RenderState newState) {
}
}
const Common::Point RenderTable::convertWarpedPointToFlatCoords(const Common::Point &point) {
uint32 index = point.y * _numColumns + point.x;
Common::Point newPoint(point);
newPoint.x += _internalBuffer[index].x;
newPoint.y += _internalBuffer[index].y;
return newPoint;
}
uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
assert(percentColorOne < 1.0f);
@ -157,7 +167,14 @@ void RenderTable::generatePanoramaLookupTable() {
}
void RenderTable::generateTiltLookupTable() {
for (uint x = 0; x < _numColumns; x++) {
for (uint y = 0; y < _numRows; y++) {
uint32 index = y * _numColumns + x;
_internalBuffer[index].x = 0;
_internalBuffer[index].y = 0;
}
}
}
void RenderTable::setPanoramaFoV(float fov) {

View File

@ -63,6 +63,9 @@ private:
public:
RenderState getRenderState() { return _renderState; }
void setRenderState(RenderState newState);
const Common::Point convertWarpedPointToFlatCoords(const Common::Point &point);
void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight, Common::Rect subRectangle, Common::Rect destRectangle);
void generateRenderTable();