# Geometry Instancing with Cylinders?

Hi,

I'm trying to figure out what the best way would be to extend the geometry instancing system to support cylinders.  Specifically, I want to be able to go beyond specifying translation, rotation, scale, and color for instances in GeometryInstanceAttributes and be able to also specify height, radius1 and radius2.

Any pointers or suggestions would be appreciated.

Thanks,

Stephen

JME has cylinder geometry already, and a Cone class that extends the cylinder.

Cylinder constructor:

`public Cylinder(String name, int axisSamples, int radialSamples, float radius, float height, boolean closed, boolean inverted)`

Cone constructor:

` public Cone( String name, int axisSamples, int radialSamples, float radius, float height, boolean closed )`

Right.  I am aware of the Cylinder primitive in JME.  What I am looking for is how to do geometry instancing with the Cylinder primitive so I can render hundreds of cylinders while still only creating one instance in memory.

Thanks,

Stephen

(This answer is from jME 1.0, 2.0 may be different)

Well you could either use the SharedMesh construct or the SharedNode

``` TriMesh cylindar = new Cylindar( "name", 12, 12, 5, 10, true, false); SharedMesh mesh = new SharedMesh( cylindar );   //<-- create as many as needed```

-or-

``` TriMesh cylindar = new Cylindar( "name", 12, 12, 5, 10, true, false); Node origNode = new Node( "node" ); origNode.attachChild( cylindar ); SharedNode node = new SharedNode( "sharedName", origNode );   //<-- create as many as needed```

(My code could be off in a couple of places, but thats pretty much it)

He wants to be able to specify the radius1-2/height attributes for each individual instance, so your code doesn't help much. Also sharing geometry data across objects is not geometry instancing; geometry instancing is putting all your objects with the same render state into a single geometry buffer in order to reduce draw calls and overhead associated with managing many objects on the driver.

I can't really come up with a solution using the current instancing system (I find it overly complicated for it's task), if all your cylinders have the same set of buffers then it should be easy enough to just append those buffers to one another, while shifting the index data by the vertex count.