Urho3D
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Urho3D::Scene Class Reference

Root scene node, represents the whole scene. More...

#include </home/runner/work/urho3d-doxygen.github.io/urho3d-doxygen.github.io/urho3d_repo/Source/Urho3D/Scene/Scene.h>

Inheritance diagram for Urho3D::Scene:
Urho3D::Node Urho3D::Animatable Urho3D::Serializable Urho3D::Object Urho3D::RefCounted

Public Member Functions

 Scene (Context *context)
 Construct.
 
 ~Scene () override
 Destruct.
 
bool Load (Deserializer &source) override
 Load from binary data. Removes all existing child nodes and components first. Return true if successful. More...
 
bool Save (Serializer &dest) const override
 Save to binary data. Return true if successful. More...
 
bool LoadXML (const XMLElement &source) override
 Load from XML data. Removes all existing child nodes and components first. Return true if successful. More...
 
bool LoadJSON (const JSONValue &source) override
 Load from JSON data. Removes all existing child nodes and components first. Return true if successful. More...
 
void MarkNetworkUpdate () override
 Mark for attribute check on the next network update. More...
 
void AddReplicationState (NodeReplicationState *state) override
 Add a replication state that is tracking this scene. More...
 
bool LoadXML (Deserializer &source)
 Load from an XML file. Return true if successful.
 
bool LoadJSON (Deserializer &source)
 Load from a JSON file. Return true if successful.
 
bool SaveXML (Serializer &dest, const String &indentation="\t") const
 Save to an XML file. Return true if successful.
 
bool SaveJSON (Serializer &dest, const String &indentation="\t") const
 Save to a JSON file. Return true if successful.
 
bool LoadAsync (File *file, LoadMode mode=LOAD_SCENE_AND_RESOURCES)
 Load from a binary file asynchronously. Return true if started successfully. The LOAD_RESOURCES_ONLY mode can also be used to preload resources from object prefab files.
 
bool LoadAsyncXML (File *file, LoadMode mode=LOAD_SCENE_AND_RESOURCES)
 Load from an XML file asynchronously. Return true if started successfully. The LOAD_RESOURCES_ONLY mode can also be used to preload resources from object prefab files.
 
bool LoadAsyncJSON (File *file, LoadMode mode=LOAD_SCENE_AND_RESOURCES)
 Load from a JSON file asynchronously. Return true if started successfully. The LOAD_RESOURCES_ONLY mode can also be used to preload resources from object prefab files.
 
void StopAsyncLoading ()
 Stop asynchronous loading.
 
NodeInstantiate (Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED)
 Instantiate scene content from binary data. Return root node if successful.
 
NodeInstantiateXML (const XMLElement &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED)
 Instantiate scene content from XML data. Return root node if successful.
 
NodeInstantiateXML (Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED)
 Instantiate scene content from XML data. Return root node if successful.
 
NodeInstantiateJSON (const JSONValue &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED)
 Instantiate scene content from JSON data. Return root node if successful.
 
NodeInstantiateJSON (Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED)
 Instantiate scene content from JSON data. Return root node if successful.
 
void Clear (bool clearReplicated=true, bool clearLocal=true)
 Clear scene completely of either replicated, local or all nodes and components.
 
void SetUpdateEnabled (bool enable)
 Enable or disable scene update.
 
void SetTimeScale (float scale)
 Set update time scale. 1.0 = real time (default).
 
void SetElapsedTime (float time)
 Set elapsed time in seconds. This can be used to prevent inaccuracy in the timer if the scene runs for a long time.
 
void SetSmoothingConstant (float constant)
 Set network client motion smoothing constant.
 
void SetSnapThreshold (float threshold)
 Set network client motion smoothing snap threshold.
 
void SetAsyncLoadingMs (int ms)
 Set maximum milliseconds per frame to spend on async scene loading.
 
void AddRequiredPackageFile (PackageFile *package)
 Add a required package file for networking. To be called on the server.
 
void ClearRequiredPackageFiles ()
 Clear required package files.
 
void RegisterVar (const String &name)
 Register a node user variable hash reverse mapping (for editing).
 
void UnregisterVar (const String &name)
 Unregister a node user variable hash reverse mapping.
 
void UnregisterAllVars ()
 Clear all registered node user variable hash reverse mappings.
 
NodeGetNode (NodeId id) const
 Return node from the whole scene by ID, or null if not found.
 
ComponentGetComponent (ComponentId id) const
 Return component from the whole scene by ID, or null if not found.
 
bool GetNodesWithTag (Vector< Node * > &dest, const String &tag) const
 Get nodes with specific tag from the whole scene, return false if empty.
 
bool IsUpdateEnabled () const
 Return whether updates are enabled.
 
bool IsAsyncLoading () const
 Return whether an asynchronous loading operation is in progress.
 
float GetAsyncProgress () const
 Return asynchronous loading progress between 0.0 and 1.0, or 1.0 if not in progress.
 
LoadMode GetAsyncLoadMode () const
 Return the load mode of the current asynchronous loading operation.
 
const StringGetFileName () const
 Return source file name.
 
hash32 GetChecksum () const
 Return source file checksum.
 
float GetTimeScale () const
 Return update time scale.
 
float GetElapsedTime () const
 Return elapsed time in seconds.
 
float GetSmoothingConstant () const
 Return motion smoothing constant.
 
float GetSnapThreshold () const
 Return motion smoothing snap threshold.
 
int GetAsyncLoadingMs () const
 Return maximum milliseconds per frame to spend on async loading.
 
const Vector< SharedPtr< PackageFile > > & GetRequiredPackageFiles () const
 Return required package files.
 
const StringGetVarName (StringHash hash) const
 Return a node user variable name, or empty if not registered.
 
void Update (float timeStep)
 Update scene. Called by HandleUpdate.
 
void BeginThreadedUpdate ()
 Begin a threaded update. During threaded update components can choose to delay dirty processing.
 
void EndThreadedUpdate ()
 End a threaded update. Notify components that marked themselves for delayed dirty processing.
 
void DelayedMarkedDirty (Component *component)
 Add a component to the delayed dirty notify queue. Is thread-safe.
 
