Hi,
I've got a serious problem with the Text class of jme.
When I render a Sphere (lesson2 from flag rush tuts), a white quad and red Text, the quad and the text are rendered in QUEUE_ORTHO mode, the text always appears behind the quad. (no matter what I change, but how can I correct this?)
The following code is contains my problem:
package texttest;
import com.jme.app.BaseGame;
import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.input.InputSystem;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;
import com.jme.scene.Text;
import com.jme.scene.shape.Quad;
import com.jme.scene.shape.Sphere;
import com.jme.scene.state.TextureState;
import com.jme.system.DisplaySystem;
import com.jme.system.JmeException;
import com.jme.util.TextureManager;
import com.jme.util.Timer;
public class Main extends BaseGame {
protected Timer timer;
private Camera cam;
private Node scene;
private TextureState ts;
private int width, height, depth, freq;
private boolean fullscreen;
private Quad rect;
private Text text;
protected void update(float interpolation) {
timer.update();
interpolation = timer.getTimePerFrame();
}
protected void render(float interpolation) {
display.getRenderer().clearBuffers();
display.getRenderer().draw(scene);
}
protected void initSystem() {
width = properties.getWidth();
height = properties.getHeight();
depth = properties.getDepth();
freq = properties.getFreq();
fullscreen = properties.getFullscreen();
try {
display = DisplaySystem.getDisplaySystem(properties.getRenderer());
display.createWindow(width, height, depth, freq, fullscreen);
cam = display.getRenderer().createCamera(width, height);
}
catch (JmeException e) {
e.printStackTrace();
System.exit(1);
}
display.getRenderer().setBackgroundColor(ColorRGBA.black);
cam.setFrustumPerspective(45.0f, (float)width / (float)height, 1, 1000);
Vector3f loc = new Vector3f(0.0f, 0.0f, 25.0f);
Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);
cam.setFrame(loc, left, up, dir);
cam.update();
timer = Timer.getTimer(properties.getRenderer());
display.getRenderer().setCamera(cam);
}
protected void initGame() {
scene = new Node("Scene graph node");
Sphere s = new Sphere("Sphere", 30, 30, 25);
s.setLocalTranslation(new Vector3f(0, 0, -40));
s.setModelBound(new BoundingBox());
s.updateModelBound();
rect = new Quad("rect", 50, 50);
rect.setDefaultColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.0f));
rect.getLocalRotation().set(0, 0, 0, 1);
rect.getLocalTranslation().set(500,
height - 25 - 10,
0);
rect.getLocalScale().set(1, 1, 1);
rect.setRenderQueueMode(Renderer.QUEUE_ORTHO);
text = Text.createDefaultTextLabel("testText");
text.setTextColor(new ColorRGBA(1.0f, 0.5f, 0.5f, 1.0f));
text.getLocalRotation().set(0, 0, 0, 1);
text.getLocalTranslation().set(500,
height - 25 - 10,
0);
text.getLocalScale().set(1, 1, 1);
text.setRenderQueueMode(Renderer.QUEUE_ORTHO);
text.print("texteee");
ts = display.getRenderer().createTextureState();
ts.setEnabled(true);
ts.setTexture(TextureManager.loadTexture("images/square.jpg",
Texture.MM_LINEAR_LINEAR,
Texture.FM_LINEAR));
s.setRenderState(ts);
scene.attachChild(rect);
scene.attachChild(text);
scene.attachChild(s);
scene.updateGeometricState(0.0f, true);
scene.updateRenderState();
}
protected void reinit() {
display.recreateWindow(width, height, depth, freq, fullscreen);
}
protected void cleanup() {
ts.deleteAll();
}
public static void main(String[] args) {
Main app = new Main();
app.setDialogBehaviour(NEVER_SHOW_PROPS_DIALOG, "");
app.start();
}
}
Has anybody got a solution?
Thanks,
Starik