Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotate a 3D object on 3 axis in JavaFX properly

Tags:

So the method that I've used so far to rotate objects in JavaFX was that I layered it in 3 groups, each of them with a Rotate attached and locked to a single axis like so:

    Rotate heading, roll, pitch;
    Group normalrotate, rollrotate, verticalrotate;

    heading.setAxis(new Point3D(0,1,0));
    normalrotate.getTransforms().add(heading);

    roll.setAxis(new Point3D(0,0,1));
    rollrotate.getTransforms().add(roll);

    pitch.setAxis(new Point3D(1,0,0));
    verticalrotate.getTransforms().add(pitch);

and did a setAngle() for each time I needed to rotate the object. This worked very well for only heading and roll until i decided that I need pitch too. Now a lot of tutorials for OpenGL and alike say that rotational matixes or quaternions are best for these type of rotations, but the javadoc lacks any usefull data regaring this.

Example: What happens when I rotate an object by 180 degrees on the y axis (and what should actually have happened in transparent blue) enter image description here Am I missing something? All help would be appreciated.