hi everyone, I was trying to lock a sharedmesh and I was getting lots of flat colored textures or no performance gains.I couldnt find an example so after I got it to work I made a quick test class, and here it is, youll have to substitute your image for wood.png
public class TestLockedSharedMesh extends SimpleGame {
public static void main(String[] args) {
TestLockedSharedMesh app = new TestLockedSharedMesh();
app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
app.start();
}
protected void simpleInitGame() {
cam.setLocation(new Vector3f(0f, 0f, 1100f));
cam.setDirection(new Vector3f(0, 0, -1));
cam.update();
lightState.setEnabled(false);
URL url;
url = this.getClass().getClassLoader().getResource("wood.png");
TextureState ts = display.getRenderer().createTextureState();
Texture t0 = TextureManager.loadTexture(url, Texture.MM_LINEAR,
Texture.FM_LINEAR);
ts.setTexture(t0);
AlphaState as = DisplaySystem.getDisplaySystem().getRenderer()
.createAlphaState();
as.setEnabled(true);
as.setBlendEnabled(true);
as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
as.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
as.setTestEnabled(true);
as.setTestFunction(AlphaState.TF_GREATER);
Quad quad = new Quad("quad", 32, 32);
quad.setModelBound(new BoundingBox());
quad.updateModelBound();
quad.setRenderState(ts);
quad.setRenderState(as);
// this lock doesnt work
// quad.lock();
for (int x = 0; x < 1000; x++) {
// Test.this.x = x;
SharedMesh sm = new SharedMesh("Share", quad);
sm.getLocalTranslation().z = x;
sm.updateGeometricState(0, false);
// this lock works
sm.lock();
rootNode.attachChild(sm);
}
// this lock doesnt work
// quad.lock();
}
}