API

class ipyanimlab.viewer.ShadowQuality(value)

The shadow quality

.LOW .MID .HIGH .ULTRA

class ipyanimlab.viewer.ShadowSize(value)

Shadow size

.NARROW .WIDE

class ipyanimlab.viewer.Viewer(**kwargs: Any)

The Viewer for the ipyAnimLab

This inherits from the ipywebgl viewer, so all the function from there are available.

The ipyAnimLab is using the column_major shader convention.

Args:
shadow_quality

(ShadowQuality enum, optional): the quality of the shadow. Defaults to ShadowQuality.MID.

shadow_size

(ShadowSize enum, optional): the type of shadow (around one character or around the scene). Defaults to ShadowSize.WIDE.

width

(int): the width of the canvas. Defaults to 1000.

height

(int): the height of the canvas. Defaults to 600.

camera_pos

([float, float, float]): the camera position in the scene. Defaults to [-370, 280, 350].

camera_yaw

(float): the camera yaw angle in degree. Defaults to -45.

camera_pitch

(float): the camera pitch angle in degree. Defaults to -18.

camera_fov

(float): the camera field of view in degree. Defaults to 50.

camera_near

(float): the camera near plane distance. Defaults to 20.

camera_far

(float): the camera far plane distance. Defaults to 2800.

mouse_speed

(float): mouse speed (camera rotation speed). Defaults to 1.

move_speed

(float): move speed (camera translation speed). Defaults to 1.

move_keys

(str): the move keys as a string. Forward, Left, Back, Right. Defaults to ‘wasd’.

sync_image_data

(bool): do we store the rendered imaged in python. This will significantly slow the rendering. Defaults to False.

image_data

(bytes): the stored image as bytes. If the sync_image_data is set to True.

verbose

(int): with verbose set to 1, all the commands executed by the frontend will be logged in the console. Defaults to 0.

begin_display()

Before rendering any asset to screen (and after ending the shadow rendering) we need to activate the display rendering mode. This will activate all the needed gbuffers for the deferred rendering.

begin_shadow()

Before rendering any asset in the shadow rendered texture we need to activate the shadow rendering mode.

create_asset(vertices=None, indices=None, materials=None, boneids=None, weights=None, bindpose=None, initialpose=None, bone_names=None, bone_parents=None, name=None, mesh=None)

Create an asset from raw data

For a skinned mesh we only support 256 bones maximum

Args:
vertices

(np float32 array, optional): the flatten vertex buffer with [pos.x, pos.y, pos.z, normal.x, normal.y, normal.z, color.r, color.g, color.b, ambientocclusion] * number_of_vertices. Defaults to None.

indices

(np int16 array, optional): the indices to draw the mesh as triangle list. Defaults to None.

materials

(list of Material, optional): the material list to render the mesh. If none it renders the entire mesh with one default material. Defaults to None.

boneids

(np int 32 array, optional): if skinned mesh, the flatten list of boneids per vertex, can be 4 ids per vertex or 8 ids per vertex. Defaults to None.

weights

(np float 32 array, optional): if skinned mesh, the fatten list of bone weights per vertex, can be 4 or 8 weights per vertex, but it must match the boneids. Defaults to None.

bindpose

(np float 32 [bone_count,4,4], optional): if skinned mesh this is the bindpose of the skeleton (the inverse of the world matrices of each bone). Defaults to None.

initialpose

(np float 32 [bone_count,4,4], optional): if skinned mesh this is the localpose of the skeleton. Defaults to None.

bone_names

(list of strings, optional): the list of bone names. It must match the number of bone. Defaults to None.

bone_parents

(np int32 array, optional): the list of parent ids for each bone. It must match the number of bone. Defaults to None.

name

(string, optional): the name of the asset. Defaults to None.

mesh

(Mesh, optional): if a mesh is already created we will discard any given buffers and use the provided mesh instead. Defaults to None.

Returns:
Asset

the created asset

create_cube(width=1.0, height=1.0, depth=1.0)

create a cube asset

Args:
width

