How to color Font3D / Text3D?

Dear Sirs,

I have the following code to create a 3D text:

Font3D font3D = new Font3D(font, 0.001f, false, true, false);
text3D = font3D.createText(text, size, 0);

I try to apply red color to that text in these two ways:




MaterialState ms = display.getRenderer().createMaterialState();
text3D.setModelBound(new BoundingBox());

But none of these ways work. The text is always in white color, it's not changing to the color I want (red).

What's the correct procedure to apply color to a Font3D/Text3D?

Thank you.

Hmm, I haven't played with 3D text.  2D is colored with text.setTextColor()

also, try setting


There are special Font3DEffect classes you need to use to color a Text3D.

For example setting a Texture:

Font3DTexture fonttexture = new Font3DTexture(this.getClass().

or setting a Color:

Font3DGradient gradient = new Font3DGradient(Vector3f.UNIT_Y,,;

Thank you, basixs and Core-Dump.

basixs, I also tried that, but It doesn't seem to work.

Core-Dump, your first solution using a texture it does work perfectly. But the second one, it does not! I just see all in black (the scene background). The font does not paint, and I did exactly what you posted. Is there any other step I should do to paint a font using gradient effect or any other programmatic way?

I can use texture - as it already works - but in case I need to dynamically switch the color font I would need the second alternative to work fine.

Sorry, Core-Dump, I have re-checked my test code using the gradient solution you posted, and it works perfect. I was commenting a few important lines and then I realized  :smiley:

So, both of your solutions works perfect. Thanks.

manuelbarzi said:

So, both of your solutions works perfect. Thanks.

of course they do  ;)