mirror of
https://github.com/Mr-X-GTA/GTAV-Classes-1.git
synced 2024-12-22 14:37:31 +08:00
helper functions (#77)
This commit is contained in:
parent
39a134dcf4
commit
b7584e635c
@ -16,6 +16,13 @@ public:
|
|||||||
{
|
{
|
||||||
return reinterpret_cast<rage::fvector3*>(&m_transformation_matrix.rows[3]);
|
return reinterpret_cast<rage::fvector3*>(&m_transformation_matrix.rows[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void model_to_world(const rage::fvector3& model_coords, rage::fvector3& world_coords)
|
||||||
|
{
|
||||||
|
world_coords.x = model_coords.x * m_transformation_matrix.data[0][0] + model_coords.y * m_transformation_matrix.data[1][0] + model_coords.z * m_transformation_matrix.data[2][0] + m_transformation_matrix.data[3][0];
|
||||||
|
world_coords.y = model_coords.x * m_transformation_matrix.data[0][1] + model_coords.y * m_transformation_matrix.data[1][1] + model_coords.z * m_transformation_matrix.data[2][1] + m_transformation_matrix.data[3][1];
|
||||||
|
world_coords.z = model_coords.x * m_transformation_matrix.data[0][2] + model_coords.y * m_transformation_matrix.data[1][2] + model_coords.z * m_transformation_matrix.data[2][2] + m_transformation_matrix.data[3][2];
|
||||||
|
}
|
||||||
}; //Size: 0x0060
|
}; //Size: 0x0060
|
||||||
static_assert(sizeof(CNavigation) == 0x60);
|
static_assert(sizeof(CNavigation) == 0x60);
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
@ -31,6 +31,18 @@ namespace rage
|
|||||||
uint32_t dwordB0; //0x00B0
|
uint32_t dwordB0; //0x00B0
|
||||||
char gapB4[4]; //0x00B4
|
char gapB4[4]; //0x00B4
|
||||||
std::uint8_t byteB8; //0x00B8
|
std::uint8_t byteB8; //0x00B8
|
||||||
|
|
||||||
|
rage::fvector3* get_position()
|
||||||
|
{
|
||||||
|
return reinterpret_cast<rage::fvector3*>(&m_transformation_matrix.rows[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void model_to_world(const fvector3& model_coords, fvector3& world_coords)
|
||||||
|
{
|
||||||
|
world_coords.x = model_coords.x * m_transformation_matrix.data[0][0] + model_coords.y * m_transformation_matrix.data[1][0] + model_coords.z * m_transformation_matrix.data[2][0] + m_transformation_matrix.data[3][0];
|
||||||
|
world_coords.y = model_coords.x * m_transformation_matrix.data[0][1] + model_coords.y * m_transformation_matrix.data[1][1] + model_coords.z * m_transformation_matrix.data[2][1] + m_transformation_matrix.data[3][1];
|
||||||
|
world_coords.z = model_coords.x * m_transformation_matrix.data[0][2] + model_coords.y * m_transformation_matrix.data[1][2] + model_coords.z * m_transformation_matrix.data[2][2] + m_transformation_matrix.data[3][2];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
static_assert(sizeof(fwEntity) == 0xB9);
|
static_assert(sizeof(fwEntity) == 0xB9);
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
14
ped/CPed.hpp
14
ped/CPed.hpp
@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#include "../vehicle/CVehicle.hpp"
|
#include "../vehicle/CVehicle.hpp"
|
||||||
#include "../player/CPlayerInfo.hpp"
|
#include "../player/CPlayerInfo.hpp"
|
||||||
#include "CPedModelInfo.hpp"
|
#include "CPedModelInfo.hpp"
|
||||||
@ -15,14 +14,13 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
class CPed : public rage::CPhysical
|
class CPed : public rage::CPhysical
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char gap2EC[20];
|
char gap2EC[20];
|
||||||
rage::fvector3 m_velocity; //0x0300
|
rage::fvector3 m_velocity; //0x0300
|
||||||
char pad_030C[260]; //0x030C
|
char pad_030C[260]; //0x030C
|
||||||
class CPedBoneInfo m_bone_info; //0x0410
|
class CPedBoneInfo m_bone_info[9]; //0x0410
|
||||||
char pad_04A0[2160]; //0x04A0
|
char pad_04A0[2160]; //0x04A0
|
||||||
class CVehicle *m_vehicle; //0x0D10
|
class CVehicle *m_vehicle; //0x0D10
|
||||||
char pad_0D18[896]; //0x0D18
|
char pad_0D18[896]; //0x0D18
|
||||||
@ -49,7 +47,14 @@ public:
|
|||||||
char pad_1524[240]; //0x1524
|
char pad_1524[240]; //0x1524
|
||||||
uint16_t m_cash; //0x1614
|
uint16_t m_cash; //0x1614
|
||||||
|
|
||||||
float get_speed() { return std::sqrt(m_velocity.x * m_velocity.x + m_velocity.y * m_velocity.y + m_velocity.z * m_velocity.z); }
|
float get_speed() { return sqrt(m_velocity.x * m_velocity.x + m_velocity.y * m_velocity.y + m_velocity.z * m_velocity.z); }
|
||||||
|
|
||||||
|
rage::fvector3 get_bone_coords(ePedBoneType type)
|
||||||
|
{
|
||||||
|
rage::fvector3 world_coords;
|
||||||
|
model_to_world(m_bone_info[(uint32_t)type].model_coords, world_coords);
|
||||||
|
return world_coords;
|
||||||
|
}
|
||||||
|
|
||||||
bool can_be_ragdolled() { return m_ped_type & 0x20; }
|
bool can_be_ragdolled() { return m_ped_type & 0x20; }
|
||||||
|
|
||||||
@ -60,5 +65,4 @@ public:
|
|||||||
void forced_aim(bool toggle) { m_forced_aim ^= (m_forced_aim ^ -(char)toggle) & 0x20; }
|
void forced_aim(bool toggle) { m_forced_aim ^= (m_forced_aim ^ -(char)toggle) & 0x20; }
|
||||||
}; //Size: 0x1616
|
}; //Size: 0x1616
|
||||||
static_assert(sizeof(CPed) == 0x1616);
|
static_assert(sizeof(CPed) == 0x1616);
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
@ -2,26 +2,23 @@
|
|||||||
|
|
||||||
#include "../rage/vector.hpp"
|
#include "../rage/vector.hpp"
|
||||||
|
|
||||||
|
enum class ePedBoneType
|
||||||
|
{
|
||||||
|
HEAD,
|
||||||
|
L_FOOT,
|
||||||
|
R_FOOT,
|
||||||
|
L_ANKLE,
|
||||||
|
R_ANKLE,
|
||||||
|
L_HAND,
|
||||||
|
R_HAND,
|
||||||
|
NECK,
|
||||||
|
ABDOMEN
|
||||||
|
};
|
||||||
|
|
||||||
class CPedBoneInfo
|
class CPedBoneInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
rage::fvector3 m_bone_head_model_coords; //0x0000
|
rage::fvector3 model_coords;
|
||||||
char pad_000C[4]; //0x000C
|
char pad_000C[4];
|
||||||
rage::fvector3 m_bone_left_foot_model_coords; //0x0010
|
};
|
||||||
char pad_001C[4]; //0x001C
|
static_assert(sizeof(CPedBoneInfo) == 0x10);
|
||||||
rage::fvector3 m_bone_right_foot_model_coords; //0x0020
|
|
||||||
char pad_002C[4]; //0x002C
|
|
||||||
rage::fvector3 m_bone_left_ankle_model_coords; //0x0030
|
|
||||||
char pad_003C[4]; //0x003C
|
|
||||||
rage::fvector3 m_bone_right_ankle_model_coords; //0x0040
|
|
||||||
char pad_004C[4]; //0x004C
|
|
||||||
rage::fvector3 m_bone_left_hand_model_coords; //0x0050
|
|
||||||
char pad_005C[4]; //0x005C
|
|
||||||
rage::fvector3 m_bone_right_hand_model_coords; //0x0060
|
|
||||||
char pad_006C[4]; //0x006C
|
|
||||||
rage::fvector3 m_bone_neck_model_coords; //0x0070
|
|
||||||
char pad_007C[4]; //0x007C
|
|
||||||
rage::fvector3 m_bone_abdomen_model_coords; //0x0080
|
|
||||||
char pad_008C[4]; //0x008C
|
|
||||||
}; //Size: 0x0090
|
|
||||||
static_assert(sizeof(CPedBoneInfo) == 0x90);
|
|
@ -4,6 +4,7 @@
|
|||||||
#include "CHandlingData.hpp"
|
#include "CHandlingData.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
class CVehicle : public rage::CPhysical
|
class CVehicle : public rage::CPhysical
|
||||||
@ -47,6 +48,8 @@ public:
|
|||||||
char pad_0CD0[0x6A0]; //0x0CD0
|
char pad_0CD0[0x6A0]; //0x0CD0
|
||||||
uint32_t m_door_lock_status; //0x1370
|
uint32_t m_door_lock_status; //0x1370
|
||||||
char pad_1374[0xDC]; //0x1374
|
char pad_1374[0xDC]; //0x1374
|
||||||
|
|
||||||
|
float get_speed() { return sqrt(m_velocity.x * m_velocity.x + m_velocity.y * m_velocity.y + m_velocity.z * m_velocity.z); }
|
||||||
};
|
};
|
||||||
static_assert(sizeof(CVehicle) == 0x1450);
|
static_assert(sizeof(CVehicle) == 0x1450);
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
Loading…
Reference in New Issue
Block a user