GetCameraRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Flagged as deprecated.)
No edit summary
Line 2: Line 2:
{{Client function}}
{{Client function}}
{{Deprecated}}
{{Deprecated}}
This function returns the local camera rotation.
'''This function no longer exists.''' The following code snippet achieves a similar result:
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float, float, float getCameraRotation ( )
local function getCameraRotation ()
    local px, py, pz, lx, ly, lz = getCameraMatrix()
    local rotz = 6.2831853071796 - math.atan2 ( ( lx - px ), ( ly - py ) ) % 6.2831853071796
    local rotx = math.atan2 ( lz - pz, getDistanceBetweenPoints2D ( lx, ly, px, py ) )
    --Convert to degrees
    rotx = math.deg(rotx)
    rotz = -math.deg(rotz)
    return rotx, 180, rotz
end
</syntaxhighlight>  
</syntaxhighlight>  


===Returns===
Returns three [[float]]s containing the X, Y and Z rotation values.
==Example==
This page lacks an example.
<syntaxhighlight lang="lua">
--add an example here
</syntaxhighlight>
==See Also==
==See Also==
{{Camera functions}}
{{Camera functions}}
[[Category:Needs_Example]]
[[Category:Needs_Example]]

Revision as of 20:37, 10 July 2010

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions, but there should be a more generic way to perform what it does.

This function no longer exists. The following code snippet achieves a similar result:

local function getCameraRotation ()
    local px, py, pz, lx, ly, lz = getCameraMatrix()
    local rotz = 6.2831853071796 - math.atan2 ( ( lx - px ), ( ly - py ) ) % 6.2831853071796
    local rotx = math.atan2 ( lz - pz, getDistanceBetweenPoints2D ( lx, ly, px, py ) )
    --Convert to degrees
    rotx = math.deg(rotx)
    rotz = -math.deg(rotz)	
    return rotx, 180, rotz
end

See Also