Classes

Scene/Objects

Brief descriptions

Classes

nau::scene_internal::ObjectWeakRefBase

nau::scene::NauObject

Base class for any scene-related object.

nau::scene::ObjectUniquePtr

Incapsulates unique pointer to a NauObject instance.

nau::scene::ObjectWeakRef

nau::scene_internal::RuntimeObjectWeakRefValueImpl

nau::scene::SceneObject

An object that can be placed at a scene

Structures

nau::scene::RuntimeObjectWeakRefValue

Detailed information

scene_internal::ObjectWeakRefBase

engine/core/modules/scene/include/nau/scene/nau_object.h

class ObjectWeakRefBase : public eastl::intrusive_list_node

Base class for a weak reference to a NauObject instance.

An ObjectWeakRefBase object maintains reference count on binding/unbinding the referenced object. It is not responsible for memory deallocation on destruction of the referenced object. See also: ObjectUniquePtr.

Subclassed by nau::scene::ObjectWeakRef< nau::physics::RigidBodyComponent >, nau::scene::ObjectWeakRef< nau::scene::SceneObject >, nau::scene::ObjectWeakRef< T >

Protected Functions

~ObjectWeakRefBase()

Destructor.

ObjectWeakRefBase() = default

Default constructor.

Leaves the reference set to NULL.

ObjectWeakRefBase(scene::NauObject *object)

Initialization constructor.

Binds the reference to object.

ObjectWeakRefBase(const ObjectWeakRefBase&)

Copy constructor.

Binds the refence to the object referenced by other.

Parameters:

other[in] Another reference to the object.

ObjectWeakRefBase &operator=(const ObjectWeakRefBase&)

Assignment operator.

Unbinds the reference from the currently referenced object and binds it to the object referenced by right.

Parameters:

right[in] Assigned object.

Returns:

A reference to the resulted object.

bool equals(const ObjectWeakRefBase &other) const

Checks whether two ObjectWeakRefBase instances reference the same object.

Parameters:

other[in] Instance to compare this reference with.

Returns:

true if both references are bound to the same object.

void reset(scene::NauObject *object = nullptr)

Resets the reference and possibly binds it to a different object.

Parameters:

newObject[in] A pointer to the object to bind the reference to. NULL can be passed to render the reference unbound.

template<typename T = scene::NauObject>
inline T *getMutableTypedPtr() const

Retrieves a non-const pointer to the referenced object.

Template Parameters:

T – Type of the output. It has to be either statically convertible to NauObject or RTTI-castable to NauObject.

Returns:

Retrieved pointer to the referenced object.

inline scene::NauObject *getMutableNauObjectPtr() const

Retrieves a non-const pointer to the referenced object.

Returns:

Retrieved pointer to the referenced object.

inline bool refIsValid() const

Checks whether the reference is valid.

Returns:

true if the refence is valied (i.e. the bound object can be safely obtained from it), false otherwise.

Private Functions

inline void notifyReferencedObjectDestroyed()

Called upon the referenced object destruction.

Private Members

scene::NauObject *m_object = nullptr
eastl::optional<scene::SceneQuery> m_objectQuery

Friends

friend class scene::NauObject
friend class scene::ObjectWeakRef
friend class RuntimeObjectWeakRefValueImpl

scene::NauObject

engine/core/modules/scene/include/nau/scene/nau_object.h

class NauObject : public virtual IRttiObject

Base class for any scene-related object.

This class supports reference counting mechanism when the object is addressed using ObjectWeakRefю

Subclassed by nau::scene::Component, nau::scene::IScene, nau::scene::IWorld, nau::scene::SceneObject

Protected Functions

void deleteObjectNow()

Immediately unbinds all references from the object and destroys it, effectively deallocating memory.

void clearAllWeakReferences()

Unbinds all weak references from the object.

virtual void onBeforeDeleteObject()

Private Types

using DestructorFunc = void *(*)(NauObject *self) noexcept

Private Functions

inline  IRttiObject (1(m_uid, "uid")) public

Constructs an object.

Template Parameters:
  • T – Type of the object to construct. It has to be derived from NauObject.

  • A – Parameter pack for the object constructor.

