Lunar
Lunar

Reputation: 4711

Losing rotation in Java3D when trying to animate

I have created a Cylinder and rotated it so it lies on its side. This works fine.

However I'm now trying to add some animation to it. I have coded the animations with a PositionInterpolar, and it works fine and moves across the right axis.

The problem I have, is that it seems to overwrite my Transform3D I used to rotate the cylinder in the first place, so my cylinder is not standing upright and moving side ways.

Any ideas? Do I need to rotate the object in a different way?

Upvotes: 4

Views: 278

Answers (1)

msj121
msj121

Reputation: 2842

Perhaps this could be a simple instance where as I recall Java3D likes you to use different Transform3D objects for each rotation etc.... For instance:

public class Static3DWorld extends JFrame {
    private Transform3D rotate1 = new Transform3D();
    private Transform3D rotate2 = new Transform3D();
    ....
    private Transform3D rotateCube() {
      rotate1.rotX(Math.PI / 4.0d);
      rotate2.rotY(Math.PI / 4.0d);
      rotate1.mul(rotate2);
      return rotate1;
    }
    ....
}

Is this how your are doing your rotations etc...? You can see the tutorial here: http://www.java-tips.org/other-api-tips/java3d/introduction-to-java3d-api-5.html

Upvotes: 2

Related Questions