(float, optional): the with of the cube. Defaults to 1.0.

height

(float, optional): the height of the cube. Defaults to 1.0.

depth

(float, optional): the depth of the cube. Defaults to 1.0.

Returns:
asset

the created asset

create_sphere(radius=1.0)

Create a sphere asset

Args:
radius

(float, optional): radius of the sphere. Defaults to 1.0.

Returns:
asset

the created asset

debug_display_ao()

debug display the ambient occlusion buffer (the value coming the ao in the mesh), this must be after the end_display

debug_display_buffer(texture_id: int, lod_id: int = 0)

debug display one of the internal render texture used by the viewer, this must be after the end_display

Args:
texture_id

(int): the id of the texture to render

lod_id

(int, optional): the lod of the texture to render. Defaults to 0.

debug_display_color()

Debug display the color buffer, this must be after the end_display

debug_display_normal()

debug display the normal buffer, this must be after the end_display

debug_display_ssao()

debug display the screen space ambien occlusion buffer, this must be after the end_display

debug_draw_frustum(viewproj_matrix)

display a frustum

Args:
viewproj_matrix

(np float 32 array [4,4]): the matrix to display

debug_draw_shadow_frustum()

display the shadow frustrum, this must be after the end_display

draw(asset, worlds=None, names=None, materials=None)

Draw an asset This funciton is only available bewteen begin_shadow and end_shadow, and begin_display and end_display

if no worlds are given, we use the internal values from the asset. if we have one world and a rigid asset, we use the given matrix instead of the xform from the asset. if we have multiple worlds and a rigid asset, we do a instancied rendering of the mesh. if we have multiple worlds and a skinned asset, we assume them to be the skeleton matrices in local space. > if we have names, we do the mapping between the names and the skeleton. names and worlds must have the same length > if we do not have names, we assume that the list of worlds match the skeleton exactly.

Args:
asset

(Asset): the asset to render.

worlds

(np float32 […,4,4], optional): a 4x4 matrix of an array of 4x4 matrices. Defaults to None.

names

(list of string, optional): the list of names of the bones given as worlds. Defaults to None.

materials

(list of Material, optional): the list of materials we want to use instead of the one found in the asset. Defaults to None.

draw_axis(matrices, scale=5.0)

Draw one or multiple XYZ axis, this must be called after end_display You can use a disable(depth_test=True) to be sure to display on top of the zbuffer

Args:
matrices

(np float32 array […, 4, 4]): the matrix of list of matrices to render

scale

(float, optional): the size of the axis to render. Defaults to 5.0.

draw_lines(positions, color=array([0., 0., 0.], dtype=float32))

Draw lines, this must be called after end_display You can use a disable(depth_test=True) to be sure to display on top of the zbuffer

Args:
positions

(np float 32 array [2*line_count, 3]): a list of points to draw line. A line will be rendered between each pair of points

color

(np float 32 array, optional): the rgb color between 0 and 1. Defaults to np.zeros([3], dtype=np.float32).

end_display()

Once all the asset are draw in the gbuffers we call end_display. This will compute the SSAO, lighting and shadow and display the result on framebuffer

end_shadow()

Once we have finished rendering all the asset we wanted in the shadow rendered texture we deactivate the shadow rendering mode. This will make the texture available for the lighting after.

import_fbx_asset(path, read_material=True)

Import an fbx file as an asset. The asset can be a rigid asset or a skeletal asset

if the path is not found, we will try to load the asset from the internal ‘assets’ folder

Args:
path

(string): the path to the fbx file

read_material

(bool): do we use the materials colors. Defaults : True

Returns:
Asset

the loaded asset

import_usd_asset(path)

Import a usd file as an asset. The asset can be a rigid asset or a skeletal asset

if the path is not found, we will try to load the asset from the internal ‘assets’ folder

Args:
path

(string): the path to the usd file

Returns:
Asset

the loaded asset

set_shadow_poi(position)

update the shadow point of interest (the center of the projection)

Args:
position

(np.array([0,0,0], dtype=np.float32)): the position as a float32 numpy array

