Skip to main content

Problem with interactive rotation

No replies
Stefan1971HH
Offline
Joined: 2012-12-30
Points: 0

Hello,

I'm trying to rotate objects around the x-axis by providing an angle
with a JSlider. The objects actually do rotate around the x-axis but
in an irregular,unsteady way, not corresponding to the provided angle.
What I do suspect is, that the the provided angles do add up unintendely.
It's also very obvious that the same JSlider value does not always lead to
the same position of the object. Here's the JSlider's stateChanged method,
preUni.activeObject is field holding the object to be rotated.
Any help would be much appreciated, thanks

 private void xMainRotatorStateChanged(javax.swing.event.ChangeEvent evt) {                                          
  Transform3D t3D = new Transform3D();
     Transform3D temp = new Transform3D();
     ((TransformGroup)preUni.activeObject.getParent())
       .getTransform(t3D);
     Vector3d trans = new Vector3d();
     Vector3d scale = new Vector3d();
     t3D.get(trans);
     t3D.getScale(scale);
    Transform3D xRot = new Transform3D();
    xRot.rotX((float)Math.toRadians(xMainRotator.getValue()));
    temp.setScale(scale);
    temp.setTranslation(trans);
    temp.mul(xRot,temp);
    ((TransformGroup)preUni.activeObject.getParent())
       .setTransform(temp);