Class ModelInstanceActor
Base class for actor types that use ModelInstanceEntries for mesh rendering.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Level/Actors/ModelInstanceActor.h
Syntax
public class ModelInstanceActor : public Actor
Fields
_sceneRenderingKey
Declaration
protected int32 _sceneRenderingKey = -1
Field Value
int32
|
Entries
The model instance buffer.
Declaration
public ModelInstanceEntries Entries
Field Value
ModelInstanceEntries
|
Methods
CreateAndSetVirtualMaterialInstance(int32 entryIndex)
Utility to crate a new virtual Material Instance asset, set its parent to the currently applied material, and assign it to the entry. Can be used to modify the material parameters from code.
Declaration
public MaterialInstance* CreateAndSetVirtualMaterialInstance(int32 entryIndex)
Parameters
int32
entryIndex
The material slot entry index. |
Returns
MaterialInstance
The created virtual material instance. |
GetEntries()
Gets the model entries collection. Each entry contains data how to render meshes using this entry (transformation, material, shadows casting, etc.).
Declaration
public Array<ModelInstanceEntry> GetEntries() const
Returns
Array<ModelInstanceEntry>
|
GetMaterial(int32 entryIndex)
Gets the material used to draw the meshes which are assigned to that slot (set in Entries or model's default).
Declaration
public virtual MaterialBase* GetMaterial(int32 entryIndex) = 0
Parameters
int32
entryIndex
The material slot entry index. |
Returns
MaterialBase
|
GetMaterialSlots()
Gets the material slots array set on the asset (eg. model or skinned model asset).
Declaration
public virtual Span<class MaterialSlot> GetMaterialSlots() const = 0
Returns
Span<class MaterialSlot>
|
GetMeshData(const MeshReference& ref, MeshBufferType type, BytesContainer& result, int32& count, GPUVertexLayout* *layout=nullptr)
Extracts mesh buffer data from CPU. Might be cached internally (eg. by Model/SkinnedModel).
Declaration
public virtual bool GetMeshData(const MeshReference& ref, MeshBufferType type, BytesContainer& result, int32& count, GPUVertexLayout* *layout=nullptr) const
Parameters
MeshReference
ref
Mesh reference. |
MeshBufferType
type
Buffer type |
BytesContainer
result
The result data |
int32
count
The amount of items inside the result buffer. |
GPUVertexLayout
layout
The result layout of the result buffer (for vertex buffers). Optional, pass null to ignore it. |
Returns
bool
True if failed, otherwise false. |
GetMeshDeformation()
Gets the mesh deformation utility for this model instance (optional).
Declaration
public virtual MeshDeformation* GetMeshDeformation() const
Returns
MeshDeformation
Model deformation utility or null if not supported. |
IntersectsEntry(const Ray& ray, Real& distance, Vector3& normal, int32& entryIndex)
Determines if there is an intersection between the model actor mesh entry and a ray. If mesh data is available on the CPU performs exact intersection check with the geometry. Otherwise performs simple BoundingBox vs Ray test. For more efficient collisions detection and ray casting use physics.
Declaration
public virtual bool IntersectsEntry(const Ray& ray, Real& distance, Vector3& normal, int32& entryIndex)
Parameters
Ray
ray
The ray to test. |
Real
distance
When the method completes and returns true, contains the distance of the intersection (if any valid). |
Vector3
normal
When the method completes, contains the intersection surface normal vector (if any valid). |
int32
entryIndex
When the method completes, contains the intersection entry index (if any valid). |
Returns
bool
True if the actor is intersected by the ray, otherwise false. |
IntersectsEntry(int32 entryIndex, const Ray& ray, Real& distance, Vector3& normal)
Determines if there is an intersection between the model actor mesh entry and a ray. If mesh data is available on the CPU performs exact intersection check with the geometry. Otherwise performs simple BoundingBox vs Ray test. For more efficient collisions detection and ray casting use physics.
Declaration
public virtual bool IntersectsEntry(int32 entryIndex, const Ray& ray, Real& distance, Vector3& normal)
Parameters
int32
entryIndex
The material slot entry index to test. |
Ray
ray
The ray to test. |
Real
distance
When the method completes and returns true, contains the distance of the intersection (if any valid). |
Vector3
normal
When the method completes, contains the intersection surface normal vector (if any valid). |
Returns
bool
True if the actor is intersected by the ray, otherwise false. |
OnDisable()
Called when actor gets removed from game systems. Occurs on EndPlay event or when actor gets inactivated in hierarchy. Use this event to unregister object from other game system (eg. audio).
Declaration
protected virtual void OnDisable() override
Overrides
OnEnable()
Called when actor gets added to game systems. Occurs on BeginPlay event or when actor gets activated in hierarchy. Use this event to register object to other game system (eg. audio).
Declaration
protected virtual void OnEnable() override
Overrides
OnLayerChanged()
Called when layer gets changed.
Declaration
public virtual void OnLayerChanged() override
Overrides
OnStaticFlagsChanged()
Called when actor static flag gets changed.
Declaration
public virtual void OnStaticFlagsChanged() override
Overrides
OnTransformChanged()
Called when actor transform gets changed.
Declaration
public virtual void OnTransformChanged() override
Overrides
SetEntries(const Array<ModelInstanceEntry>& value)
Sets the model entries collection. Each entry contains data how to render meshes using this entry (transformation, material, shadows casting, etc.).
Declaration
public void SetEntries(const Array<ModelInstanceEntry>& value)
Parameters
Array<ModelInstanceEntry>
value
|
SetMaterial(int32 entryIndex, MaterialBase* material)
Sets the material to the entry slot. Can be used to override the material of the meshes using this slot.
Declaration
public void SetMaterial(int32 entryIndex, MaterialBase* material)
Parameters
int32
entryIndex
The material slot entry index. |
MaterialBase
material
The material to set. |
UpdateBounds()
Updates the model bounds (eg. when mesh has applied significant deformation).
Declaration
public virtual void UpdateBounds() = 0
WaitForModelLoad()
Declaration
protected virtual void WaitForModelLoad()