// AroundRelPoint
RotMatrixMatrixAroundRelPoint(Float: matrix1[4][4], Float: oX, Float: oY, Float: oZ, Float: matrix2[4][4])
RotMatrixQuatAroundRelPoint(Float: matrix[4][4], Float: oX, Float: oY, Float: oZ, Float: w, Float: x, Float: y, Float: z)
RotMatrixEulerAroundRelPoint(Float: matrix[4][4], Float: oX, Float: oY, Float: oZ, Float: rX, Float: rY, Float: rZ, eulermode: mode = euler_samp)
RotMatrixAxisAroundRelPoint(Float: matrix1[4][4], Float: oX, Float: oY, Float: oZ, Float: angle, Float: aX, Float: aY, Float: aZ)
// AroundPoint
RotMatrixMatrixAroundPoint(Float: matrix1[4][4], Float: x, Float: y, Float: z, Float: matrix2[4][4])
RotMatrixQuatAroundPoint(Float: matrix[4][4], Float: x, Float: y, Float: z, Float: w, Float: qX, Float: qY, Float: qZ)
RotMatrixEulerAroundPoint(Float: matrix[4][4], Float: x, Float: y, Float: z, Float: rX, Float: rY, Float: rZ, eulermode: mode = euler_samp)
RotMatrixAxisAroundPoint(Float: matrix1[4][4], Float: x, Float: y, Float: z, Float: angle, Float: aX, Float: aY, Float: aZ)
// TranslateMatrix
TranslateMatrix(Float: matrix[4][4], Float: x, Float: y, Float: z)
// RotateMatrix
RotateMatrixWithMatrix(Float: matrix1[4][4], Float: matrix2[4][4])
RotateMatrixWithQuat(Float: matrix[4][4], Float: w, Float: x, Float: y, Float: z)
RotateMatrixWithEuler(Float: matrix[4][4], Float: rX, Float: rY, Float: rZ, eulermode: mode = euler_samp)
RotateMatrixWithAxisAngle(Float: matrix[4][4], Float: angle, Float: aX, Float: aY, Float: aZ)
// GetTranslationMatrix
GetTranslationMatrix(Float: matrix[4][4], Float: x, Float: y, Float: z)
Hmm... Wasn't there a lot more comments on this thread? I know I had a discussion about this include here and said how badass it was...
|
Never was but thanks anyways, maybe another thread, 3DTryg from AbyssMorgan ?
|
I still get this feeling that this include isn't very user friendly but I am not sure how to accomplish a more compact structure within pawn
|
new Float:lGraffitiX, Float:lGraffitiY, Float:lGraffitiZ, Float:lGraffitiRX, Float:lGraffitiRY, Float:lGraffitiRZ; GetDynamicObjectPos(Graffiti[tagid][graffiti_object], lGraffitiX, lGraffitiY, lGraffitiZ); GetDynamicObjectRot(Graffiti[tagid][graffiti_object], lGraffitiRX, lGraffitiRY, lGraffitiRZ); Use(lGraffitiX, lGraffitiY, lGraffitiZ, lGraffitiRX, lGraffitiRY, lGraffitiRZ, lGraffitiX, lGraffitiY, lGraffitiZ); Graffiti[tagid][graffiti_object_made] = CreateDynamicObject(18659, lGraffitiX, lGraffitiY, lGraffitiZ, lGraffitiRX, lGraffitiRY, lGraffitiRZ, .interiorid = 0); Use(Float:oX, Float:oY, Float:oZ, Float:rX, Float:rY, Float:rZ, &Float:x, &Float:y, &Float:z) { new Float: matrix[4][4] ; // Get rotation Matrix from Euler GetRotationMatrixFromEuler(matrix, rX, rY, rZ); // Rotate matrix around relative point of object // 0.0, 0.0, 1.0 = relative point = 1.0 above object center // 5.0, 0.0, 0.0 = euler rotation = 5.0 degress in rX direction RotMatrixEulerAroundRelPoint(matrix, 0.0, 0.0, 1.0, 5.0, 0.0, 0.0); // Getting relative point, 0.0, 0.0, 0.0, 1.0 = offsets x, y, z and translation // because we only need the translation we set, x, y, z offsets to 0.0 MatrixRotate(matrix, 0.0, 0.0, 0.0, 1.0, oX, oY, oZ); x = oX; y = oY; z = oZ; }
GetQuatFromEuler(rx, ry, rz, qw, qx, qy, qz); QuatRotate(qw, qx, qy, qz, -0.05, 0.0, 0.0, x, y, z); //use x, y, z
Done it, I used wrong function. Working code
Code:
GetQuatFromEuler(rx, ry, rz, qw, qx, qy, qz); QuatRotate(qw, qx, qy, qz, -0.05, 0.0, 0.0, x, y, z); //use x, y, z |
GetVehicleObjectPositionWorld(vehicleid, Float: att_X, Float: att_Y, Float: att_Z, Float: att_rotX, Float: att_rotY, Float: att_rotZ, &Float: X, &Float: Y, &Float: Z, &Float: rotX, &Float: rotY, &Float: rotZ)
GetVehicleObjectPositionOffset(vehicleid, Float: X, Float: Y, Float: Z, Float: rotX, Float: rotY, Float: rotZ, &Float: att_X, &Float: att_Y, &Float: att_Z, &Float: att_rotX, &Float: att_rotY, &Float: att_rotZ)
Do you know how you can get the right rotations of world objects? Like if i copy and paste the world objects from sa-mp map editor it sometimes returns the wrong rotations.
|
How to make an adequate GetXYInFrontOfPlayer using this library?
|
GetPointInFront2D(Float:x,Float:y,Float:rz,Float:radius,&Float:tx,&Float:ty);
GetPointInFront3D(Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,&Float:tx,&Float:ty,&Float:tz);
Float:GetPointInFrontOfPlayer(playerid,&Float:tx,&Float:ty,Float:radius);
Float:GetPointInFrontOfCamera2D(playerid,&Float:tx,&Float:ty,Float:radius);
GetPointInFrontOfCamera3D(playerid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0);
Float:GetPointInFrontOfVehicle2D(vehicleid,&Float:tx,&Float:ty,Float:radius);
GetPointInFrontOfVehicle3D(vehicleid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0);
How to make an adequate GetXYInFrontOfPlayer using this library?
|
MatrixRotate(Float: matrix[4][4], Float: oX, Float: oY, Float: oZ, Float: oT, & Float: X, & Float: Y, & Float: Z) QuatRotate(Float: w, Float: x, Float: y, Float: z, Float: oX, Float: oY, Float: oZ, & Float: X, & Float: Y, & Float: Z) EulerRotate(Float: rX, Float: rY, Float: rZ, Float: oX, Float: oY, Float: oZ, & Float: X, & Float: Y, & Float: Z, eulermode: mode = euler_samp) AxisAngleRotate(Float: angle, Float: aX, Float: aY, Float: aZ, Float: oX, Float: oY, Float: oZ, & Float: X, & Float: Y, & Float: Z) |
new Float: X, Float: Y, Float: Z;
GetPlayerPos(playerid, X, Y, Z);
new Float: rZ; // the only angle you can get is rZ
GetPlayerFacingAngle(playerid, rZ); // use 0.0 for rX and rY
// oX (right vector offset) = 0.0, oY (front vector offset) = 5.0, oZ (up vector offset) = 0.0
EulerRotate(0.0, 0.0, rZ, 0.0, 5.0, 0.0, X, Y, Z);
// X, Y, Z should now be 5 units before the player
AbyssMorgan is correct, it is not the main purpose of this include
But to answer your question you could use any "Rotate" function For players I would suggest EulerRotate because there is only GetPlayerFacingAngle PHP код:
Just search for GetXYInFrontOfPlayer, it has been asked / posted thousand times |
Xmm, anyway, you can go outside the landfill. For a reason that I do not understand. How can I fix it?
https://www.youtube.com/watch?v=ZakA...ature=********* |
SetPlayerTimerEx(playerid, "@@CheckPlayerInPolygons", 250, -1, "d", playerid);
@@CheckPlayerInPolygons(const playerid);
@@CheckPlayerInPolygons(const playerid)
{
new Float: x_pos,
Float: y_pos,
Float: z_pos;
GetPlayerPos(playerid, x_pos, y_pos, z_pos);
if(!IsPointInPolygon(x_pos, y_pos, { 42.0,2336.0,
-1327.0,2601.0,
-1349.0,2675.0,
-1397.0,2712.0,
-1435.0,2728.0,
-1501.0,2737.0,
-1560.0,2740.0,
-1627.0,2734.0,
-1653.0,2718.0,
-1639.0,2654.0,
-1610.0,2604.0,
-1604.0,2547.0,
-1596.0,2499.0,
-1474.0,2486.0,
-1406.0,2521.0,
-1337.0,2523.0,
-1327.0,2601.0}))
{
new Float: X, Float: Y, Float: Z;
GetPlayerPos(playerid, X, Y, Z);
new Float: rZ; // the only angle you can get is rZ
GetPlayerFacingAngle(playerid, rZ); // use 0.0 for rX and rY
// oX (right vector offset) = 0.0, oY (front vector offset) = 5.0, oZ (up vector offset) = 0.0
EulerRotate(0.0, 0.0, rZ, 0.0, -5.0, 0.0, X, Y, Z);
// X, Y, Z should now be 5 units before the player
SetPlayerPos(playerid, X, Y, Z);
}
}
Well, it is a bug in your code, no clue how you use GetXYInFrontOfPlayer to determine if the player is outside or not but the correct solution for your problem would be to check if the player is inside a polygon
Refer to IsPlayerInPolygon, it can be found in 3DTryg, it is based on ray-casting (wiki) Still remember that RyDeR`posted the function and ****** said, it has been here for years XD |
new Float:matrix[4][4]; GetRotationMatrixFromEuler(matrix, 0.0, 0.0, rz, euler_samp); RotateMatrixWithEuler(matrix, surface_rx, surface_ry, 0.0, euler_samp); GetQuatFromMatrix(matrix, qw, qx, qy, qz);