SceneNode
From Crumbled World Wiki
Example Code
function done()
--Do stuff here
end
--Run exportScript.lua in a background thread.
local worker = Worker("MapEditor/exportScript.lua",false)
worker:addCallbackFinished(done)
Static functions
| return | function | description |
|---|---|---|
| SceneNode | new() | Create a new Instance of the the SceneNode |
| SceneNode | new(string name) | Create a new Instance of the the SceneNode |
| SceneNode | newNil() | return a null pointer of type SceneNode |
Functions
| return | function | description |
|---|---|---|
| destroy() | Destroy this node. | |
| destroyTree() | Destroy this node and all nodes towards leaf nodes.
This is the only way to a node completely. | |
| NodeId | getNodeType() | Returns the node id, Check NodeId. |
| SceneNode | toSceneNode() | Converts the pointer to a sceneNode. |
| SceneNode | getRootNode() | Returns root node of the scene tree. |
| string | getSceneName() | Returns this nodes scene name. |
| SceneNode | getParent() | Returns this nodes parent. If this node is a rootNode null is returned. |
| int | getId() | Returns this nodes unique id. |
| PlayerNode | getPlayerNode() | Returns the player node. The player node is only returned if the parent to this node is of the type PlayerNode.
This should always return a node except when this function is called from Camera or rootNode |
| BoundType | getBoundType() | Returns the Bounding type. |
| Vec3 | getGlobalPosition() | Returns the global position. |
| Vec3 | getLocalPosition() | Returns the local position. |
| Matrix | getGlobalMatrix() | Returns the global matrix. |
| Matrix | getLocalMatrix() | Returns the local matrix. |
| Box | getGlobalBoundingBox() | Returns the global box. |
| Sphere | getGlobalBoundingSphere() | Returns the global sphere. |
| LuaScript | getScriptByName(string scriptName) | Returns the script with the given name. |
| {LuaScript()} | getAllScript() | Return all script from this node. |
| number | countAllNodeInTree() | Return a number counting all nodes |
| LuaScript | getCurrentScript() | Returns the current running script. |
| bool | getisUpdatedEnabled() | Returns if this node accepts update. |
| bool | getVisibleInCamera() | Returns true is this sceneNode was visible in any camera during last frame. |
| Work | getWork() | Returns this nodes worker. |
| bool | getCollisionEnabled() | Returns true if collision is enabled on this node. |
| bool | getVisible() | Returns this nodes visible variable set by setVisible(). |
| {SceneNode()} | findAllNodeByNameTowardsLeaf(string sceneName) | Returns all nodes with the given name towards the leafNodes. |
| {SceneNode()} | findAllNodeByNameTowardsLeaf(table sceneNames) | Returns all nodes with the given name towards the leafNodes. |
| {SceneNode()} | findAllNodeByNameTowardsRoot(string sceneName) | Returns all nodes with the given name towards the root node. |
| {SceneNode()} | findAllNodeByNameTowardsRoot(table sceneNames) | Returns all nodes with the given name towards the root node. |
| {SceneNode()} | findAllNodeByTypeTowardsLeaf(NodeId id) | Returns all nodes with the given nodeId towards the leaf node. |
| {SceneNode()} | findAllNodeByTypeTowardsLeaf(table idList) | Returns all nodes with the given nodeIds towards the leaf node. |
| {SceneNode()} | getAllNodeByTypeTowardsLeafWithinSphere(NodeId id, Sphere aSphere) | Returns all nodes with the given nodeId within the sphere towards the leaf node. |
| SceneNode | findNodeByName(string sceneName) | Returns the first node with the given name.
Looks first towards the leafNodes then look toward the root node |
| SceneNode | findNodeByType(NodeId id) | Returns the first node with the given nodeId.
Looks first towards the leafNodes then look toward the root node |
| SceneNode | findNodeByTypeTowardsLeafe(NodeId id) | Returns the first node with the given nodeId towards leaf nodes. |
| SceneNode | findNodeByTypeTowardsRoot(NodeId id) | Returns the first node with the given nodeId towards root node. |
| setSceneName(string name) | Set the name of the sceneNode. | |
| setLocalMatrix(Matrix mat) | Set local matrix. | |
| setLocalPosition(Vec3 position) | Set local position. | |
| setVisible(bool visible) | Set if node should be visible. | |
| setParent(SceneNode parent) | Set the parent. | |
| setEnableUpdates(bool enabled) | Set if this node should be updated. if this nodes update is disabeld all children will not ether get updated. | |
| setCollisionEnabled(bool enabled) | Set if this node should have collision enabled, by default all node has collision enabled. | |
| DisableBoundingVolumesDynamicUpdates() | changing position rotation and scale should not effect parrent bounding volume.
This is an optimization for dynamic object that changes it's local matrix but not actually it's position. | |
| setBoundingVolumeCanShrink(bool canShrink) | Config the bounding volume never to shrink. this is useful to increase performance on object that may move around internal but have a somewhat constant bounding volume. | |
| createBoundVolumeGroup() | Force create a bound volume group. | |
| Work | createWork() | create a work from this node.
This function is not needed at all. It's used to make some very specific optimization. |
| SceneNode | collision(Line3D line) | Perform collision against this node. Return this sceneNode if collision was found. |
| SceneNode | collision(Line3D line, Vec3 normal) | Perform collision against this node. Return this sceneNode if collision was found and the normal of the collision. |
| SceneNode | collisionTree(Line3D line) | Perform collision against this node and all nodes towards the leaf nodes. Return the sceneNode from the closest collision. if no collision was detected return null. |
| SceneNode | collisionTree(Line3D line, Vec3 normal) | Perform collision against this node and all nodes towards the leaf nodes. Return the sceneNode from the closest collision and the normal. if no collision was detected return null. |
| SceneNode | collisionTree(Line3D line, NodeId id) | Perform collision against this node and all towards the leaf nodes with the same nodeId. Return the sceneNode from the closest collision. if no collision was detected return null. |
| SceneNode | collisionTree(Line3D line, table whiteListedNodeIds) | Perform collision against this node and all towards the leaf nodes if the NodeId of the sceneNode is contained in the table. |
| SceneNode | collisionTree(Line3D line, Vec3 normal, table whiteListedNodeIds) | Perform collision against this node and all towards the leaf nodes if the NodeId of the sceneNode is contained in the table. |
| {SceneNode()} | collisionTree(Frustrum aFrustruml, table whiteListedNodeIds) | Perform collision against this node and all towards the leaf nodes if the NodeId of the sceneNode is contained in the table. |
| SceneNode | addChild(SceneNode child) | Add the node as a child to this one |
| bool | removeChild(SceneNode child) | Remove the child. Returns true if the child was removed else false. |
| SceneNode | getChildNode(int index) | Get child by index. |
| int | getChildSize() | Get number of children. |
| SceneNode | getVisibleChildNode(int index) | Get visible child by index. |
| int | getVisibleChildSize() | Get number of visible children. |
| bool | getCanBeSaved() | Get if the this scene can be saved by the saveScene() function. |
| loadLuaScriptAndRunOnce(String scriptName) | Try to load a new script from file and immediately execute the script and then destroy the script. | |
| loadLuaScriptAndRunOnce(string scriptName) | Try to load a new script from file and immediately execute the script and then destroy the script. | |
| LuaScript | loadLuaScript(String scriptName) | Try to load a new script from file. return null if failed |
| LuaScript | loadLuaScript(string scriptName) | Try to load a new script from file. return null if failed |
| removeScript(String scriptName) | Removes a script with the given name. | |
| removeScript(string scriptName) | Removes a script with the given name. | |
| update() | Update node. This function is automatically called by the game if the nood is connected to the main sceneNode. | |
| setCanBeSaved(bool canBeSaved) | Set if the this scene can be saved by the saveScene() function. | |
| saveScene(string fileName) | Save the tree hierarchy from this scene node. This will save all nodes and some local state.
Used to create save and load functionality for map editor. This is NOT a in game save functionality. | |
| SceneNode | loadScene(string fileName) | Load a scene node hierarchy as a child to this node. |
Overloaded returns
| return | function | Parameter |
|---|---|---|
| SceneNode | findNodeByType | id |
| {SceneNode()} | findAllNodeByTypeTowardsLeaf | id |
| SceneNode | findNodeByTypeTowardsLeafe | id |
| SceneNode | findNodeByTypeTowardsRoot | id |
| {SceneNode()} | getAllNodeByTypeTowardsLeafWithinSphere | id |
| SceneNode | addChild | child |
| SceneNode | collision | id |