Hey guys,
i hope someone can help me. In my Project wich is a little 3d game I have a building with some rooms and doors. now i want to automatically open the doors by animations, when my camera is in front of them. I´ve already wrote the animation with an rotation interpolator to open the first door. but the interpolator starts immediatly after the programm starts. Until now i didn´t find a solution to start the animation only when i want to.
The plan is everytime when the camera achieved one door a counter counts up and the animation for exactly this specific door is activated.
Here is my code:
public void eingangstuer2()
{
ColorCube colorcube = new ColorCube();
TransformGroup neu2 = new TransformGroup();
TransformGroup t = new TransformGroup();
t.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Transform3D tgTuer4 = new Transform3D();
transformgroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
tgTuer2.setScale(new Vector3d( 0.0365, 0.1, 0.005 ));
tgTuer2.setTranslation(new Vector3f(0.03f,0f,0f));
transformgroup .setTransform(tgTuer2);
tgTuer4 .setTranslation(new Vector3f(-0.06f,-0.4425f,-5.057f));
neu2.setTransform(tgTuer4);
Alpha rotationTuer =new Alpha (1,50000);
rotationTuer.setStartTime(System.currentTimeMillis());
RotationInterpolator wegTuer = new RotationInterpolator(rotationTuer, t);
wegTuer.setMinimumAngle((float)Math.toRadians(0));
wegTuer.setMaximumAngle((float)Math.toRadians(180));
wegTuer.setEnable(false);
wegTuer.setSchedulingBounds(new BoundingSphere(new Point3d(), 1000));
rotationTuer.finished();
t.addChild(wegTuer);
transformgroup.addChild(colorcube);
t.addChild(transformgroup);
neu2.addChild(t);
BranchGroup branchtuer2 = new BranchGroup();
branchtuer2.addChild(neu2);
u.addBranchGraph(branchtuer2);
}
else if(e.getKeyChar() == '8'){
eingangstuer2();
}
}
Thanks in advance