Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:WorldToScreen

From RoR Wiki

UI Lua API · WorldObject functions
Version: WAR 1.4.8

Projects a point in the 3D scene to screen pixel coordinates.

onScreen, x, y = WorldToScreen(sceneX, sceneY, sceneZ)

Arguments

sceneX, sceneY, sceneZ
number – The point, in the coordinate space of the 3D scene (see Details).

Returns

onScreen
boolean – true if the point is in front of the camera and inside the view.
x, y
number – Screen position in whole pixels, measured from the top-left corner, at the game's display resolution. Both are 0 when onScreen is false.

Details

  • The three values are passed to the camera projection as given. When the client projects an object's position (for example in MoveWindowToWorldObject) it first subtracts a world origin from X and Y and negates the height. This function does no such conversion, so positions taken from game data do not project to the right place.
  • The pixel values use the resolution from the video settings, not the UI's scaled coordinate space.
  • The function needs at least three arguments and only reads the last three.
  • The stock UI never calls this function.

Errors

None besides the generic Invalid Parameters message when an argument is not a number.

Example

A minimal call built from the signature:

local onScreen, x, y = WorldToScreen( sceneX, sceneY, sceneZ )
if onScreen then
    -- x, y are pixel coordinates
end

See also