RenderTree3DResult
Package: Libraries.Game.Graphics.Trees · Inherits from: Libraries.Language.Object
RenderTree3DResult holds what a render tree finds for one frame of drawing, in two lists: - visible: items inside the camera's view, which are drawn on screen. - invisible: items the camera cannot see that can still change the picture, such as an object behind the camera whose shadow falls into view. A layer keeps one RenderTree3DResult and empties it at the start of each frame, so its arrays are reused instead of made again.
Example Code
use Libraries.Game.Graphics.Trees.RenderTree3DResult
use Libraries.Game.Graphics.Trees.DynamicVolumeRenderTree3D
use Libraries.Interface.Item3D
use Libraries.Compute.Matrix4
DynamicVolumeRenderTree3D tree
Item3D box
box:SetDimensions(1, 1, 1)
tree:Add(box)
// A new Matrix4 does nothing to a point, so its view is the space from
// -1 to 1 around the origin, where the box is.
Matrix4 view
RenderTree3DResult result
result:SetViewProjection(view)
tree:CollectVisible(view, result)
output result:GetVisible():GetSize()
Actions
Add(Libraries.Game.Graphics.Trees.RenderTreeNode3D leaf)
This action adds a leaf's item to this result, unless it was already added with this result's frame and search count. An item the camera can see, even in part, goes in the visible list. Any other item goes in the invisible list. So each item is added at most once, in one list, however many searches find it. The camera, or with no camera the view-projection matrix, must be set first. The layer sets the frame and search count before searching, and must give each new filling of a result a frame and search count that no other filling of this tree used.
Parameters
leafLibraries.Game.Graphics.Trees.RenderTreeNode3D: The leaf whose item was found.
AddToInvisible(Libraries.Interface.Item3D item)
Parameters
AddToVisible(Libraries.Interface.Item3D item)
with no game window.
Parameters
Empty()
This action empties both lists, keeping their storage, so they can be filled again next frame without making new arrays.
GetCamera()
This action returns the point light being searched for, as its bit, or 0 for none.
Returns
Libraries.Game.Graphics.Camera: The light's bit, or 0.
GetFrame()
This action empties both lists, keeping their storage, so they can be filled again next frame without making new arrays.
Returns
integer
GetInvisible()
This action returns the items outside the camera's view that can still change the picture, such as shadow casters.
Returns
Libraries.Containers.Array<Libraries.Interface.Item3D>: The array of invisible items.
GetSearchCount()
This action returns the items inside the camera's view.
Returns
integer: The array of visible items.
GetShadowBit()
This action returns the point light being searched for, as its bit, or 0 for none.
Returns
integer: The light's bit, or 0.
GetViewProjection()
This action returns the view-projection matrix used to sort items when no camera is set, or undefined if none was given.
Returns
Libraries.Compute.Matrix4: The view-projection matrix, or undefined.
GetVisible()
This action returns the items inside the camera's view.
Returns
Libraries.Containers.Array<Libraries.Interface.Item3D>: The array of visible items.
SetCamera(Libraries.Game.Graphics.Camera camera)
This action sets the point light being searched for, as its bit, or 0 for none. Every item Add is given while it is set is marked with it (Item3D:AddShadowLight), with this result's frame.
Parameters
SetFrame(integer frame)
This action returns the items outside the camera's view that can still change the picture, such as shadow casters.
Parameters
frameinteger
SetSearchCount(integer searchCount)
This action sets the view-projection matrix used to sort items into the visible and invisible lists when no camera is set, such as in a test with no game window. A camera, if set, is used instead.
Parameters
searchCountinteger
SetShadowBit(integer bit)
This action sets the point light being searched for, as its bit, or 0 for none. Every item Add is given while it is set is marked with it (Item3D:AddShadowLight), with this result's frame.
Parameters
bitinteger: The light's bit, or 0.
SetViewProjection(Libraries.Compute.Matrix4 matrix)
This action sets the view-projection matrix used to sort items into the visible and invisible lists when no camera is set, such as in a test with no game window. A camera, if set, is used instead.
Parameters
matrixLibraries.Compute.Matrix4: The view-projection matrix.