----- Original Message -----
Sent: Monday, November 19, 2001 1:34
PM
Subject: Re: [JAVA3D] Static scene vs.
Camera navigated scene
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
>From: "Wang, Lihui" <[EMAIL PROTECTED]>
>Reply-To: Discussion list for Java 3D API
<[EMAIL PROTECTED]>
>To:
[EMAIL PROTECTED]
>Subject: [JAVA3D] Static scene vs. Camera navigated scene
>Date: Fri, 16 Nov 2001 14:43:24 -0500
>
>Hello,
>
>I have a scene graph attached to a Simple Universe. By
manipulating a
>camera's TransformGroup obtained through
>SimpleU.getViewingPlatform().getViewPlatformTransform(), It
is possible to
>do a camera-based navigation through my Java 3D scene.
>
>Now, I want to add a stationary background with a static
Text3D label to the
>same Canvas3D, but not to be affected by the camera's
viewpoint. It means
>that no matter where the viewpoint is and no matter what the
camera's
>orientation is, the background and the text label remain
stationary to the
>viewer.
>
>Could somebody kindly give me a hint of how to do it? Is it
possible to
>detach the ViewPlatform from the SimpleUniverse and attach it
to a lower
>node, so the higher part of the scene graph may become
stationary?
>
>Thanks.
>
>Ian Wang