class Renderable

Renderable represents any visible object in the scene.

It has a mesh, bounds and a set of materials. Renderer will render any Renderable objects visible by a camera.

Public

Methods

SetMesh

void SetMesh(const HMesh &mesh)

Determines the mesh to render.

All sub-meshes of the mesh will be rendered, and you may set individual materials for each sub-mesh.

SetMaterial

void SetMaterial(u32 index, const HMaterial &material)

Sets a material that will be used for rendering a sub-mesh with the specified index.

If a sub-mesh doesn't have a specific material set then the primary material will be used.

SetMaterial

void SetMaterial(const HMaterial &material)

Sets the primary material to use for rendering.

Any sub-mesh that doesn't have an explicit material set will use this material.

SetMaterials

void SetMaterials(const Vector<HMaterial> &materials)

Determines all materials used for rendering this renderable.

Each of the materials is used for rendering a single sub-mesh. If number of materials is larger than number of sub-meshes, they will be ignored. If lower, the remaining materials will be removed.

SetLayer

void SetLayer(u64 layer)

Determines the layer bitfield that controls whether a renderable is considered visible in a specific camera.

Renderable layer must match camera layer in order for the camera to render the component.

SetOverrideBounds

void SetOverrideBounds(const AABox &bounds)

Sets bounds that will be used when determining if object is visible.

Only relevant if SetUseOverrideBounds() is set to true.

bounds
Bounds in local space.

SetUseOverrideBounds

void SetUseOverrideBounds(bool enable)

Enables or disables override bounds.

When enabled the bounds provided to SetOverrideBounds() will be used for determining object visibility, otherwise the bounds from the object's mesh will be used. Disabled by default.

SetWriteVelocity

void SetWriteVelocity(bool enable)

If enabled this renderable will write per-pixel velocity information when rendered.

This is required for effects such as temporal anti-aliasing and motion blur, but comes with a minor performance overhead. If you are not using those effects you can disable this for a performance gain.

SetCullDistanceFactor

void SetCullDistanceFactor(float factor)

Factor to be applied to the cull distance set in the camera's render settings.

SetAnimation

void SetAnimation(const HAnimation &animation)

Determines the animation that will be used for animating the attached mesh.

Note this will automatically be set if an animation component exists on the same scene object as the renderable.

GetAnimation

const HAnimation &GetAnimation() const

IsAnimated

bool IsAnimated() const

Checks is the renderable animated or static.

GetBounds

Bounds GetBounds() const

Gets world bounds of the mesh rendered by this object.

CalculateBounds

bool CalculateBounds(Bounds &bounds) override

Calculates bounds of the visible contents represented by this component (for example a mesh for Renderable).

bounds
Bounds of the contents in world space coordinates.

Returns: True if the component has bounds with non-zero volume, otherwise false.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

GetMesh

MeshType GetMesh() const

Determines the mesh to render.

All sub-meshes of the mesh will be rendered, and you may set individual materials for each sub-mesh.

GetMaterial

MaterialType GetMaterial(u32 index) const

Returns the material used for rendering a sub-mesh with the specified index.

GetMaterials

const Vector<MaterialType> &GetMaterials() const

Determines all materials used for rendering this renderable.

Each of the materials is used for rendering a single sub-mesh. If number of materials is larger than number of sub-meshes, they will be ignored. If lower, the remaining materials will be removed.

GetWriteVelocity

bool GetWriteVelocity() const

If enabled this renderable will write per-pixel velocity information when rendered.

This is required for effects such as temporal anti-aliasing and motion blur, but comes with a minor performance overhead. If you are not using those effects you can disable this for a performance gain.

GetCullDistanceFactor

float GetCullDistanceFactor() const

Factor to be applied to the cull distance set in the camera's render settings.

GetLayer

u64 GetLayer() const

Determines the layer bitfield that controls whether a renderable is considered visible in a specific camera.

Renderable layer must match camera layer in order for the camera to render the component.

GetAnimType

RenderableAnimType GetAnimType() const

Returns the type of animation influencing this renderable, if any.

Internal

Methods

RegisterAnimation

void RegisterAnimation(const HAnimation &animation)

Registers an Animation component that will be used for animating the renderable's mesh.

