Hey folks,
I'm trying to implement floating name/tile text for NPCs in my project. In short, I'd like there to be a name and (optionally) a title floating above the spatials that represent NPCs in my scene graph.
I'm trying to use the com.jme.scene.Text class. I can see the text, but it's always in the lower-right corner of my display… never floating along with my NPCs.
Here's my code (i hope this is enough of it)…
// Also add floating name/(title)...
Text floatingNameText = new Text("nameText-"+we.get(Tracable.ID), we.get(Entity.NAME));
floatingNameText.setRenderState(Text.getDefaultFontTextureState());
floatingNameText.setRenderState(Text.getFontBlend());
floatingNameText.setTextColor(ColorRGBA.white);
Node floatingNameNode = new Node("nameNode-"+we.get(Tracable.ID));
...
this.getRootNode().attachChild(floatingNameNode);
...
Vector3f v = floatingNameNode.getSpatial().getLocalTranslation();
Vector3f target = sp.getLocalTranslation();
v.set(target.getX() + a.getXOffset(),
target.getY() + a.getYOffset(),
target.getZ() + a.getZOffset());
Can the com.jme.scene.Text class do what I'm looking for? Should I be going about this task differently?
Thanks a million!