This is jme1.0
I'm building a map made of boxes, and I use the GeometryBatch util class to combine the boxes so each layer is one Node.
My problem is for a map of 128x128 size it takes forever to load.
import utils.GeometryBatch;
import com.jme.image.Texture;
import com.jme.math.Vector3f;
import com.jme.scene.Node;
import com.jme.scene.shape.Box;
import com.jme.scene.shape.MultiFaceBox;
import com.jme.scene.state.LightState;
import com.jme.scene.state.TextureState;
import com.jme.system.DisplaySystem;
import com.jme.util.TextureManager;
public class World extends Node {
GeometryBatch dirt;
GeometryBatch grass;
Box dirt2;
MultiFaceBox grass2;
public World(){
createDirt();
createGrass();
for(int x=0; x<32;x++){
for(int y=0;y<32;y++){
addDirtBlock(x,0,y);
}
}
for(int x=0; x<32;x++){
for(int y=0;y<32;y++){
if(Math.random()>0.8)
addGrassBlock(x,1,y);
}
}
attachChild(dirt);
attachChild(grass);
setLightCombineMode(LightState.OFF);
lock();
}
public void createDirt(){
dirt2 = new Box("dirt2", new Vector3f(0,0,0), new Vector3f(1,1,1));
TextureState ts2 = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
Texture t2 = TextureManager.loadTexture(HelloWorld.class.getClassLoader()
.getResource("res/dirt.png"),
Texture.MM_LINEAR ,
Texture.MM_NEAREST_LINEAR );
ts2.setTexture(t2);
dirt = GeometryBatch.create("dirtGeom", dirt2);
dirt.setRenderState(ts2);
}
public void createGrass(){
grass2 = new MultiFaceBox("grass", new Vector3f(0,0,0), new Vector3f(1,1,1));
TextureState ts2 = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
Texture t2 = TextureManager.loadTexture(HelloWorld.class.getClassLoader()
.getResource("res/grass.png"),
Texture.MM_LINEAR ,
Texture.MM_NEAREST_LINEAR,1,false );
ts2.setTexture(t2);
grass = GeometryBatch.create("grassGeom", grass2);
grass.setRenderState(ts2);
}
public void addDirtBlock(int x, int y, int z){
dirt.addGeometry(dirt2,new Vector3f(x,y,z));
}
public void addGrassBlock(int x, int y, int z){
grass.addGeometry(grass2,new Vector3f(x,y,z));
}
}