Added method to fast-forward animations, beginnings of support for model

variants.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4102 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Andrzej Kapolka
2006-05-08 23:30:07 +00:00
parent bfa0dd1749
commit 8e42599c6d
2 changed files with 34 additions and 4 deletions
+34 -3
View File
@@ -380,6 +380,14 @@ public class Model extends ModelNode
return anim.getDuration() / _animSpeed;
}
/**
* Fast-forwards the current animation by the given number of seconds.
*/
public void fastForwardAnimation (float time)
{
updateAnimation(time);
}
/**
* Gets a reference to the animation with the given name.
*/
@@ -522,16 +530,29 @@ public class Model extends ModelNode
}
/**
* Creates and returns a new instance of this model.
*/
* Creates and returns a new instance of this model's default
* variant.
*/
public Model createInstance ()
{
return createInstance(null);
}
/**
* Creates and returns a new instance of this model.
*
* @param variant the name of the variant desired, or <code>null</code>
* for the default variant
*/
public Model createInstance (String variant)
{
if (_prototype != null) {
return _prototype.createInstance();
return _prototype.createInstance(variant);
}
if (_ccreator == null) {
_ccreator = new ModelCloneCreator(this);
}
_ccreator.variant = variant;
Model instance = (Model)_ccreator.createCopy();
instance.initInstance();
return instance;
@@ -564,7 +585,14 @@ public class Model extends ModelNode
} else {
mstore = (Model)store;
}
// don't clone the emission node, as it contains transient geometry
if (_emissionNode != null) {
detachChild(_emissionNode);
}
super.putClone(mstore, properties);
if (_emissionNode != null) {
attachChild(_emissionNode);
}
mstore._prototype = this;
if (_anims != null) {
mstore._anims = new HashMap<String, Animation>();
@@ -847,6 +875,9 @@ public class Model extends ModelNode
/** Customized clone creator for models. */
protected static class ModelCloneCreator extends CloneCreator
{
/** The model variant desired, or <code>null</code> for the default. */
public String variant;
/** A shared seed used to select textures consistently. */
public int random;
@@ -88,7 +88,6 @@ public class ModelMesh extends TriMesh
public void configure (
boolean solid, String texture, boolean transparent, Properties props)
{
_textures = (texture == null) ? null : StringUtil.parseStringArray(
props.getProperty(texture, texture));
_solid = solid;