Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreCamCS #164

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions code/midtown/mmcamcs/appcamcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class AppCamCS : public BaseCamCS
// ?ApproachIt@AppCamCS@@IAEXXZ
ARTS_IMPORT void ApproachIt();

private:
public:
// ?DApproach@AppCamCS@@AAEHAAMMMM0M@Z
ARTS_IMPORT i32 DApproach(f32& arg1, f32 arg2, f32 arg3, f32 arg4, f32& arg5, f32 arg6);

Expand All @@ -72,7 +72,28 @@ class AppCamCS : public BaseCamCS
// ?UpdateMaxDist@AppCamCS@@AAEXXZ
ARTS_IMPORT void UpdateMaxDist();

u8 gap9C[0x78];
Matrix34* CarMatrix;
Vector3 TrackTo;
f32 ApproachOn;
f32 AppAppOn;
f32 AppRot;
f32 AppXRot;
f32 AppYPos;
f32 AppXZPos;
f32 AppApp;
f32 AppRotMin;
f32 AppPosMin;
b32 LookAbove;
b32 OneShot;
f32 MaxDist;
f32 MinDist;
f32 LookAt;
f32 field_E4;
f32 field_E8;
f32 field_EC;
Vector3 Vector_F0;
Vector3 Vector_FC;
Vector3 Vector_F108;
};

check_size(AppCamCS, 0x114);
14 changes: 13 additions & 1 deletion code/midtown/mmcamcs/basecamcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@

#include "arts7/node.h"

#include "mmcamcs/viewcs.h"

#include "vector7/matrix34.h"

class BaseCamCS : public asNode
{
public:
Expand Down Expand Up @@ -79,7 +83,15 @@ class BaseCamCS : public asNode
// ?DeclareFields@BaseCamCS@@SAXXZ
ARTS_IMPORT static void DeclareFields();

u8 gap20[0x7C];
b16 Active;
Matrix34 camera_ {};
Matrix34 matrix_ {};
mmViewCS* View;
f32 BlendTime;
f32 BlendGoal;
f32 CameraFOV;
f32 CameraNear;
f32 CameraFar;
};

check_size(BaseCamCS, 0x9C);
2 changes: 1 addition & 1 deletion code/midtown/mmcamcs/carcamcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CarCamCS : public AppCamCS
// ?DeclareFields@CarCamCS@@SAXXZ
ARTS_IMPORT static void DeclareFields();

u8 gap114[0x4];
mmCar* Car;
};

check_size(CarCamCS, 0x118);
49 changes: 49 additions & 0 deletions code/midtown/mmcamcs/precamcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,52 @@
define_dummy_symbol(mmcamcs_precamcs);

#include "precamcs.h"

#include "mmcar/car.h"
#include "mmcar/trailer.h"

#include "carcamcs.h"

PreCamCS::PreCamCS()
: CarCamCS()
{
PolarAngle = 0.0f;
AzimuthOffset = 0.0f;
PolarHeight = 2.0f;
PolarDistance = 22.0f;
PolarIncline = 1.1f;
field_128 = 2.0f;
BlendTime = 3.0f;
}

void PreCamCS::Init(mmCar* car)
{
Car = car;
CarMatrix = &Car->Sim.LCS.World;
SetName(Car->Sim.GetNodeName());
}

void PreCamCS::MakeActive()
{
Car->Model.Activate();

if (Car->Trailer)
Car->Trailer->Inst.Flags |= INST_FLAG_ACTIVE;

PolarAngle = atan2(CarMatrix->m2.x, CarMatrix->m2.z) + AzimuthOffset;
}

void PreCamCS::Reset()
{
asNode::Reset();
}

void PreCamCS::Update()
{
camera_.PolarView(PolarDistance, PolarAngle, PolarIncline, 0.0f);

if (CarMatrix)
camera_.m3 += CarMatrix->m3;

camera_.m3.y += PolarHeight;
}
19 changes: 12 additions & 7 deletions code/midtown/mmcamcs/precamcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class PreCamCS final : public CarCamCS
{
public:
// ??0PreCamCS@@QAE@XZ
ARTS_IMPORT PreCamCS();
ARTS_EXPORT PreCamCS();

// ??_EPreCamCS@@UAEPAXI@Z
// ??1PreCamCS@@UAE@XZ | inline
ARTS_IMPORT ~PreCamCS() override = default;
ARTS_EXPORT ~PreCamCS() override = default;

#ifdef ARTS_DEV_BUILD
// ?AddWidgets@PreCamCS@@UAEXPAVBank@@@Z
Expand All @@ -55,21 +55,26 @@ class PreCamCS final : public CarCamCS
ARTS_IMPORT MetaClass* GetClass() override;

// ?Init@PreCamCS@@QAEXPAVmmCar@@@Z
ARTS_IMPORT void Init(mmCar* arg1);
ARTS_EXPORT void Init(mmCar* car);

// ?MakeActive@PreCamCS@@UAEXXZ
ARTS_IMPORT void MakeActive() override;
ARTS_EXPORT void MakeActive() override;

// ?Reset@PreCamCS@@UAEXXZ
ARTS_IMPORT void Reset() override;
ARTS_EXPORT void Reset() override;

// ?Update@PreCamCS@@UAEXXZ
ARTS_IMPORT void Update() override;
ARTS_EXPORT void Update() override;

// ?DeclareFields@PreCamCS@@SAXXZ
ARTS_IMPORT static void DeclareFields();

u8 gap118[0x18];
f32 PolarHeight;
f32 PolarDistance;
f32 PolarAngle;
f32 PolarIncline;
f32 field_128;
f32 AzimuthOffset;
};

check_size(PreCamCS, 0x130);