Merge pull request #328 from noway421/first-person-spec
Added first person view for spectate mode
This commit is contained in:
commit
b26d4c7821
@ -138,6 +138,7 @@ namespace spades {
|
||||
KeypadInput keypadInput;
|
||||
Player::ToolType lastTool;
|
||||
bool hasLastTool;
|
||||
bool FirstPersonSpectate;
|
||||
Vector3 lastFront;
|
||||
float lastPosSentTime;
|
||||
int lastHealth;
|
||||
|
@ -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;
|
||||
|
@ -200,11 +200,17 @@ namespace spades {
|
||||
Vector3 front = center - eye;
|
||||
front = front.Normalize();
|
||||
|
||||
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;
|
||||
|
||||
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) *
|
||||
|
Loading…
x
Reference in New Issue
Block a user