2021-01-26, 01:05 PM
I was wondering if you need help with this, because it might help.
What I have done has been a function to obtain the euler rotation from a matrix.
In the unoccupied sync, the SA-MP client sends the right and front vectors to the server, so it is necessary to build the up vector to obtain the euler rotation, so I also made a function for that.
To test it, I converted the C code to Pawn, this would be the result:
[Video: https://youtu.be/_sBAISz_JMo]
00:00 incar testing
00:20 unoccupied testing
[Video: https://youtu.be/3mZZsGd-g0M]
00:00 airplane testing
Part of the Pawn code would look like this:
Code:
forward test_timer();
public test_timer()
{
?? ?if(test_vehicleid != INVALID_VEHICLE_ID)
?? ?{
?? ???? new mat[MATRIX];
?? ???? new pos[VECTOR];
?? ???? new rot[VECTOR];
?? ????
?? ???? mat = GetVehicleMatrix(test_vehicleid);
?? ???? rot = Matrix_GetRotation(mat, Vector(-9999.0, -9999.0, -9999.0));
?? ???? pos = Matrix_Multiply3x3(mat, Vector(0.0, 12.0, 2.0));
?? ????
?? ???? pos[X] = mat[POS][X];
?? ???? pos[Y] = mat[POS][Y];
?? ???? pos[Z] = mat[POS][Z];
?? ????
?? ???? SetObjectPos(test_objectid, pos[X], pos[Y], pos[Z]);
?? ???? SetObjectRot(test_objectid, rot[X], rot[Y], rot[Z]);
?? ?}
}
I would not know who to talk to to discuss this issue, so I created this post. If you are interested in this, you can send me a private and I will send you the source code in C , including the Pawn code.
Note: Sorry for my English, I speak Spanish and I have translated this with google translate.