Petra Neumann Guest
|
Posted: Fri Jul 25, 2003 1:39 pm Post subject: Text3D |
|
|
Hi,
I have a problem using Text3D.
I have several labels for objects in my scene and set up a button to
turn those labels on and off (make them visible and invisible). When I
turn the labels off and then back on they seem to have moved to
arbitrary points in my 3d scene, mostly the origin. This is really odd
since I only influence the setVisible rendering attribute not any of the
transformgroups.
Has anything like this happened to anyone before?
Here is some of my code if this helps...
Petra
I set up several Text3D objects like this:
***********method in which the text is created*****************
private Shape3D setText(String text,float x,float y,float z,int fontSize){
Font f=new Font("Helvetica",Font.PLAIN,fontSize);
Text3D am=new Text3D(new Font3D(f,new FontExtrusion()),text,new
Point3f(x,y,z));
Shape3D t=new Shape3D();
t.setGeometry(am);
Appearance app=new Appearance();
Color3f textColor=new Color3f(0.6f,0.6f,0.6f);
ColoringAttributes coloringAttributes = new ColoringAttributes( );
coloringAttributes.setColor( textColor );
coloringAttributes.setShadeModel( ColoringAttributes.SHADE_FLAT );
app.setColoringAttributes( coloringAttributes );
t.setAppearance(app);
return t;
}
**********where the method is called:
Shape3D label=setText(text,0.0f,lp+lp/10f-cy,0.0f,fontsize);
//sphereLabelText[...]stores all my labels
sphereLabelText[id]=label;
//set rendering attributes
sphereLabelText[id].getAppearance().setRenderingAttributes(r);
sphereLabelText[id].setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
sphereLabelText[id].setCapability(Shape3D.ALLOW_APPEARANCE_READ);
sphereLabelText[id].getAppearance().setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_READ);
sphereLabelText[id].getAppearance().setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_WRITE);
sphereLabelText[id].getAppearance().getRenderingAttributes().setCapability(RenderingAttributes.ALLOW_VISIBLE_READ
);
sphereLabelText[id].getAppearance().getRenderingAttributes().setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE
);
Group sphereLabel=new Group();
sphereLabel.addChild(sphereLabelText[id]);
sphereLabel.addChild(sphereLabelSticks[id]);
//this group is then added to a transformgroup
**********how the labels are made visible and invisible*****
sphereLabelText[id].getAppearance().getRenderingAttributes().setVisible(false);
|
|