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:
@@ -380,6 +380,14 @@ public class Model extends ModelNode
|
|||||||
return anim.getDuration() / _animSpeed;
|
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.
|
* 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 ()
|
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) {
|
if (_prototype != null) {
|
||||||
return _prototype.createInstance();
|
return _prototype.createInstance(variant);
|
||||||
}
|
}
|
||||||
if (_ccreator == null) {
|
if (_ccreator == null) {
|
||||||
_ccreator = new ModelCloneCreator(this);
|
_ccreator = new ModelCloneCreator(this);
|
||||||
}
|
}
|
||||||
|
_ccreator.variant = variant;
|
||||||
Model instance = (Model)_ccreator.createCopy();
|
Model instance = (Model)_ccreator.createCopy();
|
||||||
instance.initInstance();
|
instance.initInstance();
|
||||||
return instance;
|
return instance;
|
||||||
@@ -564,7 +585,14 @@ public class Model extends ModelNode
|
|||||||
} else {
|
} else {
|
||||||
mstore = (Model)store;
|
mstore = (Model)store;
|
||||||
}
|
}
|
||||||
|
// don't clone the emission node, as it contains transient geometry
|
||||||
|
if (_emissionNode != null) {
|
||||||
|
detachChild(_emissionNode);
|
||||||
|
}
|
||||||
super.putClone(mstore, properties);
|
super.putClone(mstore, properties);
|
||||||
|
if (_emissionNode != null) {
|
||||||
|
attachChild(_emissionNode);
|
||||||
|
}
|
||||||
mstore._prototype = this;
|
mstore._prototype = this;
|
||||||
if (_anims != null) {
|
if (_anims != null) {
|
||||||
mstore._anims = new HashMap<String, Animation>();
|
mstore._anims = new HashMap<String, Animation>();
|
||||||
@@ -847,6 +875,9 @@ public class Model extends ModelNode
|
|||||||
/** Customized clone creator for models. */
|
/** Customized clone creator for models. */
|
||||||
protected static class ModelCloneCreator extends CloneCreator
|
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. */
|
/** A shared seed used to select textures consistently. */
|
||||||
public int random;
|
public int random;
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ public class ModelMesh extends TriMesh
|
|||||||
public void configure (
|
public void configure (
|
||||||
boolean solid, String texture, boolean transparent, Properties props)
|
boolean solid, String texture, boolean transparent, Properties props)
|
||||||
{
|
{
|
||||||
|
|
||||||
_textures = (texture == null) ? null : StringUtil.parseStringArray(
|
_textures = (texture == null) ? null : StringUtil.parseStringArray(
|
||||||
props.getProperty(texture, texture));
|
props.getProperty(texture, texture));
|
||||||
_solid = solid;
|
_solid = solid;
|
||||||
|
|||||||
Reference in New Issue
Block a user