bool IsThreadedUpdate () const
 Return threaded update flag.
 
NodeId GetFreeNodeID (CreateMode mode)
 Get free node ID, either non-local or local.
 
ComponentId GetFreeComponentID (CreateMode mode)
 Get free component ID, either non-local or local.
 
void NodeTagAdded (Node *node, const String &tag)
 Cache node by tag if tag not zero, no checking if already added. Used internaly in Node::AddTag.
 
void NodeTagRemoved (Node *node, const String &tag)
 Cache node by tag if tag not zero.
 
void NodeAdded (Node *node)
 Node added. Assign scene pointer and add to ID map.
 
void NodeRemoved (Node *node)
 Node removed. Remove from ID map.
 
void ComponentAdded (Component *component)
 Component added. Add to ID map.
 
void ComponentRemoved (Component *component)
 Component removed. Remove from ID map.
 
void SetVarNamesAttr (const String &value)
 Set node user variable reverse mappings.
 
String GetVarNamesAttr () const
 Return node user variable reverse mappings.
 
void PrepareNetworkUpdate ()
 Prepare network update by comparing attributes and marking replication states dirty as necessary.
 
void CleanupConnection (Connection *connection)
 Clean up all references to a network connection that is about to be removed.
 
void MarkNetworkUpdate (Node *node)
 Mark a node for attribute check on the next network update.
 
void MarkNetworkUpdate (Component *component)
 Mark a component for attribute check on the next network update.
 
void MarkReplicationDirty (Node *node)
 Mark a node dirty in scene replication states. The node does not need to have own replication state yet.
 
ComponentGetComponent (StringHash type, bool recursive=false) const
 Return component by type. If there are several, returns the first.
 
template<class T >
T * GetComponent (bool recursive=false) const
 Template version of returning a component by type.
 
bool SaveXML (XMLElement &dest) const override
 Save as XML data. Return true if successful. More...
 
bool SaveXML (Serializer &dest, const String &indentation="\t") const
 Save to an XML file. Return true if successful.
 
bool SaveJSON (JSONValue &dest) const override
 Save as JSON data. Return true if successful. More...
 
bool SaveJSON (Serializer &dest, const String &indentation="\t") const
 Save to a JSON file. Return true if successful.
 
- Public Member Functions inherited from Urho3D::Node
 Node (Context *context)
 Construct.
 
 ~Node () override
 Destruct. Any child nodes are detached.
 
bool Load (Deserializer &source) override
 Load from binary data. Return true if successful. More...
 
bool LoadXML (const XMLElement &source) override
 Load from XML data. Return true if successful. More...
 
bool LoadJSON (const JSONValue &source) override
 Load from JSON data. Return true if successful. More...
 
bool Save (Serializer &dest) const override
 Save as binary data. Return true if successful. More...
 
bool SaveXML (XMLElement &dest) const override
 Save as XML data. Return true if successful. More...
 
bool SaveJSON (JSONValue &dest) const override
 Save as JSON data. Return true if successful. More...
 
void ApplyAttributes () override
 Apply attribute changes that can not be applied immediately recursively to child nodes and components. More...
 
bool SaveDefaultAttributes () const override
 Return whether should save default-valued attributes into XML. Always save node transforms for readability, even if identity. More...
 
void MarkNetworkUpdate () override
 Mark for attribute check on the next network update. More...
 
virtual void AddReplicationState (NodeReplicationState *state)
 Add a replication state that is tracking this node. More...
 
bool SaveXML (Serializer &dest, const String &indentation="\t") const
 Save to an XML file. Return true if successful.
 
bool SaveJSON (Serializer &dest, const String &indentation="\t") const
 Save to a JSON file. Return true if successful.
 
void SetName (const String &name)
 Set name of the scene node. Names are not required to be unique.
 
void SetTags (const StringVector &tags)
 Set tags. Old tags are overwritten.
 
void AddTag (const String &tag)
 Add a tag.
 
void AddTags (const String &tags, char separator=';')
 Add tags with the specified separator (; by default).
 
void AddTags (const StringVector &tags)
 Add tags.
 
bool RemoveTag (const String &tag)
 Remove tag. Return true if existed.
 
void RemoveAllTags ()
 Remove all tags.
 
void SetPosition (const Vector3 &position)
 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.
 
void SetPosition2D (const Vector2 &position)
 Set position in parent space (for Urho2D).
 
void SetPosition2D (float x, float y)
 Set position in parent space (for Urho2D).
 
void SetRotation (const Quaternion &rotation)
 Set rotation in parent space.
 
void SetRotation2D (float rotation)
 Set rotation in parent space (for Urho2D).
 
void SetDirection (const Vector3 &direction)
 Set forward direction in parent space. Positive Z axis equals identity rotation.
 
void SetScale (float scale)
 Set uniform scale in parent space.
 
void SetScale (const Vector3 &scale)
 Set scale in parent space.
 
void SetScale2D (const Vector2 &scale)
 Set scale in parent space (for Urho2D).
 
void SetScale2D (float x, float y)
 Set scale in parent space (for Urho2D).
 
void SetTransform (const Vector3 &position, const Quaternion &rotation)
 Set both position and rotation in parent space as an atomic operation. This is faster than setting position and rotation separately.
 
void SetTransform (const Vector3 &position, const Quaternion &rotation, float scale)
 Set position, rotation, and uniform scale in parent space as an atomic operation.
 
void SetTransform (const Vector3 &position, const Quaternion &rotation, const Vector3 &scale)
 Set position, rotation, and scale in parent space as an atomic operation.
 
void SetTransform (const Matrix3x4 &matrix)
 Set node transformation in parent space as an atomic operation.
 
void SetTransform2D (const Vector2 &position, float rotation)
 Set both position and rotation in parent space as an atomic operation (for Urho2D).
 
void SetTransform2D (const Vector2 &position, float rotation, float scale)
 Set position, rotation, and uniform scale in parent space as an atomic operation (for Urho2D).
 
void SetTransform2D (const Vector2 &position, float rotation, const Vector2 &scale)
 Set position, rotation, and scale in parent space as an atomic operation (for Urho2D).
 
void SetWorldPosition (const Vector3 &position)
 Set position in world space.
 
void SetWorldPosition2D (const Vector2 &position)
 Set position in world space (for Urho2D).
 
void SetWorldPosition2D (float x, float y)
 Set position in world space (for Urho2D).
 
void SetWorldRotation (const Quaternion &rotation)
 Set rotation in world space.
 
void SetWorldRotation2D (float rotation)
 Set rotation in world space (for Urho2D).
 
void SetWorldDirection (const Vector3 &direction)
 Set forward direction in world space.
 
void SetWorldScale (float scale)
 Set uniform scale in world space.
 
void SetWorldScale (const Vector3 &scale)
 Set scale in world space.
 
void SetWorldScale2D (const Vector2 &scale)
 Set scale in world space (for Urho2D).
 
void SetWorldScale2D (float x, float y)
 Set scale in world space (for Urho2D).
 
void SetWorldTransform (const Vector3 &position, const Quaternion &rotation)
 Set both position and rotation in world space as an atomic operation.
 
void SetWorldTransform (const Vector3 &position, const Quaternion &rotation, float scale)
 Set position, rotation, and uniform scale in world space as an atomic operation.
 
void SetWorldTransform (const Vector3 &position, const Quaternion &rotation, const Vector3 &scale)
 Set position, rotation, and scale in world space as an atomic opration.
 
void SetWorldTransform (const Matrix3x4 &worldTransform)
 Set position, rotation, and scale in world space as an atomic operation from a transformation matrix.
 
void SetWorldTransform2D (const Vector2 &position, float rotation)
 Set both position and rotation in world space as an atomic operation (for Urho2D).
 
void SetWorldTransform2D (const Vector2 &position, float rotation, float scale)
 Set position, rotation, and uniform scale in world space as an atomic operation (for Urho2D).
 
void SetWorldTransform2D (const Vector2 &position, float rotation, const Vector2 &scale)
 Set position, rotation, and scale in world space as an atomic opration (for Urho2D).
 
void Translate (const Vector3 &delta, TransformSpace space=TransformSpace::Local)
 Move the scene node in the chosen transform space.
 
void Translate2D (const Vector2 &delta, TransformSpace space=TransformSpace::Local)
 Move the scene node in the chosen transform space (for Urho2D).
 
void Rotate (const Quaternion &delta, TransformSpace space=TransformSpace::Local)
 Rotate the scene node in the chosen transform space.
 
void Rotate2D (float delta, TransformSpace space=TransformSpace::Local)
 Rotate the scene node in the chosen transform space (for Urho2D).
 
void RotateAround (const Vector3 &point, const Quaternion &delta, TransformSpace space=TransformSpace::Local)
 Rotate around a point in the chosen transform space.
 
void RotateAround2D (const Vector2 &point, float delta, TransformSpace space=TransformSpace::Local)
 Rotate around a point in the chosen transform space (for Urho2D).
 
void Pitch (float angle, TransformSpace space=TransformSpace::Local)
 Rotate around the X axis.
 
void Yaw (float angle, TransformSpace space=TransformSpace::Local)
 Rotate around the Y axis.
 
void Roll (float angle, TransformSpace space=TransformSpace::Local)
 Rotate around the Z axis.
 
bool LookAt (const Vector3 &target, const Vector3 &up=Vector3::UP, TransformSpace space=TransformSpace::World)
 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.
 
void Scale (float scale)
 Modify scale in parent space uniformly.
 
void Scale (const Vector3 &scale)
 Modify scale in parent space.
 
void Scale2D (const Vector2 &scale)
 Modify scale in parent space (for Urho2D).
 
void SetEnabled (bool enable)
 Set enabled/disabled state without recursion. Components in a disabled node become effectively disabled regardless of their own enable/disable state.
 
void SetDeepEnabled (bool enable)
 Set enabled state on self and child nodes. Nodes' own enabled state is remembered (IsEnabledSelf) and can be restored.
 
void ResetDeepEnabled ()
 Reset enabled state to the node's remembered state prior to calling SetDeepEnabled.
 
void SetEnabledRecursive (bool enable)
 Set enabled state on self and child nodes. Unlike SetDeepEnabled this does not remember the nodes' own enabled state, but overwrites it.
 
void SetOwner (Connection *owner)
 Set owner connection for networking.
 
void MarkDirty ()
 Mark node and child nodes to need world transform recalculation. Notify listener components.
 
NodeCreateChild (const String &name=String::EMPTY, CreateMode mode=REPLICATED, NodeId id=0, bool temporary=false)
 Create a child scene node (with specified ID if provided).
 
NodeCreateTemporaryChild (const String &name=String::EMPTY, CreateMode mode=REPLICATED, NodeId id=0)
 Create a temporary child scene node (with specified ID if provided).
 
void AddChild (Node *node, i32 index=ENDPOS)
 Add a child scene node at a specific index. If index is not explicitly specified or is ENDPOS, append the new child at the end.
 
void RemoveChild (Node *node)
 Remove a child scene node.
 
void RemoveAllChildren ()
 Remove all child scene nodes.
 
void RemoveChildren (bool removeReplicated, bool removeLocal, bool recursive)
 Remove child scene nodes that match criteria.
 
ComponentCreateComponent (StringHash type, CreateMode mode=REPLICATED, ComponentId id=0)
 Create a component to this node (with specified ID if provided).
 
ComponentGetOrCreateComponent (StringHash type, CreateMode mode=REPLICATED, ComponentId id=0)
 Create a component to this node if it does not exist already.
 
ComponentCloneComponent (Component *component, ComponentId id=0)
 Clone a component from another node using its create mode. Return the clone if successful or null on failure.
 
ComponentCloneComponent (Component *component, CreateMode mode, ComponentId id=0)
 Clone a component from another node and specify the create mode. Return the clone if successful or null on failure.
 
void RemoveComponent (Component *component)
 Remove a component from this node.
 
void RemoveComponent (StringHash type)
 Remove the first component of specific type from this node.
 
