Labeling a geometry

Hi guys,

Im just wondering if it is possible to attach a piece of text onto a geometry instead of having to attach a logo or a picture. I have a large grid of cubes and I need to label them with numbers and letters and it would take me quite a long time creating and attaching different logos to each cube. Is there a way to have it in a for loop so I can just attach different numbers to different cubes?

Thanks guys.

I’m not sure I understood this completely. But you can generate textures (on the fly) with numbers/text on them quite easily with regular JAVA and use them dynamically on your cubes.

Yeah, or use an atlas or other similar mechanisms.

http://wiki.jmonkeyengine.org/doku.php/jme3:beginner:hello_material

This shows you how to attach a picture to a cube. What I want to do is to attach a number to the cube instead. Thing is I have a lot of them and creating a picture of a number for each one is crazy. Im wondering if there is like one line of code that I can loop that sets the texture on a cube to a integer or a string of my choice

Possible with BitmapText.
I have a class “BitmapText3D”.
Only problem is that you need to keep some distance between text and geometry (in jME3.0 - for jME3.1 I heard there is a little trick - z compare function is available there).
Which jME do you use?

P.S. I might publish that BitmapText3D and also a HoverText3D I wrote a week ago, if you like. It’s really very simple - I made a SDK 3.0 project demonstrating those two custom Text classes…

1 Like

I use JME 3.0. Thanks for the advice ill look into bitmaptext in the morning. HoverText3D sounds good. Have any snapshots?

Sure, here: Test_JME30.zip - Google Drive

Please respect the @author tag when committing some of that code to the jME core or any other open source project. The license is BSD-like (same as jME), permission granted.

You find the relevant code under src/jme3test/gui.

1 Like