Urho.Node Class

Scene node that may contain components and child nodes.

See Also: Node

Syntax

public class Node : Animatable

Remarks

Nodes are the building block of your application.   Each Node has a 3D transform (position, rotation and scale), a name and an ID and can contain other nodes (child nodes).   Your application starts life with a special kind of node, the Scene node.

To bring Nodes to life, you attach one or more components into it (Urho.Component).   Components provide functionality from giving a node a visual representation, to emitting sound, to emitting light and many more. These are created either with their constructors and then by attaching them using the Node.AddComponent method or by calling the CreateComponent method which can do both operations in one call.

Here are some common scenarios, creating a Urho.Camera, a Light and a StaticModel.

C# Example

// Camera
var cameraNode = scene.CreateChild();
cameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f));
cameraNode.CreateComponent<Camera>();
Renderer.SetViewport(0, Viewport = new Viewport(Context, scene, cameraNode.GetComponent<Camera>(), null));

// Lights
var lightNode1 = scene.CreateChild();
lightNode1.Position = new Vector3(0, -5, -40);
lightNode1.AddComponent(new Light(Context) { LightType = LightType.Point, Range = 120, Brightness = 1.5f });

// Models
var cache = Application.ResourceCache;
var model = Node.CreateComponent<StaticModel>();
model.Model = cache.GetModel ("player.mdl");
var material = cache.GetMaterial("player.xml").Clone("");
model.SetMaterial(material);

Requirements

Namespace: Urho
Assembly: Urho (in Urho.dll)
Assembly Versions: 1.0.0.0

The members of Urho.Node are listed below.

See Also: Animatable

Public Constructors

Constructs a new instance of Urho.Node which is tied to the Application.CurrentContext.
Constructs a new instance of Urho.Node, given a raw pointer to an unmanaged object
Constructs a new instance of Urho.Node linked to a specific Context.

Protected Constructors

Empty constructor, chain to this constructor when you provide your own constructor that sets the handle field.

Public Properties

[read-only]
ChildrenIReadOnlyList<Node>. Return immediate child scene nodes.
[read-only]
ComponentsIReadOnlyList<Component>. Return all components.
[read-only]
DirectionVector3. Return forward direction in parent space. Positive Z axis equals identity rotation.
[read-only]
DirtyBoolean. Determines whether transform has changed and world transform needs recalculation.
EnabledBoolean. Controls whether the node is enabled. Disables nodes effectively disable all their components.
[read-only]
EnabledSelfBoolean. Returns the node's last own enabled state. May be different than the value returned by IsEnabled when SetDeepEnabled has been used.
IDUInt32. Return ID. Or Set ID. Called by Scene.
NameString. Return name. Or Set name of the scene node. Names are not required to be unique.
[read-only]
NameHashStringHash. Return name hash.
NetPositionAttrVector3. Return network position attribute. Or Set network position attribute.
[read-only]
NumComponentsUInt32. Return number of components.
[read-only]
NumNetworkComponentsUInt32. Return number of non-local components.
[read-only]
NumPersistentChildrenUInt32. Calculate number of non-temporary child nodes.
[read-only]
NumPersistentComponentsUInt32. Calculate number of non-temporary components.
OwnerConnection. Return owner connection in networking. Or Set owner connection for networking.
ParentNode. Return parent scene node. Or Set parent scene node. Retains the world transform.
PositionVector3. Return position in parent space. Or Set position in parent space. If the scene node is on the root level (is child of the scene itself), this is same as world space.
[read-only]
Position2DVector2. Return position in parent space (for Urho2D).
[read-only]
RightVector3. Return right direction in parent space. Positive X axis equals identity rotation.
RotationQuaternion. Return rotation in parent space. Or Set rotation in parent space.
Rotation2DSingle. Return rotation in parent space (for Urho2D). Or Set rotation in parent space (for Urho2D).
ScaleVector3. Return scale in parent space. Or Set scale in parent space.
[read-only]
Scale2DVector2. Return scale in parent space (for Urho2D).
SceneScene. Return scene. Or Set scene. Called by Scene.
[read-only]
TransformMatrix3x4. Return parent space transform matrix.
[read-only]
override
TypeStringHash. Urho's type system type.
[read-only]
override
TypeNameString. Urho's low-level type name.
[read-only]
static
TypeNameStaticString. Urho's low-level type name, accessible as a static method.
[read-only]
static
TypeStaticStringHash. Urho's low-level type, accessible as a static method.
[read-only]
UpVector3. Return up direction in parent space. Positive Y axis equals identity rotation.
[read-only]
WorldDirectionVector3. Return direction in world space.
[read-only]
WorldPositionVector3. Return position in world space.
[read-only]
WorldPosition2DVector2. Return position in world space (for Urho2D).
[read-only]
WorldRightVector3. Return node's right vector in world space.
[read-only]
WorldRotationQuaternion. Return rotation in world space.
WorldRotation2DSingle. Return rotation in world space (for Urho2D). Or Set rotation in world space (for Urho2D).
[read-only]
WorldScaleVector3. Return scale in world space.
[read-only]
WorldScale2DVector2. Return scale in world space (for Urho2D).
[read-only]
WorldTransformMatrix3x4. Return world space transform matrix.
[read-only]
WorldUpVector3. Return node's up vector in world space.