set_shadow_projection(width, height, near, far)

update the shadow projection

Args:
width

(float): width of the projection

height

(float): height of the projection

near

(float): near plane distance

far

(float): far plane distance

set_time_of_day(time: int)

Change the time of day

Args:
time

(int): the time between dawn (0) to noon (60)

ipyanimlab.utils.angle_axis_to_quat(angle, axis)

Converts from and angle-axis representation to a quaternion representation

Parameters
  • angle – angles tensor

  • axis – axis tensor

Returns

quaternion tensor

ipyanimlab.utils.critical_velocity_spring(x, v, a, v_goal, halflife, dt)

Exact update for critically damped spring system with acceleration

Args:
x

(float or tensor): current position

v

(float or tensor): current velocity

a

(float or tensor): current acceleration

v_goal

(float or tensor): target velocity

halflife

(float): time for velocity difference to halve

dt

(float): time step

Returns:

tuple (x_next, v_next, a_next): next position, velocity, and acceleration

ipyanimlab.utils.euler_to_quat(e, order='zyx')

Converts from an euler representation to a quaternion representation

Parameters
  • e – euler tensor

  • order – order of euler rotations

Returns

quaternion tensor

ipyanimlab.utils.extract_feet_contacts(pos, lfoot_idx, rfoot_idx, velfactor=0.02)

Extracts binary tensors of feet contacts

Parameters
  • pos – tensor of global positions of shape (Timesteps, Joints, 3)

  • lfoot_idx – indices list of left foot joints

  • rfoot_idx – indices list of right foot joints

  • velfactor – velocity threshold to consider a joint moving or not

Returns

binary tensors of left foot contacts and right foot contacts

ipyanimlab.utils.fast_negexp(x)

Fast approximation of exp(-x) using rational function

Args:
x

(float or tensor): input value(s) to approximate the negative exponential for

Returns:

(float or tensor): approximate value of exp(-x)

ipyanimlab.utils.halflife_to_damping(halflife, eps=1e-05)

Convert halflife parameter to damping coefficient

Args:
halflife

(float or tensor): halflife controlling spring decay speed

eps

(float): small epsilon to avoid division by zero

Returns:

(float or tensor): damping coefficient corresponding to the halflife

ipyanimlab.utils.inertialize_transition_quat(off_x, off_v, src_x, src_v, dst_x, dst_v)

Compute transition offsets for quaternion inertialization

Args:
off_x

(tensor [4]): current orientation offset quaternion

off_v

(tensor [3]): current angular velocity offset

src_x

(tensor [4]): source orientation quaternion before transition

src_v

(tensor [3]): source angular velocity before transition

dst_x

(tensor [4]): destination orientation quaternion after transition

dst_v

(tensor [3]): destination angular velocity after transition

Returns:

tuple (off_x, off_v): updated rotational offset quaternion and velocity

ipyanimlab.utils.inertialize_transition_vec3(off_x, off_v, src_x, src_v, dst_x, dst_v)

Compute transition offsets for vector inertialization

Args:
off_x

(tensor [3]): current positional offset

off_v

(tensor [3]): current velocity offset

src_x

(tensor [3]): source position before transition

src_v

(tensor [3]): source velocity before transition

dst_x

(tensor [3]): destination position after transition

dst_v

(tensor [3]): destination velocity after transition

Returns:

tuple (off_x, off_v): updated offset position and velocity for inertial blending

ipyanimlab.utils.inertialize_update_quat(in_x, in_v, off_x, off_v, halflife, dt)

Perform quaternion inertialization update using spring-damper smoothing

Args:
in_x

(tensor [4]): input orientation quaternion

in_v

(tensor [3]): input angular velocity

off_x

(tensor [4]): current offset quaternion

off_v

(tensor [3]): current angular velocity offset

halflife

(float): time for rotational offset to decay by half

dt

(float): time step

Returns:
tuple (out_x, out_v, off_x, off_v):
  • out_x: updated orientation quaternion after inertialization

  • out_v: updated angular velocity after inertialization

  • off_x/off_v: decayed offset quaternion and velocity

ipyanimlab.utils.inertialize_update_vec3(in_x, in_v, off_x, off_v, halflife, dt)

Perform vector inertialization update using spring-damper smoothing

Args:
in_x

(tensor [3]): input position

in_v

(tensor [3]): input velocity

off_x

(tensor [3]): current offset position

off_v

(tensor [3]): current offset velocity

halflife

(float): time for offset to decay by half

dt

(float): time step

Returns:
tuple (out_x, out_v, off_x, off_v):
  • out_x: updated position after inertialization

  • out_v: updated velocity after inertialization

  • off_x/off_v: decayed offset values after spring-damper update

ipyanimlab.utils.interpolate_local(lcl_r_mb, lcl_q_mb, n_past, n_future)

Performs interpolation between 2 frames of an animation sequence.

The 2 frames are indirectly specified through n_past and n_future. SLERP is performed on the quaternions LERP is performed on the root’s positions.

Parameters
  • lcl_r_mb – Local/Global root positions (B, T, 1, 3)

  • lcl_q_mb – Local quaternions (B, T, J, 4)

  • n_past – Number of frames of past context

  • n_future – Number of frames of future context

Returns

Interpolated root and quats

ipyanimlab.utils.length(x, axis=- 1, keepdims=True)

Computes vector norm along a tensor axis(axes)

Parameters
  • x – tensor

  • axis – axis(axes) along which to compute the norm

  • keepdims – indicates if the dimension(s) on axis should be kept

Returns

The length or vector of lengths.

ipyanimlab.utils.limb_ik(quats, pos, parents, names, target_quats, target_pos, effector_names=['LeftFoot', 'RightFoot'])

compute limb ik giving the end effectors

Args:
quats

(local quaternion tensor): [frame_count, bone_count, 4]

pos

(local translation tensor): [frame_count, bone_count, 3]

parents

(int tensor): the parent index in the skeleton

names

(list of strings): the names of the bones

target_quats

(global tensor of quaternions): (framecount, effector_count, 4)

target_pos

(global tensor of positions): (framecount, effector_count, 3)

effector_names

(string list): the names of the end of the chains

Returns:

tupple of tensors (quat pos)

ipyanimlab.utils.m3x3_to_quat(ts, eps=1e-10)

convert matrix3x3 tensor into a quaternion tensor

Parameters

ts – matrix tensor […, 3, 3] actually works with a […,4,4]

Returns

tensor of quaternions

ipyanimlab.utils.m4x4_to_qp(ts, eps=1e-10)

convert a matrix4x4 tensor in quat pos tensors

Parameters

ts – tensor of matrix 4x4

Returns

tuple of tensors of quaternions and positions

ipyanimlab.utils.mirror(quats, pos, parents, names, left_name='Left', right_name='Right')

Mirror an animation

Args:
quats

(local quaternion tensor): [frame_count, bone_count, 4]

pos

(local translation tensor): [frame_count, bone_count, 3]

parents

(int tensor): the parent index in the skeleton

names

(list of strings): the names of the bones

left_name

(str, optional): the name to search for in the replace. Defaults to “Left”.

right_name

(str, optional): the name to search for in the replace. Defaults to “Right”.

Returns:
tuple of tensor

the new quats and pos tensors

ipyanimlab.utils.normalize(x, axis=- 1, eps=1e-08)

Normalizes a tensor over some axis (axes)

Parameters
  • x – data tensor

  • axis – axis(axes) along which to compute the norm

  • eps – epsilon to prevent numerical instabilities

Returns

The normalized tensor

ipyanimlab.utils.qp_inv(qp)

inverse a quatpos

Parameters

qp – tuple of tensors of quaternions and positions

Returns

tuple of tensors of quaternions and positions

ipyanimlab.utils.qp_mul(qp_a, qp_b)

Multiply two quatpos (similar to matrix multiplication in numpy)

Parameters
  • qp_a – tuple of tensors of quaternions and positions

  • qp_b – tuple of tensors of quaternions and positions

