Noob needs help with performance!

Hello, I am simple minded and really noob in 3D programming, I am trying to render lots of boxes, this is pretty much whole code I am currently using:



[java] public void simpleInitApp() {

this.flyCam.setMoveSpeed(10);

shootables = new Node();

for(int x = 0; x < 60;x++)

for(int y = 0; y < 6; y++)

for(int z = 0; z < 60; z++)

{

b[y] = new Box(new Vector3f(x+(2.0fx),y+(2.0fy),z+(2.0fz)),1.5f,1.5f,1.5f);

geom = new Geometry(Integer.toString(x+y+z), b[y]);

geom.updateModelBound();

Material mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");

mat.setColor("m_Color", new ColorRGBA(r.nextFloat(),r.nextFloat(),r.nextFloat(),1.0f));

geom.setMaterial(mat);

shootables.attachChild(geom);

}

rootNode.attachChild(shootables);

}[/java]



Now that upper code, by some miracle renders 60
6*60 Boxes even though Box b is declared in main() as array with 6 values,

[java]Box b = new Box[6];[/java]

Problem is taht once when I compile and press Play button in JMonkey panel, it takes around 10 seconds for it to start showing on screen, while it is black ,I keep getting this messages in console window(included are 1st and last:


07.03.2011. 12:05:07 com.jme3.audio.lwjgl.LwjglAudioRenderer initialize
INFO: Audio max auxilary sends: 2
07.03.2011. 12:05:07 com.jme3.material.MaterialDef
INFO: Loaded material definition: Default GUI
07.03.2011. 12:05:07 com.jme3.scene.Node attachChild
.......................................................................................................
INFO: Child (123) attached to this node (null)
07.03.2011. 12:05:17 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Root Node)
07.03.2011. 12:05:18 com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation
WARNING: Uniform m_VertexColor is not declared in shader.



Also performance is really terrible when I look with camera at Boxes, I am not sure why when Minecraft can do it with ease.
Please tell me what I am doing wrong and how to optimize this.

It renders all of those boxes because you create and attach them inside the loop.



Please have a look at the tutorials. They’re good for learning the basics of the engine.



Minecraft doesn’t just simply render a 3d array of boxes, it’s more advanced than that. Again, the tutorials will lead you in the right direction.