Jump to content

Object Rotation degrees problem


koeno100

Recommended Posts

Hey guys I have a problem with the setElementRotation function.

I draw a line for the x, y and z axis from the object's center (Just like the map editor does), but for example, if I set the rotation of my x and z axis to 0, and the y axis to 180, and then use getElementRotation to get the values, the x and z axis are 180 degrees, and the y axis is 0 degrees. Does anyone know how to prevent this?

This is what I mean:

https://www.dropbox.com/s/d7ikx0lh9t3do ... d.mp4?dl=0

function drawTheVehicleAxisArrows() 
    rotation = rotation + 1 
    setElementRotation(theCreatedVehicle, 0, 0, rotation) 
    local x, y, z = getElementPosition(theCreatedVehicle) 
    local rx, ry, rz = getElementRotation(theCreatedVehicle) 
    _, miny, _, _, maxy, _ = getElementBoundingBox(theCreatedVehicle) 
    cosz = math.cos(math.rad(rz)) 
    sinz = math.sin(math.rad(rz)) 
    outputChatBox(rx.. " " ..ry.. " " ..rz) 
    cosy = math.cos(math.rad(ry)) 
    siny = math.sin(math.rad(ry)) 
    maxy = maxy + 1 
  
    dxDrawLine3D(x, y, z, x, y, z + maxy, tocolor(0, 0, 255, 255), 10) 
    dxDrawLine3D(x, y, z + maxy - 0.05, x, y - 0.25, z + maxy - 0.3, tocolor(0, 0, 255, 255), 10) 
    dxDrawLine3D(x, y, z + maxy - 0.05, x, y + 0.25, z + maxy - 0.3, tocolor(0, 0, 255, 255), 10) 
     
    dxDrawLine3D(x, y, z, x + cosz * maxy, y + sinz * maxy, z + siny * maxy, tocolor(255, 0, 0, 255), 10) 
    dxDrawLine3D(x + cosz * maxy - 0.05, y + sinz * maxy, z, x + cosz * maxy - cosz * 0.3, y + sinz * maxy - sinz * 0.3, z - 0.25, tocolor(255, 0, 0, 255), 10) 
    dxDrawLine3D(x + cosz * maxy - 0.05, y + sinz * maxy, z, x + cosz * maxy - cosz * 0.3, y + sinz * maxy - sinz * 0.3, z + 0.25, tocolor(255, 0, 0, 255), 10) 
     
    dxDrawLine3D(x, y, z, x - sinz * maxy, y + cosz * maxy, z, tocolor(0, 255, 0, 255), 10) 
    dxDrawLine3D(x - sinz * maxy, y + cosz * maxy - 0.05, z, x - sinz * maxy + sinz * 0.3, y + cosz * maxy - cosz * 0.3, z - 0.25, tocolor(0, 255, 0, 255), 10) 
    dxDrawLine3D(x - sinz * maxy, y + cosz * maxy - 0.05, z, x - sinz * maxy + sinz * 0.3, y + cosz * maxy - cosz * 0.3, z + 0.25, tocolor(0, 255, 0, 255), 10) 
end 

Edited by Guest
Link to comment

Erm - as far as I know rotation (180, 0, 180) is the same as (0, 180, 0).

When an object is facing North, X rotation is pitch (nose up/down), Y rotation is the roll, and Z is the yaw.

X=180 makes an object go up-side-down facing South, and Z=180 turns it again North

Y=180 makes the object roll up-side-down still facing North.

Same thing?

Link to comment
Erm - as far as I know rotation (180, 0, 180) is the same as (0, 180, 0).

When an object is facing North, X rotation is pitch (nose up/down), Y rotation is the roll, and Z is the yaw.

X=180 makes an object go up-side-down facing South, and Z=180 turns it again North

Y=180 makes the object roll up-side-down still facing North.

Same thing?

I know that it's the same thing, but in radians it isn't.

y = 180 degrees flips over the whole y axis

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...