[saco] Implement member functions to CCamera

This commit is contained in:
RD42 2024-02-06 21:37:52 +08:00
parent 1f16817ef0
commit 315a961c3e
6 changed files with 133 additions and 3 deletions

View File

@ -14,3 +14,4 @@
#define ADDR_RENDERWARE_GETD3D_USA10 0x7F9D50 #define ADDR_RENDERWARE_GETD3D_USA10 0x7F9D50
#define ADDR_RENDERWARE_GETD3D_EU10 0x7F9D90 #define ADDR_RENDERWARE_GETD3D_EU10 0x7F9D90
#define ADDR_CAMERA 0xB6F99C

View File

@ -0,0 +1,92 @@
#include "game.h"
#include "util.h"
//-----------------------------------------------------------
void CCamera::SetBehindPlayer()
{
ScriptCommand(&lock_camera_position, 0);
ScriptCommand(&restore_camera_to_user_defined);
field_0 = 0;
ScriptCommand(&set_camera_behind_player);
ScriptCommand(&restore_camera_jumpcut);
}
//-----------------------------------------------------------
void CCamera::SetPosition(float fX, float fY, float fZ, float fRotationX, float fRotationY, float fRotationZ)
{
ScriptCommand(&restore_camera_to_user_defined);
field_0 = 0;
ScriptCommand(&set_camera_position,fX,fY,fZ,fRotationX,fRotationY,fRotationZ);
}
//-----------------------------------------------------------
void CCamera::LookAtPoint(float fX, float fY, float fZ, int iType)
{
ScriptCommand(&restore_camera_to_user_defined);
field_0 = 0;
ScriptCommand(&point_camera,fX,fY,fZ,iType);
}
//-----------------------------------------------------------
void CCamera::Restore()
{
field_0 = 0;
ScriptCommand(&restore_camera_jumpcut);
}
//-----------------------------------------------------------
void CCamera::Fade(int iInOut)
{
ScriptCommand(&fade,500,iInOut);
}
//-----------------------------------------------------------
void CCamera::GetMatrix(PMATRIX4X4 Matrix)
{
Matrix->right.X = m_matPos->right.X;
Matrix->right.Y = m_matPos->right.Y;
Matrix->right.Z = m_matPos->right.Z;
Matrix->up.X = m_matPos->up.X;
Matrix->up.Y = m_matPos->up.Y;
Matrix->up.Z = m_matPos->up.Z;
Matrix->at.X = m_matPos->at.X;
Matrix->at.Y = m_matPos->at.Y;
Matrix->at.Z = m_matPos->at.Z;
Matrix->pos.X = m_matPos->pos.X;
Matrix->pos.Y = m_matPos->pos.Y;
Matrix->pos.Z = m_matPos->pos.Z;
}
//-----------------------------------------------------------
void CCamera::SetMatrix(MATRIX4X4 Matrix)
{
m_matPos->right.X = Matrix.right.X;
m_matPos->right.Y = Matrix.right.Y;
m_matPos->right.Z = Matrix.right.Z;
m_matPos->up.X = Matrix.up.X;
m_matPos->up.Y = Matrix.up.Y;
m_matPos->up.Z = Matrix.up.Z;
m_matPos->at.X = Matrix.at.X;
m_matPos->at.Y = Matrix.at.Y;
m_matPos->at.Z = Matrix.at.Z;
m_matPos->pos.X = Matrix.pos.X;
m_matPos->pos.Y = Matrix.pos.Y;
m_matPos->pos.Z = Matrix.pos.Z;
}
//-----------------------------------------------------------

View File

@ -1,15 +1,26 @@
#pragma once #pragma once
#include "game.h" // Main runtime interface base structs.
//-----------------------------------------------------------
class CCamera // size: 8 class CCamera // size: 8
{ {
public: public:
int field_0; int field_0;
int field_4; MATRIX4X4 *m_matPos;
public:
void SetBehindPlayer();
void SetPosition(float fX, float fY, float fZ, float fRotationX, float fRotationY, float fRotationZ); // tested
void LookAtPoint(float fX, float fY, float fZ, int iType);
void Restore();
void Fade(int iInOut);
void GetMatrix(PMATRIX4X4 Matrix);
void SetMatrix(MATRIX4X4 Matrix);
CCamera() { CCamera() {
// TODO: CCamera::CCamera() m_matPos = (MATRIX4X4 *)ADDR_CAMERA;
field_4 = 0xB6F99C;
field_0 = 0; field_0 = 0;
} }
}; };

View File

@ -1,6 +1,21 @@
#pragma once #pragma once
#include <windows.h>
#define PLAYER_PED_SLOTS 210 #define PLAYER_PED_SLOTS 210
typedef struct _VECTOR {
float X,Y,Z;
} VECTOR, *PVECTOR;
typedef struct _MATRIX4X4 {
VECTOR right;
DWORD flags;
VECTOR up;
float pad_u;
VECTOR at;
float pad_a;
VECTOR pos;
float pad_p;
} MATRIX4X4, *PMATRIX4X4;

View File

@ -2,6 +2,7 @@
#pragma once #pragma once
#include "address.h" #include "address.h"
#include "common.h"
#include "audio.h" #include "audio.h"
#include "camera.h" #include "camera.h"
#include "scripting.h" #include "scripting.h"

View File

@ -15,5 +15,15 @@ struct SCRIPT_COMMAND // Params
char Params[MAX_SCRIPT_VARS]; // v = variable char Params[MAX_SCRIPT_VARS]; // v = variable
}; // s = string }; // s = string
int ScriptCommand(const SCRIPT_COMMAND* pScriptCommand, ...); // The main scripting function. See notes.
const SCRIPT_COMMAND fade = { 0x016A, "ii" }; // (time in ms), FADE_*
const SCRIPT_COMMAND set_camera_behind_player = { 0x0373, "" }; // -/-
const SCRIPT_COMMAND point_camera = { 0x0160, "fffi" }; // x, y, z, type
const SCRIPT_COMMAND restore_camera_jumpcut = { 0x02EB, "" }; // -/-
const SCRIPT_COMMAND set_camera_position = { 0x015F, "ffffff" }; // x, y, z, vx, vy, vz
const SCRIPT_COMMAND restore_camera_to_user_defined = { 0x925, "" };
const SCRIPT_COMMAND lock_camera_position = { 0x930, "i" };