UnregisterAnimation

void UnregisterAnimation()

Removes the Animation component, making the renderable rendered as a static object.

Protected

Constructors

Renderable

Renderable(const HSceneObject &parent)

Renderable

Renderable()

Methods

RefreshAnimation

void RefreshAnimation()

Updates animation properties depending on the current mesh.

GetCoreDependencies

void GetCoreDependencies(Vector<CoreObject *> &dependencies) override

Populates the provided array with all core objects that this core object depends upon.

Dependencies are required for syncing to the render thread, so the system can be aware to update the dependant objects if a dependency is marked as dirty (for example updating a camera's viewport should also trigger an update on camera so it has a chance to potentially update its data).

OnDependencyDirty

void OnDependencyDirty(CoreObject *dependency, u32 dirtyFlags) override

Gets called on an object when one of the dependencies (as returned from GetCoreDependencies()) is marked as dirty.

It gives the dependant object a chance to determine should it mark itself as dirty due to the dependency change. Dirty flags of the dependency object can be examined for more information on what part of the dependency was modified.

GetListenerResources

void GetListenerResources(Vector<HResource> &resources) override

Retrieves all the resources that the class depends on.

NotifyResourceLoaded

void NotifyResourceLoaded(const HResource &resource) override

Called when a resource has been fully loaded.

NotifyResourceChanged

void NotifyResourceChanged(const HResource &resource) override

Called when the internal resource the resource handle is pointing to changes.

MarkRenderProxyDataDirty

void MarkRenderProxyDataDirty(ComponentDirtyFlag flag = ComponentDirtyFlag::Everything)

*********************************************************************

MarkCoreObjectDependenciesDirty

void MarkCoreObjectDependenciesDirty()

Notifies the core object manager that this object is dependant on some other CoreObject(s), and the dependencies changed since the last call to this method.

This will trigger a call to GetCoreDependencies() to collect the new dependencies.

MarkReferencedResourcesDirty

void MarkReferencedResourcesDirty()

Marks the resource dependencies list as dirty and schedules it for rebuild.

Initialize

void Initialize() override

Construct any resources the component needs before use.

Called when the parent scene object is initialized. A non-initialized component shouldn't be used in a live scene (i.e. it should not receive any of the component logic updates or events).

OnCreated

void OnCreated() override

Called once when the component has been created.

Called regardless of the state the component is in.

OnBeginPlay

void OnBeginPlay() override

Called once when the component first leaves the Stopped state.

This includes component creation if requirements for leaving Stopped state are met, in which case it is called after OnCreated. Note this is called even if the component is in disabled state.

OnEnabled

void OnEnabled() override

Called every time a component leaves the Stopped state, if the component is enabled.

This includes component creation if requirements for leaving the Stopped state are met. When called during creation it is called after OnBeginPlay.

OnDisabled

void OnDisabled() override

Called every time a component is placed into the Stopped state.

This includes component destruction if component wasn't already in Stopped state during destruction. When called during destruction it is called before OnDestroyed.

OnDestroyed

void OnDestroyed() override

Called once just before the component is destroyed.

Called regardless of the state the component is in.

OnSceneChanged

void OnSceneChanged(SceneInstance *oldScene, ecs::Entity oldEntity) override

Called when the parent SceneObject's ECS entity is migrated to a new registry (e.g. when moving between scenes).

The old scene and entity are provided so that components can access sub-systems (renderer, physics, etc.) and read any data stored only in ECS fragments.

OnTransformChanged

void OnTransformChanged(TransformChangedFlags flags) override

Called when the component's parent scene object has changed.

Not called if the component is in Stopped state. Also only called if necessary notify flags are set via SetNotifyFlagsInternal().

DoOnMeshChanged

void DoOnMeshChanged()

Triggered whenever the renderable's mesh changes.

Private

Methods

GetRenderableData

const TRenderableData<false> &GetRenderableData() const

Returns the renderable data from the ECS fragment.

Used by the CRTP getter interface.

GetFragment

ecs::Renderable &GetFragment()

Returns the ECS fragment storing renderable data.

GetFragment

const ecs::Renderable &GetFragment() const

Returns the ECS fragment storing renderable data (const).

Fields

mAnimation

HAnimation mAnimation