Files
nenya/src/java/com/threerings/jme/model/EmissionController.java
T
Andrzej Kapolka 09627624c6 Switch to using JME's serialization mechanism, which promises a degree
of version safety (meaning we won't necessarily have to recompile all 
the models when we add a new field) and should help avoid the frequent 
binary changes to which Java serialization is prone.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@71 ed5b42cb-e716-0410-a449-f6a68f950b19
2006-11-07 03:14:35 +00:00

98 lines
3.0 KiB
Java

//
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2005 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.jme.model;
import java.io.IOException;
import java.util.Properties;
import com.jme.scene.Controller;
import com.jme.scene.Spatial;
import com.jme.util.export.JMEExporter;
import com.jme.util.export.JMEImporter;
import com.jme.util.export.InputCapsule;
import com.jme.util.export.OutputCapsule;
/**
* A model controller whose target represents an emitter.
*/
public abstract class EmissionController extends ModelController
{
@Override // documentation inherited
public void configure (Properties props, Spatial target)
{
super.configure(props, target);
_hideTarget = Boolean.parseBoolean(
props.getProperty("hide_target", "true"));
}
@Override // documentation inherited
public void init (Model model)
{
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);
}
}
}
@Override // documentation inherited
public Controller putClone (
Controller store, Model.CloneCreator properties)
{
if (store == null) {
return null;
}
EmissionController estore = (EmissionController)store;
super.putClone(estore, properties);
estore._hideTarget = _hideTarget;
return estore;
}
@Override // documentation inherited
public void read (JMEImporter im)
throws IOException
{
super.read(im);
InputCapsule capsule = im.getCapsule(this);
_hideTarget = capsule.readBoolean("hideTarget", true);
}
@Override // documentation inherited
public void write (JMEExporter ex)
throws IOException
{
super.write(ex);
OutputCapsule capsule = ex.getCapsule(this);
capsule.write(_hideTarget, "hideTarget", true);
}
/** Whether or not the target should be hidden from view. */
protected boolean _hideTarget;
private static final long serialVersionUID = 1;
}