void RemoveComponents (bool removeReplicated, bool removeLocal)
 Remove components that match criteria.
 
void RemoveComponents (StringHash type)
 Remove all components of specific type.
 
void RemoveAllComponents ()
 Remove all components from this node.
 
void ReorderComponent (Component *component, i32 index)
 Adjust index order of an existing component in this node. index can be ENDPOS.
 
NodeClone (CreateMode mode=REPLICATED)
 Clone scene node, components and child nodes. Return the clone.
 
void Remove ()
 Remove from the parent node. If no other shared pointer references exist, causes immediate deletion.
 
void SetParent (Node *parent)
 Assign to a new parent scene node. Retains the world transform.
 
void SetVar (StringHash key, const Variant &value)
 Set a user variable.
 
void AddListener (Component *component)
 Add listener component that is notified of node being dirtied. Can either be in the same node or another.
 
void RemoveListener (Component *component)
 Remove listener component.
 
template<class T >
T * CreateComponent (CreateMode mode=REPLICATED, ComponentId id=0)
 Template version of creating a component.
 
template<class T >
T * GetOrCreateComponent (CreateMode mode=REPLICATED, ComponentId id=0)
 Template version of getting or creating a component.
 
template<class T >
void RemoveComponent ()
 Template version of removing a component.
 
template<class T >
void RemoveComponents ()
 Template version of removing all components of specific type.
 
NodeId GetID () const
 Return ID.
 
bool IsReplicated () const
 Return whether the node is replicated or local to a scene.
 
const StringGetName () const
 Return name.
 
StringHash GetNameHash () const
 Return name hash.
 
const StringVectorGetTags () const
 Return all tags.
 
bool HasTag (const String &tag) const
 Return whether has a specific tag.
 
NodeGetParent () const
 Return parent scene node.
 
SceneGetScene () const
 Return scene.
 
bool IsChildOf (Node *node) const
 Return whether is a direct or indirect child of specified node.
 
bool IsEnabled () const
 Return whether is enabled. Disables nodes effectively disable all their components.
 
bool IsEnabledSelf () const
 Return the node's last own enabled state. May be different than the value returned by IsEnabled when SetDeepEnabled has been used.
 
ConnectionGetOwner () const
 Return owner connection in networking.
 
const Vector3GetPosition () const
 Return position in parent space.
 
Vector2 GetPosition2D () const
 Return position in parent space (for Urho2D).
 
const QuaternionGetRotation () const
 Return rotation in parent space.
 
float GetRotation2D () const
 Return rotation in parent space (for Urho2D).
 
Vector3 GetDirection () const
 Return forward direction in parent space. Positive Z axis equals identity rotation.
 
Vector3 GetUp () const
 Return up direction in parent space. Positive Y axis equals identity rotation.
 
Vector3 GetRight () const
 Return right direction in parent space. Positive X axis equals identity rotation.
 
const Vector3GetScale () const
 Return scale in parent space.
 
Vector2 GetScale2D () const
 Return scale in parent space (for Urho2D).
 
Matrix3x4 GetTransform () const
 Return parent space transform matrix.
 
Vector3 GetWorldPosition () const
 Return position in world space.
 
Vector2 GetWorldPosition2D () const
 Return position in world space (for Urho2D).
 
Quaternion GetWorldRotation () const
 Return rotation in world space.
 
float GetWorldRotation2D () const
 Return rotation in world space (for Urho2D).
 
Vector3 GetWorldDirection () const
 Return direction in world space.
 
Vector3 GetWorldUp () const
 Return node's up vector in world space.
 
Vector3 GetWorldRight () const
 Return node's right vector in world space.
 
Vector3 GetWorldScale () const
 Return scale in world space.
 
Vector3 GetSignedWorldScale () const
 Return signed scale in world space. Utilized for Urho2D physics.
 
Vector2 GetWorldScale2D () const
 Return scale in world space (for Urho2D).
 
const Matrix3x4GetWorldTransform () const
 Return world space transform matrix.
 
Vector3 LocalToWorld (const Vector3 &position) const
 Convert a local space position to world space.
 
Vector3 LocalToWorld (const Vector4 &vector) const
 Convert a local space position or rotation to world space.
 
Vector2 LocalToWorld2D (const Vector2 &vector) const
 Convert a local space position or rotation to world space (for Urho2D).
 
Vector3 WorldToLocal (const Vector3 &position) const
 Convert a world space position to local space.
 
Vector3 WorldToLocal (const Vector4 &vector) const
 Convert a world space position or rotation to local space.
 
Vector2 WorldToLocal2D (const Vector2 &vector) const
 Convert a world space position or rotation to local space (for Urho2D).
 
bool IsDirty () const
 Return whether transform has changed and world transform needs recalculation.
 
i32 GetNumChildren (bool recursive=false) const
 Return number of child scene nodes.
 
const Vector< SharedPtr< Node > > & GetChildren () const
 Return immediate child scene nodes.
 
void GetChildren (Vector< Node * > &dest, bool recursive=false) const
 Return child scene nodes, optionally recursive.
 
Vector< Node * > GetChildren (bool recursive) const
 Return child scene nodes, optionally recursive.
 
void GetChildrenWithComponent (Vector< Node * > &dest, StringHash type, bool recursive=false) const
 Return child scene nodes with a specific component.
 
Vector< Node * > GetChildrenWithComponent (StringHash type, bool recursive=false) const
 Return child scene nodes with a specific component.
 
void GetChildrenWithTag (Vector< Node * > &dest, const String &tag, bool recursive=false) const
 Return child scene nodes with a specific tag.
 
Vector< Node * > GetChildrenWithTag (const String &tag, bool recursive=false) const
 Return child scene nodes with a specific tag.
 
NodeGetChild (i32 index) const
 Return child scene node by index.
 
NodeGetChild (const String &name, bool recursive=false) const
 Return child scene node by name.
 
NodeGetChild (const char *name, bool recursive=false) const
 Return child scene node by name.
 
NodeGetChild (StringHash nameHash, bool recursive=false) const
 Return child scene node by name hash.
 
i32 GetNumComponents () const
 Return number of components.
 
i32 GetNumNetworkComponents () const
 Return number of non-local components.
 
const Vector< SharedPtr< Component > > & GetComponents () const
 Return all components.
 
void GetComponents (Vector< Component * > &dest, StringHash type, bool recursive=false) const
 Return all components of type. Optionally recursive.
 
ComponentGetComponent (StringHash type, bool recursive=false) const
 Return component by type. If there are several, returns the first.
 
ComponentGetParentComponent (StringHash type, bool fullTraversal=false) const
 Return component in parent node. If there are several, returns the first. May optional traverse up to the root node.
 
bool HasComponent (StringHash type) const
 Return whether has a specific component.
 
const Vector< WeakPtr< Component > > GetListeners () const
 Return listener components.
 
const VariantGetVar (StringHash key) const
 Return a user variable.
 
const VariantMapGetVars () const
 Return all user variables.
 
template<class T >
T * GetDerivedComponent (bool recursive=false) const
 Return first component derived from class.
 
template<class T >
T * GetParentDerivedComponent (bool fullTraversal=false) const
 Return first component derived from class in the parent node, or if fully traversing then the first node up the tree with one.
 
template<class T >
void GetDerivedComponents (Vector< T * > &dest, bool recursive=false, bool clearVector=true) const
 Return components derived from class.
 
template<class T >
void GetChildrenWithComponent (Vector< Node * > &dest, bool recursive=false) const
 Template version of returning child nodes with a specific component.
 
template<class T >
T * GetComponent (bool recursive=false) const
 Template version of returning a component by type.
 
template<class T >
T * GetParentComponent (bool fullTraversal=false) const
 Template version of returning a parent's component by type.
 
template<class T >
void GetComponents (Vector< T * > &dest, bool recursive=false) const
 Template version of returning all components of type.
 
template<class T >
bool HasComponent () const
 Template version of checking whether has a specific component.
 
void SetID (NodeId id)
 Set ID. Called by Scene.
 
void SetScene (Scene *scene)
 Set scene. Called by Scene.
 
void ResetScene ()
 Reset scene, ID and owner. Called by Scene.
 
void SetNetPositionAttr (const Vector3 &value)
 Set network position attribute.
 
void SetNetRotationAttr (const Vector< byte > &value)
 Set network rotation attribute.
 
void SetNetParentAttr (const Vector< byte > &value)
 Set network parent attribute.
 
const Vector3GetNetPositionAttr () const
 Return network position attribute.
 
const Vector< byte > & GetNetRotationAttr () const
 Return network rotation attribute.
 
const Vector< byte > & GetNetParentAttr () const
 Return network parent attribute.
 
bool Load (Deserializer &source, SceneResolver &resolver, bool loadChildren=true, bool rewriteIDs=false, CreateMode mode=REPLICATED)
 Load components and optionally load child nodes.
 
bool LoadXML (const XMLElement &source, SceneResolver &resolver, bool loadChildren=true, bool rewriteIDs=false, CreateMode mode=REPLICATED)
 Load components from XML data and optionally load child nodes.
 
bool LoadJSON (const JSONValue &source, SceneResolver &resolver, bool loadChildren=true, bool rewriteIDs=false, CreateMode mode=REPLICATED)
 Load components from XML data and optionally load child nodes.
 
const Vector< Node * > & GetDependencyNodes () const
 Return the depended on nodes to order network updates.
 
void PrepareNetworkUpdate ()
 Prepare network update by comparing attributes and marking replication states dirty as necessary.
 
void CleanupConnection (Connection *connection)
 Clean up all references to a network connection that is about to be removed.
 
void MarkReplicationDirty ()
 Mark node dirty in scene replication states.
 
NodeCreateChild (NodeId id, CreateMode mode, bool temporary=false)
 Create a child node with specific ID.
 
void AddComponent (Component *component, ComponentId id, CreateMode mode)
 Add a pre-created component. Using this function from application code is discouraged, as component operation without an owner node may not be well-defined in all cases. Prefer CreateComponent() instead.
 
i32 GetNumPersistentChildren () const
 Calculate number of non-temporary child nodes.
 
i32 GetNumPersistentComponents () const
 Calculate number of non-temporary components.
 
void SetPositionSilent (const Vector3 &position)
 Set position in parent space silently without marking the node & child nodes dirty. Used by animation code.
 
void SetRotationSilent (const Quaternion &rotation)
 Set position in parent space silently without marking the node & child nodes dirty. Used by animation code.
 
void SetScaleSilent (const Vector3 &scale)
 Set scale in parent space silently without marking the node & child nodes dirty. Used by animation code.
 
void SetTransformSilent (const Vector3 &position, const Quaternion &rotation, const Vector3 &scale)
 Set local transform silently without marking the node & child nodes dirty. Used by animation code.
 
- Public Member Functions inherited from Urho3D::Animatable
 Animatable (Context *context)
 Construct.
 
 ~Animatable () override
 Destruct.
 
bool LoadXML (const XMLElement &source) override
 Load from XML data. Return true if successful. More...
 
bool SaveXML (XMLElement &dest) const override
 Save as XML data. Return true if successful. More...
 
bool LoadJSON (const JSONValue &source) override
 Load from JSON data. Return true if successful. More...
 
bool SaveJSON (JSONValue &dest) const override
 Save as JSON data. Return true if successful. More...
 
void SetAnimationEnabled (bool enable)
 Set automatic update of animation, default true.
 
void SetAnimationTime (float time)
 Set time position of all attribute animations or an object animation manually. Automatic update should be disabled in this case.
 
void SetObjectAnimation (ObjectAnimation *objectAnimation)
 Set object animation.
 
void SetAttributeAnimation (const String &name, ValueAnimation *attributeAnimation, WrapMode wrapMode=WM_LOOP, float speed=1.0f)
 Set attribute animation.
 
void SetAttributeAnimationWrapMode (const String &name, WrapMode wrapMode)
 Set attribute animation wrap mode.
 
void SetAttributeAnimationSpeed (const String &name, float speed)
 Set attribute animation speed.
 
