Merge pull request #328 from noway421/first-person-spec

Added first person view for spectate mode
This commit is contained in:
Tomoaki KAWADA 2015-02-02 13:59:26 +09:00
commit b26d4c7821
3 changed files with 16 additions and 5 deletions

View File

@ -138,6 +138,7 @@ namespace spades {
KeypadInput keypadInput;
Player::ToolType lastTool;
bool hasLastTool;
bool FirstPersonSpectate;
Vector3 lastFront;
float lastPosSentTime;
int lastHealth;

View File

@ -92,6 +92,7 @@ namespace spades {
return readyToClose;
}
bool FirstPersonSpectate = false;
void Client::Closing() {
SPADES_MARK_FUNCTION();
@ -382,6 +383,9 @@ namespace spades {
}else if(CheckKey(cg_keySneak, name)){
playerInput.sneak = down;
}else if(CheckKey(cg_keyJump, name)){
if(down){
FirstPersonSpectate = !FirstPersonSpectate;
}
playerInput.jump = down;
}else if(CheckKey(cg_keyAttack, name)){
weapInput.primary = down;

View File

@ -200,11 +200,17 @@ namespace spades {
Vector3 front = center - eye;
front = front.Normalize();
if(FirstPersonSpectate == false){
def.viewOrigin = eye;
def.viewAxis[0] = -Vector3::Cross(up, front).Normalize();
def.viewAxis[1] = -Vector3::Cross(front, def.viewAxis[0]).Normalize();
def.viewAxis[2] = front;
}else{
def.viewOrigin = player->GetEye();
def.viewAxis[0] = player->GetRight();
def.viewAxis[1] = player->GetUp();
def.viewAxis[2] = player->GetFront();
}
def.fovY = (float)cg_fov * static_cast<float>(M_PI) /180.f;
def.fovX = atanf(tanf(def.fovY * .5f) *