Cloning constructor for TriMesh and TriangleBatch

Task: associate extra vertex data with a given model.

This requires extending TriangleBatch class and adding more float buffers. To make it compatible with the existing model loaders it much easier to take an existing TriMesh and reconstruct it into an extended version. The only other option is to rewrite all the model loaders.

However there is no straightforward way of cloning TriMesh and TriangleBatch instanses via constructor. Extending TriMesh and TriangleBatch would be alot easier and much less error prone if there was a cloning constructor that take TriMesh and TriangleBatch instances respectively.



Example:


public class MyBatch extends TriangleBatch {

  public MyBatch(TriangleBatch batch) {
    super(batch);
    // custom initialization code
  }

}



Addition of cloning constructor would allow focusing on your own logic instead of having a tediously long copy constructor using getters/setters and most likely making an incomplete copy.

Example of cloning right now:


public class CustomBatch extends TriangleBatch {

   private CustomBatch(TriangleBatch batch) {
      super();
      if (batch.getDisplayListID() != 0) {
         // report a problem
      }
      
      // TrangleBatch
      setMode(batch.getMode());
      setIndexBuffer(batch.getIndexBuffer());
      setTriangleQuantity(batch.getTriangleCount());
      
      // GeomBatch
      setEnabled(batch.isEnabled());
      setColorBuffer(batch.getColorBuffer());
      setNormalBuffer(batch.getNormalBuffer());
      setTextureBuffers(batch.getTextureBuffers());
      setVBOInfo(batch.getVBOInfo());
      setVertexBuffer(batch.getVertexBuffer());
      setVertexCount(batch.getVertexCount());
      setDefaultColor(batch.getDefaultColor());
      
      // SceneElement
      setName(batch.getName());
      setIsCollidable(batch.isCollidable());
      setCullMode(batch.getCullMode());

               // custom initialization code
        }
}