Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11855 Posts in 1569 Topics- by 3054 Members - Latest Member: Ljustin770

11. February 2012, 12:29:57 PM
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Problem with textBillboard width
Pages: [1]
Print
Author Topic: Problem with textBillboard width  (Read 305 times)
Tensaides
Just dropped in

Offline Offline

Posts: 15


View Profile Email
« on: 25. March 2010, 02:10:27 PM »

hello everyone, I am back with a new problem Cheesy This time, I have a problem with TextBillBoards and their width. The problem is that the text is not displayed in the same width for different words or small changes.

For example I want to display a fixedHeight text billboard. Let's call it "Aircraft Table". It will be displayed like in the v1.jpg attached image.
But if I drop the space and call it "AircraftTable", it will be displayed completely different as you can see in the v2.jpg attached image.

It's really a problem, because some texts are displayed larger than others and it seems that it's not the same font or font size that is used.

Here is the code for my billboard creation :
Code:
        float dist = model.getBounds().getMaxCenterDistance()*7/10;
TransformGroup textTransform = new TransformGroup(0f, 0.05f, -dist);
TextBillboard textConc =  TextBillboard.createFixedHeight(0.06f,
                            ZeroPointLocation.CENTER_CENTER, 0f, text, color, font);
textConc.setPickable(false);
textTransform.addChild(textConc);
model.getTransformGroup().addChild(textTransform);

I hope you will be able to help me. Thank you in advance.
Logged
horati
Global Moderator
Getting respectable
*****
Offline Offline

Posts: 393


View Profile
« Reply #1 on: 25. March 2010, 03:01:29 PM »

That is happening because of upscaling of the texture used to create the billboard.  You need to create the texture yourself so that you can fix its size.

Upscaling is required because graphics cards require each dimension (height, width) is a power of 2.  So if you draw the string "foo" with a font size of 8pt, it might be 12 high by 30 wide.  This will be stretched in each dimension until it is 16x32.  If you draw the string "Hello World" with the same font, its natural size might be 13x80.  This will be stretched until it is 16x128.  Placing the texture in the 3D scene causes further scaling (bigger AND smaller) as the object moves closer and farther away from the camera.

I'm not exactly positive what program you're trying to produce; however, it seems you want lots of pixel perfect 2D drawing.  The best way to accomplish what I think you want is to 1) draw each square fully in 2D before placing it in 3D or 2) draw each square as a separate 3D scene, render that scene to its own 2D texture, then place it as a single 2D object in the 3D scene.  Basically, I'm saying that you need to draw the entire object in 2D (possibly with help from one or more scenegraphs) before placing the object in 3D if you want pixel perfection in your 2D objects.

You might be able to devise some kind of conditional logic whose behavior depends on the texture size after upscaling.
Logged

Kevin
"It may not seem like a big deal, but ignorance of character encoding issues leads to insidious code rot akin to y2k."
http://stackoverflow.com/users/3474/sylvarking
Tensaides
Just dropped in

Offline Offline

Posts: 15


View Profile Email
« Reply #2 on: 26. March 2010, 09:20:29 AM »

Thanks for your answer. But you are talking about squares. The red one on the first screenshot was made manually to show you where was the problem Smiley SO you think I have to create the texture myself and it will solve my problem. I will try it and let you know if it works. thanks again.
Logged
Tensaides
Just dropped in

Offline Offline

Posts: 15


View Profile Email
« Reply #3 on: 26. March 2010, 10:54:58 AM »

Ok thanks for the advice. It works perfectly.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic