Documentation
¶
Index ¶
- func Synchronized[T Node](node T) T
- type AddNode
- func (n *AddNode) Advance(seconds, synchronizationRate float64)
- func (n *AddNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *AddNode) BoneTransform(bone string) NodeTransform
- func (n *AddNode) Fraction() float64
- func (n *AddNode) IsSynchronized() bool
- func (n *AddNode) Rate() float64
- func (n *AddNode) SetFraction(fraction float64)
- func (n *AddNode) SetSynchronized(synchronized bool)
- func (n *AddNode) Synchronize()
- type Blend1DEntry
- type Blend1DNode
- func (n *Blend1DNode) Advance(seconds, synchronizationRate float64)
- func (n *Blend1DNode) BlendCoord() float64
- func (n *Blend1DNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *Blend1DNode) BoneTransform(bone string) NodeTransform
- func (n *Blend1DNode) Fraction() float64
- func (n *Blend1DNode) IsSynchronized() bool
- func (n *Blend1DNode) Rate() float64
- func (n *Blend1DNode) SetBlendCoord(blendCoord float64)
- func (n *Blend1DNode) SetFraction(fraction float64)
- func (n *Blend1DNode) SetSynchronized(synchronized bool)
- func (n *Blend1DNode) Synchronize()
- type BlendPairNode
- func (n *BlendPairNode) Advance(seconds, synchronizationRate float64)
- func (n *BlendPairNode) BlendFactor() float64
- func (n *BlendPairNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *BlendPairNode) BoneTransform(bone string) NodeTransform
- func (n *BlendPairNode) Fraction() float64
- func (n *BlendPairNode) IsSynchronized() bool
- func (n *BlendPairNode) Rate() float64
- func (n *BlendPairNode) SetBlendFactor(factor float64) *BlendPairNode
- func (n *BlendPairNode) SetFraction(fraction float64)
- func (n *BlendPairNode) SetSynchronized(synchronized bool)
- func (n *BlendPairNode) Synchronize()
- type DiffNode
- func (n *DiffNode) Advance(seconds, synchronizationRate float64)
- func (n *DiffNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *DiffNode) BoneTransform(bone string) NodeTransform
- func (n *DiffNode) Fraction() float64
- func (n *DiffNode) IsSynchronized() bool
- func (n *DiffNode) Rate() float64
- func (n *DiffNode) SetFraction(fraction float64)
- func (n *DiffNode) SetSynchronized(synchronized bool)
- func (n *DiffNode) Synchronize()
- type GraphNode
- func (n *GraphNode[T]) AddState(state T, animation Node)
- func (n *GraphNode[T]) AddTransition(from, to T, transition GraphNodeTransition)
- func (n *GraphNode[T]) Advance(seconds, synchronizationRate float64)
- func (n *GraphNode[T]) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *GraphNode[T]) BoneTransform(bone string) NodeTransform
- func (n *GraphNode[T]) Fraction() float64
- func (n *GraphNode[T]) IsSynchronized() bool
- func (n *GraphNode[T]) IsTransitioned() bool
- func (n *GraphNode[T]) JumpToState(state T)
- func (n *GraphNode[T]) Rate() float64
- func (n *GraphNode[T]) SetFraction(fraction float64)
- func (n *GraphNode[T]) SetSynchronized(synchronized bool)
- func (n *GraphNode[T]) SourceState() T
- func (n *GraphNode[T]) Synchronize()
- func (n *GraphNode[T]) TargetState() T
- func (n *GraphNode[T]) TransitionFraction() float64
- func (n *GraphNode[T]) TransitionTo(to T)
- type GraphNodeTransition
- type Keyframe
- type KeyframeList
- type KeyframeSet
- type ManualPoseNode
- func (n *ManualPoseNode) Advance(seconds, synchronizationRate float64)
- func (n *ManualPoseNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *ManualPoseNode) BoneTransform(bone string) NodeTransform
- func (n *ManualPoseNode) Fraction() float64
- func (n *ManualPoseNode) IsSynchronized() bool
- func (n *ManualPoseNode) Rate() float64
- func (n *ManualPoseNode) Reset()
- func (n *ManualPoseNode) SetFraction(fraction float64)
- func (n *ManualPoseNode) SetSynchronized(synchronized bool)
- func (n *ManualPoseNode) Synchronize()
- type MaskNode
- func (n *MaskNode) Advance(seconds, synchronizationRate float64)
- func (n *MaskNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *MaskNode) BoneTransform(bone string) NodeTransform
- func (n *MaskNode) Fraction() float64
- func (n *MaskNode) IsSynchronized() bool
- func (n *MaskNode) Rate() float64
- func (n *MaskNode) SetFraction(fraction float64)
- func (n *MaskNode) SetSynchronized(synchronized bool)
- func (n *MaskNode) Synchronize()
- type Node
- type NodeTransform
- func AddNodeTransforms(first, second NodeTransform) NodeTransform
- func BlendNodeTransforms(first, second NodeTransform, factor float64) NodeTransform
- func DiffNodeTransforms(first, second NodeTransform) NodeTransform
- func FirstNodeTransform(first, second NodeTransform) NodeTransform
- func InverseNodeTransform(transform NodeTransform) NodeTransform
- type OnceNode
- func (n *OnceNode) Advance(seconds, synchronizationRate float64)
- func (n *OnceNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *OnceNode) BoneTransform(bone string) NodeTransform
- func (n *OnceNode) FadeInFraction() float64
- func (n *OnceNode) FadeOutFraction() float64
- func (n *OnceNode) Finished() bool
- func (n *OnceNode) Fraction() float64
- func (n *OnceNode) IsSynchronized() bool
- func (n *OnceNode) Rate() float64
- func (n *OnceNode) SetFadeInFraction(fraction float64)
- func (n *OnceNode) SetFadeOutFraction(fraction float64)
- func (n *OnceNode) SetFraction(fraction float64)
- func (n *OnceNode) SetSynchronized(synchronized bool)
- func (n *OnceNode) Synchronize()
- func (n *OnceNode) Trigger() *OnceNode
- type OneOfNode
- func (n *OneOfNode[T]) ActiveAnimation() T
- func (n *OneOfNode[T]) Advance(seconds, synchronizationRate float64)
- func (n *OneOfNode[T]) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *OneOfNode[T]) BoneTransform(bone string) NodeTransform
- func (n *OneOfNode[T]) Fraction() float64
- func (n *OneOfNode[T]) IsSynchronized() bool
- func (n *OneOfNode[T]) PickAnimation(key T, rewind bool)
- func (n *OneOfNode[T]) Rate() float64
- func (n *OneOfNode[T]) SetFraction(fraction float64)
- func (n *OneOfNode[T]) SetSynchronized(synchronized bool)
- func (n *OneOfNode[T]) Synchronize()
- type OverlayNode
- func (n *OverlayNode) Advance(seconds, synchronizationRate float64)
- func (n *OverlayNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *OverlayNode) BoneTransform(bone string) NodeTransform
- func (n *OverlayNode) Fraction() float64
- func (n *OverlayNode) IsSynchronized() bool
- func (n *OverlayNode) Rate() float64
- func (n *OverlayNode) SetFraction(fraction float64)
- func (n *OverlayNode) SetSynchronized(synchronized bool)
- func (n *OverlayNode) Synchronize()
- type PlaybackNode
- func (n *PlaybackNode) Advance(seconds, synchronizationRate float64)
- func (n *PlaybackNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *PlaybackNode) BoneTransform(bone string) NodeTransform
- func (n *PlaybackNode) Fraction() float64
- func (n *PlaybackNode) IsSynchronized() bool
- func (n *PlaybackNode) Rate() float64
- func (n *PlaybackNode) SetFraction(fraction float64)
- func (n *PlaybackNode) SetSynchronized(synchronized bool)
- func (n *PlaybackNode) Source() Source
- func (n *PlaybackNode) Synchronize()
- type Player
- type PoseNode
- func (n *PoseNode) Advance(seconds, synchronizationRate float64)
- func (n *PoseNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *PoseNode) BoneTransform(bone string) NodeTransform
- func (n *PoseNode) Fraction() float64
- func (n *PoseNode) IsSynchronized() bool
- func (n *PoseNode) Rate() float64
- func (n *PoseNode) Reset()
- func (n *PoseNode) SetFraction(fraction float64)
- func (n *PoseNode) SetSynchronized(synchronized bool)
- func (n *PoseNode) Synchronize()
- type Recording
- func (r *Recording) Binding(name string) (KeyframeSet, bool)
- func (r *Recording) BoneTransformAt(bone string, timestamp float64) NodeTransform
- func (r *Recording) BoneTransformDelta(bone string, fromTimestamp, toTimestamp float64) NodeTransform
- func (r *Recording) BoundNodesIter() iter.Seq[string]
- func (r *Recording) EndTime() float64
- func (r *Recording) Length() float64
- func (r *Recording) Name() string
- func (r *Recording) Playback(loop bool) *PlaybackNode
- func (r *Recording) Pose(timestamp float64) *PoseNode
- func (r *Recording) RemoveBinding(name string) *Recording
- func (r *Recording) SetBinding(name string, keyframes KeyframeSet) *Recording
- func (r *Recording) SetEndTime(endTime float64) *Recording
- func (r *Recording) SetName(name string) *Recording
- func (r *Recording) SetStartTime(startTime float64) *Recording
- func (r *Recording) StartTime() float64
- type RootMotion
- type Source
- type TempoNode
- func (n *TempoNode) Advance(seconds, synchronizationRate float64)
- func (n *TempoNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
- func (n *TempoNode) BoneTransform(bone string) NodeTransform
- func (n *TempoNode) Fraction() float64
- func (n *TempoNode) IsSynchronized() bool
- func (n *TempoNode) Rate() float64
- func (n *TempoNode) SetFraction(fraction float64)
- func (n *TempoNode) SetSpeed(speed float64) *TempoNode
- func (n *TempoNode) SetSynchronized(synchronized bool)
- func (n *TempoNode) Speed() float64
- func (n *TempoNode) Synchronize()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Synchronized ¶
func Synchronized[T Node](node T) T
Synchronized is a helper function that configures a node to be synchronized and returns it. This is useful during node tree construction.
Types ¶
type AddNode ¶
type AddNode struct {
// contains filtered or unexported fields
}
AddNode returns the sum of two animations.
func NewAddNode ¶
NewAddNode creates a new node that returns the sum of two animations.
func (*AddNode) Advance ¶
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*AddNode) BoneDeltaTransform ¶
func (n *AddNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*AddNode) BoneTransform ¶
func (n *AddNode) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*AddNode) Fraction ¶
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*AddNode) IsSynchronized ¶
IsSynchronized returns whether the node should be synchronized.
func (*AddNode) SetFraction ¶
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*AddNode) SetSynchronized ¶
SetSynchronized configures whether the node should be synchronized.
func (*AddNode) Synchronize ¶
func (n *AddNode) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.
type Blend1DEntry ¶
Blend1DEntry specifies an animation to be used by a Blend1DSource.
func NewBlend1DEntry ¶
func NewBlend1DEntry(coord float64, node Node) Blend1DEntry
NewBlend1DEntry creates a new Blend1DEntry.
type Blend1DNode ¶
type Blend1DNode struct {
// contains filtered or unexported fields
}
Blend1DNode is an animation source that blends between the two closest animations positioned on a 1D line.
NOTE: All animations are considered to loop and are synchronized.
func NewBlend1DNode ¶
func NewBlend1DNode(entries ...Blend1DEntry) *Blend1DNode
NewBlend1DNode creates an animation node that can blend between multiple animations placed on a 1D line.
func (*Blend1DNode) Advance ¶
func (n *Blend1DNode) Advance(seconds, synchronizationRate float64)
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*Blend1DNode) BlendCoord ¶
func (n *Blend1DNode) BlendCoord() float64
BlendCoord returns the blending coord.
func (*Blend1DNode) BoneDeltaTransform ¶
func (n *Blend1DNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*Blend1DNode) BoneTransform ¶
func (n *Blend1DNode) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*Blend1DNode) Fraction ¶
func (n *Blend1DNode) Fraction() float64
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*Blend1DNode) IsSynchronized ¶
func (n *Blend1DNode) IsSynchronized() bool
IsSynchronized returns whether the node should be synchronized.
func (*Blend1DNode) Rate ¶
func (n *Blend1DNode) Rate() float64
Rate returns the fraction of the animation length that advances each second.
func (*Blend1DNode) SetBlendCoord ¶
func (n *Blend1DNode) SetBlendCoord(blendCoord float64)
SetBlendCoord changes the blending coord.
func (*Blend1DNode) SetFraction ¶
func (n *Blend1DNode) SetFraction(fraction float64)
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*Blend1DNode) SetSynchronized ¶
func (n *Blend1DNode) SetSynchronized(synchronized bool)
SetSynchronized configures whether the node should be synchronized.
func (*Blend1DNode) Synchronize ¶
func (n *Blend1DNode) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.
type BlendPairNode ¶
type BlendPairNode struct {
// contains filtered or unexported fields
}
BlendPairNode represents an animation node that blends two child animation nodes. The blending factor is determined by the factor field of the node.
func NewBlendPairNode ¶
func NewBlendPairNode(first, second Node) *BlendPairNode
NewBlendPairNode creates a new animation blending node that blends between a pair of sub-nodes.
func (*BlendPairNode) Advance ¶
func (n *BlendPairNode) Advance(seconds, synchronizationRate float64)
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*BlendPairNode) BlendFactor ¶
func (n *BlendPairNode) BlendFactor() float64
BlendFactor returns the blending factor of the node. A value of 0.0 means that the first blend node is used, a value of 1.0 means that the second blend node is used. The value is clamped to the range [0.0, 1.0].
func (*BlendPairNode) BoneDeltaTransform ¶
func (n *BlendPairNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*BlendPairNode) BoneTransform ¶
func (n *BlendPairNode) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*BlendPairNode) Fraction ¶
func (n *BlendPairNode) Fraction() float64
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*BlendPairNode) IsSynchronized ¶
func (n *BlendPairNode) IsSynchronized() bool
IsSynchronized returns whether the node should be synchronized.
func (*BlendPairNode) Rate ¶
func (n *BlendPairNode) Rate() float64
Rate returns the fraction of the animation length that advances each second.
func (*BlendPairNode) SetBlendFactor ¶
func (n *BlendPairNode) SetBlendFactor(factor float64) *BlendPairNode
SetBlendFactor sets the blending factor of the node. The value is clamped to the range [0.0, 1.0].
func (*BlendPairNode) SetFraction ¶
func (n *BlendPairNode) SetFraction(fraction float64)
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*BlendPairNode) SetSynchronized ¶
func (n *BlendPairNode) SetSynchronized(synchronized bool)
SetSynchronized configures whether the node should be synchronized.
func (*BlendPairNode) Synchronize ¶
func (n *BlendPairNode) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.
type DiffNode ¶
type DiffNode struct {
// contains filtered or unexported fields
}
DiffNode returns the difference between two animations.
func NewDiffNode ¶
NewDiffNode creates a node that returns the difference between two nodes.
func (*DiffNode) Advance ¶
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*DiffNode) BoneDeltaTransform ¶
func (n *DiffNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*DiffNode) BoneTransform ¶
func (n *DiffNode) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*DiffNode) Fraction ¶
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*DiffNode) IsSynchronized ¶
IsSynchronized returns whether the node should be synchronized.
func (*DiffNode) Rate ¶
Rate returns the fraction of the animation length that advances each second.
func (*DiffNode) SetFraction ¶
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*DiffNode) SetSynchronized ¶
SetSynchronized configures whether the node should be synchronized.
func (*DiffNode) Synchronize ¶
func (n *DiffNode) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.
type GraphNode ¶
type GraphNode[T comparable] struct { // contains filtered or unexported fields }
GraphNode represents an animation node that is comprised of a graph of animation states and transitions between them.
func NewGraphNode ¶
func NewGraphNode[T comparable]() *GraphNode[T]
NewGraphNode creates a new transition graph animation node.
func (*GraphNode[T]) AddTransition ¶
func (n *GraphNode[T]) AddTransition(from, to T, transition GraphNodeTransition)
AddTransition registers a new state transition.
func (*GraphNode[T]) Advance ¶
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*GraphNode[T]) BoneDeltaTransform ¶
func (n *GraphNode[T]) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*GraphNode[T]) BoneTransform ¶
func (n *GraphNode[T]) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*GraphNode[T]) Fraction ¶
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*GraphNode[T]) IsSynchronized ¶
IsSynchronized returns whether the node should be synchronized.
func (*GraphNode[T]) IsTransitioned ¶
IsTransitioned returns whether the graph has transitioned to a stable state.
func (*GraphNode[T]) JumpToState ¶
func (n *GraphNode[T]) JumpToState(state T)
JumpToState jumps to a specific state and cancels any transitions.
func (*GraphNode[T]) Rate ¶
Rate returns the fraction of the animation length that advances each second (fraction per second).
func (*GraphNode[T]) SetFraction ¶
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*GraphNode[T]) SetSynchronized ¶
SetSynchronized configures whether the node should be synchronized.
func (*GraphNode[T]) SourceState ¶
func (n *GraphNode[T]) SourceState() T
SourceState returns the current source state of the graph.
func (*GraphNode[T]) Synchronize ¶
func (n *GraphNode[T]) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.
func (*GraphNode[T]) TargetState ¶
func (n *GraphNode[T]) TargetState() T
TargetState returns the current target state of the graph.
func (*GraphNode[T]) TransitionFraction ¶
TransitionFraction returns the amount (fraction) of transition that has occurred so far. Returns 1.0 if not in transition.
func (*GraphNode[T]) TransitionTo ¶
func (n *GraphNode[T]) TransitionTo(to T)
TransitionTo triggers a new transition. Calling this while there is an ongoing transition has undefined behavior.
type GraphNodeTransition ¶
type GraphNodeTransition struct {
// FadeInFraction determines the amount of time (in fraction of the total
// animation) that it takes to fade into the transition animation (if there
// is one).
FadeInFraction float64
// FadeOutFraction determines the amount of time (in fraction of the total
// animation) that it takes to fade out of the transition animation (if there
// is one).
FadeOutFraction float64
// Duration optionally specifies a custom duration for the transition in
// case that a transition animation is not specified.
//
// Defaults to 1.0 (one second).
Duration opt.T[float64]
// Animation optionally specifies an animation to be blended on top of the
// blending from the start state to the end state. If this is not specified
// then Duration is used to determine the length of the transition.
Animation opt.T[Node]
}
GraphNodeTransition represents a transition in a GraphNode.
type KeyframeList ¶
KeyframeList is a list of keyframes.
type KeyframeSet ¶
type KeyframeSet struct {
TranslationKeyframes KeyframeList[dprec.Vec3]
RotationKeyframes KeyframeList[dprec.Quat]
ScaleKeyframes KeyframeList[dprec.Vec3]
}
KeyframeSet represents a set of keyframes for an animation, including translations, rotations, and scales.
func (KeyframeSet) Rotation ¶
func (s KeyframeSet) Rotation(timestamp float64) dprec.Quat
Rotation returns the rotation at the specified timestamp by interpolating between the two closest keyframes using spherical linear interpolation.
func (KeyframeSet) Scale ¶
func (s KeyframeSet) Scale(timestamp float64) dprec.Vec3
Scale returns the scale at the specified timestamp by interpolating between the two closest keyframes.
func (KeyframeSet) Translation ¶
func (s KeyframeSet) Translation(timestamp float64) dprec.Vec3
Translation returns the translation at the specified timestamp by interpolating between the two closest keyframes.
type ManualPoseNode ¶
type ManualPoseNode struct {
// contains filtered or unexported fields
}
ManualPoseNode is an animation node that represents a static pose that is manually configured.
func NewManualPoseNode ¶
func NewManualPoseNode(transforms map[string]NodeTransform) *ManualPoseNode
NewManualPoseNode creates a static animation pose with pre-configured bone transformations.
func (*ManualPoseNode) Advance ¶
func (n *ManualPoseNode) Advance(seconds, synchronizationRate float64)
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*ManualPoseNode) BoneDeltaTransform ¶
func (n *ManualPoseNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*ManualPoseNode) BoneTransform ¶
func (n *ManualPoseNode) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*ManualPoseNode) Fraction ¶
func (n *ManualPoseNode) Fraction() float64
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*ManualPoseNode) IsSynchronized ¶
func (n *ManualPoseNode) IsSynchronized() bool
IsSynchronized returns whether the node should be synchronized.
func (*ManualPoseNode) Rate ¶
func (n *ManualPoseNode) Rate() float64
Rate returns the fraction of the animation length that advances each second (fraction per second).
func (*ManualPoseNode) Reset ¶
func (n *ManualPoseNode) Reset()
Reset clears any update delta information, so that new interpolations can be tracked.
func (*ManualPoseNode) SetFraction ¶
func (n *ManualPoseNode) SetFraction(fraction float64)
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*ManualPoseNode) SetSynchronized ¶
func (n *ManualPoseNode) SetSynchronized(synchronized bool)
SetSynchronized configures whether the node should be synchronized.
func (*ManualPoseNode) Synchronize ¶
func (n *ManualPoseNode) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.
type MaskNode ¶
type MaskNode struct {
// contains filtered or unexported fields
}
MaskNode is an animation source that picks specific bones from another animation source.
func NewMaskNode ¶
NewMaskNode creates a new animation node that picks specific bones from the specified node.
func (*MaskNode) Advance ¶
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*MaskNode) BoneDeltaTransform ¶
func (n *MaskNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*MaskNode) BoneTransform ¶
func (n *MaskNode) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*MaskNode) Fraction ¶
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*MaskNode) IsSynchronized ¶
IsSynchronized returns whether the node should be synchronized.
func (*MaskNode) Rate ¶
Rate returns the fraction of the animation length that advances each second.
func (*MaskNode) SetFraction ¶
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*MaskNode) SetSynchronized ¶
SetSynchronized configures whether the node should be synchronized.
func (*MaskNode) Synchronize ¶
func (n *MaskNode) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.
type Node ¶
type Node interface {
// Rate returns the fraction of the animation length that advances each
// second (fraction per second).
Rate() float64
// Fraction returns the amount of animation that has elapsed. In case of
// looping, the value will wrap around.
//
// The returned value is in the range [0.0..1.0).
Fraction() float64
// SetFraction relocates the animation to the specified fractional position.
//
// NOTE: This resets the animation and accumulated delta is lost.
SetFraction(fraction float64)
// Advance moves the animation forward by the specified delta seconds.
//
// The synchronizationRate determines the amount of scaling on the seconds
// that should be applied in order to be correctly synchronized with sibling
// and parent nodes in case of synchronization.
Advance(seconds, synchronizationRate float64)
// IsSynchronized returns whether the node should be synchronized.
IsSynchronized() bool
// SetSynchronized configures whether the node should be synchronized.
SetSynchronized(synchronized bool)
// Synchronize is called each frame to allow a node to synchronized its
// children (depending on their setting).
//
// This will be called (and should be called on children) regardless if
// the current or any child node is synchronized or not.
Synchronize()
// BoneTransform returns the transformation of the specified bone. Keep in
// mind that this is after a fixed interval update has been applied. If
// this is called from within a dynamic update handler, the
// BoneTransformInterpolation method should be used instead.
BoneTransform(bone string) NodeTransform
// BoneDeltaTransform returns the transformation that the bone will experience
// throughout the next delta interval. This is used for root motion.
BoneDeltaTransform(bone string, delta float64) NodeTransform
}
Node represents an animation logic.
type NodeTransform ¶
type NodeTransform struct {
// Translation, if specified, indicates the translation of the node.
Translation opt.T[dprec.Vec3]
// Rotation, if specified, indicates the rotation of the node.
Rotation opt.T[dprec.Quat]
// Scale, if specified, indicates the scale of the node.
Scale opt.T[dprec.Vec3]
}
NodeTransform represents the transformation of a node.
func AddNodeTransforms ¶
func AddNodeTransforms(first, second NodeTransform) NodeTransform
AddNodeTransforms combines two transforms into a single one.
func BlendNodeTransforms ¶
func BlendNodeTransforms(first, second NodeTransform, factor float64) NodeTransform
BlendNodeTransforms blends two node transformations using the specified factor. A factor of 0.0 means that the first transformation is used, a factor of 1.0 means that the second transformation is used.
func DiffNodeTransforms ¶
func DiffNodeTransforms(first, second NodeTransform) NodeTransform
DiffNodeTransforms combines two transforms into a single one.
func FirstNodeTransform ¶
func FirstNodeTransform(first, second NodeTransform) NodeTransform
FirstNodeTransform combines two transforms into a single one by using the first transform that has a value.
func InverseNodeTransform ¶
func InverseNodeTransform(transform NodeTransform) NodeTransform
InverseNodeTransform returns the inverse of a node transform.
type OnceNode ¶
type OnceNode struct {
// contains filtered or unexported fields
}
OnceNode allows an animation to be played just once.
func NewOnceNode ¶
NewOnceNode creates a node that can play an animation once at a time, per user request.
func (*OnceNode) Advance ¶
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*OnceNode) BoneDeltaTransform ¶
func (n *OnceNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*OnceNode) BoneTransform ¶
func (n *OnceNode) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*OnceNode) FadeInFraction ¶
FadeInFraction returns the amount of time (in fraction of the total animation) that it takes to fade into the overlay animation.
func (*OnceNode) FadeOutFraction ¶
FadeOutFraction returns the amount of time (in fraction of the total animation) that it takes to fade out of the overlay animation.
func (*OnceNode) Fraction ¶
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*OnceNode) IsSynchronized ¶
IsSynchronized returns whether the node should be synchronized.
func (*OnceNode) Rate ¶
Rate returns the fraction of the animation length that advances each second.
func (*OnceNode) SetFadeInFraction ¶
SetFadeInFraction sets the amount of time (in fraction of the total animation) that it takes to fade into the overlay animation.
func (*OnceNode) SetFadeOutFraction ¶
SetFadeOutFraction sets the amount of time (in fraction of the total animation) that it takes to fade out of the overlay animation.
func (*OnceNode) SetFraction ¶
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*OnceNode) SetSynchronized ¶
SetSynchronized configures whether the node should be synchronized.
func (*OnceNode) Synchronize ¶
func (n *OnceNode) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.
type OneOfNode ¶
type OneOfNode[T comparable] struct { // contains filtered or unexported fields }
OneOfNode is an animation node that plays one specific animation from a set of animations. The active animation can be changed at any time.
func NewOneOfNode ¶
func NewOneOfNode[T comparable](animations map[T]Node) *OneOfNode[T]
NewOneOfNode creates an animation node that produces one specific animation from a set of animations.
func (*OneOfNode[T]) ActiveAnimation ¶
func (n *OneOfNode[T]) ActiveAnimation() T
ActiveAnimation returns the animation key that is playing.
func (*OneOfNode[T]) Advance ¶
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*OneOfNode[T]) BoneDeltaTransform ¶
func (n *OneOfNode[T]) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*OneOfNode[T]) BoneTransform ¶
func (n *OneOfNode[T]) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*OneOfNode[T]) Fraction ¶
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*OneOfNode[T]) IsSynchronized ¶
IsSynchronized returns whether the node should be synchronized.
func (*OneOfNode[T]) PickAnimation ¶
PickAnimation changes to the specified animation.
The rewind flag controls whether the new animation should start from the beginning.
func (*OneOfNode[T]) Rate ¶
Rate returns the fraction of the animation length that advances each second.
func (*OneOfNode[T]) SetFraction ¶
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*OneOfNode[T]) SetSynchronized ¶
SetSynchronized configures whether the node should be synchronized.
func (*OneOfNode[T]) Synchronize ¶
func (n *OneOfNode[T]) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.
type OverlayNode ¶
type OverlayNode struct {
// contains filtered or unexported fields
}
OverlayNode is an animation node that overlays one animation on top of another.
func NewOverlayNode ¶
func NewOverlayNode(primary, overlay Node) *OverlayNode
NewOverlayNode creates an animation node that overlays one animation on top of another.
func (*OverlayNode) Advance ¶
func (n *OverlayNode) Advance(seconds, synchronizationRate float64)
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*OverlayNode) BoneDeltaTransform ¶
func (n *OverlayNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*OverlayNode) BoneTransform ¶
func (n *OverlayNode) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*OverlayNode) Fraction ¶
func (n *OverlayNode) Fraction() float64
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*OverlayNode) IsSynchronized ¶
func (n *OverlayNode) IsSynchronized() bool
IsSynchronized returns whether the node should be synchronized.
func (*OverlayNode) Rate ¶
func (n *OverlayNode) Rate() float64
Rate returns the fraction of the animation length that advances each second (fraction per second).
func (*OverlayNode) SetFraction ¶
func (n *OverlayNode) SetFraction(fraction float64)
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*OverlayNode) SetSynchronized ¶
func (n *OverlayNode) SetSynchronized(synchronized bool)
SetSynchronized configures whether the node should be synchronized.
func (*OverlayNode) Synchronize ¶
func (n *OverlayNode) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.
type PlaybackNode ¶
type PlaybackNode struct {
// contains filtered or unexported fields
}
PlaybackNode represents an animation source that plays back an animation.
func NewPlaybackNode ¶
func NewPlaybackNode(source Source, loop bool) *PlaybackNode
NewPlaybackNode creates a simple animation Node that plays back a given source directly.
func (*PlaybackNode) Advance ¶
func (n *PlaybackNode) Advance(seconds, synchronizationRate float64)
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*PlaybackNode) BoneDeltaTransform ¶
func (n *PlaybackNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*PlaybackNode) BoneTransform ¶
func (n *PlaybackNode) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*PlaybackNode) Fraction ¶
func (n *PlaybackNode) Fraction() float64
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*PlaybackNode) IsSynchronized ¶
func (n *PlaybackNode) IsSynchronized() bool
IsSynchronized returns whether the node should be synchronized.
func (*PlaybackNode) Rate ¶
func (n *PlaybackNode) Rate() float64
Rate returns the fraction of the animation length that advances each second.
func (*PlaybackNode) SetFraction ¶
func (n *PlaybackNode) SetFraction(fraction float64)
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*PlaybackNode) SetSynchronized ¶
func (n *PlaybackNode) SetSynchronized(synchronized bool)
SetSynchronized configures whether the node should be synchronized.
func (*PlaybackNode) Source ¶
func (n *PlaybackNode) Source() Source
Source returns the underlying animation source.
func (*PlaybackNode) Synchronize ¶
func (n *PlaybackNode) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
func (*Player) BoneTransform ¶
func (p *Player) BoneTransform(name string) NodeTransform
type PoseNode ¶
type PoseNode struct {
// contains filtered or unexported fields
}
PoseNode represents an animation node that produces a single static bone pose.
func NewPoseNode ¶
NewPoseNode creates an animation node that produces a single static bone pose.
func (*PoseNode) Advance ¶
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*PoseNode) BoneDeltaTransform ¶
func (n *PoseNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*PoseNode) BoneTransform ¶
func (n *PoseNode) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*PoseNode) Fraction ¶
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*PoseNode) IsSynchronized ¶
IsSynchronized returns whether the node should be synchronized.
func (*PoseNode) Rate ¶
Rate returns the fraction of the animation length that advances each second (fraction per second).
func (*PoseNode) Reset ¶
func (n *PoseNode) Reset()
Reset clears any update delta information, so that new interpolations can be tracked.
func (*PoseNode) SetFraction ¶
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*PoseNode) SetSynchronized ¶
SetSynchronized configures whether the node should be synchronized.
func (*PoseNode) Synchronize ¶
func (n *PoseNode) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.
type Recording ¶
type Recording struct {
// contains filtered or unexported fields
}
Recording represents a pre-stored set of keyframmes that can be played back.
func (*Recording) Binding ¶
func (r *Recording) Binding(name string) (KeyframeSet, bool)
Binding returns the keyframes for the node with the specified name.
func (*Recording) BoneTransformAt ¶
func (r *Recording) BoneTransformAt(bone string, timestamp float64) NodeTransform
BoneTransformAt returns the transformation for the specified bone at the specified animation timestamp.
func (*Recording) BoneTransformDelta ¶
func (r *Recording) BoneTransformDelta(bone string, fromTimestamp, toTimestamp float64) NodeTransform
BoneTransformDelta returns the transformation that occurred for the specified bone between the from and to animation timestamps .
This is mostly used for root motion.
func (*Recording) BoundNodesIter ¶
BoundNodesIter returns an iterator over the names of all nodes that have keyframes in this recording.
func (*Recording) Playback ¶
func (r *Recording) Playback(loop bool) *PlaybackNode
Playback creates a new animtion node that plays back the animation.
func (*Recording) Pose ¶
Pose returns a new animation node that represents a fixed pose from the recording.
func (*Recording) RemoveBinding ¶
RemoveBinding removes the binding for the node with the specified name.
func (*Recording) SetBinding ¶
func (r *Recording) SetBinding(name string, keyframes KeyframeSet) *Recording
SetBinding sets the keyframes for the node with the specified name.
func (*Recording) SetEndTime ¶
SetEndTime sets the time (in seconds) at which the recording ends.
func (*Recording) SetStartTime ¶
SetStartTime sets the time (in seconds) at which the recording starts.
type RootMotion ¶
type RootMotion struct {
// contains filtered or unexported fields
}
RootMotion allows for the extraction of relative animation transformations from a root bone in order to move a character.
func NewRootMotion ¶
func NewRootMotion(node Node, bone string) *RootMotion
NewRootMotion creates a new RootMotion instance that is controlled by the specified root bone.
func (*RootMotion) DeltaTransform ¶
func (m *RootMotion) DeltaTransform(delta float64) dprec.Mat4
DeltaTransform returns the transformation that occurred during the last animation tick for the root bone.
type Source ¶
type Source interface {
// Length returns the length of the animation in seconds.
Length() float64
// BoneTransformDelta returns the transformation that occurred for the
// specified bone between the from and to animation timestamps .
//
// This is mostly used for root motion.
BoneTransformDelta(bone string, fromTimestamp, toTimestamp float64) NodeTransform
// BoneTransformAt returns the transformation for the specified bone
// at the specified animation timestamp.
BoneTransformAt(bone string, timestamp float64) NodeTransform
}
Source represents a source of animation data.
type TempoNode ¶
type TempoNode struct {
// contains filtered or unexported fields
}
TempoNode is a decorator for an animation source that allows adjusting the playback speed.
func NewTempoNode ¶
NewTempoNode creates a new animation node that can adjust the speed of the underlying animation.
func (*TempoNode) Advance ¶
Advance moves the animation forward by the specified delta seconds.
The synchronizationRate determines the amount of scaling on the seconds that should be applied in order to be correctly synchronized with sibling and parent nodes in case of synchronization.
func (*TempoNode) BoneDeltaTransform ¶
func (n *TempoNode) BoneDeltaTransform(bone string, delta float64) NodeTransform
BoneDeltaTransform returns the transformation that the bone will experience throughout the next delta interval. This is used for root motion.
func (*TempoNode) BoneTransform ¶
func (n *TempoNode) BoneTransform(bone string) NodeTransform
BoneTransform returns the transformation of the specified bone. Keep in mind that this is after a fixed interval update has been applied. If this is called from within a dynamic update handler, the BoneTransformInterpolation method should be used instead.
func (*TempoNode) Fraction ¶
Fraction returns the amount of animation that has elapsed. In case of looping, the value will wrap around.
The returned value is in the range [0.0..1.0).
func (*TempoNode) IsSynchronized ¶
IsSynchronized returns whether the node should be synchronized.
func (*TempoNode) Rate ¶
Rate returns the fraction of the animation length that advances each second.
func (*TempoNode) SetFraction ¶
SetFraction relocates the animation to the specified fractional position.
NOTE: This resets the animation and accumulated delta is lost.
func (*TempoNode) SetSynchronized ¶
SetSynchronized configures whether the node should be synchronized.
func (*TempoNode) Speed ¶
Speed returns the current playback speed of the animation. A value of 1.0 means that the animation is played at normal speed.
func (*TempoNode) Synchronize ¶
func (n *TempoNode) Synchronize()
Synchronize is called each frame to allow a node to synchronized its children (depending on their setting).
This will be called (and should be called on children) regardless if the current or any child node is synchronized or not.