This content has been marked as final. Show 6 replies
Use the Rotate(angle, point3D) method to define your rotation.
Or (probably easier to visualize and work with), concatenate your transforms about the 3 standard axes.
// rotate about 30 degrees around the axis defined by the vector x=1, y=0, z=-1 Rectangle rect = new Rectangle(50,50, Color.RED); rect.getTransforms().add(new Rotate(30, new Point(1, 0, -1)));
// rotate about 45 degrees about the z axis to make a diamond, turn the diamond side on the user 20 degrees and tilt it back 5 degrees. Rectangle rect = new Rectangle(50,50, Color.RED); rect.getTransforms().add( new Rotate(45, Rotate.Z_AXIS) new Rotate(20, Rotate.Y_AXIS) new Rotate(-5, Rotate.X_AXIS) );
For that you need to rotate the camera rather than the object.
You will need to use a recent build of Java8 (b77+) for that and a machine that can run the 3D stuff in it (currently only a Windows machine).
There is some code for specifying a movable camera:
I haven't tried it, but in JavaFX 8 the camera is just another node.
// Create a camera and add it to the Scene Camera camera = new PerspectiveCamera(); scene.setCamera(camera); // Add camera to scene graph (so it can move) Group cameraGroup = new Group(); cameraGroup.getChildren().add(camera); root.getChildren().add(cameraGroup); // Rotate the camera camera.rotate(45); // Move the cameraGroup (camera moves with it) cameraGroup.setTranslateZ(-75);
I think if you apply a RotateTransition to the camera you could animate rotating it around (like turning your head to see change your field of view).
Similarly, if you instead applied a PathTransition to the group containing the camera, then that would simulate you walking in a circle, but looking in a constant direction.
If you applied an appropriate RotateTransition to both the camera and a PathTransition to the group containing the camera and you did it at the right proportional values, then you could ensure that the as the camera was rotating around the object, it was always facing inward tangentally to the path the group is following so that it is always looking at the object being walked around.
For some inspiration look at Uluk's answer here which demonstrate animation around a circular path.
But in the second example, you put it in 3D and rotate the camera instead of scaling the node.
Thanks, I figured I might have to use both.... I will have to be able to rotate at any point around the object, or set of objects. up down, left, right, or any angel I need, at any point. I'm also going to have a part where if you click on an item it will zoom in, and you will be able to rotate around that single item, instead of the whole.