Problems with Text3D

I am having a whole host of problems with Text3D…



1.) I cannot set the color unless I use Font3DGradient



I have tried tons of different methods…



a.) Turning lightState off…



lightState.setEnabled(false);
font3D = new Font3D(new Font("Arial", Font.PLAIN, 2), 0.001f, false, true, false);
Text3D text3D = font3D.createText("something", 2, 0);
text3D.setRandomColors();
text3D.updateRenderState();
rootNode.attachChild(text3D);



b.) Setting a MaterialState...


font3D = new Font3D(new Font("Arial", Font.PLAIN, 2), 0.001f, false, true, false);
Text3D text3D = font3D.createText("something", 2, 0);

MaterialState ms = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
    ms.setDiffuse(ColorRGBA.red);
    ms.setColorMaterial(MaterialState.CM_DIFFUSE);
    ms.setEnabled(true);

text3D.setRenderState(ms);
text3D.updateRenderState();
rootNode.attachChild(text3D);



c.) Using setFontColor...


font3D = new Font3D(new Font("Arial", Font.PLAIN, 2), 0.001f, false, true, false);
Text3D text3D = font3D.createText("something", 2, 0);

text3D.setFontColor(ColorRGBA.red);
text3D.updateRenderState();
rootNode.attachChild(text3D);



d.) Even the example (Test3DText.java) in jmetest.text does not have color when I toggle the lights on!

2.) I am unable to affect a Text3D object in other ways -- I cannot set a ClipState to it, for example...


package clipstates;

import java.awt.Font;
import java.util.logging.Logger;

import com.jme.app.SimpleGame;
import com.jme.math.Vector3f;
import com.jme.scene.SharedMesh;
import com.jme.scene.shape.Box;
import com.jme.scene.state.ClipState;
import com.jmex.font3d.Font3D;
import com.jmex.font3d.Text3D;

public class ClipText3D extends SimpleGame {
    private static final Logger logger = Logger.getLogger(ClipText3D.class
            .getName());

  public static void main(String[] args) {
    ClipText3D app = new ClipText3D();
    app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
    app.start();
  }

  protected void simpleUpdate() {
  }

  private static Font3D font3D;
 
  protected void simpleInitGame() {
    display.setTitle("jME - FontPlay");
   
    font3D = new Font3D(new Font("Arial", Font.PLAIN, 2), 0.001f, false, true, false);
   
    Box b = new Box("b", new Vector3f(), 0.5f, 0.5f, 0.5f);
   
    for (int i=-20; i<100; i++) {
       Text3D text3D = font3D.createText("something", 2, 0);
       System.out.println(text3D.getCullMode());
       
       text3D.alignCenter();
       text3D.updateRenderState();
       text3D.setLocalTranslation(i, i, 0);
       rootNode.attachChild(text3D);
       
       SharedMesh m = new SharedMesh("b" + i, b);
       m.setLocalTranslation(i,i,0);
       rootNode.attachChild(m);
    }
   
    ClipState clipArea;
    clipArea = display.getRenderer().createClipState();
    clipArea.setEnableClipPlane(ClipState.CLIP_PLANE0, true);
    clipArea.setClipPlaneEquation(0, -1f, 0, 0, 2);
   
    rootNode.setRenderState(clipArea);
   rootNode.updateRenderState();
  }
}



This clips the boxes, but not the text3ds!

Has anyone else experienced these issues?

Font3D is a bit special, you use Font3DTexture or Font3DGradient to color it.



from the Java doc of Font3DTexture:

The reason this has to be done this way is because of some locking/unlocking and other
internal things of the Font3D/Text3D.

Yeah, I suspected this, I will have to work around this by using the Font3DGradient class.



What about ClipStates though? Is there any reason why they don't work?

Is there no way that I can do this to the Text3D object instead of the Font3D one? I am creating tons of text labels and have found that if I create a new Font3D and Text3D for each label, I am wasting tons of resources in creating that Font3D every time. So I use the static method to load a Font3D, and then create each Text3D using the static Font3D.createText method.



If I wanted clipstates to work, then I assume I'd need to make a class similar to Font3DTexture, which is no biggie. But there, I am applying my renderstate to a font3d, when really I should be applying it to a text3d, right?

i can't really help more, i didn't use Text3D much yet.

But what i also noticed is, that when you draw the BoundingBoxes, they seem all to be cluttered around the first Letter.

But maybe that irrelevant anyway :slight_smile:

Thanks for helping. I am still asking here because I noticed this exchange…



http://www.jmonkeyengine.com/jmeforum/index.php?topic=3180.msg29615#msg29615

http://www.jmonkeyengine.com/jmeforum/index.php?topic=3180.msg29632#msg29632



…from awhile ago and thought that maybe I could change the renderstate of a text3d object without having to change its font3d factory. Renanse! Help!!!