There are acd.x0C8_Direction and acd.x0CC_Direction. However it doesn't seem to fit Vec2D describing actor direction in world. Anyone found out how it can be of use? Or is there actor direction somewhere else?
There are acd.x0C8_Direction and acd.x0CC_Direction. However it doesn't seem to fit Vec2D describing actor direction in world. Anyone found out how it can be of use? Or is there actor direction somewhere else?
Maybe this helps Radian - Wikipedia, the free encyclopedia
I've coded few Wallhack / aimbot, and with angle I always use Math.Atan2(vec2.x, vec2.y)
And you've got the radian angle.
Ok, I feel like I'm gonna make a fool of myself but I tried interpreting those two floats as spherical coordinates (for 3D vector), including reversed angles version:
2D version (each one of them as radian):Code:// http://en.wikipedia.org/wiki/File:3D_Spherical.svg // theta is the angle between the positive Z-axis and the vector in question (0 ≤ θ ≤ π) // phi is the angle between the projection of the vector onto the X-Y-plane and the positive X-axis (0 ≤ φ < 2π) public static Vec3 FromSpherical(float theta, float phi) { return new Vec3((float)(Math.Sin(theta) * Math.Cos(phi)), (float)(Math.Sin(theta) * Math.Sin(phi)), (float)Math.Cos(theta)); }
but none of those resulted in actor forward vector. Can you plz simply supply me code sample for converting those damned pair of floats to actor forward vector?Code:public static Vec3 FromSpherical2D(float phi) { return new Vec3((float)Math.Cos(phi), (float)Math.Sin(phi), 0); }
Last edited by CrEEzz; 10-11-2014 at 10:08 PM.
I don't know what mean "actor forward version" but angle works with this code :
The right bottom corner is 0°, left bottom 45°, etc...Code:var x = player.x0A0_Direction_Abs0to1; var y = player.x0A4_Direction_1toNeg1; var angle = Math.Atan2(x, y);
EDIT : May be I understant what you want, a Vec3 in x yards in direction of the actor :
Code:var x = player.x0A0_Direction_Abs0to1; var y = player.x0A4_Direction_1toNeg1; var angle = Math.Atan2(x, y); //Vec3 is userDefined in my code // pos is the Vec3 of the actor // replace radius by the distance of the desired vec3 var vecDirection = new Vec3(radius*(float) Math.Cos(angle) + pos.x, radius*(float) Math.Sin(angle) + pos.y, pos.z)
Last edited by bastiflew; 10-11-2014 at 03:44 PM.
I meant forward vector xD Thanks for hints, I finally sat down, displayed all those numbers and figured it out. This work for me.
Code:float half_angle_cos = acd.x0CC_Direction; // -1 for X aligned, 1 for -X aligned, 0.7 for Y aligned, -0.7 for -Y aligned float radians = (float)Math.Acos(half_angle_cos) * 2; dir = new Vec3((float)Math.Cos(radians), (float)Math.Sin(radians), 0);
The 3D rotations are given in quaternion form (XYZW, 4-dimensional vector with length 1.0). You can easily spot the rotations in the fields by finding 4 consecutive floats with a vector length of 1.0.
@CrEEzz: Your example only works when there is Z rotation only (x00C_Direction). Take into account the neighbouring 3 fields in the acd (which should be XY and W). There are routines to convert quaternion to euler angles or rotation matrixes. Multiply Vec(1,0,0,0), which is "forward", onto the 4x4 rotation matrix and you'll get the correct results for all rotations.
Last edited by axlrose; 10-14-2014 at 10:09 AM.
It was some time, and I wanted to make final summary You were right axlrose. To obtain direction one have to do the following:
Code:Quat q = new Quat(acd.x0C0_Direction, acd.x0C4_Direction, acd.x0C8_Direction, acd.x0CC_Direction); // quaternion(x,y,z,w) Vec3 dir = q * new Vec3(1, 0, 0);