I am creating a game which, when run, places some randomly located spatials to act as weeds/foliage along the ground. These spatials spawn in clumps of 200, and are comprised of 8 vertices making up a cross shaped mesh.
The problem is: Obviously, the more of these weeds there are on the screen, the more the frame rate drops.
I know that you can set LOD levels of objects (although, I have tried doing this without any success. My imports are .obj converted to .j3o, so I’m not using the Ogre format). I know that in a lot of AAA titles, it’s quite common for a draw distance for specific meshes to be set, so for instance the ground foliage will not be rendered after 100 units of measurement, where as the players, terrain and other important buildings etc will not be rendered after 300 units.
Is there a nice easy way to set the draw distance as described above? Is there an equally easy alternative?
I don’t particularly want to write my own update method for them, or for example keep an array of spatials which I iterate through to find out their distance, and based on that, tell the renderer whether or not to draw them.
For the benefit of anyone in a similar situation to me; where by you have multiple spatials attached to your root node resulting in low frame rates when looking at all of the spatials in the scene, a quick fix is to use GeometryBatchFactory.
Use as directed by Momoko_Fan below. It’s increased my FPS significantly when looking out over the objects.
@Momoko_Fan said:
Just create a node, attach a bunch of stuff to it, then call optimize on it, the result is the optimized version of that node.
E.g.<
[java]<
Box box = new Box(1,1,1);
Geometry g1 = new Geometry("g1", box);
Geometry g2 = new Geometry("g2", box);
Geometry g3 = new Geometry("g3", box);
g1.move(-2, 0, 0);
g2.move(0, 0, 0);
g3.move(2, 0, 0);
Node boxes = new Node("boxes");
boxes.attachChild(g1);
boxes.attachChild(g2);
boxes.attachChild(g3);
boxes.setMaterial(...);
Node optimizedBoxes = GeometryBatchFactory.optimize(boxes);
rootNode.attachChild(optimizedBoxes);
[/java]
My only problem now is; It’s now rendering anything that I optimize (using the technique above) behind anything but the terrain. Before, it rendered it fine.