Same 3D models on a scene. How to optimize?

I’m new in 3D game development.
When I created my 2D videogames (LibGDX and Processing) I tried to pack all the game graphic in a single spritesheet and upload this single graphic file in the memory. When I needed to render the same graphic sprite/tile - I send the right spritesheet area to draw using methods like:

offlineBuffer.draw(spritesheet, x,y,w,h, leftPixel, topPixel, rightPixel, bottomPixel);

It is a normal way to achive better performance in 2D. But I can not understand how can I use the same mesh on a 3D scene twice? I have found only one dummy solution. I clone the uploaded mesh and add it again to the scene. But I think there are another ways to do that. Maybe I can add the positions and rotation quaternions in some list and the model will be rendered on all the enterred positions? Maybe I need to write my own SceneRenderer to avoid coping of the mesh? Or maybe there are no problems with the performance when I create for same models their single meshes - only the video memory usage increases?


I think the loaded models are cached by the assets manager so using the same models again is faster.

Does it mean that the clone function makes for me only one more wrapping on the same mesh? Deep in the engine I work with the same 3D mesh?

I suppose the optimizations you can do with 3D models in this regard are batching and instancing. Batching reduces object and draw call count. Instancing reduces the memory imprint. Both are supported by jME. With textures you can use texture atlas.

Like ali.barda said, the AssetManager caches (by default) the models. This optimizes the loading speed. They are copies of each other when you add multiple same models to the scene.

1 Like

From the docs:
A clone of this Spatial, the scene graph in its entirety is cloned and can be altered independently of the original scene graph. Note that meshes of geometries are not cloned explicitly, they are shared if static, or specially cloned if animated …”

So I guess they uses the same mesh

1 Like