Thanks Joachim, Xiaowen, and Thomas for your kind
helps.
Joachim suggested to use Billboard, I believe it works.
However, the text label (caption) will not be a completely fixed caption. It
appears rotating back and forth a bit (not so stationary).
Thomas' method should work. I compiled your code, and it runs
well. In my case, I didn't use keyNavigator. So I tried Xiaowen's suggestion
first.
Xiaowen suggested to use ViewingPlatform.setPlatformGeometry()
method to attach the caption to the ViewingPlatform of a SimpleUniverse. I did
it as follows. No error message. But I cannot see my caption. How can I bring it
in front of my eyes? Should I attach a BranchGroup node or a TransformGroup
node?
.....
SimpleUniverse simpleU = new
SimpleUniverse(canvas3D);
PlatformGeometry pg = new PlatformGeometry(); pg.addChild(setCaption()); ViewingPlatform vp = simpleU.getViewingPlatform(); vp.setPlatformGeometry(pg); BranchGroup scene = createSceneGraph(); simpleU.addBranchGraph(scene);
.....
public BranchGroup
setCaption()
{ BranchGroup captionBG = new BranchGroup(); TransformGroup captionTG = new TransformGroup(); String fontName = "TestFont"; String textString ="This is my Caption"; float len = textString.length(); Color3f textColor = new Color3f(0.7f, 0.8f, 0.6f); Material text = new Material(textColor,CONSTANTS.black,textColor, CONSTANTS.white,100.0f); text.setLightingEnable(true); Appearance appearText = new Appearance(); appearText.setMaterial(text); Line2D.Float height = new Line2D.Float(0.0f, 0.0f, 1.2f, 0.0f); Font3D f3d = new Font3D(new Font(fontName,Font.PLAIN,2), new FontExtrusion(height)); Text3D txt = new Text3D(f3d,textString, new Point3f(-(len-1)/2,8.5f,0.0f),Text3D.ALIGN_FIRST, Text3D.PATH_RIGHT); Shape3D textShape = new Shape3D(); textShape.setGeometry(txt); textShape.setAppearance(appearText); Transform3D tex = new Transform3D(); tex.set(new Vector3f(50.0f, 50.0f, 222.0f)); <----- location of my caption captionTG.setTransform(tex); captionTG.addChild(textShape); captionBG.addChild(captionTG); return captionBG; } I guess I didn't use the correct
TransformGroup.
Ian Wang
|
- [JAVA3D] Static scene vs. Camera navigated scene Wang, Lihui
- Re: [JAVA3D] Static scene vs. Camera navigated... Joachim Diepstraten
- Re: [JAVA3D] Static scene vs. Camera navigated... Xiaowen Wang
- [JAVA3D] Certification Jong Hang
- Re: [JAVA3D] Static scene vs. Camera navigated... Thomas Gilbert Giusepe
- Re: [JAVA3D] Static scene vs. Camera navigated... Thomas Gilbert Giusepe
- Re: [JAVA3D] Static scene vs. Camera navigated... Wang, Lihui