Difficulties adding 2D or 3D text to the scene.

View: New views
2 Messages — Rating Filter:   Alert me  

Difficulties adding 2D or 3D text to the scene.

by java3d-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello!

I have a 3D cube which I have created, and I've been able to add things to the scene such as spheres and dotted lines.  I cannot, however, get any 2D or 3D text to show up.  Here is some code I am using.  Does this look correct?

[code]        Text2D text2D = new Text2D("X Axis",
                                   new Color3f(0.0f, 0.0f, 0.0f),
                                   "Arial", 18, Font.ITALIC);
        sceneBranch.addChild(text2D);

       
       
        Font3D font3d = new Font3D(new Font("Arial", Font.PLAIN, 10),
                            new FontExtrusion());
        Text3D textGeom = new Text3D(font3d, new String("X Axis"),
                              new Point3f(-2.0f, 0.0f, 0.0f));
        Shape3D textShape = new Shape3D(textGeom);
        sceneBranch.addChild(textShape);
[/code]

Thanks for the help,
Chris
[Message sent by forum member 'cwrighta70' (chris.wright@...)]

http://forums.java.net/jive/thread.jspa?messageID=370385

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...


Re: Difficulties adding 2D or 3D text to the scene.

by java3d-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Chris
If using 2D text maybe you should consider a billboard to make it face the user point of view. If using 3D text, maybe you should play with something like the little class bellow, before developing further your code.
Hope it helps,
   Antonio Jose Cacho

import java.awt.*;
import javax.vecmath.*;
import javax.media.j3d.*;
/**
 * Generates a simple 3D text label to anotate a location or a feature of a scene
 * @author Antonio Cacho, cacho@...
 */
public class TextLabel {
    private static final Font font= new Font("TextLabel", Font.PLAIN, 2);
    private static final Font3D font3D = new Font3D(font, new FontExtrusion());
    private static final BoundingSphere bounds= new BoundingSphere(new Point3d(0,0,0), Double.POSITIVE_INFINITY);

    public TextLabel(String label, Point3f location, BranchGroup holdingBG) {
        Shape3D labelShape= new Shape3D( new Text3D(font3D, label, location), new Appearance() );
        labelShape.setBounds( bounds );
        BranchGroup labelBranchGroup= new BranchGroup();
        labelBranchGroup.addChild(labelShape);
        labelBranchGroup.compile();
        holdingBG.addChild( labelBranchGroup );
    }
}
[Message sent by forum member 'aj_cacho' (ajcacho@...)]

http://forums.java.net/jive/thread.jspa?messageID=370439

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...