Parameters:
  • allocator[in] Allocator to use for costructing the object. If NULL is passed, the default allocator is going to be used.

  • a[in] Object constructor arguments.

Returns:

A pointer to the constructed object.

virtual ~NauObject()

Destructor.

Uid getUid() const

Retrieves the identifier of the object.

Returns:

UID of the object.

void setUid(Uid)

Assigns an identifier to the object.

Parameters:

uid[in] Identifier to assign.

virtual void destroy()

Immediately unbinds all references from the object and destroys it, effectively deallocating memory.

void addReference(scene_internal::ObjectWeakRefBase &reference)

Adds the reference from the list.

Parameters:

reference[in] Reference to add.

void removeReference(scene_internal::ObjectWeakRefBase &reference)

Removes the reference from the list.

Parameters:

reference[in] Reference to remove.

inline void setHasPtrOwner(bool hasPtrOwner)

Private Members

bool m_hasPtrOwner = false
eastl::intrusive_list<scene_internal::ObjectWeakRefBase> m_references

List of references bound to the object.

IMemAllocator *m_allocator = nullptr
void *m_allocationAddress = nullptr
DestructorFunc m_destructorFunc
Uid m_uid

< Called upon the actual object destruction.

Friends

friend class SceneManagerImpl
friend class ObjectUniquePtr
friend class ObjectWeakRef
friend class scene_internal::ObjectWeakRefBase

scene::ObjectUniquePtr

engine/core/modules/scene/include/nau/scene/nau_object.h

template<typename T>
class ObjectUniquePtr

Incapsulates unique pointer to a NauObject instance.

Apart from standard unique_ptr functionality (RAII support, unique ownership) it can provide non-owning access to the managed object to ObjectWeakRef instances.

Public Functions

inline ~ObjectUniquePtr()

Destructor.

Note

Calling this does not destroy the object. Instead it decrements its reference count.

ObjectUniquePtr() = default

Default construtor.

ObjectUniquePtr(const ObjectUniquePtr&) = delete

Copy constructor (deleted).

inline ObjectUniquePtr(T *object)

Initialization constructor.

Parameters:

object[in] Object to be managed by the smart pointer.

inline ObjectUniquePtr(std::nullptr_t)
inline ObjectUniquePtr(ObjectUniquePtr &&other)

Move constructor.

Parameters:

other[in] Smart pointer to move from.

template<typename U>
inline ObjectUniquePtr(ObjectUniquePtr<U> &&other)

Move constructor.

Template Parameters:

U – Type of the object managed by another smart pointer.

Parameters:

other[in] Smart pointer to move the ownership from.

ObjectUniquePtr &operator=(const ObjectUniquePtr&) = delete

Copy-assignment operator (deleted).

inline ObjectUniquePtr &operator=(std::nullptr_t)
inline ObjectUniquePtr &operator=(ObjectUniquePtr &&other)

Move-assignment operator.

Parameters:

other[in] Smart pointer to move the ownership from.

Returns:

Resulted smart pointer.

template<typename U>
inline ObjectUniquePtr &operator=(ObjectUniquePtr<U> &&other)

Move-assignment operator.

Template Parameters:

U – Type of the object managed by abother smart pointer.

Parameters:

other[in] Smart pointer to move the ownership from.

Returns:

Resulted smart pointer.

inline explicit operator bool() const

Checks whether the smart pointer manages an object.

Returns:

true if the smart pointer manages an object (i.e. it can be safely derefenced), false otherwise.

inline T *operator->() const

Provides access to the managed object.

Returns:

A pointer to the managed object.

inline T &operator*() const

Provides access to the managed object.

Returns:

A reference to the managed object.

inline T *get() const

Provides access to the managed object.

Returns:

A pointer to the managed object.

ObjectWeakRef<T> getRef() const

Constructs an ObjectWeakRef instance from the bound object.

@endskip

Returns:

Consturcted reference object.

inline void reset(T *newObject = nullptr)

Resets the pointer possibly binding it to a different object.

Parameters:

newObject[in] A pointer to the object to bind the smart pointer to. NULL can be passed to render the reference ‘dangling’.

inline T *giveUp()

Orders the pointer to give up exclusive ownership of the object.

Note

Calling this renders the pointer ‘dangling’. That means the smart pointer is no more responsible for the object destruction.

Returns:

A pointer to the managed (prior to the call) object.

Private Members

T *m_object = nullptr

Friends

friend class ObjectUniquePtr

scene::ObjectWeakRef

engine/core/modules/scene/include/nau/scene/nau_object.h

template<typename T>
class ObjectWeakRef : public nau::scene_internal::ObjectWeakRefBase

@endskip Encapsulates a weak reference (typed) to a NauObject instance.

Public Functions

~ObjectWeakRef() = default

Destructor.

ObjectWeakRef() = default

Default constructor.

inline ObjectWeakRef(T &object)

Initialization constructor.

Binds the reference to object.

Parameters:

object[in] Object to bind the reference to.

inline ObjectWeakRef(T *object)

Initialization constructor.

Binds the reference to object.

Parameters:

object[in] A pointer to the object to bind the reference to.

template<typename U>
inline ObjectWeakRef(U &object)

Initialization constructor.

Binds the reference to object.

Template Parameters:

U – Type of the object to bind the reference to.

Parameters:

object[in] Object to bind the reference to.

inline ObjectWeakRef(std::nullptr_t)
inline ObjectWeakRef(const ObjectWeakRef<T> &other)

Copy constructor.

Binds the reference to the object bound to other.

Parameters:

other[in] Another reference.

template<typename U>
inline ObjectWeakRef(const ObjectWeakRef<U> &other)

Copy constructor.

Binds the reference to the object bound to other.

Template Parameters:

U – Type of the object bound to another reference.

Parameters:

other[in] Another reference.

inline ObjectWeakRef &operator=(T &object)

Assignment operator.

Binds the reference to object.

Parameters:

object[in] Object to bind the reference to.

Returns:

Result reference object.

template<typename U>
inline ObjectWeakRef &operator=(U &object)

Assignment operator.

Binds the reference to object.

Template Parameters:

U – Type of the object to bind the reference to.

Parameters:

object[in] Object to bind the reference to.

Returns:

Resulted reference object.

inline ObjectWeakRef &operator=(std::nullptr_t)
inline ObjectWeakRef &operator=(const ObjectWeakRef<T> &other)

Assignment operator.

Binds the reference to the object referenced by other.

Parameters:

other[in] Another reference.

Returns:

Resulted reference object.

template<typename U>
inline ObjectWeakRef &operator=(const ObjectWeakRef<U> &other)

Assignment operator.

Binds the reference to the object referenced by other.

Template Parameters:

U – Type of the object to bind the reference to.

Parameters:

other[in] Another reference.

Returns:

Resulted reference object.

inline explicit operator bool() const

Checks if the refence is valid.

Returns:

true if the reference is valid (i.e. an object can be obtained from it), false otherwise.

inline T *operator->()

Provides non-const access to the referenced object.

Returns:

A pointer to the referenced object.

inline const T *operator->() const

Provides const access to the referenced object.

Returns:

A pointer to the referenced object.

inline T &operator*()

Provides non-const access to the referenced object.

Returns:

A reference to the bound object.

inline const T &operator*() const

Provides const access to the referenced object.

Returns:

A reference to the bound object.

inline T *get()

Provides non-const access to the referenced object.

Returns:

A pointer to the referenced object.

inline const T *get() const

Provides const access to the referenced object.

Returns:

A pointer to the referenced object.

template<typename U>
inline bool operator==(const ObjectWeakRef<U> &other) const

Checks whether two ObjectWeakRef instances reference the same object.

Parameters:

other[in] Instance to compare this reference with.

Returns:

true if both references are bound to the same object.

Private Types

using Base = scene_internal::ObjectWeakRefBase

scene_internal::RuntimeObjectWeakRefValueImpl

engine/core/modules/scene/include/nau/scene/nau_object.h

class RuntimeObjectWeakRefValueImpl : public ser_detail::NativePrimitiveRuntimeValueBase<scene::RuntimeObjectWeakRefValue>, public RuntimeStringValue

Public Types

using CopyCtorTag = TypeTag<int>

Public Functions

