LocalTranslation on Text causes crash

Hi all,



I’ve been trying to set the local translation for text during calls to simpleUpdate():

[java] label.setLocalTranslation(localTranslation);[/java]

I also tried removing the label from the scene, setting the translation and re-attaching it:

[java] label.removeFromParent();

label.setLocalTranslation(localTranslation);

label.attachTo(scene);[/java]



Here my definition of Label:

[java]public Label(String text) {

this.text = text;



Quad q = new Quad(6, 3);

g = new Geometry(“quad”, q);

g.setLocalTranslation(0, -3, -0.0001f);

Material material = new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”);

material.setColor(“m_Color”, ColorRGBA.Black);

g.setMaterial(material);



BitmapFont fnt = assetManager.loadFont(“Interface/Fonts/Default.fnt”);

label = new BitmapText(fnt, false);

label.setColor(ColorRGBA.White);

label.setBox(new Rectangle(0, 0, 6, 3));

label.setQueueBucket(Bucket.Transparent);

label.setSize(0.3f);

label.setText(target.getMMSI());

}[/java]



Both cause the application to crash (screen just flickers between black and random colours and everything becomes unresponsive. Only a hard reboot helps).



Any help would be great, as always :slight_smile:

Thanks.

Do you have the latest drivers? Changing the local translation doesn’t really do anything, there’s no reason why the whole world would go down just because you changed some values in a matrix …

Yup, I updated my drivers yesterday and downloaded last night’s JME build.



Changing the local translation of other spatials works fine.



[java]label.setText(getLabelText());

localTranslation.setY(localTranslation.getY() + 2f);

label.setSize(0.3f);

label.setLocalTranslation(localTranslation);[/java]



I just realized that it is most likely isn’t setLocalTranslation, but maybe setText? Or something else altogether? As long as I uncomment all of the above, everything works fine. Otherwise everything just crashes…

are you modifiing it in the opengl thread

Yup, it’s running as part of simpleUpdate(). Well, to be precise, it is one of many updater objects registered in a queue whose contents is popped and executed as part of simpleUpdate().

Super-strange :confused: Why u always get the strange ones? ^^

I wish I knew :frowning: I must have enraged the Java Gods :stuck_out_tongue:

Apologies: It is in fact the changing of the display text that causes the problems, and not changing the local translation. Tried it on both an nVidia and ATI Radeon…

I tested this on a third machine. To summarize:



Given:



[java]BitmapFont fnt = assetManager.loadFont(“Interface/Fonts/Default.fnt”);

label = new BitmapText(fnt, false);

label.setColor(ColorRGBA.White);

label.setBox(new Rectangle(0, 0, 6, 3));

label.setQueueBucket(Bucket.Transparent);

label.setSize(0.3f);

label.setText(text);[/java]



Changing the text of label inside of simpleUpdate causes the everything to crash (black stripes flicker on screen, everything becomes unresponsive).



Re-attaching the label (i.e. label.removeFromParent(); … rootNode.attachChild(label)) causes the application to crash with an

invalid memory exception.

Somebody had problems with special characters and umlauts, maybe it works with a-z characters?

Are you calling those methods outside the rendering thread by any chance?

@normen: Thanks, but I tried that. Using a-z only produces the same results.

@momoko: No, this is all taking place inside of simpleUpdate().