Rotating object inside actionPerformed()
Posted by bchinfosieeuw on Jul 14, 2018; 7:24pm
URL: https://forum.jogamp.org/Rotating-object-inside-actionPerformed-tp4039031.html
I am rotating a cylinder like this:
TransformGroup cylinder4RotGroup = rotate(cylinder4TransGroup, new Alpha(-1, Alpha.INCREASING_ENABLE|Alpha.DECREASING_ENABLE, 0, 0, 1000, 0, 0, 1000, 0, 0));
TransformGroup rotate(Node node, Alpha alpha){
TransformGroup xformGroup = new TransformGroup();
xformGroup.setCapability(
TransformGroup.ALLOW_TRANSFORM_WRITE);
Transform3D axisOfTransform = new Transform3D();
RotationInterpolator interpolator = new RotationInterpolator(alpha, xformGroup, axisOfTransform, 0, 1);
interpolator.setSchedulingBounds(new BoundingSphere(new Point3d(0.0,0.0,0.0),1.0));
Transform3D axisZ = new Transform3D();
axisZ.rotZ(Math.PI/2);
interpolator.setTransformAxis(axisZ);
xformGroup.addChild(interpolator);
xformGroup.addChild(node);
return xformGroup;
}
However, I need more control over the rotation. Is it an idea to call the rotate method from actionPerformed()? I do not want to use the -1 option from the Alpha to rotate repeatedly. I do not get it working. Any ideas? Please be concrete by providing some example code. (Currently the rotate method is called from createSceneGraph(), which is only carried out once.)