|
How to rotate the Color Cube |
|
|
We can rotate the cube to show more than one face of it. The first step is to
create the desired transformation using a Transform3D object. After call the
rotX method of Transform3D object and apply it to a TransformGroup object,
the cube included by the TransformGroup object is rotated.
public class RotateCube extends JFrame {
public RotateCube() {
...
}
public BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
// Create the Transform3D object
Transform3D rotate=new Transform3D();
rotate.rotX(Math.PI/4.0d);
// instantiate the TransformGroup object
TransformGroup objRotate=new TransformGroup(rotate);
// Add the Cube into the TransformGroup object
objRotate.addChild(new ColorCube(0.4));
objRoot.addChild(objRotate);
return objRoot;
}
public static void main(String[] args){
...
}
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.