Re: Re: Re: Untitled

From Scanty Dolphin, 10 Years ago, written in Lua, viewed 886 times. This paste will give up the ghost in 1 Second. This paste is a reply to Re: Re: Untitled from Bitty Lemur - view diff
URL https://paste.godclan.hu/view/U5RxZ9Ft Embed
Download Paste or View Raw
  1. function baseRotate(x, y, rz)
  2.     local x2 = x * cos(rz) - y * sin(rz)
  3.     local y2 = x * sin(rz) + y * cos(rz)
  4.     return x2, y2
  5. end
  6.  
  7. -- ZYX rotation
  8. function rotate(x, y, z, rx, ry, rz)
  9.     x, y = baseRotate(x, y, rz)
  10.     x, z = baseRotate(-x, z, ry)
  11.     x = -x
  12.     y, z = baseRotate(y, z, rx)
  13.     return x, y, z
  14. end
  15.  
  16. local thisVeh
  17. local x1, y1, z1, x2, y2, z2 = 0, 0, 0, 0, 0, 0
  18.  
  19. function setTurnVelocityAlong(vehElement, x, y, z, v)
  20.     -- Normalize vector
  21.     local r = sqrt(x * x + y * y + z * z)
  22.     x2, y2, z2 = x * v / r, y * v / r, z * v / r
  23.  
  24.     -- Rotate vector
  25.     local rx, ry, rz = getElementRotation(vehElement, "ZYX")
  26.     x2, y2, z2 = rotate(x2, y2, z2, rx, ry, rz)
  27.  
  28.     -- For debug
  29.     x1, y1, z1 = getElementPosition(vehElement)
  30.     addEventHandler("onClientRender", getRootElement(), createLine)
  31.  
  32.     -- Set turn velocity
  33.     -- return setVehicleTurnVelocity(vehElement, x2, y2, z2)
  34. end
  35.  
  36. function createLine ( )
  37.         dxDrawLine3D(x1, y1, z1, x1 + x2, y1 + y2, z1 + z2, tocolor(0, 255, 0, 230), 2)
  38. end

Reply to "Re: Re: Re: Untitled"

Here you can reply to the paste above