Text in the scene graph

Hi!



I did what it said in the hello assets tutorial regarding text, and it works when attaching to guiNode.



But I tried attaching it to rootNode to make it show up in the “world”, but I don’t see it. What do I need to do in order to make it visible? My goal is to provide names over the characters heads, so some kind of billboarding might be required.

Just use the GUI node and convert from world to screen using the camera.

But what if someone stands behind a tree, trying to hide. Then I’m gonna see his name and no player, right? Also, if I have the name in the scene graph, I can just create it and then forget about it, because it will move with the player. Having it in the scene graph just seems like the right thing to do.

I would suggest having it in the gui.

Create an abstractAppState to take care of it. Using ray or ghost object to see if he is visible enough to have name tag.



It would look odd if you saw half the name sticking out of a corner :stuck_out_tongue: Havn’t seen any game that would do that…

I think WoW does that, IIRC. Anyway, is it really hard to put it in the scene graph? How would I do it? If I knew I could just try both ways. Partly, I wanna know just to get to know jme3 better.

Figured it out, this is my code (in Clojure):

[java]

(defn test-billboard []

(let [text (doto (BitmapText. font false)

(.setQueueBucket RenderQueue$Bucket/Transparent)

(.setSize 0.5)

(.setText "hello world")

(.addControl (doto (BillboardControl.)

(.setAlignment BillboardControl$Alignment/Screen))))]

(.setLocalTranslation text

(- (/ (.getLineWidth text) 2))

(/ (.getLineHeight text) 2)

2)

(.attachChild root-node text)))

[/java]