Returns

tuple of tensors of quaternions and positions

ipyanimlab.utils.quat_abs(q)

Ensure quaternion has positive real (w) component

Args:
q

(tensor): quaternion(s) […, 4] where q[…,0] is the real component

Returns:

(tensor): quaternion(s) with positive real component

ipyanimlab.utils.quat_between(x, y, up=None)

Quaternion rotations between two 3D-vector arrays

Parameters
  • x – tensor of 3D vectors

  • y – tensor of 3D vectors

  • up – tensor of 3D vectors (not mandatory)

Returns

tensor of quaternions

ipyanimlab.utils.quat_exp(x, eps=1e-08)

Compute quaternion exponential

Args:
x

(tensor): input vector(s) […, 3]

eps

(float): small epsilon for numerical stability

Returns:

(tensor): resulting quaternion(s) […, 4]

ipyanimlab.utils.quat_fk(lrot, lpos, parents)

Performs Forward Kinematics (FK) on local quaternions and local positions to retrieve global representations

Parameters
  • lrot – tensor of local quaternions with shape (…, Nb of joints, 4)

  • lpos – tensor of local positions with shape (…, Nb of joints, 3)

  • parents – list of parents indices

Returns

tuple of tensors of global quaternion, global positions

ipyanimlab.utils.quat_from_scaled_angle_axis(x, eps=1e-08)

Convert scaled angle-axis representation to quaternion

Args:
x

(tensor): scaled angle-axis vector(s) […, 3]

eps

(float): small epsilon for numerical stability

Returns:

(tensor): quaternion(s) […, 4]

ipyanimlab.utils.quat_ik(grot, gpos, parents)

Performs Inverse Kinematics (IK) on global quaternions and global positions to retrieve local representations

Parameters
  • grot – tensor of global quaternions with shape (…, Nb of joints, 4)

  • gpos – tensor of global positions with shape (…, Nb of joints, 3)

  • parents – list of parents indices

Returns

tuple of tensors of local quaternion, local positions

ipyanimlab.utils.quat_inv(q)

Inverts a tensor of quaternions

Parameters

q – quaternion tensor

Returns

tensor of inverted quaternions

ipyanimlab.utils.quat_log(x, eps=1e-08)

Compute quaternion logarithm

Args:
x

(tensor): input quaternion(s) […, 4]

eps

(float): small epsilon for numerical stability

Returns:

(tensor): logarithmic map (vector part scaled by half-angle)

ipyanimlab.utils.quat_mul(x, y, short_path=False)

Performs quaternion multiplication on arrays of quaternions

Parameters
  • x – tensor of quaternions of shape (…, Nb of joints, 4)

  • y – tensor of quaternions of shape (…, Nb of joints, 4)

Returns

The resulting quaternions

ipyanimlab.utils.quat_mul_vec(q, x)

Performs multiplication of an array of 3D vectors by an array of quaternions (rotation).

Parameters
  • q – tensor of quaternions of shape (…, Nb of joints, 4)

  • x – tensor of vectors of shape (…, Nb of joints, 3)

Returns

the resulting array of rotated vectors

ipyanimlab.utils.quat_normalize(x, eps=1e-08)

Normalizes a quaternion tensor

Parameters
  • x – data tensor

  • eps – epsilon to prevent numerical instabilities

Returns

The normalized quaternions tensor

ipyanimlab.utils.quat_slerp(x, y, a)

Performs spherical linear interpolation (SLERP) between x and y, with proportion a

Parameters
  • x – quaternion tensor

  • y – quaternion tensor

  • a – indicator (between 0 and 1) of completion of the interpolation.

Returns

tensor of interpolation results

ipyanimlab.utils.quat_to_mat(rot, pos)

Converts from a quaternion representation to a matrix 4x4 representation :param rot: quaternion tensor :param pos: position tensor :return: matrix4x4 tensor

ipyanimlab.utils.quat_to_scaled_angle_axis(x, eps=1e-08)

Convert quaternion to scaled angle-axis representation

