mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-26 03:37:53 +00:00
MYST3: Implement opcode 163 - Set camera FOV
This commit is contained in:
parent
52f33cac75
commit
b9fa7eeffa
@ -152,8 +152,7 @@ void Cursor::draw() {
|
||||
|
||||
void Cursor::setVisible(bool show) {
|
||||
if (show)
|
||||
if (--_hideLevel < 0)
|
||||
_hideLevel = 0;
|
||||
_hideLevel = MAX<int32>(0, --_hideLevel);
|
||||
else
|
||||
_hideLevel++;
|
||||
}
|
||||
|
@ -152,11 +152,18 @@ void Renderer::setupCameraOrtho2D() {
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
void Renderer::setupCameraPerspective(float pitch, float heading) {
|
||||
void Renderer::setupCameraPerspective(float pitch, float heading, float fov) {
|
||||
// TODO: Find a correct and exact formula for the FOV
|
||||
GLfloat glFOV = 0.63 * fov; // Approximative and experimental formula
|
||||
if (fov > 79.0 && fov < 81.0)
|
||||
glFOV = 50.5; // Somewhat good value for fov == 80
|
||||
else if (fov > 59.0 && fov < 61.0)
|
||||
glFOV = 36.0; // Somewhat good value for fov == 60
|
||||
|
||||
glViewport(0, kBottomBorderHeight, kOriginalWidth, kFrameHeight);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(50.5, (GLfloat)kOriginalWidth / (GLfloat)kFrameHeight, 1.0, 10000.0);
|
||||
gluPerspective(glFOV, (GLfloat)kOriginalWidth / (GLfloat)kFrameHeight, 1.0, 10000.0);
|
||||
|
||||
// Rotate the model to simulate the rotation of the camera
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
|
||||
void clear();
|
||||
void setupCameraOrtho2D();
|
||||
void setupCameraPerspective(float pitch, float heading);
|
||||
void setupCameraPerspective(float pitch, float heading, float fov);
|
||||
|
||||
Texture *createTexture(const Graphics::Surface *surface);
|
||||
void freeTexture(Texture *texture);
|
||||
|
@ -359,7 +359,8 @@ void Myst3Engine::drawFrame() {
|
||||
if (_state->getViewType() == kCube) {
|
||||
float pitch = _state->getLookAtPitch();
|
||||
float heading = _state->getLookAtHeading();
|
||||
_gfx->setupCameraPerspective(pitch, heading);
|
||||
float fov = _state->getLookAtFOV();
|
||||
_gfx->setupCameraPerspective(pitch, heading, fov);
|
||||
} else {
|
||||
_gfx->setupCameraOrtho2D();
|
||||
}
|
||||
|
@ -43,12 +43,6 @@ void Scene::updateCamera(Common::Point &mouse) {
|
||||
heading += mouse.x / 3.0f;
|
||||
}
|
||||
|
||||
// Keep heading in 0..360 range
|
||||
if (heading > 360.0f)
|
||||
heading -= 360.0f;
|
||||
else if (heading < 0.0f)
|
||||
heading += 360.0f;
|
||||
|
||||
// Keep heading within allowed values
|
||||
if (_vm->_state->isCameraLimited()) {
|
||||
float minHeading = _vm->_state->getMinHeading();
|
||||
@ -68,6 +62,12 @@ void Scene::updateCamera(Common::Point &mouse) {
|
||||
}
|
||||
}
|
||||
|
||||
// Keep heading in 0..360 range
|
||||
if (heading > 360.0f)
|
||||
heading -= 360.0f;
|
||||
else if (heading < 0.0f)
|
||||
heading += 360.0f;
|
||||
|
||||
// Keep pitch within allowed values
|
||||
float minPitch = _vm->_state->getCameraMinPitch();
|
||||
float maxPitch = _vm->_state->getCameraMaxPitch();
|
||||
|
@ -188,6 +188,7 @@ Script::Script(Myst3Engine *vm):
|
||||
OP_1(160, cameraLookAtVar, kVar );
|
||||
OP_1(161, cameraGetLookAt, kVar );
|
||||
OP_1(162, lootAtMovieStartImmediate, kEvalValue );
|
||||
OP_1(163, cameraSetFOV, kEvalValue );
|
||||
OP_1(164, changeNode, kValue );
|
||||
OP_2(165, changeNodeRoom, kValue, kValue );
|
||||
OP_3(166, changeNodeRoomAge, kValue, kValue, kValue );
|
||||
@ -1835,6 +1836,14 @@ void Script::lootAtMovieStartImmediate(Context &c, const Opcode &cmd) {
|
||||
_vm->_state->lookAt(startPitch, startHeading);
|
||||
}
|
||||
|
||||
void Script::cameraSetFOV(Context &c, const Opcode &cmd) {
|
||||
debugC(kDebugScript, "Opcode %d: Set camera fov %d", cmd.op, cmd.args[0]);
|
||||
|
||||
int32 fov = _vm->_state->valueOrVarValue(cmd.args[0]);
|
||||
|
||||
_vm->_state->setLookAtFOV(fov);
|
||||
}
|
||||
|
||||
void Script::changeNode(Context &c, const Opcode &cmd) {
|
||||
debugC(kDebugScript, "Opcode %d: Go to node %d", cmd.op, cmd.args[0]);
|
||||
|
||||
|
@ -238,6 +238,7 @@ private:
|
||||
DECLARE_OPCODE(cameraLookAtVar);
|
||||
DECLARE_OPCODE(cameraGetLookAt);
|
||||
DECLARE_OPCODE(lootAtMovieStartImmediate);
|
||||
DECLARE_OPCODE(cameraSetFOV);
|
||||
DECLARE_OPCODE(changeNode);
|
||||
DECLARE_OPCODE(changeNodeRoom);
|
||||
DECLARE_OPCODE(changeNodeRoomAge);
|
||||
|
@ -166,6 +166,8 @@ public:
|
||||
ViewType getViewType() { return static_cast<ViewType>(_data.currentNodeType); }
|
||||
void setViewType(ViewType t) { _data.currentNodeType = t; }
|
||||
|
||||
float getLookAtFOV() { return _data.lookatFOV; }
|
||||
void setLookAtFOV(float fov) { _data.lookatFOV = fov; }
|
||||
float getLookAtPitch() { return _data.lookatPitch; }
|
||||
float getLookAtHeading() { return _data.lookatHeading; }
|
||||
void lookAt(float pitch, float heading) { _data.lookatPitch = pitch; _data.lookatHeading = heading; }
|
||||
|
Loading…
Reference in New Issue
Block a user