• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Question] Vehicle rotation | help with this?
#1
[Image: vrot.jpg]



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.
  Reply
#2
You might want to have a look at this: https://github.com/IllidanS4/i_quat
Always keep in mind that a lot of people are active on this forum in their spare time.

They are sacrificing time they could easily spend on things they would rather do, to help you instead.

  Reply
#3
No need for that, we are already provisioned just fine. It does seem to be describing everything i_quat does and can offer.
  Reply
#4
We appreciate the effort to try to help and contribute though.
Always keep in mind that a lot of people are active on this forum in their spare time.

They are sacrificing time they could easily spend on things they would rather do, to help you instead.

  Reply
#5
They are absolutely right. The truth is that he had been out of SA-MP for like 5 years and had no idea of the existence of that include.



I have checked the results of both methods, comparing them with AttachObjectToVehicle, and they both seem to have the same result.



https://youtu.be/vSZyMilgcuU



But I have to say one thing in favor of i_quat, is that it is more efficient, and requires less calculations. Even building the up vector is 1000 times faster. What I had done was to obtain 2 times the rotation, one with up.z = 1.0 and another with up.z = -1.0, then compare which of the two results is equal to the right and front vectors. The difference is brutal.



Anyway, I'm going to post the include, in case it can help someone to have these matrix functions in Pawn.



Once again, Sorry for my English.
  Reply
#6
It is quite impressive if you managed to find a solution to this problem on your own anyway; too bad you didn't release it 5 years ago ;-) Good job anyway!
  Reply


Forum Jump: