mirror of
https://github.com/glest/glest-source.git
synced 2025-08-28 10:19:55 +02:00
space is used to reset camera to normal game view
mouse scrollwheel behaves different in maxZoom position
This commit is contained in:
@@ -549,6 +549,10 @@ void Game::keyDown(char key){
|
|||||||
console.addLine(lang.get("CameraModeSet")+" "+ stateString);
|
console.addLine(lang.get("CameraModeSet")+" "+ stateString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//reset camera mode to normal
|
||||||
|
else if(key==' '){
|
||||||
|
gameCamera.resetPosition();
|
||||||
|
}
|
||||||
//pause
|
//pause
|
||||||
else if(key=='P'){
|
else if(key=='P'){
|
||||||
if(speedChangesAllowed){
|
if(speedChangesAllowed){
|
||||||
|
@@ -57,7 +57,7 @@ GameCamera::GameCamera() : pos(0.f, defaultHeight, 0.f),
|
|||||||
move= Vec3f(0.f);
|
move= Vec3f(0.f);
|
||||||
|
|
||||||
maxRenderDistance = Config::getInstance().getFloat("RenderDistanceMax","64");
|
maxRenderDistance = Config::getInstance().getFloat("RenderDistanceMax","64");
|
||||||
maxHeight = Config::getInstance().getFloat("CameraMaxDistance","35");
|
maxHeight = Config::getInstance().getFloat("CameraMaxDistance","20");
|
||||||
minHeight = Config::getInstance().getFloat("CameraMinDistance","8");
|
minHeight = Config::getInstance().getFloat("CameraMinDistance","8");
|
||||||
maxCameraDist = maxHeight;
|
maxCameraDist = maxHeight;
|
||||||
minCameraDist = minHeight;
|
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){
|
void GameCamera::centerXZ(float x, float z){
|
||||||
destPos.x = pos.x= x;
|
destPos.x = pos.x= x;
|
||||||
destPos.z = pos.z= z+centerOffsetZ;
|
destPos.z = pos.z= z+centerOffsetZ;
|
||||||
@@ -241,13 +248,7 @@ void GameCamera::transitionVH(float v, float h) {
|
|||||||
void GameCamera::zoom(float dist) {
|
void GameCamera::zoom(float dist) {
|
||||||
float flatDist = dist * cosf(degToRad(vAng));
|
float flatDist = dist * cosf(degToRad(vAng));
|
||||||
Vec3f offset(flatDist * sinf(degToRad(hAng)), dist * sinf(degToRad(vAng)), flatDist * -cosf(degToRad(hAng)));
|
Vec3f offset(flatDist * sinf(degToRad(hAng)), dist * sinf(degToRad(vAng)), flatDist * -cosf(degToRad(hAng)));
|
||||||
float mult = 1.f;
|
destPos += offset;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameCamera::load(const XmlNode *node) {
|
void GameCamera::load(const XmlNode *node) {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -109,6 +109,7 @@ public:
|
|||||||
void update();
|
void update();
|
||||||
Quad2i computeVisibleQuad() const;
|
Quad2i computeVisibleQuad() const;
|
||||||
void switchState();
|
void switchState();
|
||||||
|
void resetPosition();
|
||||||
|
|
||||||
void centerXZ(float x, float z);
|
void centerXZ(float x, float z);
|
||||||
void rotateHV(float h, float v);
|
void rotateHV(float h, float v);
|
||||||
|
Reference in New Issue
Block a user