Advertisement
adri1

Untitled

Mar 29th, 2015
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. AttachObjectToObjectEx(attachoid, Float:off_x, Float:off_y, Float:off_z, Float:rot_x, Float:rot_y, Float:rot_z, &Float:X, &Float:Y, &Float:Z, &Float:RX, &Float:RY, &Float:RZ, pobject = -1) // By Stylock - [url]http://forum.sa-mp.com/member.php?u=114165[/url]
  2. {
  3. static
  4. Float:sin[3],
  5. Float:cos[3],
  6. Float:pos[3],
  7. Float:rot[3];
  8. if(pobject == -1)
  9. {
  10. GetObjectPos(attachoid, pos[0], pos[1], pos[2]);
  11. GetObjectRot(attachoid, rot[0], rot[1], rot[2]);
  12. }
  13. else
  14. {
  15. GetPlayerObjectPos(pobject, attachoid, pos[0], pos[1], pos[2]);
  16. GetPlayerObjectRot(pobject, attachoid, rot[0], rot[1], rot[2]);
  17. }
  18. EDIT_FloatEulerFix(rot[0], rot[1], rot[2]);
  19. cos[0] = floatcos(rot[0], degrees); cos[1] = floatcos(rot[1], degrees); cos[2] = floatcos(rot[2], degrees); sin[0] = floatsin(rot[0], degrees); sin[1] = floatsin(rot[1], degrees); sin[2] = floatsin(rot[2], degrees);
  20. pos[0] = pos[0] + off_x * cos[1] * cos[2] - off_x * sin[0] * sin[1] * sin[2] - off_y * cos[0] * sin[2] + off_z * sin[1] * cos[2] + off_z * sin[0] * cos[1] * sin[2];
  21. pos[1] = pos[1] + off_x * cos[1] * sin[2] + off_x * sin[0] * sin[1] * cos[2] + off_y * cos[0] * cos[2] + off_z * sin[1] * sin[2] - off_z * sin[0] * cos[1] * cos[2];
  22. pos[2] = pos[2] - off_x * cos[0] * sin[1] + off_y * sin[0] + off_z * cos[0] * cos[1];
  23. rot[0] = asin(cos[0] * cos[1]); rot[1] = atan2(sin[0], cos[0] * sin[1]) + rot_z; rot[2] = atan2(cos[1] * cos[2] * sin[0] - sin[1] * sin[2], cos[2] * sin[1] - cos[1] * sin[0] * -sin[2]);
  24. cos[0] = floatcos(rot[0], degrees); cos[1] = floatcos(rot[1], degrees); cos[2] = floatcos(rot[2], degrees); sin[0] = floatsin(rot[0], degrees); sin[1] = floatsin(rot[1], degrees); sin[2] = floatsin(rot[2], degrees);
  25. rot[0] = asin(cos[0] * sin[1]); rot[1] = atan2(cos[0] * cos[1], sin[0]); rot[2] = atan2(cos[2] * sin[0] * sin[1] - cos[1] * sin[2], cos[1] * cos[2] + sin[0] * sin[1] * sin[2]);
  26. cos[0] = floatcos(rot[0], degrees); cos[1] = floatcos(rot[1], degrees); cos[2] = floatcos(rot[2], degrees); sin[0] = floatsin(rot[0], degrees); sin[1] = floatsin(rot[1], degrees); sin[2] = floatsin(rot[2], degrees);
  27. rot[0] = atan2(sin[0], cos[0] * cos[1]) + rot_x; rot[1] = asin(cos[0] * sin[1]); rot[2] = atan2(cos[2] * sin[0] * sin[1] + cos[1] * sin[2], cos[1] * cos[2] - sin[0] * sin[1] * sin[2]);
  28. cos[0] = floatcos(rot[0], degrees); cos[1] = floatcos(rot[1], degrees); cos[2] = floatcos(rot[2], degrees); sin[0] = floatsin(rot[0], degrees); sin[1] = floatsin(rot[1], degrees); sin[2] = floatsin(rot[2], degrees);
  29. rot[0] = asin(cos[1] * sin[0]); rot[1] = atan2(sin[1], cos[0] * cos[1]) + rot_y; rot[2] = atan2(cos[0] * sin[2] - cos[2] * sin[0] * sin[1], cos[0] * cos[2] + sin[0] * sin[1] * sin[2]);
  30. X = pos[0];
  31. Y = pos[1];
  32. Z = pos[2];
  33. RX = rot[0];
  34. RY = rot[1];
  35. RZ = rot[2];
  36. }
  37.  
  38.  
  39. EDIT_FloatEulerFix(&Float:rot_x, &Float:rot_y, &Float:rot_z)
  40. {
  41. EDIT_FloatGetRemainder(rot_x, rot_y, rot_z);
  42. if((!floatcmp(rot_x, 0.0) || !floatcmp(rot_x, 360.0))
  43. && (!floatcmp(rot_y, 0.0) || !floatcmp(rot_y, 360.0)))
  44. {
  45. rot_y = 0.0000002;
  46. }
  47. return 1;
  48. }
  49.  
  50. EDIT_FloatGetRemainder(&Float:rot_x, &Float:rot_y, &Float:rot_z)
  51. {
  52. EDIT_FloatRemainder(rot_x, 360.0);
  53. EDIT_FloatRemainder(rot_y, 360.0);
  54. EDIT_FloatRemainder(rot_z, 360.0);
  55. return 1;
  56. }
  57.  
  58. EDIT_FloatRemainder(&Float:remainder, Float:value)
  59. {
  60. if(remainder >= value)
  61. {
  62. while(remainder >= value)
  63. {
  64. remainder = remainder - value;
  65. }
  66. }
  67. else if(remainder < 0.0)
  68. {
  69. while(remainder < 0.0)
  70. {
  71. remainder = remainder + value;
  72. }
  73. }
  74. return 1;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement