Class Model
Represents a 3D model in the game.
Inherited Members
Namespace: Genesis.Core.GameElements
Assembly: Genesis.dll
Syntax
public class Model : GameElement
Constructors
Model(string, Vec3, string)
Constructs a new instance of the Model class.
Declaration
public Model(string name, Vec3 location, string filename)
Parameters
Type | Name | Description |
---|---|---|
string | name | |
Vec3 | location | |
string | filename |
Properties
AnimationCallbacks
Gets or sets the list of animation callbacks.
Declaration
public List<AnimationCallback> AnimationCallbacks { get; set; }
Property Value
Type | Description |
---|---|
List<AnimationCallback> | A list of AnimationCallback objects representing the callbacks to be triggered at specific frames of animations. |
Remarks
This property holds the callbacks that are associated with specific frames of animations. These callbacks are checked and potentially triggered during the animation update process.
AnimationSpeed
Gets or sets the speed of animation playback.
Declaration
public float AnimationSpeed { get; set; }
Property Value
Type | Description |
---|---|
float |
Animations
Gets or sets the list of animations associated with the model.
Declaration
public List<Animation> Animations { get; set; }
Property Value
Type | Description |
---|---|
List<Animation> |
Animator
Gets or sets the animator responsible for controlling animations.
Declaration
public Animator Animator { get; set; }
Property Value
Type | Description |
---|---|
Animator |
BoneCounter
Gets or sets the counter for bones in the model.
Declaration
public int BoneCounter { get; set; }
Property Value
Type | Description |
---|---|
int |
BoneInfoMap
Gets or sets the mapping of bone names to bone information.
Declaration
public Dictionary<string, boneinfo> BoneInfoMap { get; set; }
Property Value
Type | Description |
---|---|
Dictionary<string, boneinfo> |
FileDirectory
Gets or sets the directory of the model file.
Declaration
public string FileDirectory { get; set; }
Property Value
Type | Description |
---|---|
string |
FileName
Gets or sets the name of the model file.
Declaration
public string FileName { get; set; }
Property Value
Type | Description |
---|---|
string |
Materials
Gets or sets the list of materials used by the model.
Declaration
public List<Material> Materials { get; set; }
Property Value
Type | Description |
---|---|
List<Material> |
Meshes
Gets or sets the list of meshes composing the model.
Declaration
public List<ModelMesh> Meshes { get; set; }
Property Value
Type | Description |
---|---|
List<ModelMesh> |
Shader
Gets or sets the shader program used for rendering the model.
Declaration
public ShaderProgram Shader { get; set; }
Property Value
Type | Description |
---|---|
ShaderProgram |
Methods
AddAnimationCallback(string, int, AnimationEvent)
Adds a callback to be triggered at a specific frame of a specified animation.
Declaration
public void AddAnimationCallback(string name, int frame, AnimationCallback.AnimationEvent callback)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the animation to which the callback should be added. |
int | frame | The frame at which the callback should be triggered. |
AnimationCallback.AnimationEvent | callback | The callback event to be triggered at the specified frame. |
Remarks
This method registers a new animation callback by adding it to the list of animation callbacks.
ExtractAnimations(Scene)
Extracts animations from the imported model.
Declaration
public void ExtractAnimations(Scene scene)
Parameters
Type | Name | Description |
---|---|---|
Scene | scene |
ExtractMaterials(Scene)
Extracts materials information from the imported model.
Declaration
public void ExtractMaterials(Scene scene)
Parameters
Type | Name | Description |
---|---|---|
Scene | scene |
ExtractMeshes(Scene)
Extracts mesh data from the imported model.
Declaration
public void ExtractMeshes(Scene scene)
Parameters
Type | Name | Description |
---|---|---|
Scene | scene |
FindAnimation(string)
Finds an animation with the specified name.
Declaration
public Animation FindAnimation(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name |
Returns
Type | Description |
---|---|
Animation |
GetAnimationLength(string)
Gets the keyframe length of the specified animation by its name.
Declaration
public int GetAnimationLength(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the animation. |
Returns
Type | Description |
---|---|
int | The keyframe length of the specified animation if it exists; otherwise, returns -1. |
Remarks
This method searches for an animation by its name and returns its keyframe length.
GetCurrentAnimationFrame()
Gets the current keyframe index of the animation being played by the animator.
Declaration
public int GetCurrentAnimationFrame()
Returns
Type | Description |
---|---|
int | The current keyframe index if an animation is being played; otherwise, returns -1. |
Remarks
This method checks if there is a current animation being played by the animator and retrieves the keyframe index based on the current time of the animation.
Init(Game, IRenderDevice)
Initializes the model within the game environment.
Declaration
public override void Init(Game game, IRenderDevice renderDevice)
Parameters
Type | Name | Description |
---|---|---|
Game | game | |
IRenderDevice | renderDevice |
Overrides
OnDestroy(Game)
Cleans up resources associated with the model when destroyed.
Declaration
public override void OnDestroy(Game game)
Parameters
Type | Name | Description |
---|---|---|
Game | game |
Overrides
OnRender(Game, IRenderDevice)
Renders the model within the game environment.
Declaration
public override void OnRender(Game game, IRenderDevice renderDevice)
Parameters
Type | Name | Description |
---|---|---|
Game | game | |
IRenderDevice | renderDevice |
Overrides
OnUpdate(Game, IRenderDevice)
Updates the model within the game environment.
Declaration
public override void OnUpdate(Game game, IRenderDevice renderDevice)
Parameters
Type | Name | Description |
---|---|---|
Game | game | |
IRenderDevice | renderDevice |
Overrides
PlayAnimation(string)
Plays the specified animation on the model.
Declaration
public void PlayAnimation(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name |
StopAnimation()
Stops the currently playing animation.
Declaration
public void StopAnimation()
Remarks
This method sets the animator's play state to false, effectively pausing the animation.