~RuntimeObjectWeakRefValueImpl()
RuntimeObjectWeakRefValueImpl()
explicit RuntimeObjectWeakRefValueImpl(const scene_internal::ObjectWeakRefBase&, CopyCtorTag)
explicit RuntimeObjectWeakRefValueImpl(const scene_internal::ObjectWeakRefBase&)
explicit RuntimeObjectWeakRefValueImpl(scene_internal::ObjectWeakRefBase&)
RuntimeObjectWeakRefValueImpl(const RuntimeObjectWeakRefValue&) = delete
RuntimeObjectWeakRefValueImpl &operator=(const RuntimeObjectWeakRefValueImpl&) = delete
bool isMutable() const override
Result setString(std::string_view str) override
std::string getString() const override

Private Types

using Base = ser_detail::NativePrimitiveRuntimeValueBase<scene::RuntimeObjectWeakRefValue>
using WeakRefStorage = std::aligned_storage_t<sizeof(scene_internal::ObjectWeakRefBase), alignof(scene_internal::ObjectWeakRefBase)>

Private Functions

scene::SceneQuery getObjectQuery() const override
bool isAssignable(const scene::NauObject &object) const override
scene::ObjectWeakRef getObjectWeakRefInternal() override
void setObjectWeakRefInternal(scene::ObjectWeakRef<> weakRef) override

Private Members

const bool m_isMutable
WeakRefStorage m_weakRefStorage
scene_internal::ObjectWeakRefBase *const m_weakRef

Private Static Functions

static scene_internal::ObjectWeakRefBase *allocateInternalStorage(WeakRefStorage&, const scene_internal::ObjectWeakRefBase&)

scene::SceneObject

engine/core/modules/scene/include/nau/scene/scene_object.h

class SceneObject : public nau::scene::NauObject, public nau::scene::TransformControl, public eastl::intrusive_list_node

An object that can be placed at a scene.

Public Types

using Ptr = ObjectUniquePtr<SceneObject>
using WeakRef = ObjectWeakRef<SceneObject>
using WalkObjectsCallback = bool (*)(SceneObject &object, void *callbackData)
using WalkComponentsCallback = bool (*)(Component &component, void *callbackData)
using WalkConstComponentsCallback = bool (*)(const Component &component, void *callbackData)

Public Functions

SceneObject() = delete

Default constructor (deleted).

SceneObject(ObjectUniquePtr<SceneComponent> &&rootComponent)

Initialization constructor.

Parameters:

rootComponent[in] Object root component. See m_rootComponent.

SceneObject(const SceneObject&) = delete

Copy constructor (deleted).

~SceneObject()

Destructor.

virtual void destroy() final

Destroys object’s children, components and then the object itself.

If the object is not attached to the scene (i.e. it is inactive), calling this will remove all weak references to the object as well ass to its children and components. Given that the object is owned by a ObjectUniquePtr

instance, the smart pointer is responsible for its destruction. Otherwise the object is destructed immediately.

If the object is attached to the scene all weak references to self, object’s children and components are removed as well. However, no sooner all async operations over the object’s components are finished than the actual destruction occurs.

eastl::string_view getName() const

Retrieves the object name.

Returns:

Name of the scene object.

void setName(eastl::string_view name)

Assigns name to the scene object.

Parameters:

name[in] name to assign.

IScene *getScene() const

Retrives the scene which the object is attached to.

Returns:

Scene which the object is attached to.

ActivationState getActivationState() const

Retrieves the object activation state.

Returns:

Activation state of the object.

SceneObject::Ptr clone() const
SceneObject *getParentObject() const

Retrieves the parent of the object.

Returns:

Parent object or NULL if the object does not have a parent.

template<std::derived_from<Component> ComponentType = SceneComponent>
ComponentType &getRootComponent()

Provides mutable access to the root component of the object.

Template Parameters:

ComponentType – Type of the root component. It has to be derived from SceneComponent.

Returns:

Object root component. See m_rootComponent.

template<std::derived_from<Component> ComponentType = SceneComponent>
const ComponentType &getRootComponent() const

Provides const access to the root component of the object.

Template Parameters:

ComponentType – Type of the root component. It has to be derived from SceneComponent.

Returns:

Object root component. See m_rootComponent.

SceneObject &attachChild(SceneObject::Ptr &&childObject)

Attaches an object as a child.

As a result of the call ownership of the attached object is transferred to the parent.

Note

This is a syncronous operation. For async analog see attachChildAsync.

Parameters:

childObject[in] A pointer to the object to attach.

Returns:

Child object.

async::Task<ObjectWeakRef<SceneObject>> attachChildAsync(SceneObject::Ptr &&childObject)

Asynchronously attaches an object as a child.

As a result of the operation ownership of the attached object is transferred to the parent. Also, given that the parent is active, the child get activated as well.

Note

For a synchronous analog see attachChild.

Parameters:

childObject[in] A pointer to the object to attach.

Returns:

Task object providing operation status.

void removeChild(ObjectWeakRef<SceneObject> childRef)

Destroys the specified child object.

The child object will actually be deleted only after all its component have been deactivated and all async operations over it have been finished (see removeComponent for more details).

Parameters:

childRef[in] Object to detach.

void setParent(SceneObject &newParent, SetParentOptsFlag options = {})

Assigns a parent to the scene object.

The method does not trigger any events related to the activation and deactivation of the component nor it initializes any resources. The change of parent only happens within the scene hierarchy.

Note

You can assign a parent to the object only provided that their activation states are identical.

Note

By default the system will save the world transform and adjjust the local transform relatively to the new parent. If this is not desired, pass DontKeepWorldTransform flag for options.

Parameters:
  • newParent[in] Parent object to assing.

  • options[in] Options to apply during the operation.

void walkChildObjects(WalkObjectsCallback callback, void *callbackData, bool walkRecursive)

Iterates through the child objects and applies a callback.

Note

callback has to return boolean which indicates whether iteration should proceed, i.e. if applying it to a child object returned false, the iteration stops.

Parameters:
  • callback[in] Callable object to apply to each iterated child object.

  • callbackData[in] Callback input data.

  • walkRecursive[in] If false is passed, the function iterates only through first-order descendants (i.e. children, not “grandchildren”, “great-grandchildren” etc.). Otherwise, the function iterates through all children.

Vector<SceneObject*> getChildObjects(bool recursive)

Retrieves object’s children.

Parameters:

recursive[in] If false is passed, the function retrieves only first-order descendants (i.e. children, not “grandchildren”, “great-grandchildren” etc.). Otherwise, the function retrieves all children.

Returns:

A collection of object’s children.

Vector<SceneObject*> getDirectChildObjects()

Retrieves object’s first order descendants (i.e. children, not “grandchildren”, “great-grandchildren” etc.).

To retrieve higher-order descendants (grandchildren”, “great-grandchildren” etc.) use getAllChildObjects.

Returns:

A collection of object’s children.

Vector<SceneObject*> getAllChildObjects()

Retrieves all object’s children.

To retrieve only first-order (direct) descendants use getDirectChildObjects.

Returns:

A collection of object’s children.

Component &addComponent(const rtti::TypeInfo &type, Functor<void(Component&)> initializer = nullptr)

Attaches the component to the object.

This is synchronous operation. See also: addComponentAsync(const rtti::TypeInfo&)

Parameters:

type[in] Component type information.

Returns:

Attached component.

template<std::derived_from<Component> ComponentType>
ComponentType &addComponent(Functor<void(ComponentType&)> initializer = nullptr)

Attaches the component to the object.

This is synchronous operation. See also: addComponentAsync().

Template Parameters:

ComponentType – Type of the component to attach. It has to be derived from Component.

Returns:

Attached component.

async::Task<ObjectWeakRef<Component>> addComponentAsync(const rtti::TypeInfo &type, Functor<void(Component&)> initializer = nullptr)

Attaches the component to the object.

This is asynchronous operation. See also: getComponent(const rtti::TypeInfo&).

Parameters:

type[in] Component type information.

Returns:

Attached component.

template<std::derived_from<Component> ComponentType>
async::Task<ObjectWeakRef<ComponentType>> addComponentAsync(Functor<void(ComponentType&)> initializer = nullptr)

Attaches the component to the object.

This is asynchronous operation. See also: addComponent().

Template Parameters:

ComponentType – Type of the component to attach. It has to be derived from Component.

Returns:

Attached component.

void removeComponent(ObjectWeakRef<Component> componentRef)

Removes the specified components from the scene object.

Internally component removal is asynchronous operation with multiple phases. 1.

  • A component can actually be removed from scene only from outside of the current update call. 2.

  • At the post-update stage IComponentActivation::deactivateComponent or IComponentAsyncActivation::deactivateComponentAsync will be called. Also IComponentsActivator/IComponentsAsyncActivator starts processing component’s deactivation.

  • The deactivation phase runs without blocking the update for some time. During the deactivation phase component is still a part of scene, however it is not updated anymore. 3.

  • After the deactivation has been finished the component is detached from scene (i.e. removed from the parent object).

  • The system deletes the component instance only after all async operations associated with it has been completed.

Parameters:

componentRef[in] Component to remove.

void walkComponents(WalkComponentsCallback callback, void *callbackData, bool walkRecursive, const rtti::TypeInfo *componentType = nullptr)

Iterates through the components (including its root component) of the object and its children and applies a callback.

Note

callback has to return boolean which indicates whether iteration should proceed, i.e. if applying it to a component returned false, the iteration stops.

Parameters:
  • callback[in] Callable object to apply to each iterated component.

  • callbackData[in] Callback input data.

  • walkRecursive[in] If false is passed, the function iterates only through the components that are attached to the object. Otherwise, the function iterates through the components of each child recursively.

  • componentType[in] Type of the components to apply callback to.

void walkComponents(WalkConstComponentsCallback callback, void *callbackData, bool walkRecursive, const rtti::TypeInfo *componentType = nullptr) const

Iterates through the components (including its root component) of the object and its children and applies a callback.

Note

callback has to return boolean which indicates whether iteration should proceed, i.e. if applying it to a component returned false, the iteration stops.

Parameters:
  • callback[in] Callable object to apply to each iterated component.

  • callbackData[in] Callback input data.

  • walkRecursive[in] If false is passed, the function iterates only through the components that are attached to the object. Otherwise, the function iterates through the components of each child recursively.

  • componentType[in] Type of the components to apply callback to. If NULL is passed, all components are visited.

Vector<Component*> getComponents(bool recursive, const rtti::TypeInfo *componentType = nullptr)

Retrieves object components.

Parameters:
  • recursive[in] If false is passed, the function retrieves only the components that are attached to the object. Otherwise, the function retrieves the components of all children recursively.

  • componentType[in] Type of the components to retrieve. If NULL is passed, all components are retrieved.

Returns:

A collection of object components.

Vector<const Component*> getComponents(bool recursive, const rtti::TypeInfo *componentType = nullptr) const

Retrieves object components.

Parameters:
  • recursive[in] If false is passed, the function retrieves only the components that are attached to the object. Otherwise, the function retrieves the components of all children recursively.

  • componentType[in] Type of the components to retrieve. If NULL is passed, all components are retrieved.

Returns:

A collection of object components.

template<std::derived_from<Component> ComponentType = Component>
Vector<Component*> getDirectComponents()

Retrieves object components.

Note

The function only returns components that are attached to the calling object. If you are interested in children’s components as well, use getAllComponents.

Template Parameters:

ComponentType – Type of components to retrieve. It has to be a subclass of Component.

Returns:

A collection of object components.

template<std::derived_from<Component> ComponentType = Component>
Vector<const Component*> getDirectComponents() const

Retrieves object components.

Note

The function only returns components that are attached to the calling object. If you are interested in children’s components as well, use getAllComponents.

Template Parameters:

ComponentType – Type of components to retrieve. It has to be a subclass of Component.

Returns:

A collection of object components.

template<std::derived_from<Component> ComponentType = Component>
Vector<Component*> getAllComponents()

Retrieves object components.

Note

The function returns components attached to the calling object as well as to its children. If you only are interested in the former, use getDirectComponents.

Template Parameters:

ComponentType – Type of components to retrieve. It has to be a subclass of Component.

Returns:

A collection of object components.

template<std::derived_from<Component> ComponentType = Component>
Vector<const Component*> getAllComponents() const

Retrieves object components.

Note

The function returns components attached to the calling object as well as to its children. If you only are interested in the former, use getDirectComponents.

Template Parameters:

ComponentType – Type of components to retrieve. It has to be a subclass of Component.

Returns:

A collection of object components.

Component *findFirstComponent(const rtti::TypeInfo &type, bool recursive = false)

Searches for a component of the specified type among the components of the calling object and its children.

Parameters:
  • type[in] Type of the component to retrieve.

  • recursive[in] If false is passed, the component is looked for only among the components attached to the calling object. Otherwise, the seach is conducted recursively among its children as well.

Returns:

A pointer to the retrieved component.

template<std::derived_from<Component> ComponentType>
ComponentType *findFirstComponent(bool recursive = false)

Searches for a component of the specified type among the components of the calling object and its children.

Template Parameters:

ComponentType – Type of the component to retrieve. It has to be a subclass of Component.

Parameters:

recursive[in] If false is passed, the component is looked for only among the components attached to the calling object. Otherwise, the seach is conducted recursively among its children as well.

Returns:

A pointer to the retrieved component.

virtual const math::Transform &getWorldTransform() const final

Retrieves object world transformation.

Returns:

Object transformation in world coordinates.

virtual void setWorldTransform(const math::Transform &transform) final

Sets object transform in world coordinates.

Parameters:

transform[in] Transform to assign.

virtual const math::Transform &getTransform() const final

Retrieves object local transformation.

Returns:

Object transformation with respect to its parent.

virtual void setTransform(const math::Transform &transform) final

Sets object transform relative to its parent.

Parameters:

transform[in] Transform to assign.

virtual void setRotation(math::quat rotation) final

Sets object rotation relative to its parent.

Parameters:

transform[in] Transform to assign.

virtual void setTranslation(math::vec3 position) final

Sets object translation relative to its parent.

Parameters:

transform[in] Transform to assign.

virtual void setScale(math::vec3 scale) final

Sets object scale relative to its parent.

Parameters:

transform[in] Transform to assign.

virtual math::quat getRotation() const final

Retrieves object local rotation.

Returns:

Object rotation with respect to its parent.

virtual math::vec3 getTranslation() const final

Retrieves object local translation.

Returns:

Object translation with respect to its parent.

virtual math::vec3 getScale() const final

Retrieves object local scale.

Returns:

Object scale with respect to its parent.

AsyncMessageSource &getMessageSource()

Protected Functions

const SceneComponent &getRootComponentInternal() const
SceneComponent &getRootComponentInternal()

Private Functions

virtual void onBeforeDeleteObject() override
void setScene(IScene*)
bool walkChildObjectsRecursive(WalkObjectsCallback callback, void *callbackData)
bool walkComponentsRecursive(WalkComponentsCallback callback, void *callbackData, const rtti::TypeInfo *componentType)
async::Task activate()
void clearSceneReferencesRecursive()
void resetParentInternal(SceneObject *newParent, SetParentOptsFlag options)
void removeComponentFromList(Component &component)
SceneObject &attachChildInternal(SceneObject::Ptr &&childObject, bool activateNow)
Component &addComponentInternal(const rtti::TypeInfo &componentType, Functor<void(Component&)> &initializer, bool activateNow)

Private Members

SceneComponent *m_rootComponent = nullptr

A component that is used as ‘base’. Local transform of all other components are relative to the root component.

SceneObject *m_parent = nullptr
IScene *m_scene = nullptr
eastl::string m_name
eastl::intrusive_list<scene_internal::ComponentListNode> m_components
eastl::intrusive_list<SceneObject> m_children
nau::Ptr<AsyncMessageSource> m_messageSource
ActivationState m_activationState = ActivationState::Inactive

Friends

friend class SceneImpl
friend class SceneManagerImpl
friend class Component

scene::RuntimeObjectWeakRefValue

engine/core/modules/scene/include/nau/scene/nau_object.h

struct RuntimeObjectWeakRefValue : public virtual RuntimeValue

Public Functions

template<typename T = NauObject> RuntimeValue ObjectWeakRef< T > getObjectWeakRef ()
template<typename T>
void setObjectWeakRef(ObjectWeakRef<T> weakRef)
virtual SceneQuery getObjectQuery() const = 0
virtual bool isAssignable(const NauObject &object) const = 0
template<typename T>
ObjectWeakRef<T> getObjectWeakRef()

Protected Functions

virtual ObjectWeakRef getObjectWeakRefInternal() = 0
virtual void setObjectWeakRefInternal(ObjectWeakRef<> weakRef) = 0