- fix texture atlas not cheking for existing textures anymore

- change atlas test to more approriate models

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9038 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent d3c92b586f
commit a6154e2608
  1. 22
      engine/src/test/jme3test/tools/TestTextureAtlas.java
  2. 7
      engine/src/tools/jme3tools/optimize/TextureAtlas.java

@ -32,12 +32,12 @@
package jme3test.tools; package jme3test.tools;
import com.jme3.app.SimpleApplication; import com.jme3.app.SimpleApplication;
import com.jme3.asset.plugins.ZipLocator;
import com.jme3.light.AmbientLight; import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight; import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Quad; import com.jme3.scene.shape.Quad;
import jme3tools.optimize.GeometryBatchFactory; import jme3tools.optimize.GeometryBatchFactory;
@ -52,8 +52,22 @@ public class TestTextureAtlas extends SimpleApplication {
@Override @Override
public void simpleInitApp() { public void simpleInitApp() {
flyCam.setMoveSpeed(50); flyCam.setMoveSpeed(50);
assetManager.registerLocator("town.zip", ZipLocator.class.getName()); Node scene = new Node("Scene");
Spatial scene = assetManager.loadModel("main.scene"); Spatial obj1 = assetManager.loadModel("Models/Ferrari/Car.scene");
obj1.setLocalTranslation(-4, 0, 0);
Spatial obj2 = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
obj2.setLocalTranslation(-2, 0, 0);
Spatial obj3 = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
obj3.setLocalTranslation(-0, 0, 0);
Spatial obj4 = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
obj4.setLocalTranslation(2, 0, 0);
Spatial obj5 = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
obj5.setLocalTranslation(4, 0, 0);
scene.attachChild(obj1);
scene.attachChild(obj2);
scene.attachChild(obj3);
scene.attachChild(obj4);
scene.attachChild(obj5);
Geometry geom = GeometryBatchFactory.makeAtlasBatch(scene, assetManager, 2048); Geometry geom = GeometryBatchFactory.makeAtlasBatch(scene, assetManager, 2048);
@ -70,7 +84,7 @@ public class TestTextureAtlas extends SimpleApplication {
//quad to display material //quad to display material
Geometry box = new Geometry("displayquad", new Quad(4, 4)); Geometry box = new Geometry("displayquad", new Quad(4, 4));
box.setMaterial(geom.getMaterial()); box.setMaterial(geom.getMaterial());
box.setLocalTranslation(0, 1, 0); box.setLocalTranslation(0, 1, 3);
rootNode.attachChild(box); rootNode.attachChild(box);
} }
} }

@ -139,8 +139,11 @@ public class TextureAtlas {
if (sourceTextureName == null && !rootMapName.equals(mapName)) { if (sourceTextureName == null && !rootMapName.equals(mapName)) {
throw new IllegalStateException("Cannot add texture to new map without source texture"); throw new IllegalStateException("Cannot add texture to new map without source texture");
} }
TextureAtlasTile location; TextureAtlasTile location = locationMap.get(name);
if (sourceTextureName == null) { if (location != null) {
locationMap.put(name, location);
return true;
} else if (sourceTextureName == null) {
Node node = root.insert(image); Node node = root.insert(image);
if (node == null) { if (node == null) {
return false; return false;

Loading…
Cancel
Save