16
Support / Re: Performance with many objects
« on: November 05, 2010, 11:20:31 pm »
This what I'm doing in an attempt to reuse the model/mesh:
Doing these steps improves framerate from ~5 FPS to ~15 FPS. Obviously still not enough to be playable so hopefully I'm just not doing this right or there are other steps that can be taken.
Code: [Select]
public class Block extends Object3D
{
public static Object3D MODEL = null;
public static Object3D getModel()
{
if(MODEL == null)
{
MODEL = Primitives.getCube(0.5f);
MODEL.setTexture("box");
MODEL.setEnvmapped(Object3D.ENVMAP_ENABLED);
MODEL.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
MODEL.build();
MODEL.rotateY((float) -Math.PI / 4f);
}
Object3D newModel = MODEL.cloneObject();
newModel.shareCompiledData(MODEL);
newModel.compile();
return newModel;
}
public Block()
{
super(getModel());
}
... etc.
Doing these steps improves framerate from ~5 FPS to ~15 FPS. Obviously still not enough to be playable so hopefully I'm just not doing this right or there are other steps that can be taken.