libgdx API

com.badlogic.gdx.graphics.g3d.keyframed
Class KeyframedModel

java.lang.Object
  extended by com.badlogic.gdx.graphics.g3d.keyframed.KeyframedModel

public class KeyframedModel
extends java.lang.Object

An animated model with KeyframeAnimations. Currently the animations can only be instanced from an MD5Animation. Support for binary serialization may be included in loadFuture development.

Author:
Dave Clayton

Constructor Summary
KeyframedModel()
           
 
Method Summary
 void dispose()
           
 KeyframeAnimation getAnimation(java.lang.String animKey)
          Gets the specified KeyframeAnimation from the animation map.
 Animator getAnimator()
          Gets the KeyframeAnimator for this model.
 void getJointData(int tagIndex, Vector3 pos, Quaternion orient)
           
 void render()
          Draws the model using the current interpolated animation frame and the material list set by setMaterials(com.badlogic.gdx.graphics.g3d.Material[]).
 KeyframeAnimation sampleAnimationFromMD5(MD5Model md5model, MD5Renderer md5renderer, MD5Animator md5animator, MD5Animation md5animation, float sampleRate, java.lang.String modelAsset, java.lang.String animKey)
          Loads a single KeyframeAnimation from an MD5Animation, then stores it in the animation dictionary for runtime playback.
 void setAnimation(java.lang.String animKey, Animator.WrapMode wrapMode)
          Set the current playing animation.
 void setMaterials(Material[] mats)
          Sets the Material list for this model, one for each mesh, in mesh order.
 void setMeshVisible(int idx, boolean visible)
          Sets the specified mesh's visibility (MD5 models typically consist of a number of meshes).
 void setTaggedJoints(java.util.ArrayList<java.lang.String> joints)
          Sets the tagged joints for this model's animations.
 void update(float dt)
          Updates the model, causing the model's KeyframeAnimator to interpolate the animation and update the render geometry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyframedModel

public KeyframedModel()
Method Detail

getAnimator

public Animator getAnimator()
Gets the KeyframeAnimator for this model.

Returns:
the animator.

setMaterials

public void setMaterials(Material[] mats)
Sets the Material list for this model, one for each mesh, in mesh order.

Parameters:
mats - An array of materials.

setTaggedJoints

public void setTaggedJoints(java.util.ArrayList<java.lang.String> joints)
Sets the tagged joints for this model's animations. Tagged joints have their data preserved post-sampling.

Parameters:
joints - An array of joint names.

sampleAnimationFromMD5

public KeyframeAnimation sampleAnimationFromMD5(MD5Model md5model,
                                                MD5Renderer md5renderer,
                                                MD5Animator md5animator,
                                                MD5Animation md5animation,
                                                float sampleRate,
                                                java.lang.String modelAsset,
                                                java.lang.String animKey)
Loads a single KeyframeAnimation from an MD5Animation, then stores it in the animation dictionary for runtime playback. The dictionary manages ref counted animations so you do not have multiple copies of 100k animations in memory when you only need one per unique MD5 model. You must call dispose() when finished with this class.

Parameters:
md5model - The source MD5Model.
md5renderer - An MD5Renderer instance, used to calculate the skinned geometry.
md5animator - An MD5Animator instance to control the MD5 animation cycle the keyframing samples from.
md5animation - The MD5Animation to sample.
sampleRate - The sample rate (use smaller values for smoother animation but greater memory usage). Recommended value: 0.3
modelAsset - The name of the model asset. Must be unique to the model. Using its path is recommended
animKey - The name used to store the animation in the mode's animation map.

getJointData

public void getJointData(int tagIndex,
                         Vector3 pos,
                         Quaternion orient)

setAnimation

public void setAnimation(java.lang.String animKey,
                         Animator.WrapMode wrapMode)
Set the current playing animation.

Parameters:
animKey - The name of the animation.
wrapMode - The animation Animator.WrapMode.

getAnimation

public KeyframeAnimation getAnimation(java.lang.String animKey)
Gets the specified KeyframeAnimation from the animation map.

Parameters:
animKey - The name of the animation.
Returns:
The animation.

update

public void update(float dt)
Updates the model, causing the model's KeyframeAnimator to interpolate the animation and update the render geometry.

Parameters:
dt - Delta time since last frame.

render

public void render()
Draws the model using the current interpolated animation frame and the material list set by setMaterials(com.badlogic.gdx.graphics.g3d.Material[]). update(float) must be called prior to this.


setMeshVisible

public void setMeshVisible(int idx,
                           boolean visible)
Sets the specified mesh's visibility (MD5 models typically consist of a number of meshes).

Parameters:
idx - the mesh's index (same order as found in the .md5mesh file)
visible - whether the mesh should be drawn or not

dispose

public void dispose()

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)