Table of Contents

Struct AnimatedModelInstance

Namespace
PopcorningGuineaPig.Engine.Gameplay
Assembly
PopcorningGuineaPig.Engine.dll

Lightweight per-entity state for an animated model (Flyweight extrinsic state). Playback lives here (~20 bytes); mesh/clips live on the shared AnimatedModelData.

Pose and draw are adjacent: Update(float) only advances the frame, Draw(Vector3, Vector3, Vector3, Color) uploads bone matrices then draws. Never call Raylib.UpdateModelAnimation on a GPU-skinned model — that writes posed vertices into the VBO, and the shader then skins them again (collapsed/exploded mesh).

public struct AnimatedModelInstance
Inherited Members

Constructors

AnimatedModelInstance(AnimatedModelData)

public AnimatedModelInstance(AnimatedModelData data)

Parameters

data AnimatedModelData

Properties

AnimationSpeed

Playback speed multiplier (1.0 = normal speed).

public float AnimationSpeed { readonly get; set; }

Property Value

float

CurrentAnimIndex

Index of the currently active animation.

public int CurrentAnimIndex { readonly get; set; }

Property Value

int

CurrentFrame

Current frame in the active animation.

public int CurrentFrame { readonly get; set; }

Property Value

int

Data

Reference to the shared model and animation data.

public readonly AnimatedModelData Data { get; }

Property Value

AnimatedModelData

IsLooping

Whether the animation loops or plays once.

public bool IsLooping { readonly get; set; }

Property Value

bool

IsPlaying

Whether the animation is currently playing.

public bool IsPlaying { readonly get; set; }

Property Value

bool

IsValid

True if the underlying shared data is valid and not disposed.

public readonly bool IsValid { get; }

Property Value

bool

Methods

ApplyPose()

Pushes this instance's current frame onto the shared model.

public void ApplyPose()

Remarks

Call immediately before drawing when several instances share one AnimatedModelData. The palette for a frame is built once and copied onto the model, so the last copy is the one that draws. The CPU fallback re-skins every vertex.

Draw(Vector3, Vector3, Vector3, Color)

Renders the model with the current animation pose.

public void Draw(Vector3 position, Vector3 rotationDeg, Vector3 scale, Color tint)

Parameters

position Vector3

The position to render at.

rotationDeg Vector3

The rotation in degrees around each axis.

scale Vector3

The scale to apply.

tint Color

The color tint to apply.

PlayAnimation(int)

Starts playing the animation at the specified index.

public void PlayAnimation(int animIndex)

Parameters

animIndex int

The index of the animation to play.

Exceptions

ArgumentOutOfRangeException

Thrown if animIndex is invalid.

PlayAnimation(string)

Starts playing the animation with the specified name.

public void PlayAnimation(string animName)

Parameters

animName string

The name of the animation to play.

Exceptions

ArgumentException

Thrown if the animation name is not found.

StopAnimation()

Stops the current animation playback.

public void StopAnimation()

Update(float)

Updates the animation playback based on elapsed time.

public void Update(float deltaTime)

Parameters

deltaTime float

Time elapsed since the last update.