20.11.2017, 18:22
This algorithm working only for 2D orientation.
In this example:
old pos: 3400.0,0.0,0.0
old: rz: 0.0
new pos: 3200.0,0.0,0.0
new rz: 180.0
Libs:
3DTryg.inc
PHP код:
for(new i = 1, j = Streamer_GetUpperBound(STREAMER_TYPE_OBJECT); i <= j; i++){
if(IsValidDynamicObject(i)){
new Float:offset_x,Float:offset_y,Float:offset_z,
Float:ox,Float:oy,Float:oz,
Float:tx,Float:ty,Float:tz,
Float:dist;
GetDynamicObjectPos(i,ox,oy,oz);
ShiftPositionToOffset(3400.0,0.0,0.0, 0.0,0.0,0.0, offset_x,offset_y,offset_z, ox,oy,oz); //started position
dist = VectorSize(offset_x,offset_y,offset_z);
ShiftVectorRotation(offset_x,offset_y,offset_z, 0.0,0.0,180.0, tx,ty,tz); //new rotation here
tx *= dist;
ty *= dist;
tz *= dist;
ShiftOffsetToPosition(3200.0,0.0,0.0, 0.0,0.0,0.0, tx,ty,tz, ox,oy,oz); //new position
SetDynamicObjectPos(i,ox,oy,oz);
GetDynamicObjectRot(i,ox,oy,oz);
SetDynamicObjectRot(i,ox,oy,oz+180.0); //new rotation here
}
}
old pos: 3400.0,0.0,0.0
old: rz: 0.0
new pos: 3200.0,0.0,0.0
new rz: 180.0
Libs:
3DTryg.inc