Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ===============
- idPlayer::SpectateWinner
- ===============
- */
- void idPlayer::SpectateWinner( void ) {
- idVec3 view, focusAngles, focusPoint, origin;
- trace_t trace;
- float focusDist, forwardScale, sideScale, endGameAngle, endGameRange, endGameHeight;
- idAngles angles;
- idMat3 axis;
- idBounds bounds;
- idEntity* vehicle = NULL;
- idEntity* ent = NULL;
- bool inVehicle = false;
- idPlayer* player;
- if ( !gameLocal.IsSpectatingWinner() ) {
- return;
- }
- fl.takedamage = false;
- playerView.ClearEffects();
- if ( pfl.hasInvisibility ) {
- Invisibility( false );
- }
- ClearPowerUps();
- ClearFocus();
- if ( mphud ) {
- mphud->HandleNamedEvent( "spectateWinner" );
- }
- winningEnt = gameLocal.mpGame.GetGameState()->winningEnt;
- winningTeam = gameLocal.mpGame.GetGameState()->winningTeam;
- ent = winningEnt.GetEntity();
- endGameAngle = GetLimitRandomFloat( 0, 1079 );
- endGameRange = GetLimitRandomFloat( 310, 530 );
- endGameHeight = GetLimitRandomFloat( 60, 180 );
- //needed for mp inactive state->game review, dedicated server will crash if a player connects
- if ( !ent ) {
- ent = this;
- }
- if ( ent->spawnArgs.GetFloat( "endViewHeight", "0" ) ) {
- endGameHeight -= ent->spawnArgs.GetFloat( "endViewHeight", "0" );
- }
- if ( !ent->IsType( idPlayer::GetClassType() ) ) {
- axis = ent->GetSpawnAxis();
- angles = ent->GetSpawnAxis().ToAngles();
- origin = ent->GetSpawnOrigin();
- } else if ( ent->IsType( idPlayer::GetClassType() ) ) {
- player = ent->GetStaticPlayer();
- inVehicle = player->IsInVehicle();
- if ( !inVehicle ) {
- angles = player->GetPhysics()->GetAxis().ToAngles();
- origin = player->GetPhysics()->GetOrigin();
- axis = player->GetPhysics()->GetAxis();
- } else if ( inVehicle ) {
- vehicle = GetEntityByNum( player->GetVehicleController().GetVehicle()->entityNumber );
- rvVehiclePosition * position = player->GetDriverPosition();
- origin = position->GetOrigin();
- angles = position->GetAxis().ToAngles();
- axis = position->GetAxis();
- }
- }
- focusPoint = origin + angles.ToForward() * THIRD_PERSON_FOCUS_DISTANCE;
- focusPoint.z += endGameHeight;
- view = origin;
- view += physicsObj.GetGravityAxis()[2] * endGameHeight;
- idMath::SinCos( DEG2RAD( endGameAngle ), sideScale, forwardScale );
- view -= endGameRange * forwardScale * axis[ 0 ];
- view += endGameRange * sideScale * axis[ 1 ];
- if ( !inVehicle ) {
- bounds = idBounds( idVec3( -4, -4, -4 ), idVec3( 4, 4, 4 ) );
- gameLocal.TraceBounds( ent, trace, origin, view, bounds, MASK_SOLID, ent );
- if ( trace.fraction != 1.0f ) {
- view = trace.endpos;
- view += physicsObj.GetGravityAxis()[2] * ( 1.0f - trace.fraction ) * 32.0f;
- gameLocal.TraceBounds( ent, trace, origin, view, bounds, MASK_SOLID, ent );
- view = trace.endpos;
- }
- } else if ( inVehicle ) {
- const idVec3 clip_mins( -4.0f, -4.0f, -4.0f );
- const idVec3 clip_maxs( 4.0f, 4.0f, 4.0f );
- const idBounds clip_bounds( clip_mins, clip_maxs );
- idClipModel clipBounds( clip_bounds );
- gameLocal.Translation( ent, trace, origin, view, &clipBounds, vehicle->GetPhysics()->GetAxis(), MASK_SOLID, vehicle, vehicle->GetBindMaster() );
- if ( trace.fraction != 1.0 ) {
- view = trace.endpos;
- view += physicsObj.GetGravityAxis()[2] * ( 1.0f - trace.fraction ) * 32.0f;
- gameLocal.Translation( ent, trace, origin, view, &clipBounds, vehicle->GetPhysics()->GetAxis(), MASK_SOLID, vehicle, vehicle->GetBindMaster() );
- view = trace.endpos;
- }
- }
- focusPoint -= view;
- focusDist = idMath::Sqrt( focusPoint[0] * focusPoint[0] + focusPoint[1] * focusPoint[1] );
- if ( focusDist < 1.0f ) {
- focusDist = 1.0f;
- }
- angles.pitch = RAD2DEG( idMath::ATan( focusPoint.z, focusDist ) );
- angles.yaw -= endGameAngle;
- if ( !winnerCam ) {
- const idDict* modDict;
- idEntity* camEnt;
- playerViewOrigin = firstPersonViewOrigin;
- playerViewAxis = firstPersonViewAxis;
- modDict = gameLocal.FindEntityDefDict ( "func_cameraview", false );
- gameLocal.SpawnEntityDef( *modDict, &camEnt );
- winnerCam = static_cast<idCameraView*>(camEnt);
- winnerCam->fl.networkSync = false;
- winnerCam->SetOrigin( view );
- winnerCam->SetAxis( angles.ToMat3() * physicsObj.GetGravityAxis() );
- winnerCam->GetRenderView()->viewID = 0;
- } else {
- DrawShadow( !head.IsValid() ? NULL : head.GetEntity()->GetRenderEntity() );
- UpdateLiquidCamera( winnerCam->GetRenderView(), winnerCam );
- }
- UpdatePauseHud();
- }
- /*
- ===============
- idPlayer::ThirdPersonView
- ===============
- */
- void idPlayer::ThirdPersonView( float angle, float range, float height, bool clip, bool endGame, bool inVehicle ) {
- idVec3 view;
- idVec3 focusAngles;
- trace_t trace;
- idVec3 focusPoint;
- float focusDist;
- float forwardScale, sideScale;
- idVec3 origin;
- idAngles angles;
- idMat3 axis;
- idBounds bounds;
- idEntity* vehicle = NULL;
- pfl.thirdpersonView = true;
- angles = viewAngles;
- GetViewPos( origin, axis );
- if ( inVehicle ) {
- vehicle = vehicleController.GetVehicle();
- rvVehiclePosition * position = GetDriverPosition();
- origin = position->GetEyeOrigin();
- angles = position->GetEyeAxis().ToAngles();
- axis = position->GetAxis();
- }
- focusPoint = GetPhysics()->GetAbsBounds().GetCenter() + angles.ToForward() * THIRD_PERSON_FOCUS_DISTANCE;
- focusPoint.z += height;
- view = origin;
- view += physicsObj.GetGravityAxis()[2] * (8.0f + height);
- //if ( !inVehicle ) {
- idMath::SinCos( DEG2RAD( angle ), sideScale, forwardScale );
- view -= range * forwardScale * renderView->viewaxis[ 0 ];
- view += range * sideScale * renderView->viewaxis[ 1 ];
- //}
- if ( clip && !inVehicle ) {
- bounds = idBounds( idVec3( -4, -4, -4 ), idVec3( 4, 4, 4 ) );
- gameLocal.TraceBounds( this, trace, origin, view, bounds, MASK_SOLID, this );
- if ( trace.fraction != 1.0f ) {
- view = trace.endpos;
- view += physicsObj.GetGravityAxis()[2] * ( 1.0f - trace.fraction ) * 32.0f;
- gameLocal.TraceBounds( this, trace, origin, view, bounds, MASK_SOLID, this );
- view = trace.endpos;
- }
- } else if ( clip && inVehicle ) {
- const idVec3 clip_mins( -4.0f, -4.0f, -4.0f );
- const idVec3 clip_maxs( 4.0f, 4.0f, 4.0f );
- const idBounds clip_bounds( clip_mins, clip_maxs );
- idClipModel clipBounds( clip_bounds );
- gameLocal.Translation( this, trace, origin, view, &clipBounds, vehicle->GetPhysics()->GetAxis(), MASK_SOLID, vehicle, vehicle->GetBindMaster() );
- if ( trace.fraction != 1.0 )
- {
- view = trace.endpos;
- view += physicsObj.GetGravityAxis()[2] * ( 1.0f - trace.fraction ) * 32;
- gameLocal.Translation( this, trace, origin, view, &clipBounds, vehicle->GetPhysics()->GetAxis(), MASK_SOLID, vehicle, vehicle->GetBindMaster() );
- view = trace.endpos;
- }
- }
- focusPoint -= view;
- focusDist = idMath::Sqrt( focusPoint[0] * focusPoint[0] + focusPoint[1] * focusPoint[1] );
- if ( focusDist < 1.0f ) {
- focusDist = 1.0f;
- }
- angles.pitch = - RAD2DEG( idMath::ATan( focusPoint.z, focusDist ) );
- angles.yaw -= angle;
- renderView->vieworg = view;
- renderView->viewaxis = angles.ToMat3() * physicsObj.GetGravityAxis();
- renderView->viewID = 0;
- UpdateLiquidCamera( renderView, this );
- }
- void idPlayer::thirdPerson_zoomin( void ) {
- int duration = 10;
- rvVehicle * vehicle = NULL;
- if ( IsInVehicle ( ) ) {
- vehicle = vehicleController.GetVehicle();
- //vehicle->thirdpersonRange;
- camera_zoom.Init( gameLocal.time, gameLocal.time + SEC2MS( pm_thirdPersonZoomTime.GetInteger() ), camera_zoom.GetCurrentValue( gameLocal.time ), ( camera_zoom.GetCurrentValue( gameLocal.time ) - 10 ) );
- } else {
- camera_zoom.Init( gameLocal.time, gameLocal.time + SEC2MS( pm_thirdPersonZoomTime.GetInteger() ), camera_zoom.GetCurrentValue( gameLocal.time ), ( camera_zoom.GetCurrentValue( gameLocal.time ) - 10 ) );
- }
- }
- void idPlayer::thirdPerson_zoomout( void ) {
- int duration = 10;
- rvVehicle * vehicle = NULL;
- if ( IsInVehicle ( ) ) {
- vehicle = vehicleController.GetVehicle();
- //vehicle->thirdpersonRange;
- camera_zoom.Init( gameLocal.time, gameLocal.time + SEC2MS( pm_thirdPersonZoomTime.GetInteger() ), camera_zoom.GetCurrentValue( gameLocal.time ), ( camera_zoom.GetCurrentValue( gameLocal.time ) + 10 ) );
- } else {
- camera_zoom.Init( gameLocal.time, gameLocal.time + SEC2MS( pm_thirdPersonZoomTime.GetInteger() ), camera_zoom.GetCurrentValue( gameLocal.time ), ( camera_zoom.GetCurrentValue( gameLocal.time ) + 10 ) );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement