Class StaticModel
Renders model on the screen.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Level/Actors/StaticModel.h
Syntax
public class StaticModel : public ModelInstanceActor
Constructors
~StaticModel()
Fields
DrawModes
The draw passes to use for rendering this object.
Declaration
public DrawPass DrawModes = DrawPass::Default
Field Value
DrawPass
|
Lightmap
Model
The model asset to draw.
Declaration
public AssetReference<Model> Model
Field Value
AssetReference<Model>
|
Methods
Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
Deserializes object from the input stream.
Declaration
public virtual void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override
Parameters
DeserializeStream
stream
The input stream. |
ISerializeModifier
modifier
The deserialization modifier object. Always valid. |
Overrides
Draw(RenderContext& renderContext)
Draws this actor. Called by Scene Rendering service. This call is more optimized than generic Draw (eg. geometry is rendered during all pass types but other actors are drawn only during GBufferFill pass).
Declaration
public virtual void Draw(RenderContext& renderContext) override
Parameters
RenderContext
renderContext
The rendering context. |
Overrides
Draw(RenderContextBatch& renderContextBatch)
Draws this actor. Called by Scene Rendering service. This call is more optimized than generic Draw (eg. geometry is rendered during all pass types but other actors are drawn only during GBufferFill pass).
Declaration
public virtual void Draw(RenderContextBatch& renderContextBatch) override
Parameters
RenderContextBatch
renderContextBatch
The rendering context batch (eg, main view and shadow projections). |
Overrides
GetBoundsScale()
Gets the model bounds scale. It is useful when using Position Offset to animate the vertices of the object outside of its bounds. Increasing the bounds of an object will reduce performance.
Declaration
public float GetBoundsScale() const
Returns
float
|
GetForcedLOD()
Gets the model forced Level Of Detail index. Allows to bind the given model LOD to show. Value -1 disables this feature.
Declaration
public int32 GetForcedLOD() const
Returns
int32
|
GetLODBias()
Gets the model Level Of Detail bias value. Allows to increase or decrease rendered model quality.
Declaration
public int32 GetLODBias() const
Returns
int32
|
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) override
Parameters
int32
entryIndex
The material slot entry index. |
Returns
MaterialBase
|
Overrides
GetMaterial(int32 meshIndex, int32 lodIndex)
Gets the material used to render mesh at given index (overriden by model instance buffer or model default).
Declaration
public MaterialBase* GetMaterial(int32 meshIndex, int32 lodIndex) const
Parameters
int32
meshIndex
The zero-based mesh index. |
int32
lodIndex
The LOD index. |
Returns
MaterialBase
Material or null if not assigned. |
GetMaterialSlots()
Gets the material slots array set on the asset (eg. model or skinned model asset).
Declaration
public virtual Span<MaterialSlot> GetMaterialSlots() const override
Returns
Span<MaterialSlot>
|
Overrides
GetMeshData(const MeshReference& ref, MeshBufferType type, BytesContainer& result, int32& count, GPUVertexLayout* *layout)
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) const override
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. |
Overrides
GetMeshDeformation()
Gets the mesh deformation utility for this model instance (optional).
Declaration
public virtual MeshDeformation* GetMeshDeformation() const override
Returns
MeshDeformation
Model deformation utility or null if not supported. |
Overrides
GetScaleInLightmap()
Gets the model scale in lightmap (applied to all the meshes).
Declaration
public float GetScaleInLightmap() const
Returns
float
|
GetSortOrder()
Gets the model sort order key used when sorting drawable objects during rendering. Use lower values to draw object before others, higher values are rendered later (on top). Can be used to control transparency drawing.
Declaration
public int32 GetSortOrder() const
Returns
int32
|
GetVertexColor(int32 lodIndex, int32 meshIndex, int32 vertexIndex)
Gets the color of the painter vertex (this model instance).
Declaration
public Color32 GetVertexColor(int32 lodIndex, int32 meshIndex, int32 vertexIndex) const
Parameters
int32
lodIndex
The model LOD index. |
int32
meshIndex
The mesh index. |
int32
vertexIndex
The vertex index. |
Returns
Color32
The color of the vertex. |
HasContentLoaded()
Returns true if actor has loaded content.
Declaration
public virtual bool HasContentLoaded() const override
Returns
bool
|
Overrides
HasLightmap()
Determines whether this model has valid lightmap data.
Declaration
public bool HasLightmap() const
Returns
bool
|
HasVertexColors()
Returns true if model instance is using custom painted vertex colors buffer, otherwise it will use vertex colors from the original asset.
Declaration
public bool HasVertexColors() const
Returns
bool
|
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) override
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. |
Overrides
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) override
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. |
Overrides
IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
Determines if there is an intersection between the current object and a ray.
Declaration
public virtual bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override
Parameters
Ray
ray
The ray to test. |
Real
distance
When the method completes, 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 whether the two objects intersected, otherwise false. |
Overrides
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
RemoveLightmap()
Removes the lightmap data from the model.
Declaration
public void RemoveLightmap()
RemoveVertexColors()
Removes the vertex colors buffer from this instance.
Declaration
public void RemoveVertexColors()
Serialize(SerializeStream& stream, const void* otherObj)
Serializes object to the output stream compared to the values of the other object instance (eg. default class object). If other object is null then serialize all properties.
Declaration
public virtual void Serialize(SerializeStream& stream, const void* otherObj) override
Parameters
SerializeStream
stream
The output stream. |
void
otherObj
The instance of the object to compare with and serialize only the modified properties. If null, then serialize all properties. |
Overrides
SetBoundsScale(float value)
Sets the model bounds scale. It is useful when using Position Offset to animate the vertices of the object outside of its bounds.
Declaration
public void SetBoundsScale(float value)
Parameters
float
value
|
SetForcedLOD(int32 value)
Sets the model forced Level Of Detail index. Allows to bind the given model LOD to show. Value -1 disables this feature.
Declaration
public void SetForcedLOD(int32 value)
Parameters
int32
value
|
SetLODBias(int32 value)
Sets the model Level Of Detail bias value. Allows to increase or decrease rendered model quality.
Declaration
public void SetLODBias(int32 value)
Parameters
int32
value
|
SetScaleInLightmap(float value)
Sets the model scale in lightmap (applied to all the meshes).
Declaration
public void SetScaleInLightmap(float value)
Parameters
float
value
|
SetSortOrder(int32 value)
Sets the model sort order key used when sorting drawable objects during rendering. Use lower values to draw object before others, higher values are rendered later (on top). Can be used to control transparency drawing.
Declaration
public void SetSortOrder(int32 value)
Parameters
int32
value
|
SetVertexColor(int32 lodIndex, int32 meshIndex, int32 vertexIndex, const Color32& color)
Sets the color of the painter vertex (this model instance).
Declaration
public void SetVertexColor(int32 lodIndex, int32 meshIndex, int32 vertexIndex, const Color32& color)
Parameters
int32
lodIndex
The model LOD index. |
int32
meshIndex
The mesh index. |
int32
vertexIndex
The vertex index. |
Color32
color
The color to set. |
UpdateBounds()
Updates the model bounds (eg. when mesh has applied significant deformation).
Declaration
public virtual void UpdateBounds() override
Overrides
WaitForModelLoad()
Declaration
protected virtual void WaitForModelLoad() override