void SetAttributeAnimationTime (const String &name, float time)
 Set attribute animation time position manually. Automatic update should be disabled in this case.
 
void RemoveObjectAnimation ()
 Remove object animation. Same as calling SetObjectAnimation with a null pointer.
 
void RemoveAttributeAnimation (const String &name)
 Remove attribute animation. Same as calling SetAttributeAnimation with a null pointer.
 
bool GetAnimationEnabled () const
 Return animation enabled.
 
ObjectAnimationGetObjectAnimation () const
 Return object animation.
 
ValueAnimationGetAttributeAnimation (const String &name) const
 Return attribute animation.
 
WrapMode GetAttributeAnimationWrapMode (const String &name) const
 Return attribute animation wrap mode.
 
float GetAttributeAnimationSpeed (const String &name) const
 Return attribute animation speed.
 
float GetAttributeAnimationTime (const String &name) const
 Return attribute animation time position.
 
void SetObjectAnimationAttr (const ResourceRef &value)
 Set object animation attribute.
 
ResourceRef GetObjectAnimationAttr () const
 Return object animation attribute.
 
- Public Member Functions inherited from Urho3D::Serializable
 Serializable (Context *context)
 Construct.
 
 ~Serializable () override
 Destruct.
 
virtual void OnSetAttribute (const AttributeInfo &attr, const Variant &src)
 Handle attribute write access. Default implementation writes to the variable at offset, or invokes the set accessor.
 
virtual void OnGetAttribute (const AttributeInfo &attr, Variant &dest) const
 Handle attribute read access. Default implementation reads the variable at offset, or invokes the get accessor.
 
virtual const Vector< AttributeInfo > * GetAttributes () const
 Return attribute descriptions, or null if none defined. More...
 
virtual const Vector< AttributeInfo > * GetNetworkAttributes () const
 Return network replication attribute descriptions, or null if none defined.
 
virtual bool Load (Deserializer &source)
 Load from binary data. Return true if successful. More...
 
virtual bool Save (Serializer &dest) const
 Save as binary data. Return true if successful. More...
 
virtual bool LoadXML (const XMLElement &source)
 Load from XML data. Return true if successful. More...
 
virtual bool SaveXML (XMLElement &dest) const
 Save as XML data. Return true if successful. More...
 
virtual bool LoadJSON (const JSONValue &source)
 Load from JSON data. Return true if successful. More...
 
virtual bool SaveJSON (JSONValue &dest) const
 Save as JSON data. Return true if successful. More...
 
virtual void ApplyAttributes ()
 Apply attribute changes that can not be applied immediately. Called after scene load or a network update. More...
 
virtual bool SaveDefaultAttributes () const
 Return whether should save default-valued attributes into XML. Default false. More...
 
virtual void MarkNetworkUpdate ()
 Mark for attribute check on the next network update. More...
 
bool SetAttribute (unsigned index, const Variant &value)
 Set attribute by index. Return true if successfully set.
 
bool SetAttribute (const String &name, const Variant &value)
 Set attribute by name. Return true if successfully set.
 
void SetInstanceDefault (bool enable)
 Set instance-level default flag.
 
void ResetToDefault ()
 Reset all editable attributes to their default values.
 
void RemoveInstanceDefault ()
 Remove instance's default values if they are set previously.
 
void SetTemporary (bool enable)
 Set temporary flag. Temporary objects will not be saved.
 
void SetInterceptNetworkUpdate (const String &attributeName, bool enable)
 Enable interception of an attribute from network updates. Intercepted attributes are sent as events instead of applying directly. This can be used to implement client side prediction.
 
void AllocateNetworkState ()
 Allocate network attribute state.
 
void WriteInitialDeltaUpdate (Serializer &dest, unsigned char timeStamp)
 Write initial delta network update.
 
void WriteDeltaUpdate (Serializer &dest, const DirtyBits &attributeBits, unsigned char timeStamp)
 Write a delta network update according to dirty attribute bits.
 
void WriteLatestDataUpdate (Serializer &dest, unsigned char timeStamp)
 Write a latest data network update.
 
bool ReadDeltaUpdate (Deserializer &source)
 Read and apply a network delta update. Return true if attributes were changed.
 
bool ReadLatestDataUpdate (Deserializer &source)
 Read and apply a network latest data update. Return true if attributes were changed.
 
Variant GetAttribute (unsigned index) const
 Return attribute value by index. Return empty if illegal index.
 
Variant GetAttribute (const String &name) const
 Return attribute value by name. Return empty if not found.
 
Variant GetAttributeDefault (unsigned index) const
 Return attribute default value by index. Return empty if illegal index.
 
Variant GetAttributeDefault (const String &name) const
 Return attribute default value by name. Return empty if not found.
 
unsigned GetNumAttributes () const
 Return number of attributes.
 
unsigned GetNumNetworkAttributes () const
 Return number of network replication attributes.
 
bool IsTemporary () const
 Return whether is temporary.
 
bool GetInterceptNetworkUpdate (const String &attributeName) const
 Return whether an attribute's network updates are being intercepted.
 
NetworkStateGetNetworkState () const
 Return the network attribute state, if allocated.
 
- Public Member Functions inherited from Urho3D::Object
 Object (Context *context)
 Construct.
 
 ~Object () override
 Destruct. Clean up self from event sender & receiver structures.
 
virtual StringHash GetType () const =0
 Return type hash. More...
 
virtual const StringGetTypeName () const =0
 Return type name. More...
 
virtual const TypeInfoGetTypeInfo () const =0
 Return type info.
 
virtual void OnEvent (Object *sender, StringHash eventType, VariantMap &eventData)
 Handle event.
 
bool IsInstanceOf (StringHash type) const
 Check current instance is type of specified type.
 
bool IsInstanceOf (const TypeInfo *typeInfo) const
 Check current instance is type of specified type.
 
template<typename T >
bool IsInstanceOf () const
 Check current instance is type of specified class.
 
template<typename T >
T * Cast ()
 Cast the object to specified most derived class.
 
template<typename T >
const T * Cast () const
 Cast the object to specified most derived class.
 
