I am trying to create graffiti object in front of another graffiti object (graffiti tagged), but I don't know how to get position in front of object relative to object's rotation (rx, ry, rz). My actual code
Code:
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;
}
It works only with one angle, see image below. Grove tag should cover another tag. On the wall it works, but on the ground it does not. Any ideas?
https://i.imgur.com/3DXKHt7.jpg
//EDIT
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