Node object is a container with a Transform applied to it.Node objects are object-oriented and are the basis for all objects within LGE. This means that all Light, Model, and Body objects are extensions of a Node object.Node is 100% object-oriented and includes a reference to a parent Node, and for child Nodes.Node object includes a localTransform and a globalTransform. The globalTransform represents the transform of the Node in global space, and localTransform represents the transform of the Node relative to the parent Node.type string: The class type of the object. A Node will always have this defaulted to "Node".scene Scene object: The Scene object that the Node will be parented to.parent Node object: The Node that the Node is attached to/is a child of.name string: The name of the Node.visible bool: Whether the Node is visible or not for rendering. This is applicable to Model, Light, and Particle objects mainly.localTransform Transform object: The Transform object representing the position and rotation of the Node relative to the parent. This also includes the scale but it is independant from the parent.globalTransform Transform object: The Transform object representing the position and rotation of the Node relative to the origin of the world (0, 0, 0). This also includes the localTransform scale.Node object is easily done by passing in a table.
LGE.Node({
scene = myScene [string], -- Necessary, this is the Scene object that the Node will be a member of
parent = myNode [Node object], -- Optional, this is the parent object that the Node will be attached to. The Node must either be a descendant of the "root" Node of the scene, otherwise it will not be considered a member of the scene.
name = "myNode" [string], -- Optional, this gets passed to the .name property and is highly recommended to distinguish Nodes from one another.
})
myNode ~= nil might first come to mind, the use of metatables for object oriented systems makes things a tiny bit complicated.getmetatable(myNode) should be used instead of myNode ~= nil.Node:destroy()
Node:setParent(newParent [Node object])
.children variable given a name.
Node:findFirstChild(name [string])
Node:getParent(name [optional string])
Node:getRoot()
Node:getDescendants()
Node:getDescendants() to find a Node with a given name.
Node:findFirstDescendant()
Node:setGlobalPosition(position [vector3])
vector4, a quaternion can be unpacked into a vector4 and it will behave the same way.
Node:setGlobalRotation(rotation [vector4])
Node:setGlobalTransformMatrix(matrix [mat4])
Node:setLocalPosition(position [vector3])
vector4, a quaternion can be unpacked into a vector4 and it will behave the same way.
Node:setLocalRotation(rotation [vector4])
Node:setScale(position [vector3])
Node:lookAt(position [vector3])
Node:lookToward(direction [vector3])
Keep in mind update methods usually don’t have to be done manually. LGE takes care of this whenever necessary!
localTransform of the Node if it has been modified or the parent Node has had it’s globalTransform modified since the last update.
Node:updateLocalTransform()
globalTransform of the Node if it has been modified or the parent Node has had it’s globalTransform modified since the last update.
Node:updateGlobalTransform()