Args:
x

(tensor): quaternion(s) […, 4]

eps

(float): small epsilon for numerical stability

Returns:

(tensor): scaled angle-axis vector(s) […, 3]

ipyanimlab.utils.remove_quat_discontinuities(rotations)

Removing quat discontinuities on the time dimension (removing flips)

Parameters

rotations – Array of quaternions of shape (T, J, 4)

Returns

The processed array without quaternion inversion.

ipyanimlab.utils.rotate_at_frame(X, Q, parents, n_past=10)

Re-orients the animation data according to the last frame of past context.

Parameters
  • X – tensor of local positions of shape (Batchsize, Timesteps, Joints, 3)

  • Q – tensor of local quaternions (Batchsize, Timesteps, Joints, 4)

  • parents – list of parents’ indices

  • n_past – number of frames in the past context

Returns

The rotated positions X and quaternions Q

ipyanimlab.utils.simple_spring_damper_exact(x, v, x_goal, halflife, dt)

Exact solution of a simple spring-damper system (scalar or vector)

Args:
x

(float or tensor): current position

v

(float or tensor): current velocity

x_goal

(float or tensor): target position

halflife

(float): time for amplitude to decay by half

dt

(float): time step

Returns:

tuple (x_next, v_next): next position and velocity after dt

ipyanimlab.utils.simple_spring_damper_exact_quat(x, v, x_goal, halflife, dt)

Exact spring-damper integration for quaternion (rotational motion)

Args:
x

(tensor): current orientation quaternion […, 4]

v

(tensor): current angular velocity (scaled angle-axis form) […, 3]

x_goal

(tensor): target orientation quaternion […, 4]

halflife

(float): time for angular difference to halve

dt

(float): time step

Returns:

tuple (x_next, v_next): next orientation quaternion and angular velocity

ipyanimlab.utils.vec_lerp(x, y, a)

Performs linear interpolation (LERP) between x and y, with proportion a

Parameters
  • x – vector tensor

  • y – vector tensor

  • a – indicator (between 0 and 1) of completion of the interpolation.

Returns

tensor of interpolation results

class ipyanimlab.asset.Asset(mesh, materials)

An asset in the viewer that can be rendered. An asset represent a mesh in webgl. Several asset can share the same mesh for a smaller memory footprint on the GPU

add_bone(name, q, p, parent_name=None, global_space=True)

add a bone in the skeleton

Args:
name

(str): the name of the skeleton

q

(np.array([4], dtype=np.float32)): the quaternion of the bone to add

p

(np.array([3], dtype=np.float32)): the position of the bone to add

parent_name

(str, optional): the name of the parent bone. Defaults to None.

global_space

(bool, optional): is the quaternion and position in localspace or worldspace. Defaults to True.

bone_count()

get the bone count

Returns:
int

the number of bones

bone_index(name)

get the index of a bone

Args:
name

(str): the name of the bone

Returns:
int

the index of that bone

bone_names()

get the bone names

Returns:
list(str)

the bone names

duplicate()

Duplicate the asset This allows to have several asset using the same GPU buffers

Returns:
Asset

the duplicated asset

is_rigid()

is this a rigid mesh or a skinned mesh with skeleton

Returns:
bool

rigid or not

material(name)

get one material by name

Args:
name

(str): the name of the material

Returns:
Material

the material

material_names()

get the list of material names

Returns:
list(str)

the list of names of the materials

materials()

get the list of materials

Returns:
list(Material)

the list of materials

name()

get the name of the asset/mesh

Returns:
str

the name

replace_materials(materials=None)

replace the list of materials

Args:
materials

(List(Material), optional): the list of material to use, or None to get a default material. Defaults to None.

reset()

Reset will reset the internal xform to the identity and the skeleton to the bindpose

set_skeleton(local_matrices=None, names=None)

set the internal skeleton pose

Args:
local_matrices

(np.array([…,4,4], dtype=np.float32), optional): the list of matrices or none to get back to the bindpose. Defaults to None.

names

