Documentation
¶
Overview ¶
Package mocap turns a parsed BVH bvh.Hierarchy into an animatable seen scene-graph skeleton.
It mirrors the Mocap/MocapModel/MocapAnimator types from the original seen.js library: New walks the joint tree building a nested seen.Group per joint (so each joint inherits its parent's transform), draws a bone shape from every joint to each of its children, and precomputes the per-frame translation+rotation for every animated joint. Model.Apply then poses the skeleton at a given motion frame.
h, _ := bvh.Load("dance.bvh")
m := mocap.New(h, nil)
scene.Group.Add(m.Group)
m.Apply(frameIndex) // pose the skeleton, e.g. once per animation tick
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Model ¶
type Model struct {
// Group is the root of the skeleton's scene-graph subtree.
Group *seen.Group
// FrameTime is the sampling interval between motion frames.
FrameTime time.Duration
// contains filtered or unexported fields
}
Model is a skeleton built from a parsed BVH hierarchy together with the per-frame transforms needed to animate it. Add Model.Group to a scene and call Model.Apply to pose the skeleton at a frame.
func New ¶
func New(h bvh.Hierarchy, factory ShapeFactory) *Model
New builds an animatable skeleton from h, using factory to create the bone shapes. If factory is nil, DefaultShapeFactory is used.
func (*Model) Apply ¶
Apply poses the skeleton at frame index i, wrapping modulo Model.Frames.
type ShapeFactory ¶
ShapeFactory builds the bone shape drawn from a joint's origin to endpoint, where endpoint is the offset of one of the joint's children expressed in the joint's local frame. Returning nil omits that bone (e.g. for a zero-length segment).