Simple bíllboard question about positioning the billboard

Hi!

I created this chatbubble like this:

[java]public ChatBubble(Node piv, String msg, boolean shout) {

Picture bubble = new Picture("");

bubble.setImage(MainClass.getAsset(), “SpeechBubble.png”, true);

bubble.setHeight(82);

bubble.setWidth(81);

BillboardControl bc = new BillboardControl();

bc.setAlignment(BillboardControl.Alignment.Camera);

bubble.addControl(bc);

bubble.setLocalTranslation(0,3,0);

piv.attachChild(bubble);

}[/java]

Problem is, it doesn’t do anything of what I expected from it.



First, attaching it to a node (the piv is connected to a bodycontrol on the character) doesn’t really help me in any way.

I wanted the billboard to be placed as a chatbubble 3m over the character facing the screen without being disformed by 3D viewangles.

What I get is a speechbubble in my left down corner of the screen, it twists around like 3D yet is renderd ontop of everything.

I want it to be NOT transformed in rotation but to be transformed by the characters location.

What it DOES is being rotated, but not editing the translation at all.

So it basicly do the opposite of what I want.



I’m guessing billboard is not what I want? I should make my own class for such objects?

Its the only solution I can find, it’s weard as I thought billboards was to be used in hp bars, name tags etc, but in such cases seems useless…

What am I missing?

What happens if you use:

bc.setAlignment( BillboardControl.Alignment.Screen );

?

1 Like

Fairly the same, it doesn’t twist it, as the camera does, but it still rotates it.

AxialY doesn’t seem to rotate, but I still need to know how to place it ontop of the character.

The translation is still bottom left corner…

This is what I use to put a name over my character’s heads:



[java]

label = new BitmapText( font, false );

label.setSize( 1f );

label.setText( s );

float textWidth = label.getLineWidth() + 20;

float textOffset = textWidth / 2;

label.setBox( new Rectangle(-textOffset,0, textWidth, label.getHeight()) );

label.setColor( new ColorRGBA( 0, 1, 1, 1 ) );

label.setAlignment( BitmapFont.Align.Center );

label.setQueueBucket( RenderQueue.Bucket.Transparent );

BillboardControl bc = new BillboardControl();

bc.setAlignment( BillboardControl.Alignment.Screen );

label.addControl(bc);

[/java]

1 Like

Okej but do you parent the label to the characters node?

I dont see how it would place the text above the character as there is nothing concerning translation in that code :confused:

Yeah, sorry… it’s added to a node:



[java]

textNode = new Node( “LabelNode” );

textNode.setLocalTranslation( 0, label.getHeight(), 0 );

textNode.attachChild( label );

[/java]



Note: that in my case, the origin is the player’s head… adjust the local translation accordingly.

1 Like

That looks pritty awsome :smiley:

It’s exacly what I want, but with the image!



I added a text “Player” over all characters, and they will be displayed properly over each head. But when I change

to using Picture with a loaded image, the bubbles will appear missplaced. Is it a bug or am I suppose to use something else than a picture for images?

Misplaced how? Code and maybe a pic to see what you mean?

1 Like


There.

As you can see, your text label will be above their heads, but my speechbubble will gather in the corner.



I do same operation as you did with the text on the picture tho:

[java]label.addControl(bc);

label.setLocalTranslation(0,3,0);

piv.attachChild(label);[/java]

and

[java]bubble.addControl(bc);

bubble.setLocalTranslation(0,3,0);

piv.attachChild(bubble);[/java]



Dont really see what I’m doing wrong…

Ah… Picture may be in the GUI bucket by default or something. Text used to be this way until we fixed it.



See if you assign it to the regular render bucket if it fixes things.



Edit: or in this case the transparent bucket, I guess.

1 Like

AWSOME! It works! :smiley:



Thanks very much pspeed :slight_smile: