Geometry Instancing

A couple of months ago I created a small interface for creating larger Meshes (batches) from instances of other meshes (“Geometry Instancing”), which was added to jME. When this is used in the correct way the application can get a significant speed boost. Since then I have evolved the interface into something that is easier and more straight forward to use. To demo this I have created two test applications that I would like to get some feedback on, as well as the source.

Test #1 (aka “Test”): Shows the FPS difference when rendering a grid of cubes, with and without the geometry instancing.

Test #2 (aka “Demo”): Shows how to extend the classes to create something more advanced, in this case I added tangents and a shader to the final mesh.

The source for everything can be found here:

Related posts:

Cool! I've updated jcrpg to use the new code! Works good.

One small thing:

        if ((instanceBatch.getType() & TriangleBatch.TRIANGLEBATCH)>0) {
           return ((TriangleBatch)instanceBatch).getMaxIndex();           

I modified like above to avoid use of "instanceof".

In jre 1.6 instanceof is likely to be even be faster than that…

Irrisor beat me to it.  :stuck_out_tongue:

irrisor said:

In jre 1.6 instanceof is likely to be even be faster than that...

Hmm. Sorry for hijacking the thread, but is 1.6 faster with JME than 1.5?

afaik any application runs faster in jre1.6 than in jre1.5, so do jME apps

BTW Snylt, I tried out your webstart demo.  It looks very nice. :slight_smile:

The webstart demo does not run for me :frowning:

System: Linux (32 bit), Geforce 7600 with latest drivers.

The webstart is windows only, I will fix it asap…

getting a crash on the mac when trying to run DemoGeometryInstancing from the src link provided

Oct 4, 2007 1:42:16 PM class externaldevcode.test.DemoGeometryInstancing start()
SEVERE: Exception in game loop
   at java.nio.Buffer.position(
   at externaldevcode.geometryinstancing.GeometryBatchSpatialInstance.skipBuffer(
   at externaldevcode.geometryinstancing.GeometryBatchTangentSpatialInstance.commitTangents(
   at externaldevcode.geometryinstancing.GeometryBatchTangentSpatialInstance.commitNormals(
   at externaldevcode.geometryinstancing.GeometryBatchSpatialInstance.commit(
   at externaldevcode.geometryinstancing.GeometryBatchMesh.commit(
   at externaldevcode.geometryinstancing.GeometryBatchMesh.draw(
   at com.jme.scene.Spatial.onDraw(
   at externaldevcode.geometryinstancing.GeometryBatchMesh.onDraw(
   at com.jme.scene.Node.draw(
   at com.jme.scene.Spatial.onDraw(
   at com.jme.renderer.lwjgl.LWJGLRenderer.draw(
   at com.jme.renderer.pass.RenderPass.doRender(
   at com.jme.renderer.pass.Pass.renderPass(
   at com.jme.renderer.pass.BasicPassManager.renderPasses(
   at externaldevcode.test.DemoGeometryInstancing.main(
Oct 4, 2007 1:42:16 PM cleanup

the TestGeometryInstancing runs fine and improved framerate from 44fps to 90fps....which is a serious boost....
test on an intel i-mac....