SharedBatch + target & TextureState

Hi,



I loading a collada model with the ColladaImporter. Now I want to change some TextureState's in this model. The last elements in the hierarchy are a SharedBatch with a TriangleBatch as target.



For this elements I want to change the TextureState (adding some dynamic text to the existing texture).

So I wrote the following:



Constructor:


      this.sharedLabel = ((SharedMesh) model.getChild("sharedBoardNodeLabel-mesh")).getBatch(0);
      this.targetLabel = sharedLabel.getTarget();

      graphics = ImageGraphics.createInstance(512, 32, 0);
      TextureState oldState = (TextureState) targetLabel.getRenderState(RenderState.RS_TEXTURE);
      labelTextureState =DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
      labelTextureState.setTexture(oldState.getTexture());

      labelTexture = new Texture();
      labelTexture.setImage(graphics.getImage());
      labelTexture.setScale(new Vector3f(3f, -1f, 1f));
      labelTexture.setFilter(Texture.FM_LINEAR);
      labelTexture.setMipmapState(Texture.MM_LINEAR_LINEAR);
      labelTexture.setWrap(Texture.WM_WRAP_S_WRAP_T);
      labelTexture.setApply(Texture.AM_DECAL);

      labelTextureState.setTexture(labelTexture, 0);

      targetLabel.copyTextureCoordinates(0, 1, 1);
      sharedLabel.setRenderState(labelTextureState);
      sharedLabel.updateRenderState();



adding some text:


public void addText(String newText) {
      GameTaskQueueManager.getManager().update(new Callable<Object>() {
         public Object call() throws Exception {
            graphics.setColor(Color.black);
            graphics.drawString(newText, 24, 100);

            labelTextureState.apply();
            graphics.update(labelTexture);
            return null;
         }
      });
}



The first time I call "addText" the text is added to the texture. But when I do it a second or more times, nothing happens. Im totally confused, tried alot but nothing seems to work.
The TextureState connection between the SharedBatch and TriangleBatch is also an understanding problem for me.

try setting the texture on the actual geometry.



u can get the geometry trimeh object by using sharedNode.getTarget();

Thanks for reply.



I have more than one instances of this model. So I cant set it to the geometry.