Hide nodes not included as targets in an animation. I haven't tested
all the units with this; there's a chance some of the animations will have to be re-exported if they mistakenly omit nodes. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@24 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -49,6 +49,11 @@ public abstract class EmissionController extends ModelController
|
||||
super.init(model);
|
||||
if (_hideTarget) {
|
||||
_target.setCullMode(Spatial.CULL_ALWAYS);
|
||||
if (_target instanceof ModelNode) {
|
||||
// make sure the node isn't turned back on by an
|
||||
// animation
|
||||
((ModelNode)_target).setForceCull(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -508,6 +508,14 @@ public class Model extends ModelNode
|
||||
if (_anim != null) {
|
||||
_animObservers.apply(new AnimCancelledOp(_animName));
|
||||
}
|
||||
|
||||
// first cull all model nodes, then re-activate the ones in the
|
||||
// target list
|
||||
cullModelNodes();
|
||||
for (Spatial target : anim.transformTargets) {
|
||||
((ModelNode)target).updateCullMode();
|
||||
}
|
||||
|
||||
_paused = false;
|
||||
_anim = anim;
|
||||
_animName = name;
|
||||
|
||||
@@ -282,6 +282,24 @@ public class ModelNode extends Node
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether this node should be culled even if it has mesh
|
||||
* descendants.
|
||||
*/
|
||||
public void setForceCull (boolean force)
|
||||
{
|
||||
_forceCull = force;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this node should be culled even if it has mesh
|
||||
* descendants.
|
||||
*/
|
||||
public boolean getForceCull ()
|
||||
{
|
||||
return _forceCull;
|
||||
}
|
||||
|
||||
// documentation inherited from interface ModelSpatial
|
||||
public void writeBuffers (FileChannel out)
|
||||
throws IOException
|
||||
@@ -334,7 +352,7 @@ public class ModelNode extends Node
|
||||
_hasVisibleDescendants = true;
|
||||
}
|
||||
}
|
||||
setCullMode(_hasVisibleDescendants ? CULL_INHERIT : CULL_ALWAYS);
|
||||
updateCullMode();
|
||||
return _hasVisibleDescendants;
|
||||
}
|
||||
|
||||
@@ -372,6 +390,31 @@ public class ModelNode extends Node
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively culls all model nodes under this one in preparation for
|
||||
* activating the ones listed in an animation.
|
||||
*/
|
||||
protected void cullModelNodes ()
|
||||
{
|
||||
for (int ii = 0, nn = getQuantity(); ii < nn; ii++) {
|
||||
Spatial child = getChild(ii);
|
||||
if (child instanceof ModelNode) {
|
||||
child.setCullMode(CULL_ALWAYS);
|
||||
((ModelNode)child).cullModelNodes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes this node visible if and only if it has visible descendants and
|
||||
* has not been specifically culled.
|
||||
*/
|
||||
protected void updateCullMode ()
|
||||
{
|
||||
setCullMode((_hasVisibleDescendants && !_forceCull) ?
|
||||
CULL_INHERIT : CULL_ALWAYS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a matrix to the transform defined by the given translation,
|
||||
* rotation, and scale values.
|
||||
@@ -405,5 +448,8 @@ public class ModelNode extends Node
|
||||
/** Whether or not this node has mesh descendants. */
|
||||
protected boolean _hasVisibleDescendants;
|
||||
|
||||
/** If true, cull the node even if it has mesh descendants. */
|
||||
protected boolean _forceCull;
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user