Label problem - urgent

sorry for urgent tag but i am running out of time for evaluating jmonkey for the task at hand. in the multiview example, i add a label next to teapot. it shows up in main cam view but not in others. what gives? is it possible to render label correctly, ie. left to right, in a multiple view use case… it makes sense for a object to show other side but label should not be in reverse. thanks.

How are you attaching the label, is it a quad with text, is it a Nifty component? What views are you talking about? Viewports?



If viewports, remember that with multiple viewports you have to tell them what nodes to render:

[java]viewport.attachScene(rootNode);[/java]

TestMultiViews.java shows how to do multiple GUI viewports too.

hi, i just added a bitmaptext next to a teapot in the multi view port example as shown below. i am showing the teapot from 4 different angles. what i need is a label next to the object, not on the object, and readable label rendering in correct left to right order in all four views. -a









package monkey2;



import com.jme3.app.SimpleApplication;

import com.jme3.font.BitmapText;

import com.jme3.light.DirectionalLight;

import com.jme3.math.ColorRGBA;

import com.jme3.math.FastMath;

import com.jme3.math.Quaternion;

import com.jme3.math.Vector3f;

import com.jme3.renderer.Camera;

import com.jme3.renderer.ViewPort;

import com.jme3.scene.Geometry;



public class Untitled4 extends SimpleApplication

{

public static void main(String[] args)

{

Untitled4 app = new Untitled4();

// app.setShowSettings(false);

app.start();

}



public void simpleInitApp()

{

// settings.setRenderer(AppSettings.LWJGL_OPENGL2);

// settings.setBitsPerPixel(4);

// settings.setFrameRate(60);



setDisplayFps(false);

setDisplayStatView(false);



Geometry tp = (Geometry) assetManager

.loadModel(“Models/Teapot/Teapot.obj”);



tp.scale(3);



DirectionalLight dl1 = new DirectionalLight();

dl1.setColor(ColorRGBA.White);

dl1.setDirection(Vector3f.UNIT_X.negate());

rootNode.addLight(dl1);



DirectionalLight dl2 = new DirectionalLight();

dl2.setColor(ColorRGBA.White);

dl2.setDirection(Vector3f.UNIT_Y.negate());

rootNode.addLight(dl2);



DirectionalLight dl3 = new DirectionalLight();

dl3.setColor(ColorRGBA.White);

dl3.setDirection(Vector3f.UNIT_Z.negate());

rootNode.addLight(dl3);



rootNode.attachChild(tp);



BitmapText label = guiFont.createLabel(“Teapot”);

label.scale(.03f);

label.setLocalTranslation(0, 0, 0);

rootNode.attachChild(label);



viewPort.setBackgroundColor(ColorRGBA.Black);

cam.setViewPort(.5f, 1f, 0f, 0.5f);



Camera left = cam.clone();

left.setViewPort(0f, 0.5f, 0f, 0.5f);



left.setLocation(new Vector3f(0f, 0f, -10f));

left.lookAt(tp.getLocalTranslation(), Vector3f.UNIT_Y);



ViewPort leftView = renderManager.createMainView(“left”, left);

leftView.setClearFlags(true, true, true);

leftView.attachScene(rootNode);



Camera front = cam.clone();

front.setViewPort(0f, 0.5f, 0.5f, 1f);

front.setLocation(new Vector3f(10f, 0f, 0f));

front.lookAt(tp.getLocalTranslation(), Vector3f.UNIT_Y);



ViewPort frontView = renderManager.createMainView(“front”, front);

frontView.setClearFlags(true, true, true);

frontView.attachScene(rootNode);



Camera back = cam.clone();

back.setViewPort(0.5f, 1f, 0.5f, 1f);

back.setLocation(new Vector3f(-10f, 0f, 0f));

back.lookAt(tp.getLocalTranslation(), Vector3f.UNIT_Y);



ViewPort backView = renderManager.createMainView(“back”, back);

backView.setClearFlags(true, true, true);

backView.attachScene(rootNode);



// cam.setViewPort(0, .5f, .5f, 1f);



// cam.setLocation(new Vector3f(3.3212643f, 4.484704f, 4.2812433f));

// cam.setRotation(new Quaternion(-0.07680723f, 0.92299235f, -0.2564353f, -0.27645364f));

}

}

Text is just a geometry with a font texture on it, so if you want it to be different in each view you will have to have 4 scenes of the same geometries but make the labels face the camera in each one.

Or you can have your one scene, and then 4 new viewport overlays on top of the regular 4 scene viewports, these ones rendering the labels facing the camera (using a billboard control).

Or, probably even easier, is just attach another node to each viewport that is your different text. You can attach several scenes to each viewport.

Thanks for the quick answers. They all sound foreign to me but at lease I have a direction now. I will start rtfm based on the suggestions. It would be great if the TestMultiViews example included text as well because text is obviously a different matter than other geometries since it has to keep its direction in all different views. Thanks.

Add it to the gui node not the root node and it will always point towards the camera…



Or use a billboard if you want the text inside the scene. Billboards have code to keep them pointed towards the camera…