mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 04:02:30 +01:00
finally I am a bit happy with the "f4" camera view
This commit is contained in:
parent
784ccb7e56
commit
8dd43e2e31
@ -1506,16 +1506,26 @@ void Game::update() {
|
||||
|
||||
if(currentCameraFollowUnit!=NULL){
|
||||
Vec3f c=currentCameraFollowUnit->getCurrVector();
|
||||
int rotation=currentCameraFollowUnit->getRotation();
|
||||
float angle=rotation+180;
|
||||
|
||||
|
||||
#ifdef USE_STREFLOP
|
||||
c.z=c.z+4*streflop::cosf(static_cast<streflop::Simple>(degToRad(angle)));
|
||||
c.x=c.x+4*streflop::sinf(static_cast<streflop::Simple>(degToRad(angle)));
|
||||
#else
|
||||
c.z=c.z+4*cosf(degToRad(angle));
|
||||
c.x=c.x+4*sinf(degToRad(angle));
|
||||
#endif
|
||||
c.y=c.y+currentCameraFollowUnit->getType()->getHeight()/2.f+2.0f;
|
||||
|
||||
getGameCameraPtr()->setPos(c);
|
||||
|
||||
int rotation=currentCameraFollowUnit->getRotation();
|
||||
getGameCameraPtr()->rotateToVH(18.0f,(540-rotation)%360);
|
||||
rotation=(540-rotation)%360;
|
||||
getGameCameraPtr()->rotateToVH(18.0f,rotation);
|
||||
|
||||
if(currentCameraFollowUnit->isAlive()==false){
|
||||
currentCameraFollowUnit=NULL;
|
||||
gameCamera.resetPosition();
|
||||
getGameCameraPtr()->setClampDisabled(false);
|
||||
getGameCameraPtr()->setGameState();
|
||||
}
|
||||
}
|
||||
@ -1931,7 +1941,7 @@ void Game::render() {
|
||||
isFirstRender = false;
|
||||
|
||||
if(this->loadGameNode == NULL) {
|
||||
gameCamera.resetPosition();
|
||||
gameCamera.setGameState();
|
||||
this->restoreToStartXY();
|
||||
}
|
||||
}
|
||||
@ -2881,7 +2891,7 @@ void Game::mouseDownRight(int x, int y) {
|
||||
}
|
||||
|
||||
if(mouseMoved == false) {
|
||||
gameCamera.resetPosition();
|
||||
gameCamera.setGameState();
|
||||
}
|
||||
else {
|
||||
mouseMoved = false;
|
||||
@ -3169,7 +3179,6 @@ void Game::startCameraFollowUnit() {
|
||||
Unit *currentUnit = selection->getUnitPtr(0);
|
||||
if(currentUnit != NULL) {
|
||||
currentCameraFollowUnit = currentUnit;
|
||||
getGameCameraPtr()->setClampDisabled(true);
|
||||
getGameCameraPtr()->setUnitState();
|
||||
getGameCameraPtr()->setPos(currentCameraFollowUnit->getCurrVector());
|
||||
|
||||
@ -3303,7 +3312,16 @@ void Game::keyDown(SDL_KeyboardEvent key) {
|
||||
//change camera mode
|
||||
//else if(key == configKeys.getCharKey("FreeCameraMode")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("FreeCameraMode"),key, false) == true) {
|
||||
gameCamera.switchState();
|
||||
if(gameCamera.getState()==GameCamera::sFree)
|
||||
{
|
||||
gameCamera.setGameState();
|
||||
}
|
||||
else if(gameCamera.getState()==GameCamera::sGame)
|
||||
{
|
||||
gameCamera.setFreeState();
|
||||
}
|
||||
//else ignore!
|
||||
|
||||
string stateString= gameCamera.getState()==GameCamera::sGame? lang.get("GameCamera"): lang.get("FreeCamera");
|
||||
console.addLine(lang.get("CameraModeSet")+" "+ stateString);
|
||||
}
|
||||
@ -3313,9 +3331,7 @@ void Game::keyDown(SDL_KeyboardEvent key) {
|
||||
if(currentCameraFollowUnit != NULL) {
|
||||
currentCameraFollowUnit = NULL;
|
||||
}
|
||||
|
||||
gameCamera.resetPosition();
|
||||
gameCamera.setClampDisabled(false);
|
||||
gameCamera.setGameState();
|
||||
}
|
||||
//pause
|
||||
//else if(key == configKeys.getCharKey("PauseGame")) {
|
||||
|
@ -287,20 +287,24 @@ Quad2i GameCamera::computeVisibleQuad() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void GameCamera::switchState(){
|
||||
if(state==sGame){
|
||||
state= sFree;
|
||||
}
|
||||
else{
|
||||
state= sGame;
|
||||
destAng.x = startingVAng;
|
||||
destAng.y = startingHAng;
|
||||
destPos.y = calculatedDefault;
|
||||
}
|
||||
void GameCamera::setGameState() {
|
||||
state = sGame;
|
||||
setClampDisabled(false);
|
||||
resetPosition();
|
||||
}
|
||||
void GameCamera::setUnitState() {
|
||||
state = sUnit;
|
||||
setClampDisabled(true);
|
||||
}
|
||||
void GameCamera::setFreeState() {
|
||||
state = sFree;
|
||||
setClampDisabled(false);
|
||||
resetPosition();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GameCamera::resetPosition(){
|
||||
state= sGame;
|
||||
destAng.x = startingVAng;
|
||||
destAng.y = startingHAng;
|
||||
destPos.y = calculatedDefault;
|
||||
|
@ -105,9 +105,10 @@ public:
|
||||
float getHAng() const {return hAng;};
|
||||
float getVAng() const {return vAng;}
|
||||
State getState() const {return state;}
|
||||
void setGameState() { state = sGame; }
|
||||
void setUnitState() { state = sUnit; }
|
||||
void setState(State value) { state = value; }
|
||||
|
||||
void setGameState();
|
||||
void setUnitState();
|
||||
void setFreeState();
|
||||
|
||||
const Vec3f &getPos() const {return pos;}
|
||||
float getFov() const {return fov;}
|
||||
@ -140,8 +141,7 @@ public:
|
||||
//other
|
||||
void update();
|
||||
Quad2i computeVisibleQuad();
|
||||
void switchState();
|
||||
void resetPosition();
|
||||
|
||||
|
||||
void centerXZ(float x, float z);
|
||||
void transitionXYZ(float x, float y, float z);
|
||||
@ -155,8 +155,6 @@ public:
|
||||
void load(const XmlNode *node);
|
||||
void save(XmlNode *node) const;
|
||||
|
||||
void setClampBounds(bool value) { clampBounds = value; }
|
||||
void setClampDisabled(bool value) { clampDisable = value; };
|
||||
void setMaxHeight(float value);
|
||||
float getCalculatedDefault() const{ return calculatedDefault; }
|
||||
void setCalculatedDefault(float calculatedDefault);
|
||||
@ -173,6 +171,9 @@ public:
|
||||
void loadGame(const XmlNode *rootNode);
|
||||
|
||||
private:
|
||||
void setClampBounds(bool value) { clampBounds = value; }
|
||||
void resetPosition();
|
||||
void setClampDisabled(bool value) { clampDisable = value; };
|
||||
void clampPosXYZ(float x1, float x2, float y1, float y2, float z1, float z2);
|
||||
void clampPosXZ(float x1, float x2, float z1, float z2);
|
||||
void clampAng();
|
||||
|
Loading…
x
Reference in New Issue
Block a user