Rotation and Billboard Control

Hey guys. i got some billboard text above my Npcs:

But if i walk around to the other side:

Code that i use to display it:

[java]
trollTextNode = new Node(“Troll title above head”);
trollTextNode.setQueueBucket(Bucket.Transparent);
trollTextNode.attachChild(ui.trollText());

    ui.trollText().addControl(trollText);
    troll.attachChild(trollTextNode);
    this.app.getRootNode().attachChild(trollTextNode);

[/java]
[java]
public void update(float tpf) {
trollTextNode.setLocalTranslation(troll.getWorldTranslation().add(-10, 25, 0));
}
[/java]

So as you can see, the text is not aligned when i go behind the npcs, I want the text to always be above their head in any position. I have to take in account for the player and camera position, im just not sure how i would implement that mathrmatically wise to trollTextNode.setLocalTranslation(troll.getWorldTranslation().add(-10, 25, 0));

You probably actually want to center the text over their heads… either use alignment and position the text properly or offset the text under a node and then stick the billboard on that node.

1 Like
@pspeed said: You probably actually want to center the text over their heads... either use alignment and position the text properly or offset the text under a node and then stick the billboard on that node.

Fixed, i have so much to learn ;( Thanks again pspeed.

@JacobAmaral said: Fixed, i have so much to learn ;( Thanks again pspeed.

That was fast. Don’t sell yourself short. :slight_smile:

I throw the “dungeon master” style answers out there (I’m probably showing my age referencing an 80s cartoon). Some people get it and run with it and others come back with additional questions. You can feel good that you snapped it right up. :slight_smile:

@pspeed said: That was fast. Don't sell yourself short. :)

I throw the “dungeon master” style answers out there (I’m probably showing my age referencing an 80s cartoon). Some people get it and run with it and others come back with additional questions. You can feel good that you snapped it right up. :slight_smile:

Im my opinion programming can be so satisfying, but mistakes can destroy you;that gut feeling when you know something isn’t 100%. Im only 19, im just afraid when i got into the workplace (i want to work for an AAA video game company) that if i make a mistake or not how my boss wants it they will fire me :frowning:

@JacobAmaral said: Im my opinion programming can be so satisfying, but mistakes can destroy you;that gut feeling when you know something isn't 100%. Im only 19, im just afraid when i got into the workplace (i want to work for an AAA video game company) that if i make a mistake or not how my boss wants it they will fire me :(

Everyone makes mistakes. It’s how quickly you find and correct them that matters.

I guess the AAA industry is not really such a hot place to work right now, though, anyway. I used to have the sweetest gig ever: writing data visualization apps for research and development. We were told that if we weren’t failing half the time that we weren’t cutting edge enough. Interesting way to work and I miss it.

I had the same problem. I tried to setAlignment on a BitmapText, but got: “java.lang.RuntimeException: Bound is not set”. What’s up with that.

@tuffe said: I had the same problem. I tried to setAlignment on a BitmapText, but got: "java.lang.RuntimeException: Bound is not set". What's up with that.

Well… the bound is not set.

@pspeed said: Well... the bound is not set.

Hehe. Yes, but why not? Am I doing something wrong? (I hope and think that you can figure out what I’m doing, even if it’s not Java.)

[java]
(doto (BitmapText. font)
(.setQueueBucket RenderQueue$Bucket/Transparent)
(.setSize 0.5)
(.setText name)
(.setAlignment BitmapFont$Align/Center)
(.addControl
(doto (BillboardControl.)
(.setAlignment BillboardControl$Alignment/Camera))))
[/java]

It’s not called bound, unfortunately, but this is what you need:
http://hub.jmonkeyengine.org/javadoc/com/jme3/font/BitmapText.html#setBox(com.jme3.font.Rectangle)

Hmmm…
((It’s (not called (bound))) (unfortunately but) (this (is (what you need))))
…sorry, I’m speaking with a lisp again… :wink:

@pspeed :slight_smile:

Thanks, that worked! But, BitmapText.getLineWidth seems to be about 90% of what I need to put into the Rectangle’s width for the text to have enough room. Shouldn’t it be 100%? I can live with it, but it seems odd.

@tuffe said: @pspeed :)

Thanks, that worked! But, BitmapText.getLineWidth seems to be about 90% of what I need to put into the Rectangle’s width for the text to have enough room. Shouldn’t it be 100%? I can live with it, but it seems odd.

I haven’t experienced this… but looking at Lemur code, I do pad the width by an extra 0.01. I don’t know if it’s related and it sounds like considerably less than you’ve had to adjust yours.