Re: Re: Re: Untitled

From Scanty Dolphin, 9 Years ago, written in Lua, viewed 765 times. This paste will check out in 1 Second. This paste is a reply to Re: Re: Untitled from Bitty Lemur - go back
URL https://paste.godclan.hu/view/U5RxZ9Ft/diff Embed
Viewing differences between Re: Re: Untitled and Re: Re: Re: Untitled
function baseRotate(x, y, rz)
    local x2 = x * cos(rz) - y * sin(rz)
    local y2 = x * sin(rz) + y * cos(rz)
    return x2, y2
end

-- ZYX rotation
function rotate(x, y, z, rx, ry, rz)
    x, y = baseRotate(x, y, z = baseRotate(y, z, rx)
rz)
    x, z = baseRotate(-x, z, ry)
    x = -x
    x, y = baseRotate(x, y, rz)
z = baseRotate(y, z, rx)
    return x, y, z
end

local thisVeh
local x1, y1, z1, x2, y2, z2 = 0, 0, 0, 0, 0, 0

function setTurnVelocityAlong(vehElement, x, y, z, v)
    -- Normalize vector
    local r = sqrt(x * x + y * y + z * z)
    local x2, y2, z2 = x * v / r, y * v / r, z * v / r

    -- Rotate vector
    local rx, ry, rz = getElementRotation(vehElement, "ZYX")
    x, y, z x2, y2, z2 = rotate(x2, y2, z2, rx, ry, rz)

rz)

    -- For debug
    x1, y1, z1 = getElementPosition(vehElement)
    addEventHandler("onClientRender", getRootElement(), createLine)

    -- Set turn velocity
    -- return setVehicleTurnVelocity(vehElement, x, y, z)
x2, y2, z2)
end

function createLine ( )
        dxDrawLine3D(x1, y1, z1, x1 + x2, y1 + y2, z1 + z2, tocolor(0, 255, 0, 230), 2)
end

Reply to "Re: Re: Re: Untitled"

Here you can reply to the paste above