Public Methods

AddChild(Node)
Adds the specified node as a child of this node.
AddChild(Node, UInt32)
Add a child scene node at a specific index. 
AddComponent(Component, UInt32)
Add a pre-created component.
AddComponent(Component, UInt32, CreateMode)
Add a pre-created component.
AddListener(Component)
Add listener component that is notified of node being dirtied. Can either be in the same node or another.
AddReplicationState(NodeReplicationState*)
AddTag(String)
Attaches the specified string as a tag to this Node.
override
ApplyAttributes()
Apply attribute changes that can not be applied immediately recursively to child nodes and components.
ChangeParent(Node)
Changes the parent for the node
CleanupConnection(Connection)
Clean up all references to a network connection that is about to be removed.
Clone(CreateMode) : Node
Clone scene node, components and child nodes. Return the clone.
CloneComponent(Component, UInt32) : Component
Clone a component from another node using its create mode. Return the clone if successful or null on failure.
CloneComponent(Component, CreateMode, UInt32) : Component
Clone a component from another node and specify the create mode. Return the clone if successful or null on failure.
CreateChild(UInt32, CreateMode, Boolean) : Node
CreateChild(String, UInt32, CreateMode, Boolean) : Node
CreateChild(String, CreateMode, UInt32, Boolean) : Node
CreateComponent(StringHash, CreateMode, UInt32) : Component
Create a component to this node (with specified ID if provided).
CreateComponent<T>(CreateMode, UInt32) : T
Creates a component with the Node’s context and attaches it to the node.
CreateComponent<T>(StringHash, CreateMode, UInt32) : T
Creates a component with the Node’s context and attaches it to the node using an UrhoType description.
CreateTemporaryChild(String, CreateMode, UInt32) : Node
GetChild(UInt32) : Node
Return child scene node by index.
GetChild(String, Boolean) : Node
Return child scene node by name.
GetChild(StringHash, Boolean) : Node
Return child scene node by name hash.
GetChildrenWithComponent<T>(Boolean) : Node[]
Returns children nodes that have a specific component attached to it.
GetComponent(StringHash, Boolean) : Component
Return component by type. If there are several, returns the first.
GetComponent<T>(Boolean) : T
Return the component of the specified T parameters. If there are several, returns the first.
GetNumChildren(Boolean) : UInt32
Return number of child scene nodes.
GetOrCreateComponent(StringHash, CreateMode, UInt32) : Component
Create a component to this node if it does not exist already.
GetOrCreateComponent<T>(Boolean) : T
Create a component to this node if it does not exist already.
GetParentComponent(StringHash, Boolean) : Component
HasComponent(StringHash) : Boolean
Return whether has a specific component.
HasTag(String) : Boolean
Determines if the node has the specified tag attached to it.
override
Load(File, Boolean) : Boolean
override
Load(MemoryBuffer, Boolean) : Boolean
override
LoadXml(XmlElement, Boolean) : Boolean
LocalToWorld(Vector3) : Vector3
Convert a local space position to world space.
LocalToWorld(Vector4) : Vector3
Convert a local space position or rotation to world space.
LocalToWorld2D(Vector2) : Vector2
Convert a local space position or rotation to world space (for Urho2D).
LookAt(Vector3, Vector3, TransformSpace) : Boolean
Look at a target position in the chosen transform space. Note that the up vector is always specified in world space. Return true if successful, or false if resulted in an illegal rotation, in which case the current rotation remains.
MarkDirty()
Mark node and child nodes to need world transform recalculation. Notify listener components.
override
MarkNetworkUpdate()
Mark for attribute check on the next network update.
MarkReplicationDirty()
Mark node dirty in scene replication states.
PauseAllActions()
Pauses all actions that have been started with RunActionsAsync.
Pitch(Single, TransformSpace)
Rotate around the X axis.
PrepareNetworkUpdate()
Prepare network update by comparing attributes and marking replication states dirty as necessary.
static
RegisterObject(Context)
Register object factory.
Remove()
Remove from the parent node. If no other shared pointer references exist, causes immediate deletion.
RemoveAction(ActionState)
RemoveAction(BaseAction)
RemoveAllActions()
Removes all actions that have been started with RunActionsAsync.
RemoveAllChildren()
Remove all child scene nodes.
RemoveAllComponents()
Remove all components from this node.
RemoveAllTags()
Removes all tags that have been associated with the node.
RemoveChild(Node)
Remove a child scene node.
RemoveChildren(Boolean, Boolean, Boolean)
Remove child scene nodes that match criteria.
RemoveComponent(Component)
Remove a component from this node.
RemoveComponent(StringHash)
Remove the first component of specific type from this node.
RemoveComponent<T>()
Removes the component of the specified type.
RemoveComponents(StringHash)
Remove all components of specific type.
RemoveComponents(Boolean, Boolean)
Remove components that match criteria.
RemoveListener(Component)
Remove listener component.
RemoveTag(String) : Boolean
Removes a string tag from the Node.
ReorderComponent(Component, UInt32)
ResetDeepEnabled()
Reset enabled state to the node's remembered state prior to calling SetDeepEnabled.
ResetScene()
Reset scene, ID and owner. Called by Scene.
ResumeAllActions()
Resumes all actions that have been started with RunActionsAsync.
Roll(Single, TransformSpace)
Rotate around the Z axis.
Rotate(Quaternion, TransformSpace)
Rotate the scene node in the chosen transform space.
Rotate2D(Single, TransformSpace)
Rotate the scene node in the chosen transform space (for Urho2D).
RotateAround(Vector3, Quaternion, TransformSpace)
Rotate around a point in the chosen transform space.
RotateAround2D(Vector2, Single, TransformSpace)
Rotate around a point in the chosen transform space (for Urho2D).
RunActions(params FiniteTimeAction[])
Runs the specified actions.
RunActionsAsync(FiniteTimeAction) : System.Threading.Tasks.Task<Urho.Actions.ActionState>
RunActionsAsync(params FiniteTimeAction[]) : System.Threading.Tasks.Task<Urho.Actions.ActionState>
Runs a sequence of Actions so that it can be awaited.
override
Save(File) : Boolean
override
Save(MemoryBuffer) : Boolean
override
SaveDefaultAttributes() : Boolean
Return whether should save default-valued attributes into XML. Always save node transforms for readability, even if identity.
SaveJson(File, String) : Boolean
Saves the entire node as a prefab as Json data.
SaveJson(MemoryBuffer, String) : Boolean
override
SaveXml(XmlElement) : Boolean
Saves the entire node as a prefab into the provided XmlElement.
SaveXml(File, String) : Boolean
SaveXml(MemoryBuffer, String) : Boolean
ScaleNode(Single)
Modify scale in parent space uniformly.
ScaleNode(Vector3)
Modify scale in parent space.
ScaleNode2D(Vector2)
Modify scale in parent space (for Urho2D).
SetDeepEnabled(Boolean)
Set enabled state on self and child nodes. Nodes' own enabled state is remembered (IsEnabledSelf) and can be restored.
SetDirection(Vector3)
Set forward direction in parent space. Positive Z axis equals identity rotation.
SetEnabledRecursive(Boolean)
Set enabled state on self and child nodes. Unlike SetDeepEnabled this does not remember the nodes' own enabled state, but overwrites it.
SetPosition2D(Vector2)
Set position in parent space (for Urho2D).
SetPosition2D(Single, Single)
Set position in parent space (for Urho2D).
SetPositionSilent(Vector3)
Updates the position but does not flag the node as dirty, nor as requiring a network update.
SetRotationSilent(Quaternion)
Sets the rotation but does not flag the node as dirty, nor as requiring a network update.
SetScale(Single)
Set uniform scale in parent space.
SetScale2D(Vector2)
Set scale in parent space (for Urho2D).
SetScale2D(Single, Single)
Set scale in parent space (for Urho2D).
SetScaleSilent(Vector3)
Sets the scale but does not flag the node as dirty, nor as requiring a network update.
SetTransform(Matrix3x4)
SetTransform(Vector3, Quaternion)
Set both position and rotation in parent space as an atomic operation. This is faster than setting position and rotation separately.
SetTransform(Vector3, Quaternion, Single)
Set both position, rotation and uniform scale in parent space as an atomic operation.
SetTransform(Vector3, Quaternion, Vector3)
Set both position, rotation and scale in parent space as an atomic operation.
SetTransform2D(Vector2, Single)
Set both position and rotation in parent space as an atomic operation (for Urho2D).
SetTransform2D(Vector2, Single, Single)
Set both position, rotation and uniform scale in parent space as an atomic operation (for Urho2D).
SetTransform2D(Vector2, Single, Vector2)
Set both position, rotation and scale in parent space as an atomic operation (for Urho2D).
SetTransformSilent(Vector3, Quaternion, Vector3)
Sets the node transform but does not flag the node as dirty, nor as requiring a network update.
SetVar(StringHash, Int32)
Set a user variable.
SetVar(StringHash, Single)
Set a user variable.
SetVar(StringHash, String)
Set a user variable.
SetVar(StringHash, Color)
Set a user variable.
SetVar(StringHash, IntRect)
Set a user variable.
SetVar(StringHash, IntVector2)
Set a user variable.
SetVar(StringHash, Matrix3x4)
SetVar(StringHash, Matrix4)
SetVar(StringHash, Quaternion)
Set a user variable.
SetVar(StringHash, Vector2)
Set a user variable.
SetVar(StringHash, Vector3)
Set a user variable.
SetVar(StringHash, Vector4)
Set a user variable.
SetWorldDirection(Vector3)
Set forward direction in world space.
SetWorldPosition(Vector3)
Set position in world space.
SetWorldPosition2D(Vector2)
Set position in world space (for Urho2D).
SetWorldPosition2D(Single, Single)
Set position in world space (for Urho2D).
SetWorldRotation(Quaternion)
Set rotation in world space.
SetWorldScale(Single)
Set uniform scale in world space.
SetWorldScale(Vector3)
Set scale in world space.
SetWorldScale2D(Vector2)
Set scale in world space (for Urho2D).
SetWorldScale2D(Single, Single)
Set scale in world space (for Urho2D).
SetWorldTransform(Vector3, Quaternion)
Set both position and rotation in world space as an atomic operation.
SetWorldTransform(Vector3, Quaternion, Single)
Set both position, rotation and uniform scale in world space as an atomic operation.
SetWorldTransform(Vector3, Quaternion, Vector3)
Set both position, rotation and scale in world space as an atomic opration.
SetWorldTransform2D(Vector2, Single)
Set both position and rotation in world space as an atomic operation (for Urho2D).
SetWorldTransform2D(Vector2, Single, Single)
Set both position, rotation and uniform scale in world space as an atomic operation (for Urho2D).
SetWorldTransform2D(Vector2, Single, Vector2)
Set both position, rotation and scale in world space as an atomic opration (for Urho2D).
SubscribeToAnimationTrigger(Action<AnimationTriggerEventArgs>) : Subscription
Subscribes to the AnimationTrigger event raised by the Node.
SubscribeToBoneHierarchyCreated(Action<BoneHierarchyCreatedEventArgs>) : Subscription
Subscribes to the BoneHierarchyCreated event raised by the Node.
SubscribeToNodeCollision(Action<NodeCollisionEventArgs>) : Subscription
Subscribes to the NodeCollision event raised by the Node.
SubscribeToNodeCollisionEnd(Action<NodeCollisionEndEventArgs>) : Subscription
Subscribes to the NodeCollisionEnd event raised by the Node.
SubscribeToNodeCollisionStart(Action<NodeCollisionStartEventArgs>) : Subscription
Subscribes to the NodeCollisionStart event raised by the Node.
Translate(Vector3)
Move the scene node in the chosen transform space.
Translate(Vector3, TransformSpace)
Move the scene node in the chosen transform space.
Translate2D(Vector2, TransformSpace)
Move the scene node in the chosen transform space (for Urho2D).
WorldToLocal(Vector3) : Vector3
Convert a world space position to local space.
WorldToLocal(Vector4) : Vector3
Convert a world space position or rotation to local space.
WorldToLocal2D(Vector2) : Vector2
Convert a world space position or rotation to local space (for Urho2D).
Yaw(Single, TransformSpace)
Rotate around the Y axis.

Public Events