(list(str), optional): the list of names of each bone we sent, if none we assume that the matrices are matching the skeleton order and size. Defaults to None.

set_xform(xform)

set the xform

Args:
xform

(np.array([4,4], dtype=np.float32)): the matrix of the xform

skinning_bones(local_matrices=None, names=None)

get the skinning transforms for the shader to render

Args:
local_matrices

(np.array([…,4,4], dtype=np.float32), optional): the list of matrices or none to get back to the bindpose. Defaults to None.

names

(list(str), optional): the list of names of each bone we sent, if none we assume that the matrices are matching the skeleton order and size. Defaults to None.

Returns:
np.array([bone_count,4,4], dtype=np.float32)

the skin transforms of the skeleton

world_skeleton_lines(local_matrices=None, names=None)

get the skeleton as a couple of points in world space, to be passed to the line renderer

Args:
local_matrices

(np.array([…,4,4], dtype=np.float32), optional): the list of matrices or none to get back to the bindpose. Defaults to None.

names

(list(str), optional): the list of names of each bone we sent, if none we assume that the matrices are matching the skeleton order and size. Defaults to None.

Returns:
np.array([2*bone_count,3], dtype=np.float32)

the list of points to render the lines

world_skeleton_xforms(local_matrices=None, names=None)

get the world skeleton transforms

Args:
local_matrices

(np.array([…,4,4], dtype=np.float32), optional): the list of matrices or none to get back to the bindpose. Defaults to None.

names

(list(str), optional): the list of names of each bone we sent, if none we assume that the matrices are matching the skeleton order and size. Defaults to None.

Returns:
np.array([bone_count,4,4], dtype=np.float32)

the world transforms of the skeleton

xform()

get the transform of the asset

Returns:
np.array([4,4], dtype=np.float32)

the xform matrix

class ipyanimlab.animation.Anim(quats, pos, offsets, parents, bones)

A very basic animation object

ipyanimlab.animation.compute_root_motion(anim)

Compute a root motion, by projecting the second bone on the ground and using this as the value for the first bone

Args:
anim

(Anim): the input animation

Returns:
Anim

the output animation

ipyanimlab.animation.remap_animation_to_asset(anim, asset, keep_translation=False)

Create a new animation that match the skeleton of the asset

Parameters
  • anim – the animation to align

  • asset – the asset to map to

  • keep_translation – do we keep the translation of the animation or do we force the one from the asset, default:False

Returns

a new Anim

ipyanimlab.animation.remap_animation_to_asset_with_ik(anim, asset, effector_names=['LeftFoot', 'RightFoot'], effector_offests=None, local_offsets=None)

Create a new animation that match the skeleton of the asset, but also make sure that the effectors from effector_names will stay in place

Args:
anim

(Anim): the input animation

asset

(Asset): the skinned asset to map to

effector_names

(list, optional): the list of effectors we want to match. Defaults to [‘LeftFoot’, ‘RightFoot’].

effector_offests

(list of 3*float32 np.array, optional): the offsets for each effectors we want to add before matching. Defaults to None.

local_offsets

(dict{str:3*float32}, optional): a dictionnary that offsets a bone in local space of the mapped character. Defaults to None.

Returns:
Anim

the new animation

ipyanimlab.usd.import_animation.import_usd_animation(filepath, anim_mapper=None)

Import a usd animation

Args:
filepath

(str): the path of the usd stage

anim_mapper

(AnimMapper, optional): the AnimMapper to use when matching to a character. Defaults to None.

Returns:
Anim

the animation

ipyanimlab.bvh.import_bvh(filepath, start=None, end=None, order=None, anim_mapper=None)

Reads a BVH file and extracts animation information.

Parameters
  • filepath – BVh filepath

  • start – start frame

  • end – end frame

  • order – order of euler rotations

  • anim_mapper – the mapper to map the animation to an asset

Returns

A simple Anim object containing the extracted information.

class ipyanimlab.timeline.Timeline(**kwargs: Any)

A timeline play/pause/stop with slider for Jupiter

value

Int value