From bf9ebf4912f9e3e1167639c3a8a92d05d1e92755 Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Thu, 25 Mar 2010 00:58:58 +0000 Subject: [PATCH] space is used to reset camera to normal game view mouse scrollwheel behaves different in maxZoom position --- source/glest_game/game/game.cpp | 6 +++++- source/glest_game/game/game_camera.cpp | 17 +++++++++-------- source/glest_game/game/game_camera.h | 3 ++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 963f6d9c..d7c5fc6c 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -548,7 +548,11 @@ void Game::keyDown(char key){ string stateString= gameCamera.getState()==GameCamera::sGame? lang.get("GameCamera"): lang.get("FreeCamera"); console.addLine(lang.get("CameraModeSet")+" "+ stateString); } - + + //reset camera mode to normal + else if(key==' '){ + gameCamera.resetPosition(); + } //pause else if(key=='P'){ if(speedChangesAllowed){ diff --git a/source/glest_game/game/game_camera.cpp b/source/glest_game/game/game_camera.cpp index 7b8885dc..751754d6 100644 --- a/source/glest_game/game/game_camera.cpp +++ b/source/glest_game/game/game_camera.cpp @@ -57,7 +57,7 @@ GameCamera::GameCamera() : pos(0.f, defaultHeight, 0.f), move= Vec3f(0.f); maxRenderDistance = Config::getInstance().getFloat("RenderDistanceMax","64"); - maxHeight = Config::getInstance().getFloat("CameraMaxDistance","35"); + maxHeight = Config::getInstance().getFloat("CameraMaxDistance","20"); minHeight = Config::getInstance().getFloat("CameraMinDistance","8"); maxCameraDist = maxHeight; minCameraDist = minHeight; @@ -219,6 +219,13 @@ void GameCamera::switchState(){ } } +void GameCamera::resetPosition(){ + state= sGame; + destAng.x = startingVAng; + destAng.y = startingHAng; + destPos.y = defaultHeight; +} + void GameCamera::centerXZ(float x, float z){ destPos.x = pos.x= x; destPos.z = pos.z= z+centerOffsetZ; @@ -241,13 +248,7 @@ void GameCamera::transitionVH(float v, float h) { void GameCamera::zoom(float dist) { float flatDist = dist * cosf(degToRad(vAng)); Vec3f offset(flatDist * sinf(degToRad(hAng)), dist * sinf(degToRad(vAng)), flatDist * -cosf(degToRad(hAng))); - float mult = 1.f; - if(destPos.y + offset.y < minHeight) { - mult = abs((destPos.y - minHeight) / offset.y); - } else if(destPos.y + offset.y > maxHeight) { - mult = abs((maxHeight - destPos.y) / offset.y); - } - destPos += offset * mult; + destPos += offset; } void GameCamera::load(const XmlNode *node) { diff --git a/source/glest_game/game/game_camera.h b/source/glest_game/game/game_camera.h index 5d70243c..4dc65ca5 100644 --- a/source/glest_game/game/game_camera.h +++ b/source/glest_game/game/game_camera.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Marti�o Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -109,6 +109,7 @@ public: void update(); Quad2i computeVisibleQuad() const; void switchState(); + void resetPosition(); void centerXZ(float x, float z); void rotateHV(float h, float v);