Hello guys. I’m trying to use the JMonkeyEngine 3 to create a simple pseudo-isometric game. To begin, I have a conceptual question:
How should I implement the tile-map? For example a code snippet:
public void simpleInitApp() {
int w =settings.getWidth();
int h =settings.getHeight();
this.flyCam.setEnabled(false);
this.cam.setLocation(new Vector3f(w/2, h/2, 580));
//-------------------------
Material m = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md");
m.setColor("Color", ColorRGBA.Blue);
for (int x = 0; x < w/32; x++) {
for (int y = 0; y < h/32; y++) {
Quad q = new Quad(32,32);
Geometry g = new Geometry("Map", q);
g.setLocalTranslation(x*32, y*32, 0);
g.setMaterial(m);
rootNode.attachChild(g);
}
}
}
Will get me around 3,6k FPS. While this is decent, I only want it to use to show the contrast. If I change the last doubled for loop, which will create 32x32 tiles on my whole screen, with a single mesh like that:
Quad q = new Quad(32*w, 32*h);
Geometry g = new Geometry("Map",q);
g.setMaterial(m);
rootNode.attachChild(g);
I will get more than 6,8k FPS. Nearly the double amout, altough I’m using just one material. In the final game all tile-textures will able to match into a single texture/texture-atlas, so one material for all is realistic for now. Now to my question: Is it better to use one mesh instead of many small ones? Or has JMonkey a special feature to handle those snippets?
For ease of answering: The map-data is delivered in runtime from a server-app. in stripes of tiles (1xN tiles). Therefore creating chunk-based textures for bigger meshes seems hard to me.
I hope my question was understandable, although my english is extremely rusty.
Edit: After finding the tutorials on the texture atlas, I saw that this one can create a geometry using one texture. that would suit my needs if I can add and remove geometry dynamically, i think (?)