Problem with TransparencyInterpolator!!(Java3D)
Posted by Davidave on Dec 09, 2014; 4:43pm
URL: https://forum.jogamp.org/Problem-with-TransparencyInterpolator-Java3D-tp4033734.html
Hey guys !
I created a headline on my main page of my programm! when I start my program i want to make a text3D (Headline) from INvisible to visible and i use a transparency interpolator!!! but there is one big problem !!
when my program starts the text3D is visible for ONE second and then gets invisible. But it should be INVISIBLE from the start ! what did i do wrong ? did a add something in the wrong order ? this is my code
Main class
public class World implements ActionListener {
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D c = new Canvas3D(config);
SimpleUniverse u = new SimpleUniverse(c);
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JButton startbtn = new JButton();
JPanel panelSouth = new JPanel();
Headline h = new Headline();
Alpha objektAlpha2 = new Alpha(1, 10000);
TransparencyAttributes objTransp;
TransformGroup ViewTG = u.getViewingPlatform().getViewPlatformTransform();
Transform3D ViewT3D = new Transform3D();
}
public World(){
startbtn.setText("start");
startbtn.setBackground(Color.RED);
startbtn.setForeground(Color.BLACK);
Font font = new Font("Chiller", Font.BOLD,60);
startbtn.setFont(font);
startbtn.addActionListener(this);
panel.setLayout(new BorderLayout());
panel.add(c,BorderLayout.CENTER);
panel.add(panelSouth, BorderLayout.SOUTH);
panelSouth.setLayout(new BorderLayout());
panelSouth.add(geisterText,BorderLayout.CENTER);
panelSouth.add(startbtn,BorderLayout.EAST);
frame.add("Center",panel);
frame.setFocusable(true);
Alpha objektAlpha2 = new Alpha(1, 10000);
objektAlpha2.setLoopCount(1);
OrbitBehavior ob = new OrbitBehavior(c);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1600, 850);
frame.setVisible(true);
ob.setSchedulingBounds(new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE));
u.getViewingPlatform().setViewPlatformBehavior(ob);
}
public BranchGroup createSceneGraph(){
BranchGroup RootBg = new BranchGroup();
RootBg.addChild(h.createHeadline()); // This is the method i use !!!!!
return RootBg;
}
HeadlineClass:
public class Headline {
public Headline(){
}
BranchGroup createHeadline(){
BranchGroup branch = new BranchGroup();
//Farben
Color3f red = new Color3f(1.0f,0f,0f);
Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
//1st Text Haunted House
Appearance a = new Appearance();
Material m = new Material(white, red, red, red, 80.0f);
m.setLightingEnable(true);
a.setMaterial(m);
Font3D f3d = new Font3D(new Font("Arial", Font.PLAIN, 1),new FontExtrusion());
Text3D text = new Text3D(f3d, new String("Haunted House"), new Point3f(0,0, 0));
text.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Shape3D textshape1 = new Shape3D();
TransformGroup tg = new TransformGroup();
Transform3D t3d = new Transform3D();
t3d.setScale(0.2);
Vector3f v3f = new Vector3f(-1.27f, -0.55f, -4f);
t3d.setTranslation(v3f);
t3d.setRotation(new AxisAngle4f(0,1,0,(float)Math.toRadians(25)));
textshape1.setGeometry(text);
textshape1.setAppearance(a);
Alpha objektAlpha1 = new Alpha(1, 10000);
objektAlpha1.setStartTime(System.currentTimeMillis()+6000);
objektAlpha1.setLoopCount(1);
BoundingSphere view1 = new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE);
TransparencyAttributes objTransp1 = new TransparencyAttributes(TransparencyAttributes.BLENDED, 0f);
objTransp1.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
objTransp1.setTransparencyMode( TransparencyAttributes.NICEST );
a.setTransparencyAttributes(objTransp1);
TransparencyInterpolator traInt1 = new TransparencyInterpolator( objektAlpha1,objTransp1 ,1f, 0f);
tg.setTransform(t3d);
tg.addChild(textshape1);
branch.addChild(tg);
traInt1.setSchedulingBounds(view1);
branch.addChild(traInt1);
return branch;
please help me its vry important! i hope you understand my problem
cheers
david