Table of Contents

Class Animation

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll

Represents a shape animation and can calculate the transformation matrices for each frame to be sent to the shader Process

  1. For each frame, for each root element, calculate the transformation matrix. Curent model matrix is identy mat. 1.1. Get previous and next key frame. Apply translation, rotation and scale to model matrix. 1.2. Store this matrix as animationmatrix in list 1.3. For each child element 1.3.1. Multiply local transformation matrix with the animation matrix. This matrix is now the curent model matrix. Go to 1 with child elements as root elems

  2. For each frame, for each joint 2.1. Calculate the inverse model matrix 2.2. Multiply stored animationmatrix with the inverse model matrix

  3. done

[JsonObject(MemberSerialization.OptIn)]
public class Animation
Inheritance
Animation
Inherited Members
Extension Methods

Fields

Code

[JsonProperty]
public string Code

Field Value

string

CodeCrc32

public uint CodeCrc32

Field Value

uint

EaseAnimationSpeed

[JsonProperty]
public bool EaseAnimationSpeed

Field Value

bool

KeyFrames

[JsonProperty]
public AnimationKeyFrame[] KeyFrames

Field Value

AnimationKeyFrame[]

Name

[JsonProperty]
public string Name

Field Value

string

OnActivityStopped

[JsonProperty]
public EnumEntityActivityStoppedHandling OnActivityStopped

Field Value

EnumEntityActivityStoppedHandling

OnAnimationEnd

[JsonProperty]
public EnumEntityAnimationEndHandling OnAnimationEnd

Field Value

EnumEntityAnimationEndHandling

PrevNextKeyFrameByFrame

public AnimationFrame[][] PrevNextKeyFrameByFrame

Field Value

AnimationFrame[][]

QuantityFrames

[JsonProperty]
public int QuantityFrames

Field Value

int

Version

[JsonProperty]
public int Version

Field Value

int

jointsDone

protected HashSet<int> jointsDone

Field Value

HashSet<int>

Methods

Clone()

public Animation Clone()

Returns

Animation

GenerateAllFrames(ShapeElement[], Dictionary<int, AnimationJoint>, bool)

Compiles the animation into a bunch of matrices, 31 matrices per frame.

public void GenerateAllFrames(ShapeElement[] rootElements, Dictionary<int, AnimationJoint> jointsById, bool recursive = true)

Parameters

rootElements ShapeElement[]
jointsById Dictionary<int, AnimationJoint>
recursive bool

When false, will only do root elements

GenerateFrame(int, AnimationFrame[], ShapeElement[], Dictionary<int, AnimationJoint>, float[], List<ElementPose>, bool)

protected void GenerateFrame(int indexNumber, AnimationFrame[] resKeyFrames, ShapeElement[] elements, Dictionary<int, AnimationJoint> jointsById, float[] modelMatrix, List<ElementPose> transforms, bool recursive = true)

Parameters

indexNumber int
resKeyFrames AnimationFrame[]
elements ShapeElement[]
jointsById Dictionary<int, AnimationJoint>
modelMatrix float[]
transforms List<ElementPose>
recursive bool

GenerateFrameForElement(int, ShapeElement, ref ElementPose)

protected void GenerateFrameForElement(int frameNumber, ShapeElement element, ref ElementPose transform)

Parameters

frameNumber int
element ShapeElement
transform ElementPose

getLeftRightResolvedFrame(int, AnimationFrame[], out AnimationFrame, out AnimationFrame)

protected void getLeftRightResolvedFrame(int frameNumber, AnimationFrame[] frames, out AnimationFrame left, out AnimationFrame right)

Parameters

frameNumber int
frames AnimationFrame[]
left AnimationFrame
right AnimationFrame

getTwoKeyFramesElementForFlag(int, ShapeElement, int, out AnimationKeyFrameElement, out AnimationKeyFrameElement)

protected void getTwoKeyFramesElementForFlag(int frameNumber, ShapeElement forElement, int forFlag, out AnimationKeyFrameElement left, out AnimationKeyFrameElement right)

Parameters

frameNumber int
forElement ShapeElement
forFlag int
left AnimationKeyFrameElement
right AnimationKeyFrameElement

lerpKeyFrameElement(AnimationKeyFrameElement, AnimationKeyFrameElement, int, float, ref ElementPose)

protected void lerpKeyFrameElement(AnimationKeyFrameElement prev, AnimationKeyFrameElement next, int forFlag, float t, ref ElementPose transform)

Parameters

prev AnimationKeyFrameElement
next AnimationKeyFrameElement
forFlag int
t float
transform ElementPose