void SubscribeToEvent (StringHash eventType, EventHandler *handler)
 Subscribe to an event that can be sent by any sender.
 
void SubscribeToEvent (Object *sender, StringHash eventType, EventHandler *handler)
 Subscribe to a specific sender's event.
 
void SubscribeToEvent (StringHash eventType, const std::function< void(StringHash, VariantMap &)> &function, void *userData=nullptr)
 Subscribe to an event that can be sent by any sender.
 
void SubscribeToEvent (Object *sender, StringHash eventType, const std::function< void(StringHash, VariantMap &)> &function, void *userData=nullptr)
 Subscribe to a specific sender's event.
 
void UnsubscribeFromEvent (StringHash eventType)
 Unsubscribe from an event.
 
void UnsubscribeFromEvent (Object *sender, StringHash eventType)
 Unsubscribe from a specific sender's event.
 
void UnsubscribeFromEvents (Object *sender)
 Unsubscribe from a specific sender's events.
 
void UnsubscribeFromAllEvents ()
 Unsubscribe from all events.
 
void UnsubscribeFromAllEventsExcept (const Vector< StringHash > &exceptions, bool onlyUserData)
 Unsubscribe from all events except those listed, and optionally only those with userdata (script registered events).
 
void SendEvent (StringHash eventType)
 Send event to all subscribers.
 
void SendEvent (StringHash eventType, VariantMap &eventData)
 Send event with parameters to all subscribers.
 
VariantMapGetEventDataMap () const
 Return a preallocated map for event data. Used for optimization to avoid constant re-allocation of event data maps.
 
template<typename... Args>
void SendEvent (StringHash eventType, Args... args)
 Send event with variadic parameter pairs to all subscribers. The parameter pairs is a list of paramID and paramValue separated by comma, one pair after another.
 
ContextGetContext () const
 Return execution context.
 
const VariantGetGlobalVar (StringHash key) const
 Return global variable based on key.
 
const VariantMapGetGlobalVars () const
 Return all global variables.
 
void SetGlobalVar (StringHash key, const Variant &value)
 Set global variable with the respective key and value.
 
ObjectGetSubsystem (StringHash type) const
 Return subsystem by type.
 
ObjectGetEventSender () const
 Return active event sender. Null outside event handling.
 
EventHandlerGetEventHandler () const
 Return active event handler. Null outside event handling.
 
bool HasSubscribedToEvent (StringHash eventType) const
 Return whether has subscribed to an event without specific sender.
 
bool HasSubscribedToEvent (Object *sender, StringHash eventType) const
 Return whether has subscribed to a specific sender's event.
 
bool HasEventHandlers () const
 Return whether has subscribed to any event.
 
template<class T >
T * GetSubsystem () const
 Template version of returning a subsystem.
 
const StringGetCategory () const
 Return object category. Categories are (optionally) registered along with the object factory. Return an empty string if the object category is not registered.
 
void SetBlockEvents (bool block)
 Block object from sending and receiving events.
 
bool GetBlockEvents () const
 Return sending and receiving events blocking status.
 
- Public Member Functions inherited from Urho3D::RefCounted
 RefCounted ()
 Construct. Allocate the reference count structure and set an initial self weak reference.
 
virtual ~RefCounted ()
 Destruct. Mark as expired and also delete the reference count structure if no outside weak references exist.
 
 RefCounted (const RefCounted &rhs)=delete
 Prevent copy construction.
 
RefCountedoperator= (const RefCounted &rhs)=delete
 Prevent assignment.
 
void AddRef ()
 Increment reference count. Can also be called outside of a SharedPtr for traditional reference counting.
 
void ReleaseRef ()
 Decrement reference count and delete self if no more references. Can also be called outside of a SharedPtr for traditional reference counting.
 
int Refs () const
 Return reference count.
 
int WeakRefs () const
 Return weak reference count.
 
RefCountRefCountPtr ()
 Return pointer to the reference count structure.
 

Static Public Member Functions

static void RegisterObject (Context *context)
 Register object factory. Node must be registered first.
 
static bool IsReplicatedID (id32 id)
 Return whether the specified id is a replicated id.
 
- Static Public Member Functions inherited from Urho3D::Node
static void RegisterObject (Context *context)
 Register object factory.
 
- Static Public Member Functions inherited from Urho3D::Animatable
static void RegisterObject (Context *context)
 Register object factory.
 
- Static Public Member Functions inherited from Urho3D::Object
static const TypeInfoGetTypeInfoStatic ()
 Return type info static.
 

Private Member Functions

 URHO3D_OBJECT (Scene, Node)
 
void HandleUpdate (StringHash eventType, VariantMap &eventData)
 Handle the logic update event to update the scene, if active.
 
void HandleResourceBackgroundLoaded (StringHash eventType, VariantMap &eventData)
 Handle a background loaded resource completing.
 
void UpdateAsyncLoading ()
 Update asynchronous loading. More...
 
void FinishAsyncLoading ()
 Finish asynchronous loading.
 
void FinishLoading (Deserializer *source)
 Finish loading. Sets the scene filename and checksum.
 
void FinishSaving (Serializer *dest) const
 Finish saving. Sets the scene filename and checksum.
 
void PreloadResources (File *file, bool isSceneFile)
 Preload resources from a binary scene or object prefab file.
 
void PreloadResourcesXML (const XMLElement &element)
 Preload resources from an XML scene or object prefab file.
 
void PreloadResourcesJSON (const JSONValue &value)
 Preload resources from a JSON scene or object prefab file.
 

Private Attributes

HashMap< NodeId, Node * > replicatedNodes_
 Replicated scene nodes by ID.
 
HashMap< NodeId, Node * > localNodes_
 Local scene nodes by ID.
 
HashMap< ComponentId, Component * > replicatedComponents_
 Replicated components by ID.
 
HashMap< ComponentId, Component * > localComponents_
 Local components by ID.
 
HashMap< StringHash, Vector< Node * > > taggedNodes_
 Cached tagged nodes by tag.
 
AsyncProgress asyncProgress_
 Asynchronous loading progress.
 
