dzek (varez) Posted September 17, 2010 Share Posted September 17, 2010 Uhm, I thought the times I was noob in scripting are gone I'm having a vehicle. I'm setting its rotation with setVehicleRotation and I'm getting strange results with getVehicleRotation. On X and Z axis it's ok, strange thing happens only with Y axis. Testing function: function vehTest(veh) ry = 0 xx,yy,zz = getElementPosition(veh) setVehicleFrozen(veh, true) setElementPosition(veh, xx,yy,zz+10) try = 0 setTimer(function() try = try + 1 setVehicleRotation(veh, 0, ry, 0) local rotX, rotY, rotZ = getVehicleRotation(veh) outputConsole(rotY.." -- "..ry) ry = ry + 10 if (try==37) then setVehicleFrozen(veh, false) end end, 100, 37, veh, ry) end Results: 0 -- 0 10 -- 10 20 -- 20 30 -- 30 40 -- 40 50 -- 50 60 -- 60 70 -- 70 80 -- 80 90 -- 90 80 -- 100 70 -- 110 60 -- 120 50 -- 130 40 -- 140 30 -- 150 20 -- 160 10 -- 170 0 -- 180 350 -- 190 340 -- 200 330 -- 210 320 -- 220 310 -- 230 300 -- 240 290 -- 250 280 -- 260 270 -- 270 280 -- 280 290 -- 290 300 -- 300 310 -- 310 320 -- 320 330 -- 330 340 -- 340 350 -- 350 0 -- 360 I see no way to determine if car is rotated Y by 110 or 70 deg. with this Link to comment
Antibird Posted September 17, 2010 Share Posted September 17, 2010 The script is client-side I guess? Do you need to get a vehicle pitch / yaw / roll values? Link to comment
dzek (varez) Posted September 17, 2010 Author Share Posted September 17, 2010 Client-side indeed. Yes, this is what I need. I think I can achieve this with getVehicleRotation, as said - for X and Z - it's fine. Link to comment
DiSaMe Posted September 17, 2010 Share Posted September 17, 2010 That's because rotating vehicle 180 degrees on Y axes is the same as rotating it on X and Z axes, both 180 degrees. So you could use X rotation to check if the vehicle is upside down, and if it is, then ry value must be set to 180-ry. Link to comment
dzek (varez) Posted September 17, 2010 Author Share Posted September 17, 2010 lol, you are wrong. you can rotate it by Z - like turning left or right rotate by Y - like make it drive on two wheels and rotate by X - to make it "stand" on it's hood. How you want to achieve to flip car to two wheels with only Z and X? give me values, and i will agree with you Link to comment
Antibird Posted September 17, 2010 Share Posted September 17, 2010 (edited) I've figured out this works fine: m = getElementMatrix( vehicle ) pitch = math.deg( math.asin( m[2][3] ) ) roll = math.deg( -math.atan2( m[1][3], m[3][3] ) ) --I need the minus, you may not yaw = math.deg( math.atan2( m[2][1], m[2][2] ) ) if yaw < 0 then yaw = yaw + 360 end The roll goes [-180, 180] Edited September 17, 2010 by Guest Link to comment
dzek (varez) Posted September 17, 2010 Author Share Posted September 17, 2010 I'll give it a try, thanks. That math makes me scary o_O And if it returns in -180, 180 i can easly add 180 to get 0-360 Link to comment
DiSaMe Posted September 17, 2010 Share Posted September 17, 2010 lol, you are wrong.you can rotate it by Z - like turning left or right rotate by Y - like make it drive on two wheels and rotate by X - to make it "stand" on it's hood. rotate 180 degrees by Z - reverse its direction rotate 180 degrees by Y - make it stand on its roof rotate 180 degrees by X - make it stand on its roof, but the direction will be the opposite than rotating by Y So if you flip car by X and Z, it will be the same as flipping it by Y. And the way of getting Y rotation Antibird wrote here is a bit similar to the one I suggested. Link to comment
dzek (varez) Posted September 17, 2010 Author Share Posted September 17, 2010 okay, but i dont want to flip the car to the roof, i want some values between. Link to comment
DiSaMe Posted September 17, 2010 Share Posted September 17, 2010 You say you don't want to flip it to the roof, but you see it as a problem when it's flipped and Y rotation is still shown to be below 90 degrees Link to comment
dzek (varez) Posted September 17, 2010 Author Share Posted September 17, 2010 so? i don't get you.. do you see a way to flip car into two wheels with only rotating on Z, X, and leaving Y in 0-90 and 270-360? Link to comment
DiSaMe Posted September 17, 2010 Share Posted September 17, 2010 Do you see a way to flip car onto two wheels with matrices? There's no such function like setElementMatrix. But the code Antibird posted was for getting the rotation, not setting it, and I'm talking about another, similar way to do that. Link to comment
dzek (varez) Posted September 17, 2010 Author Share Posted September 17, 2010 okaaay, well, i dont need to set such rotation, but to get it, so well, I'm fine now thanks to you both, even i have no idea how can i GET "correct" rotation with only X,Z and math Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now