Table of Contents

Class StaticMeshModel

Namespace
LibGFX.Graphics
Assembly
LibGFX.dll

Static model class that represents a 3D model loaded from a file.

public class StaticMeshModel : IModel, IFileAsset, IGraphicsResource, IIdentifier, ISerialization
Inheritance
StaticMeshModel
Implements
Inherited Members

Constructors

StaticMeshModel()

Initializes a new instance of the StaticMeshModel class. Used for deserialization purposes.

public StaticMeshModel()

StaticMeshModel(string)

Static model constructor that loads model data from a file.

public StaticMeshModel(string file)

Parameters

file string

Properties

FilePath

Gets or sets the full path to the file associated with this instance.

public string FilePath { get; set; }

Property Value

string

HasTransparency

Gets a value indicating whether the content includes any transparent pixels.

public bool HasTransparency { get; }

Property Value

bool

ID

Gets the unique identifier for this instance.

public Guid ID { get; }

Property Value

Guid

IsInitialized

Gets a value indicating whether the object has been initialized.

public bool IsInitialized { get; }

Property Value

bool

Meshes

Meshes that make up the static model.

public List<Mesh> Meshes { get; set; }

Property Value

List<Mesh>

Name

Gets or sets the name associated with the object.

public string Name { get; set; }

Property Value

string

NodeStructure

Node structure of the model as imported from Assimp.

public SceneNodeData NodeStructure { get; set; }

Property Value

SceneNodeData

Methods

Deserialize(JObject, SerializationContext, Func<JObject, bool>)

Populates the current object with values from the specified JSON object.

public void Deserialize(JObject obj, SerializationContext serializationContext, Func<JObject, bool> callback = null)

Parameters

obj JObject
serializationContext SerializationContext
callback Func<JObject, bool>

Dispose(IRenderDevice)

Releases all resources used by the static model and its associated meshes using the specified render device.

public void Dispose(IRenderDevice renderer)

Parameters

renderer IRenderDevice

The render device used to dispose of the model's meshes and materials. Cannot be null.

Remarks

After calling this method, the static model and its meshes should not be used. This method must be called to free graphics resources when the model is no longer needed.

FindNodeByName(string, out SceneNodeData)

Searches for a node with the specified name in the scene graph.

public bool FindNodeByName(string name, out SceneNodeData node)

Parameters

name string

The name of the node to locate. The search is case-sensitive and cannot be null.

node SceneNodeData

When this method returns, contains the data for the found node if a node with the specified name exists; otherwise, contains the default value.

Returns

bool

true if a node with the specified name is found; otherwise, false.

FreeCPUResources()

Frees the CPU resources used by the static model and its associated meshes.

public void FreeCPUResources()

Init(IRenderDevice)

Initializes the model and loads all associated meshes and materials into the specified render device.

public void Init(IRenderDevice renderer)

Parameters

renderer IRenderDevice

The render device used to initialize materials and load meshes. Cannot be null.

Remarks

Call this method before attempting to render the model. After initialization, the model's meshes and materials are prepared for use with the provided render device. This method has no effect if called multiple times on an already initialized model.

Serialize(JsonWriter, SerializationContext, Action<JsonWriter>)

Serializes the current static mesh model to a JSON object using the specified serialization context.

public void Serialize(JsonWriter writer, SerializationContext serializationContext, Action<JsonWriter> callback = null)

Parameters

writer JsonWriter
serializationContext SerializationContext

The context that provides information and settings required for serialization.

callback Action<JsonWriter>