implemented some unused PS2 cams

This commit is contained in:
aap 2020-03-27 18:19:08 +01:00
parent f0dfaac838
commit 22e022cc9f
5 changed files with 302 additions and 6 deletions

View File

@ -2,7 +2,7 @@
#include "patcher.h" #include "patcher.h"
#include "SceneEdit.h" #include "SceneEdit.h"
int &CSceneEdit::m_bCameraFollowActor = *(int*)0x940590; int32 &CSceneEdit::m_bCameraFollowActor = *(int*)0x940590;
bool &CSceneEdit::m_bRecording = *(bool*)0x95CD1F; bool &CSceneEdit::m_bRecording = *(bool*)0x95CD1F;
CVector &CSceneEdit::m_vecCurrentPosition = *(CVector*)0x943064; CVector &CSceneEdit::m_vecCurrentPosition = *(CVector*)0x943064;
CVector &CSceneEdit::m_vecCamHeading = *(CVector*)0x942F8C; CVector &CSceneEdit::m_vecCamHeading = *(CVector*)0x942F8C;

View File

@ -3,7 +3,7 @@
class CSceneEdit class CSceneEdit
{ {
public: public:
static int &m_bCameraFollowActor; static int32 &m_bCameraFollowActor;
static bool &m_bRecording; static bool &m_bRecording;
static CVector &m_vecCurrentPosition; static CVector &m_vecCurrentPosition;
static CVector &m_vecCamHeading; static CVector &m_vecCamHeading;

View File

@ -176,9 +176,15 @@ CCam::Process(void)
case MODE_CAM_ON_A_STRING: case MODE_CAM_ON_A_STRING:
Process_Cam_On_A_String(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); Process_Cam_On_A_String(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
break; break;
// case MODE_REACTION: case MODE_REACTION:
// case MODE_FOLLOW_PED_WITH_BIND: Process_ReactionCam(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
// case MODE_CHRIS: break;
case MODE_FOLLOW_PED_WITH_BIND:
Process_FollowPed_WithBinding(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
break;
case MODE_CHRIS:
Process_Chris_With_Binding_PlusRotation(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
break;
case MODE_BEHINDBOAT: case MODE_BEHINDBOAT:
Process_BehindBoat(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); Process_BehindBoat(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
break; break;
@ -883,7 +889,7 @@ CCam::PrintMode(void)
break; break;
case MODE_REACTION: case MODE_REACTION:
sprintf(buf, "Debug:- Cam Choice2. Reaction Cam On A String "); sprintf(buf, "Debug:- Cam Choice2. Reaction Cam On A String ");
sprintf(buf, " Uses Locking Button LeftShoulder 1. "); sprintf(buf, " Uses Locking Button LeftShoulder 1. "); // lie
break; break;
case MODE_FOLLOW_PED_WITH_BIND: case MODE_FOLLOW_PED_WITH_BIND:
sprintf(buf, "Debug:- Cam Choice3. Game ReactionCam with Locking "); sprintf(buf, "Debug:- Cam Choice3. Game ReactionCam with Locking ");
@ -4092,6 +4098,277 @@ CCam::ProcessArrestCamTwo(void)
return false; return false;
} }
/*
* Unused PS2 cams
*/
void
CCam::Process_Chris_With_Binding_PlusRotation(const CVector &CameraTarget, float TargetOrientation, float, float)
{
static float AngleToBinned = 0.0f;
static float StartingAngleLastChange = 0.0f;
static float FixedTargetOrientation = 0.0f;
static float DeadZoneReachedOnePrevious;
FOV = DefaultFOV; // missing in game
bool FixOrientation = true;
if(ResetStatics){
Rotating = false;
DeadZoneReachedOnePrevious = 0.0f;
FixedTargetOrientation = 0.0f;
ResetStatics = false;
}
CVector TargetCoors = CameraTarget;
float StickX = CPad::GetPad(0)->GetRightStickX();
float StickY = CPad::GetPad(0)->GetRightStickY();
float StickAngle;
if(StickX != 0.0 || StickY != 0.0f) // BUG: game checks StickX twice
StickAngle = CGeneral::GetATanOfXY(StickX, StickY); // result unused?
else
FixOrientation = false;
CVector Dist = Source - TargetCoors;
Source.z = TargetCoors.z + 0.75f;
float Length = Dist.Magnitude2D();
if(Length > 2.5f){
Source.x = TargetCoors.x + Dist.x/Length * 2.5f;
Source.y = TargetCoors.y + Dist.y/Length * 2.5f;
}else if(Length < 2.4f){
Source.x = TargetCoors.x + Dist.x/Length * 2.4f;
Source.y = TargetCoors.y + Dist.y/Length * 2.4f;
}
Beta = CGeneral::GetATanOfXY(Dist.x, Dist.y);
if(CPad::GetPad(0)->GetLeftShoulder1()){
FixedTargetOrientation = TargetOrientation;
Rotating = true;
}
if(FixOrientation){
Rotating = true;
FixedTargetOrientation = StickX/128.0f + Beta - PI;
}
if(Rotating){
Dist = Source - TargetCoors;
Length = Dist.Magnitude2D();
// inlined
WellBufferMe(FixedTargetOrientation+PI, &Beta, &BetaSpeed, 0.1f, 0.06f, true);
Source.x = TargetCoors.x + Length*Cos(Beta);
Source.y = TargetCoors.y + Length*Sin(Beta);
float DeltaBeta = FixedTargetOrientation+PI - Beta;
while(DeltaBeta >= PI) DeltaBeta -= 2*PI;
while(DeltaBeta < -PI) DeltaBeta += 2*PI;
if(Abs(DeltaBeta) < 0.06f)
Rotating = false;
}
Front = TargetCoors - Source;
Front.Normalise();
CVector Front2 = Front;
Front2.Normalise(); // What?
// FIX: the meaning of this value must have changed somehow
Source -= Front2 * TheCamera.m_fPedZoomValueSmooth*1.5f;
// Source += Front2 * TheCamera.m_fPedZoomValueSmooth;
GetVectorsReadyForRW();
}
void
CCam::Process_ReactionCam(const CVector &CameraTarget, float TargetOrientation, float, float)
{
static float AngleToBinned = 0.0f;
static float StartingAngleLastChange = 0.0f;
static float FixedTargetOrientation;
static float DeadZoneReachedOnePrevious;
static uint32 TimeOfLastChange;
uint32 Time;
bool DontBind = false; // BUG: left uninitialized
FOV = DefaultFOV; // missing in game
if(ResetStatics){
Rotating = false;
DeadZoneReachedOnePrevious = 0.0f;
FixedTargetOrientation = 0.0f;
ResetStatics = false;
DontBind = false;
}
CVector TargetCoors = CameraTarget;
CVector Dist = Source - TargetCoors;
Source.z = TargetCoors.z + 0.75f;
float Length = Dist.Magnitude2D();
if(Length > 2.5f){
Source.x = TargetCoors.x + Dist.x/Length * 2.5f;
Source.y = TargetCoors.y + Dist.y/Length * 2.5f;
}else if(Length < 2.4f){
Source.x = TargetCoors.x + Dist.x/Length * 2.4f;
Source.y = TargetCoors.y + Dist.y/Length * 2.4f;
}
Beta = CGeneral::GetATanOfXY(Dist.x, Dist.y);
float StickX = CPad::GetPad(0)->GetLeftStickX();
float StickY = CPad::GetPad(0)->GetLeftStickY();
float StickAngle;
if(StickX != 0.0 || StickY != 0.0f){
StickAngle = CGeneral::GetATanOfXY(StickX, StickY);
while(StickAngle >= PI) StickAngle -= 2*PI;
while(StickAngle < -PI) StickAngle += 2*PI;
}else
StickAngle = 1000.0f;
if(Abs(StickAngle-AngleToBinned) > DEGTORAD(15.0f)){
DontBind = true;
Time = CTimer::GetTimeInMilliseconds();
}
if(CTimer::GetTimeInMilliseconds()-TimeOfLastChange > 200){
if(Abs(HALFPI-StickAngle) > DEGTORAD(50.0f)){
FixedTargetOrientation = TargetOrientation;
Rotating = true;
TimeOfLastChange = CTimer::GetTimeInMilliseconds();
}
}
// These two together don't make much sense.
// Only prevents rotation for one frame
AngleToBinned = StickAngle;
if(DontBind)
TimeOfLastChange = Time;
if(Rotating){
Dist = Source - TargetCoors;
Length = Dist.Magnitude2D();
// inlined
WellBufferMe(FixedTargetOrientation+PI, &Beta, &BetaSpeed, 0.1f, 0.06f, true);
Source.x = TargetCoors.x + Length*Cos(Beta);
Source.y = TargetCoors.y + Length*Sin(Beta);
float DeltaBeta = FixedTargetOrientation+PI - Beta;
while(DeltaBeta >= PI) DeltaBeta -= 2*PI;
while(DeltaBeta < -PI) DeltaBeta += 2*PI;
if(Abs(DeltaBeta) < 0.06f)
Rotating = false;
}
Front = TargetCoors - Source;
Front.Normalise();
CVector Front2 = Front;
Front2.Normalise(); // What?
// FIX: the meaning of this value must have changed somehow
Source -= Front2 * TheCamera.m_fPedZoomValueSmooth*1.5f;
// Source += Front2 * TheCamera.m_fPedZoomValueSmooth;
GetVectorsReadyForRW();
}
void
CCam::Process_FollowPed_WithBinding(const CVector &CameraTarget, float TargetOrientation, float, float)
{
static float AngleToBinned = 0.0f;
static float StartingAngleLastChange = 0.0f;
static float FixedTargetOrientation;
static float DeadZoneReachedOnePrevious;
static uint32 TimeOfLastChange;
uint32 Time;
bool DontBind = false;
FOV = DefaultFOV; // missing in game
if(ResetStatics){
Rotating = false;
DeadZoneReachedOnePrevious = 0.0f;
FixedTargetOrientation = 0.0f;
ResetStatics = false;
}
CVector TargetCoors = CameraTarget;
CVector Dist = Source - TargetCoors;
Source.z = TargetCoors.z + 0.75f;
float Length = Dist.Magnitude2D();
if(Length > 2.5f){
Source.x = TargetCoors.x + Dist.x/Length * 2.5f;
Source.y = TargetCoors.y + Dist.y/Length * 2.5f;
}else if(Length < 2.4f){
Source.x = TargetCoors.x + Dist.x/Length * 2.4f;
Source.y = TargetCoors.y + Dist.y/Length * 2.4f;
}
Beta = CGeneral::GetATanOfXY(Dist.x, Dist.y);
float StickX = CPad::GetPad(0)->GetLeftStickX();
float StickY = CPad::GetPad(0)->GetLeftStickY();
float StickAngle;
if(StickX != 0.0 || StickY != 0.0f){
StickAngle = CGeneral::GetATanOfXY(StickX, StickY);
while(StickAngle >= PI) StickAngle -= 2*PI;
while(StickAngle < -PI) StickAngle += 2*PI;
}else
StickAngle = 1000.0f;
if(Abs(StickAngle-AngleToBinned) > DEGTORAD(15.0f)){
DontBind = true;
Time = CTimer::GetTimeInMilliseconds();
}
if(CTimer::GetTimeInMilliseconds()-TimeOfLastChange > 200){
if(Abs(HALFPI-StickAngle) > DEGTORAD(50.0f)){
FixedTargetOrientation = TargetOrientation;
Rotating = true;
TimeOfLastChange = CTimer::GetTimeInMilliseconds();
}
}
if(CPad::GetPad(0)->GetLeftShoulder1JustDown()){
FixedTargetOrientation = TargetOrientation;
Rotating = true;
TimeOfLastChange = CTimer::GetTimeInMilliseconds();
}
// These two together don't make much sense.
// Only prevents rotation for one frame
AngleToBinned = StickAngle;
if(DontBind)
TimeOfLastChange = Time;
if(Rotating){
Dist = Source - TargetCoors;
Length = Dist.Magnitude2D();
// inlined
WellBufferMe(FixedTargetOrientation+PI, &Beta, &BetaSpeed, 0.1f, 0.06f, true);
Source.x = TargetCoors.x + Length*Cos(Beta);
Source.y = TargetCoors.y + Length*Sin(Beta);
float DeltaBeta = FixedTargetOrientation+PI - Beta;
while(DeltaBeta >= PI) DeltaBeta -= 2*PI;
while(DeltaBeta < -PI) DeltaBeta += 2*PI;
if(Abs(DeltaBeta) < 0.06f)
Rotating = false;
}
Front = TargetCoors - Source;
Front.Normalise();
CVector Front2 = Front;
Front2.Normalise(); // What?
// FIX: the meaning of this value must have changed somehow
Source -= Front2 * TheCamera.m_fPedZoomValueSmooth*1.5f;
// Source += Front2 * TheCamera.m_fPedZoomValueSmooth;
GetVectorsReadyForRW();
}
STARTPATCHES STARTPATCHES
InjectHook(0x456F40, WellBufferMe, PATCH_JUMP); InjectHook(0x456F40, WellBufferMe, PATCH_JUMP);
InjectHook(0x458410, &CCam::Init, PATCH_JUMP); InjectHook(0x458410, &CCam::Init, PATCH_JUMP);

View File

@ -206,6 +206,21 @@ struct CCam
void ProcessPedsDeadBaby(void); void ProcessPedsDeadBaby(void);
bool ProcessArrestCamOne(void); bool ProcessArrestCamOne(void);
bool ProcessArrestCamTwo(void); bool ProcessArrestCamTwo(void);
/* Some of the unused PS2 cams */
void Process_Chris_With_Binding_PlusRotation(const CVector &CameraTarget, float, float, float);
void Process_ReactionCam(const CVector &CameraTarget, float TargetOrientation, float, float);
void Process_FollowPed_WithBinding(const CVector &CameraTarget, float TargetOrientation, float, float);
// TODO:
// CCam::Process_CushyPillows_Arse
// CCam::Process_Look_At_Cars
// CCam::Process_CheesyZoom
// CCam::Process_Aiming
// CCam::Process_Bill // same as BehindCar due to unused variables
// CCam::Process_Im_The_Passenger_Woo_Woo
// CCam::Process_Blood_On_The_Tracks
// CCam::Process_Cam_Running_Side_Train
// CCam::Process_Cam_On_Train_Roof
}; };
static_assert(sizeof(CCam) == 0x1A4, "CCam: wrong size"); static_assert(sizeof(CCam) == 0x1A4, "CCam: wrong size");
static_assert(offsetof(CCam, Alpha) == 0xA8, "CCam: error"); static_assert(offsetof(CCam, Alpha) == 0xA8, "CCam: error");

View File

@ -377,6 +377,10 @@ DebugMenuPopulate(void)
extern int16 &DebugCamMode; extern int16 &DebugCamMode;
DebugMenuAddVarBool8("Cam", "Print Debug Code", (int8*)&PrintDebugCode, nil); DebugMenuAddVarBool8("Cam", "Print Debug Code", (int8*)&PrintDebugCode, nil);
DebugMenuAddVar("Cam", "Cam Mode", &DebugCamMode, nil, 1, 0, CCam::MODE_EDITOR, nil); DebugMenuAddVar("Cam", "Cam Mode", &DebugCamMode, nil, 1, 0, CCam::MODE_EDITOR, nil);
DebugMenuAddCmd("Cam", "Normal", []() { DebugCamMode = 0; });
DebugMenuAddCmd("Cam", "Follow Ped With Bind", []() { DebugCamMode = CCam::MODE_FOLLOW_PED_WITH_BIND; });
DebugMenuAddCmd("Cam", "Reaction", []() { DebugCamMode = CCam::MODE_REACTION; });
DebugMenuAddCmd("Cam", "Chris", []() { DebugCamMode = CCam::MODE_CHRIS; });
DebugMenuAddCmd("Cam", "Reset Statics", ResetCamStatics); DebugMenuAddCmd("Cam", "Reset Statics", ResetCamStatics);
CTweakVars::AddDBG("Debug"); CTweakVars::AddDBG("Debug");