SceneResolver resolver_
 Node and component ID resolver for asynchronous loading.
 
String fileName_
 Source file name.
 
Vector< SharedPtr< PackageFile > > requiredPackageFiles_
 Required package files for networking.
 
HashMap< StringHash, StringvarNames_
 Registered node user variable reverse mappings.
 
HashSet< NodeId > networkUpdateNodes_
 Nodes to check for attribute changes on the next network update.
 
HashSet< ComponentId > networkUpdateComponents_
 Components to check for attribute changes on the next network update.
 
Vector< Component * > delayedDirtyComponents_
 Delayed dirty notification queue for components.
 
Mutex sceneMutex_
 Mutex for the delayed dirty notification queue.
 
VariantMap smoothingData_
 Preallocated event data map for smoothing update events.
 
NodeId replicatedNodeID_
 Next free non-local node ID.
 
ComponentId replicatedComponentID_
 Next free non-local component ID.
 
NodeId localNodeID_
 Next free local node ID.
 
ComponentId localComponentID_
 Next free local component ID.
 
hash32 checksum_
 Scene source file checksum.
 
int asyncLoadingMs_
 Maximum milliseconds per frame to spend on async scene loading.
 
float timeScale_
 Scene update time scale.
 
float elapsedTime_
 Elapsed time accumulator.
 
float smoothingConstant_
 Motion smoothing constant.
 
float snapThreshold_
 Motion smoothing snap threshold.
 
bool updateEnabled_
 Update enabled flag.
 
bool asyncLoading_
 Asynchronous loading flag.
 
bool threadedUpdate_
 Threaded update flag.
 

Additional Inherited Members

- Protected Member Functions inherited from Urho3D::Node
void OnAttributeAnimationAdded () override
 Handle attribute animation added. More...
 
void OnAttributeAnimationRemoved () override
 Handle attribute animation removed. More...
 
AnimatableFindAttributeAnimationTarget (const String &name, String &outName) override
 Find target of an attribute animation from object hierarchy by name. More...
 
- Protected Member Functions inherited from Urho3D::Animatable
virtual void OnAttributeAnimationAdded ()=0
 Handle attribute animation added. More...
 
virtual void OnAttributeAnimationRemoved ()=0
 Handle attribute animation removed. More...
 
virtual AnimatableFindAttributeAnimationTarget (const String &name, String &outName)
 Find target of an attribute animation from object hierarchy by name. More...
 
void SetObjectAttributeAnimation (const String &name, ValueAnimation *attributeAnimation, WrapMode wrapMode, float speed)
 Set object attribute animation internal.
 
void OnObjectAnimationAdded (ObjectAnimation *objectAnimation)
 Handle object animation added.
 
void OnObjectAnimationRemoved (ObjectAnimation *objectAnimation)
 Handle object animation removed.
 
void UpdateAttributeAnimations (float timeStep)
 Update attribute animations.
 
bool IsAnimatedNetworkAttribute (const AttributeInfo &attrInfo) const
 Is animated network attribute.
 
AttributeAnimationInfoGetAttributeAnimationInfo (const String &name) const
 Return attribute animation info.
 
void HandleAttributeAnimationAdded (StringHash eventType, VariantMap &eventData)
 Handle attribute animation added.
 
void HandleAttributeAnimationRemoved (StringHash eventType, VariantMap &eventData)
 Handle attribute animation removed.
 
- Protected Attributes inherited from Urho3D::Node
bool networkUpdate_
 Network update queued flag.
 
VariantMap vars_
 User variables.
 
- Protected Attributes inherited from Urho3D::Animatable
bool animationEnabled_
 Animation enabled.
 
SharedPtr< ObjectAnimationobjectAnimation_
 Animation.
 
HashSet< const AttributeInfo * > animatedNetworkAttributes_
 Animated network attribute set.
 
HashMap< String, SharedPtr< AttributeAnimationInfo > > attributeAnimationInfos_
 Attribute animation infos.
 
- Protected Attributes inherited from Urho3D::Serializable
std::unique_ptr< NetworkStatenetworkState_
 Network attribute state.
 
- Protected Attributes inherited from Urho3D::Object
Contextcontext_
 Execution context.
 

Detailed Description

Root scene node, represents the whole scene.

Member Function Documentation

◆ AddReplicationState()

void Urho3D::Scene::AddReplicationState ( NodeReplicationState state)
overridevirtual

Add a replication state that is tracking this scene.

Reimplemented from Urho3D::Node.

◆ Load()

bool Urho3D::Scene::Load ( Deserializer source)
overridevirtual

Load from binary data. Removes all existing child nodes and components first. Return true if successful.

Reimplemented from Urho3D::Node.

◆ LoadJSON()

bool Urho3D::Scene::LoadJSON ( const JSONValue source)
overridevirtual

Load from JSON data. Removes all existing child nodes and components first. Return true if successful.

Reimplemented from Urho3D::Node.

◆ LoadXML()

bool Urho3D::Scene::LoadXML ( const XMLElement source)
overridevirtual

Load from XML data. Removes all existing child nodes and components first. Return true if successful.

Reimplemented from Urho3D::Node.

◆ MarkNetworkUpdate()

void Urho3D::Scene::MarkNetworkUpdate ( )
overridevirtual

Mark for attribute check on the next network update.

Reimplemented from Urho3D::Node.

◆ Save()

bool Urho3D::Scene::Save ( Serializer dest) const
overridevirtual

Save to binary data. Return true if successful.

Reimplemented from Urho3D::Node.

◆ SaveJSON()

bool Urho3D::Node::SaveJSON ( JSONValue dest) const
overridevirtual

Save as JSON data. Return true if successful.

Reimplemented from Urho3D::Node.

◆ SaveXML()

bool Urho3D::Node::SaveXML ( XMLElement dest) const
overridevirtual

Save as XML data. Return true if successful.

Reimplemented from Urho3D::Node.

◆ UpdateAsyncLoading()

void Urho3D::Scene::UpdateAsyncLoading ( )
private

Update asynchronous loading.

Todo:
Works poorly in scenes where one root-level child node contains all content

The documentation for this class was generated from the following files: