BitmapText in 3D

I am rendering BitmapText in 3D space (not in GUI) in JME3.

I want to translate this text, so that its center is exactly at some point in space, but I am having problems with this. Its method getLineWidth() always returns 0 for me, so I can’t set its location properly. getLineHeight() works though and is positioned fine. I suspect that getLineWidth() is broken? Or the user shouldn’t use it and is there any other way to do this?


Doesn’t matter what text I put there, this method always returns 0.

You can put this line:

System.out.println(“LineWidth:” + txt.getLineWidth());

in TestBitmapText3D and see for yourself. :slight_smile:

Also, if I remember correctly, this method didn’t work even in JME2.

getLineWidth() returns the width of the line, if you don’t have any string set on the line (using setText()) then getLineWidth() will return 0.

Ok I think I have found a solution. You have to call:


before you call:


Don’t know why this is not done automatically or something… :slight_smile:

Yeah you’re right. When you set the text the geometry is only generated when the text is updated.

I added this bug to the jme3 issue tracker.