Brought things up to date with the latest JME code.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4162 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Andrzej Kapolka
2006-05-31 02:21:04 +00:00
parent e981a9eed9
commit 69c20acd43
12 changed files with 233 additions and 120 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ public class JmeApp
} }
// create an appropriate timer // create an appropriate timer
_timer = Timer.getTimer(_api); _timer = Timer.getTimer();
// start with the target FPS equal to the refresh rate (but // start with the target FPS equal to the refresh rate (but
// sometimes the refresh rate is reported as zero so don't let that // sometimes the refresh rate is reported as zero so don't let that
@@ -68,7 +68,7 @@ public abstract class EmissionController extends ModelController
{ {
if (_target instanceof Geometry) { if (_target instanceof Geometry) {
BufferUtils.populateFromBuffer(result, BufferUtils.populateFromBuffer(result,
((Geometry)_target).getNormalBuffer(), 0); ((Geometry)_target).getNormalBuffer(0), 0);
} else { } else {
result.set(0f, 0f, -1f); result.set(0f, 0f, -1f);
} }
+77 -64
View File
@@ -49,7 +49,6 @@ import com.jme.math.Matrix4f;
import com.jme.math.Quaternion; import com.jme.math.Quaternion;
import com.jme.math.Vector3f; import com.jme.math.Vector3f;
import com.jme.renderer.Camera; import com.jme.renderer.Camera;
import com.jme.renderer.CloneCreator;
import com.jme.renderer.Renderer; import com.jme.renderer.Renderer;
import com.jme.scene.Controller; import com.jme.scene.Controller;
import com.jme.scene.Node; import com.jme.scene.Node;
@@ -222,6 +221,71 @@ public class Model extends ModelNode
private static final long serialVersionUID = 1; private static final long serialVersionUID = 1;
} }
/** Customized clone creator for models. */
public static class CloneCreator
{
/** A shared seed used to select textures consistently. */
public int random;
/** Maps original objects to their copies. */
public HashMap originalToCopy = new HashMap();
public CloneCreator (Model toCopy)
{
_toCopy = toCopy;
addProperty("vertices");
addProperty("colors");
addProperty("normals");
addProperty("texcoords");
addProperty("vboinfo");
addProperty("indices");
addProperty("obbtree");
addProperty("displaylistid");
addProperty("bound");
}
/**
* Sets the named property.
*/
public void addProperty (String name)
{
_properties.add(name);
}
/**
* Clears the named property.
*/
public void removeProperty (String name)
{
_properties.remove(name);
}
/**
* Checks whether the named property has been set.
*/
public boolean isSet (String name)
{
return _properties.contains(name);
}
/**
* Creates a new copy of the target model.
*/
public Model createCopy ()
{
random = RandomUtil.getInt(Integer.MAX_VALUE);
Model copy = (Model)_toCopy.putClone(null, this);
originalToCopy.clear(); // make sure no references remain
return copy;
}
/** The model to copy. */
protected Model _toCopy;
/** The set of added properties. */
protected HashSet<String> _properties = new HashSet<String>();
}
/** /**
* Attempts to read a model from the specified file. * Attempts to read a model from the specified file.
* *
@@ -464,8 +528,13 @@ public class Model extends ModelNode
public Node getEmissionNode () public Node getEmissionNode ()
{ {
if (_emissionNode == null) { if (_emissionNode == null) {
attachChild(_emissionNode = new Node("emissions")); attachChild(_emissionNode = new Node("emissions") {
_emissionNode.setTransformable(false); public void updateWorldVectors () {
worldTranslation.set(localTranslation);
worldRotation.set(localRotation);
worldScale.set(localScale);
}
});
} }
return _emissionNode; return _emissionNode;
} }
@@ -530,30 +599,17 @@ public class Model extends ModelNode
} }
/** /**
* Creates and returns a new instance of this model's default * Creates and returns a new instance of this model.
* 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(variant); return _prototype.createInstance();
} }
if (_ccreator == null) { if (_ccreator == null) {
_ccreator = new ModelCloneCreator(this); _ccreator = new CloneCreator(this);
} }
_ccreator.variant = variant; Model instance = _ccreator.createCopy();
Model instance = (Model)_ccreator.createCopy();
instance.initInstance(); instance.initInstance();
return instance; return instance;
} }
@@ -764,7 +820,7 @@ public class Model extends ModelNode
/** For prototype models, a customized clone creator used to generate /** For prototype models, a customized clone creator used to generate
* instances. */ * instances. */
protected ModelCloneCreator _ccreator; protected CloneCreator _ccreator;
/** For instances, maps prototype nodes to their corresponding instance /** For instances, maps prototype nodes to their corresponding instance
* nodes. */ * nodes. */
@@ -872,50 +928,7 @@ public class Model extends ModelNode
protected String _name; protected String _name;
} }
/** 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;
public ModelCloneCreator (Model toCopy)
{
super(toCopy);
addProperty("vertices");
addProperty("colors");
addProperty("normals");
addProperty("texcoords");
addProperty("vboinfo");
addProperty("indices");
addProperty("obbtree");
addProperty("displaylistid");
addProperty("bound");
}
@Override // documentation inherited
public void addProperty (String name)
{
props.put(name, Boolean.TRUE);
}
@Override // documentation inherited
public void removeProperty (String name)
{
props.remove(name);
}
@Override // documentation inherited
public Spatial createCopy ()
{
random = RandomUtil.getInt(Integer.MAX_VALUE);
Spatial copy = super.createCopy();
originalToCopy.clear(); // make sure no references remain
return copy;
}
}
private static final long serialVersionUID = 1; private static final long serialVersionUID = 1;
} }
@@ -30,7 +30,6 @@ import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Properties; import java.util.Properties;
import com.jme.renderer.CloneCreator;
import com.jme.scene.Controller; import com.jme.scene.Controller;
import com.jme.scene.Node; import com.jme.scene.Node;
import com.jme.scene.Spatial; import com.jme.scene.Spatial;
@@ -85,18 +84,21 @@ public abstract class ModelController extends Controller
} }
} }
@Override // documentation inherited /**
public Controller putClone (Controller store, CloneCreator properties) * Creates or populates and returns a clone of this object using the given
* clone properties.
*
* @param store an instance of this class to populate, or <code>null</code>
* to create a new instance
*/
public Controller putClone (
Controller store, Model.CloneCreator properties)
{ {
if (store == null) { if (store == null) {
return null; return null;
} }
ModelController mstore = (ModelController)store; ModelController mstore = (ModelController)store;
mstore._target = (Spatial)properties.originalToCopy.get(_target); mstore._target = ((ModelSpatial)_target).putClone(null, properties);
if (mstore._target == null) {
properties.originalToCopy.put(_target,
mstore._target = _target.putClone(null, properties));
}
mstore._animations = _animations; mstore._animations = _animations;
return mstore; return mstore;
} }
@@ -38,14 +38,16 @@ import java.util.Properties;
import com.jme.bounding.BoundingVolume; import com.jme.bounding.BoundingVolume;
import com.jme.math.Quaternion; import com.jme.math.Quaternion;
import com.jme.math.Vector3f; import com.jme.math.Vector3f;
import com.jme.renderer.CloneCreator;
import com.jme.renderer.Renderer; import com.jme.renderer.Renderer;
import com.jme.scene.Controller;
import com.jme.scene.SharedMesh; import com.jme.scene.SharedMesh;
import com.jme.scene.Spatial; import com.jme.scene.Spatial;
import com.jme.scene.TriMesh; import com.jme.scene.TriMesh;
import com.jme.scene.VBOInfo; import com.jme.scene.VBOInfo;
import com.jme.scene.batch.TriangleBatch;
import com.jme.scene.state.AlphaState; import com.jme.scene.state.AlphaState;
import com.jme.scene.state.CullState; import com.jme.scene.state.CullState;
import com.jme.scene.state.RenderState;
import com.jme.scene.state.TextureState; import com.jme.scene.state.TextureState;
import com.jme.scene.state.ZBufferState; import com.jme.scene.state.ZBufferState;
import com.jme.system.DisplaySystem; import com.jme.system.DisplaySystem;
@@ -138,11 +140,11 @@ public class ModelMesh extends TriMesh
*/ */
public void centerVertices () public void centerVertices ()
{ {
Vector3f offset = getModelBound().getCenter().negate(); Vector3f offset = getBatch(0).getModelBound().getCenter().negate();
if (!offset.equals(Vector3f.ZERO)) { if (!offset.equals(Vector3f.ZERO)) {
getLocalTranslation().subtractLocal(offset); getLocalTranslation().subtractLocal(offset);
getModelBound().getCenter().set(Vector3f.ZERO); getBatch(0).getModelBound().getCenter().set(Vector3f.ZERO);
getBatch().translatePoints(offset); getBatch(0).translatePoints(offset);
} }
} }
@@ -173,8 +175,8 @@ public class ModelMesh extends TriMesh
_textureBufferSize = (textures == null) ? 0 : textures.capacity(); _textureBufferSize = (textures == null) ? 0 : textures.capacity();
} }
@Override // documentation inherited // documentation inherited from interface ModelSpatial
public Spatial putClone (Spatial store, CloneCreator properties) public Spatial putClone (Spatial store, Model.CloneCreator properties)
{ {
ModelMesh mstore = (ModelMesh)properties.originalToCopy.get(this); ModelMesh mstore = (ModelMesh)properties.originalToCopy.get(this);
if (mstore != null) { if (mstore != null) {
@@ -184,17 +186,65 @@ public class ModelMesh extends TriMesh
} else { } else {
mstore = (ModelMesh)store; mstore = (ModelMesh)store;
} }
super.putClone(mstore, properties); properties.originalToCopy.put(this, mstore);
mstore.normalsMode = normalsMode;
mstore.cullMode = cullMode;
for (int ii = 0; ii < RenderState.RS_MAX_STATE; ii++) {
RenderState rstate = getRenderState(ii);
if (rstate != null) {
mstore.setRenderState(rstate);
}
}
mstore.renderQueueMode = renderQueueMode;
mstore.lockedMode = lockedMode;
mstore.lightCombineMode = lightCombineMode;
mstore.textureCombineMode = textureCombineMode;
mstore.name = name;
mstore.isCollidable = isCollidable;
mstore.localRotation.set(localRotation);
mstore.localTranslation.set(localTranslation);
mstore.localScale.set(localScale);
for (Object controller : getControllers()) {
if (controller instanceof ModelController) {
mstore.addController(
((ModelController)controller).putClone(null, properties));
}
}
TriangleBatch batch = (TriangleBatch)getBatch(0),
mbatch = (TriangleBatch)mstore.getBatch(0);
mbatch.setVertexBuffer(properties.isSet("vertices") ?
batch.getVertexBuffer() :
BufferUtils.clone(batch.getVertexBuffer()));
mbatch.setColorBuffer(properties.isSet("colors") ?
batch.getColorBuffer() :
BufferUtils.clone(batch.getColorBuffer()));
mbatch.setNormalBuffer(properties.isSet("normals") ?
batch.getNormalBuffer() :
BufferUtils.clone(batch.getNormalBuffer()));
FloatBuffer texcoords;
for (int ii = 0; (texcoords = batch.getTextureBuffer(ii)) != null;
ii++) {
mbatch.setTextureBuffer(properties.isSet("texcoords") ?
texcoords : BufferUtils.clone(texcoords), ii);
}
mbatch.setIndexBuffer(properties.isSet("indices") ?
batch.getIndexBuffer() :
BufferUtils.clone(batch.getIndexBuffer()));
if (properties.isSet("vboinfo")) {
mbatch.setVBOInfo(batch.getVBOInfo());
}
if (properties.isSet("obbtree")) {
mbatch.setCollisionTree(batch.getCollisionTree());
}
if (properties.isSet("displaylistid")) { if (properties.isSet("displaylistid")) {
mstore.batch.setDisplayListID(getDisplayListID()); mbatch.setDisplayListID(batch.getDisplayListID());
} }
if (properties.isSet("bound")) { if (batch.getModelBound() != null) {
mstore.setModelBound(getModelBound()); mbatch.setModelBound(properties.isSet("bound") ?
batch.getModelBound() : batch.getModelBound().clone(null));
} }
if (_textures != null && _textures.length > 1 && if (_textures != null && _textures.length > 1) {
properties instanceof Model.ModelCloneCreator) { int tidx = properties.random % _textures.length;
int tidx = ((Model.ModelCloneCreator)properties).random %
_textures.length;
mstore._textures = new String[] { _textures[tidx] }; mstore._textures = new String[] { _textures[tidx] };
mstore._tstates = new TextureState[] { _tstates[tidx] }; mstore._tstates = new TextureState[] { _tstates[tidx] };
mstore.setRenderState(_tstates[tidx]); mstore.setRenderState(_tstates[tidx]);
@@ -221,7 +271,7 @@ public class ModelMesh extends TriMesh
out.writeObject(getLocalTranslation()); out.writeObject(getLocalTranslation());
out.writeObject(getLocalRotation()); out.writeObject(getLocalRotation());
out.writeObject(getLocalScale()); out.writeObject(getLocalScale());
out.writeObject(getModelBound()); out.writeObject(getBatch(0).getModelBound());
out.writeInt(_vertexBufferSize); out.writeInt(_vertexBufferSize);
out.writeInt(_normalBufferSize); out.writeInt(_normalBufferSize);
out.writeInt(_colorBufferSize); out.writeInt(_colorBufferSize);
@@ -36,10 +36,11 @@ import java.util.HashSet;
import com.jme.math.Matrix4f; import com.jme.math.Matrix4f;
import com.jme.math.Quaternion; import com.jme.math.Quaternion;
import com.jme.math.Vector3f; import com.jme.math.Vector3f;
import com.jme.renderer.CloneCreator;
import com.jme.renderer.Renderer; import com.jme.renderer.Renderer;
import com.jme.scene.Controller;
import com.jme.scene.Node; import com.jme.scene.Node;
import com.jme.scene.Spatial; import com.jme.scene.Spatial;
import com.jme.scene.state.RenderState;
import com.threerings.jme.Log; import com.threerings.jme.Log;
@@ -128,8 +129,8 @@ public class ModelNode extends Node
} }
} }
@Override // documentation inherited // documentation inherited from interface ModelSpatial
public Spatial putClone (Spatial store, CloneCreator properties) public Spatial putClone (Spatial store, Model.CloneCreator properties)
{ {
ModelNode mstore = (ModelNode)properties.originalToCopy.get(this); ModelNode mstore = (ModelNode)properties.originalToCopy.get(this);
if (mstore != null) { if (mstore != null) {
@@ -139,8 +140,37 @@ public class ModelNode extends Node
} else { } else {
mstore = (ModelNode)store; mstore = (ModelNode)store;
} }
super.putClone(mstore, properties); properties.originalToCopy.put(this, mstore);
mstore.normalsMode = normalsMode;
mstore.cullMode = cullMode; mstore.cullMode = cullMode;
for (int ii = 0; ii < RenderState.RS_MAX_STATE; ii++) {
RenderState rstate = getRenderState(ii);
if (rstate != null) {
mstore.setRenderState(rstate);
}
}
mstore.renderQueueMode = renderQueueMode;
mstore.lockedMode = lockedMode;
mstore.lightCombineMode = lightCombineMode;
mstore.textureCombineMode = textureCombineMode;
mstore.name = name;
mstore.isCollidable = isCollidable;
mstore.localRotation.set(localRotation);
mstore.localTranslation.set(localTranslation);
mstore.localScale.set(localScale);
for (Object controller : getControllers()) {
if (controller instanceof ModelController) {
mstore.addController(
((ModelController)controller).putClone(null, properties));
}
}
for (int ii = 0, nn = getQuantity(); ii < nn; ii++) {
Spatial child = getChild(ii);
if (child instanceof ModelSpatial) {
mstore.attachChild(
((ModelSpatial)child).putClone(null, properties));
}
}
return mstore; return mstore;
} }
@@ -163,16 +193,19 @@ public class ModelNode extends Node
setLocalTranslation((Vector3f)in.readObject()); setLocalTranslation((Vector3f)in.readObject());
setLocalRotation((Quaternion)in.readObject()); setLocalRotation((Quaternion)in.readObject());
setLocalScale((Vector3f)in.readObject()); setLocalScale((Vector3f)in.readObject());
ArrayList children = (ArrayList)in.readObject(); ArrayList<Spatial> children = (ArrayList<Spatial>)in.readObject();
for (int ii = 0, nn = children.size(); ii < nn; ii++) { if (children != null) {
attachChild((Spatial)children.get(ii)); for (Spatial child : children) {
attachChild(child);
}
} }
} }
// documentation inherited from interface ModelSpatial // documentation inherited from interface ModelSpatial
public void expandModelBounds () public void expandModelBounds ()
{ {
for (Object child : getChildren()) { for (int ii = 0, nn = getQuantity(); ii < nn; ii++) {
Spatial child = getChild(ii);
if (child instanceof ModelSpatial) { if (child instanceof ModelSpatial) {
((ModelSpatial)child).expandModelBounds(); ((ModelSpatial)child).expandModelBounds();
} }
@@ -183,7 +216,8 @@ public class ModelNode extends Node
public void setReferenceTransforms () public void setReferenceTransforms ()
{ {
updateWorldVectors(); updateWorldVectors();
for (Object child : getChildren()) { for (int ii = 0, nn = getQuantity(); ii < nn; ii++) {
Spatial child = getChild(ii);
if (child instanceof ModelSpatial) { if (child instanceof ModelSpatial) {
((ModelSpatial)child).setReferenceTransforms(); ((ModelSpatial)child).setReferenceTransforms();
} }
@@ -194,7 +228,8 @@ public class ModelNode extends Node
public void lockStaticMeshes ( public void lockStaticMeshes (
Renderer renderer, boolean useVBOs, boolean useDisplayLists) Renderer renderer, boolean useVBOs, boolean useDisplayLists)
{ {
for (Object child : getChildren()) { for (int ii = 0, nn = getQuantity(); ii < nn; ii++) {
Spatial child = getChild(ii);
if (child instanceof ModelSpatial) { if (child instanceof ModelSpatial) {
((ModelSpatial)child).lockStaticMeshes(renderer, useVBOs, ((ModelSpatial)child).lockStaticMeshes(renderer, useVBOs,
useDisplayLists); useDisplayLists);
@@ -205,7 +240,8 @@ public class ModelNode extends Node
// documentation inherited from interface ModelSpatial // documentation inherited from interface ModelSpatial
public void resolveTextures (TextureProvider tprov) public void resolveTextures (TextureProvider tprov)
{ {
for (Object child : getChildren()) { for (int ii = 0, nn = getQuantity(); ii < nn; ii++) {
Spatial child = getChild(ii);
if (child instanceof ModelSpatial) { if (child instanceof ModelSpatial) {
((ModelSpatial)child).resolveTextures(tprov); ((ModelSpatial)child).resolveTextures(tprov);
} }
@@ -216,7 +252,8 @@ public class ModelNode extends Node
public void writeBuffers (FileChannel out) public void writeBuffers (FileChannel out)
throws IOException throws IOException
{ {
for (Object child : getChildren()) { for (int ii = 0, nn = getQuantity(); ii < nn; ii++) {
Spatial child = getChild(ii);
if (child instanceof ModelSpatial) { if (child instanceof ModelSpatial) {
((ModelSpatial)child).writeBuffers(out); ((ModelSpatial)child).writeBuffers(out);
} }
@@ -227,7 +264,8 @@ public class ModelNode extends Node
public void readBuffers (FileChannel in) public void readBuffers (FileChannel in)
throws IOException throws IOException
{ {
for (Object child : getChildren()) { for (int ii = 0, nn = getQuantity(); ii < nn; ii++) {
Spatial child = getChild(ii);
if (child instanceof ModelSpatial) { if (child instanceof ModelSpatial) {
((ModelSpatial)child).readBuffers(in); ((ModelSpatial)child).readBuffers(in);
} }
@@ -237,7 +275,8 @@ public class ModelNode extends Node
// documentation inherited from interface ModelSpatial // documentation inherited from interface ModelSpatial
public void sliceBuffers (MappedByteBuffer map) public void sliceBuffers (MappedByteBuffer map)
{ {
for (Object child : getChildren()) { for (int ii = 0, nn = getQuantity(); ii < nn; ii++) {
Spatial child = getChild(ii);
if (child instanceof ModelSpatial) { if (child instanceof ModelSpatial) {
((ModelSpatial)child).sliceBuffers(map); ((ModelSpatial)child).sliceBuffers(map);
} }
@@ -63,6 +63,15 @@ public interface ModelSpatial
*/ */
public void resolveTextures (TextureProvider tprov); public void resolveTextures (TextureProvider tprov);
/**
* Creates or populates and returns a clone of this object using the given
* clone properties.
*
* @param store an instance of this class to populate, or <code>null</code>
* to create a new instance
*/
public Spatial putClone (Spatial store, Model.CloneCreator properties);
/** /**
* Recursively writes any data buffers to the output channel. * Recursively writes any data buffers to the output channel.
*/ */
@@ -29,7 +29,6 @@ import java.util.Properties;
import com.jme.math.Quaternion; import com.jme.math.Quaternion;
import com.jme.math.Vector3f; import com.jme.math.Vector3f;
import com.jme.renderer.CloneCreator;
import com.jme.scene.Controller; import com.jme.scene.Controller;
import com.jme.scene.Spatial; import com.jme.scene.Spatial;
@@ -83,7 +82,8 @@ public class Rotator extends ModelController
} }
@Override // documentation inherited @Override // documentation inherited
public Controller putClone (Controller store, CloneCreator properties) public Controller putClone (
Controller store, Model.CloneCreator properties)
{ {
Rotator rstore; Rotator rstore;
if (store == null) { if (store == null) {
@@ -38,7 +38,6 @@ import java.util.HashSet;
import com.jme.bounding.BoundingVolume; import com.jme.bounding.BoundingVolume;
import com.jme.math.Matrix4f; import com.jme.math.Matrix4f;
import com.jme.math.Vector3f; import com.jme.math.Vector3f;
import com.jme.renderer.CloneCreator;
import com.jme.renderer.Renderer; import com.jme.renderer.Renderer;
import com.jme.scene.Spatial; import com.jme.scene.Spatial;
import com.jme.scene.VBOInfo; import com.jme.scene.VBOInfo;
@@ -182,7 +181,7 @@ public class SkinMesh extends ModelMesh
} }
@Override // documentation inherited @Override // documentation inherited
public Spatial putClone (Spatial store, CloneCreator properties) public Spatial putClone (Spatial store, Model.CloneCreator properties)
{ {
SkinMesh mstore = (SkinMesh)properties.originalToCopy.get(this); SkinMesh mstore = (SkinMesh)properties.originalToCopy.get(this);
if (mstore != null) { if (mstore != null) {
@@ -235,9 +234,10 @@ public class SkinMesh extends ModelMesh
@Override // documentation inherited @Override // documentation inherited
public void expandModelBounds () public void expandModelBounds ()
{ {
BoundingVolume obound = (BoundingVolume)getModelBound().clone(null); BoundingVolume obound =
(BoundingVolume)getBatch(0).getModelBound().clone(null);
updateModelBound(); updateModelBound();
getModelBound().mergeLocal(obound); getBatch(0).getModelBound().mergeLocal(obound);
} }
@Override // documentation inherited @Override // documentation inherited
@@ -336,7 +336,7 @@ public class SkinMesh extends ModelMesh
} }
// copy it from array to buffer // copy it from array to buffer
FloatBuffer vbuf = getVertexBuffer(), nbuf = getNormalBuffer(); FloatBuffer vbuf = getVertexBuffer(0), nbuf = getNormalBuffer(0);
vbuf.rewind(); vbuf.rewind();
vbuf.put(_vbuf); vbuf.put(_vbuf);
nbuf.rewind(); nbuf.rewind();
@@ -348,7 +348,7 @@ public class SkinMesh extends ModelMesh
*/ */
protected void storeOriginalBuffers () protected void storeOriginalBuffers ()
{ {
FloatBuffer vbuf = getVertexBuffer(), nbuf = getNormalBuffer(); FloatBuffer vbuf = getVertexBuffer(0), nbuf = getNormalBuffer(0);
vbuf.rewind(); vbuf.rewind();
nbuf.rewind(); nbuf.rewind();
FloatBuffer.wrap(_ovbuf = new float[vbuf.capacity()]).put(vbuf); FloatBuffer.wrap(_ovbuf = new float[vbuf.capacity()]).put(vbuf);
@@ -508,13 +508,13 @@ public class ModelDef
HashSet<Spatial> referenced) HashSet<Spatial> referenced)
{ {
boolean hasValidChildren = false; boolean hasValidChildren = false;
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { for (int ii = node.getQuantity() - 1; ii >= 0; ii--) {
Spatial child = (Spatial)it.next(); Spatial child = node.getChild(ii);
if (!(child instanceof ModelNode) || if (!(child instanceof ModelNode) ||
pruneUnusedNodes((ModelNode)child, nodes, referenced)) { pruneUnusedNodes((ModelNode)child, nodes, referenced)) {
hasValidChildren = true; hasValidChildren = true;
} else { } else {
it.remove(); node.detachChildAt(ii);
nodes.remove(child.getName()); nodes.remove(child.getName());
} }
} }
@@ -333,7 +333,7 @@ public class ModelViewer extends JmeCanvasApp
} }
Line grid = new Line("grid", points, null, null, null); Line grid = new Line("grid", points, null, null, null);
grid.getDefaultColor().set(0.25f, 0.25f, 0.25f, 1f); grid.getBatch(0).getDefaultColor().set(0.25f, 0.25f, 0.25f, 1f);
grid.setLightCombineMode(LightState.OFF); grid.setLightCombineMode(LightState.OFF);
grid.setModelBound(new BoundingBox()); grid.setModelBound(new BoundingBox());
grid.updateModelBound(); grid.updateModelBound();
@@ -75,7 +75,7 @@ public class JabberApp extends JmeApp
for (int i = 0; i < 24; i++) { for (int i = 0; i < 24; i++) {
colors[i] = ColorRGBA.randomColor(); colors[i] = ColorRGBA.randomColor();
} }
t.setColorBuffer(BufferUtils.createFloatBuffer(colors)); t.setColorBuffer(0, BufferUtils.createFloatBuffer(colors));
_root.attachChild(t); _root.attachChild(t);
_root.updateRenderState(); _root.updateRenderState();
@@ -90,7 +90,7 @@ public class JabberApp extends JmeApp
_camera.update(); _camera.update();
// speed up key input // speed up key input
_input.setKeySpeed(100f); _input.setActionSpeed(100f);
return true; return true;
} }