my first JME3 Project is coming along nicely. I managed to render basic cell-based terrain, and I have water which flows from higher ground to lower ground dynamically. Terrain can be raised and lowered on the fly. Everything looks great so far.
Now I want to add trees and people to my game. There will be many many (thousands) trees in a map and up to a few hundred units. Trees will come and go, units will move around constantly.
So my question is: How do I render this efficiently in JME3? I guess Instancing will be the best way to go, but I have no idea how to use it. Any tips and recommendations will be greatly appreciated.
What do you mean by “Trees will come and go”? Do you want the trees to be able to get chopped down and after a while they respawn?
You might find some information about Optimization in the wiki.
It probably would be helpful when you make yourself familiar with Batching (BatchNode, GeometryBatchFactory).
However, as it sounds, when you want to have thousands of trees, it definitely would be much more efficient to divide your game world (map) into several chunks and then only load the chunks the player can currently see.
[quote=“Domenic, post:2, topic:38491, full:true”]
What do you mean by “Trees will come and go”? Do you want the trees to be able to get chopped down and after a while they respawn?[/quote]
They might be chopped down, they might burn down, anything. And new trees will grow over time. In short: The number of trees is dynamic and always changing.
Right now the camera can be zoomed out as far as the player likes. So the entire map is potentially visible at any point in time. Of course in that situation it is understandable to have worse performance than when zooming in closer.
My game world is currently divided into chunks of 32x32 cells. I could probably organize trees the same way.
Thanks! I will have a look at it and perhaps I may be able to use some bits of it. Could you perhaps tell me which classes are the most important for the instanced rendering? This could help me understand the code a lot quicker. Thank you very much.