mocap

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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

func DefaultShapeFactory

func DefaultShapeFactory(_ bvh.Joint, endpoint point.Point) seen.Object

DefaultShapeFactory draws a light-grey unit-radius pipe from the joint origin to endpoint, skipping zero-length segments.

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

func (m *Model) Apply(i int)

Apply poses the skeleton at frame index i, wrapping modulo Model.Frames.

func (*Model) Frames

func (m *Model) Frames() int

Frames returns the number of motion frames available.

type ShapeFactory

type ShapeFactory func(joint bvh.Joint, endpoint point.Point) seen.Object

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL