GetElementBoundingBox: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Typo)
Line 3: Line 3:
This function returns the minimum and maximum coordinates of an element's bounding box.
This function returns the minimum and maximum coordinates of an element's bounding box.


It should be noted that the values returned are relevant to the position of the element, and as such if you wish to get world coordinates for drawing, et cetera, you should retrieve the position of the element and add the returned values onto that.
It should be noted that the values returned are relative to the position of the element, and as such if you wish to get world coordinates for drawing, et etcetera, you should retrieve the position of the element and add the returned values onto that.


==Syntax==
==Syntax==

Revision as of 16:37, 15 June 2009

This function returns the minimum and maximum coordinates of an element's bounding box.

It should be noted that the values returned are relative to the position of the element, and as such if you wish to get world coordinates for drawing, et etcetera, you should retrieve the position of the element and add the returned values onto that.

Syntax

float float float float float float getElementBoundingBox ( element theElement )

Required Arguments

theElement: the element whose bounding box we want to get.

Returns

  • Returns min x, min y, min z, max x, max y, max z if the passed element is valid, false otherwise.

Example

This example outputs to chatbox the minimum and the maximum coordinates of an element.

function minMaxOutput ( theElement )
    local x0, y0, z0, x1, y1, z1 = getElementBoundingBox ( theElement )
    if ( x0 ) then
        outputChatBox ( "The coords are: " .. x0 .. ", " .. y0 .. ", " .. z0 .. ", " .. x1 .. ", " .. y1 .. ", " .. z1 )
    else
        outputChatBox ( "Failed to retrieve bounding box" )
    end
end

See Also