Vehicle zAngle

mrT101

Active member
Joined
Feb 18, 2014
Messages
58
Reaction score
0
I have been able to calculate the rotation of my vehicle around the zAxis (yaw) however it only calculates correctly if the vehicle is completely horizontal. If the vehicle rotates on the x or y axis, the zAngle becomes offset by between 0-90 degrees and doesn't give the same value as shown using cleo opcode 0172. I am trying not to use cleo. is there a simpler way to read the vehicle's zrotation?
 

T3KTONIT

Well-known member
Joined
Sep 2, 2013
Messages
308
Reaction score
5
you can get your vehicle(current vehicle) rotation like this :

PHP:
void GetMyVehicleRotation(float *Rotation)
{
 DWORD CurrentVehicle = *(DWORD*)0xBA18FC;
 DWORD CMatrix = *(DWORD*)(CurrentVehicle + 20);
 Rotation[0] = *(float*)(CMatrix);          // X
 Rotation[1] = *(float*)(CMatrix + 4);    // Y
 Rotation[2] = *(float*)(CMatrix + 8);    // Z
}

------------------------
float rotation[3];
GetMyVehicleRotation(rotation);

PS: the rotations are in GRAD so you have to convert them to radians or degrees if you want to.
 

mrT101

Active member
Joined
Feb 18, 2014
Messages
58
Reaction score
0
Thanks for reply T3K!
I modified your code since I am only interested in the Zaxis Rotation and using 0xBA18FC crashes me
Code:
void GetMyVehicleRotation(float *Rotation)
{
 DWORD CurrentVehicle = *(DWORD*)(0xB6F980);
 DWORD CMatrix = *(DWORD*)(CurrentVehicle + 0x14);
 Rotation[0] = *(float*)(CMatrix);
 Rotation[1] = *(float*)(CMatrix + 0x4);
 Rotation[2] = *(float*)(CMatrix + 0x8);
}

float rotation[3];
GetMyVehicleRotation(rotation);
float zAngle = (0.9 * rotation[2]);     //*0.9 to convert GRAD to DEGREES       

The values i am reading are around 0.00003 and only seem to change if i am moving. have you any idea why this could be?
 

T3KTONIT

Well-known member
Joined
Sep 2, 2013
Messages
308
Reaction score
5
mrT101 link said:
Thanks for reply T3K!
I modified your code since I am only interested in the Zaxis Rotation and using 0xBA18FC crashes me
Code:
void GetMyVehicleRotation(float *Rotation)
{
 DWORD CurrentVehicle = *(DWORD*)(0xB6F980);
 DWORD CMatrix = *(DWORD*)(CurrentVehicle + 0x14);
 Rotation[0] = *(float*)(CMatrix);
 Rotation[1] = *(float*)(CMatrix + 0x4);
 Rotation[2] = *(float*)(CMatrix + 0x8);
}

float rotation[3];
GetMyVehicleRotation(rotation);
float zAngle = (0.9 * rotation[2]);     //*0.9 to convert GRAD to DEGREES       

The values i am reading are around 0.00003 and only seem to change if i am moving. have you any idea why this could be?

0xB6F980 is for the vehicle pool (contains many pointers to vehicles) you can't use that...
just use 0xBA18FC, i think i made a mistake in my code that's why it crashes please just try to fix it a little bit more xD srry

try to verify using cheat engine
 

mrT101

Active member
Joined
Feb 18, 2014
Messages
58
Reaction score
0
Hey, I have used CE to try to work this out, but still it gives me very small numbers (3.89x10^-6) as the z rotation. I have attached a picture of the CE pointer window to show whats happening.
oiDerQA.png
 

T3KTONIT

Well-known member
Joined
Sep 2, 2013
Messages
308
Reaction score
5
nevermind, it looks alright to me...

were you inside a vehicle by the way?
 

mrT101

Active member
Joined
Feb 18, 2014
Messages
58
Reaction score
0
yes i was inside a plane looking exactly west when i took that screenshot
 

T3KTONIT

Well-known member
Joined
Sep 2, 2013
Messages
308
Reaction score
5
mrT101 link said:
yes i was inside a plane looking exactly west when i took that screenshot

well idk but since you said 'Looking', there are another set of offsets for the 'Looking' rotation XD honestly i don't know what it is but here is it :

+0 = [float] X-axis Rotation (Grad)
+4 = [float] Y-axis Rotation (Grad)
+8 = [float] Z-axis Rotation (Grad)
+16 = [float] X-axis Rotation (Looking)
+20 = [float] Y-axis Rotation (Looking)
+24 = [float] Z-axis Rotation (Looking)
+48 = [float] X-axis Position
+52 = [float] Y-axis Position
+56 = [float] Z-axis Position

verify if you're doing everything right by checking the position as well.

Source
 

mrT101

Active member
Joined
Feb 18, 2014
Messages
58
Reaction score
0
The offsets for x,y, and z position all work great, but the rotation offsets give me very weird values as described above. by looking i mean that the plane was facing directly west. thanks for all the help!
 
Top