NodesΒΆ
A Guerilla scene is a hierarchy of nodes, with Document being the root node of the hierarchy.
All classes of nodes are derived from the Node base class. Examples of node classes are:
- SceneGraphNode the base class for all 3d objects
- Primitive the class for rendering objects
- RenderGraph the class for rendergraphs
- RenderGraphNode the class for rendergraph nodes
Each node can contain children nodes, starting with Document which contains the whole scene.
Iterating through a node children
Use the children iterator:
-- List all Camera nodes directly in Document
for node in children (Document, "Camera") do
print (node:getname ())
end
Iterating through the whole hierarcy
Use the children iterator again, with the recursive option turned to true:
-- List all Primitive nodes in Document, even in hierarchy
for node in children (Document, "Primitive", nil true) do
print (node:getname ())
end
Picking a node from its name or its path
Nodes in hierarchy are identified by their path, which is
the concatenation of the parent nodes names, separated by the '|'
(pipe) character. For instance, "Perspective|Frustum"
is the
path to the Frustum node contained in the Perspective node.
Use the getchild method with the immediate child name:
-- Get the Perspective node in Document
local perspective = Document:getchild ("Perspective")
Or use the findchild method with the relative child path:
-- Get the Frustum node in Perspective
local frustum = Document:findchild ("Perspective|Frustum")
Guerilla also offers a simple and convenient way to retrieve a node using the '_' (underscore) function:
-- Get the Frustum node in Perspective
local frustum = _("Perspective|Frustum")
-- When using strings directly, you can omit the ():
local frustum = _"Perspective|Frustum"