We often need to apply multi transformations to one object. There are two ways to do it.One way is to create the TransformGroup object for each transformation and other way is to combine the Transform3D objects by mul method.

This program illustrates how to apply multi transformation to the Cube by these ways.

Creating the TransformGroup object for each Transform3D object:

 public BranchGroup createSceneGraph() {
  BranchGroup objRoot = new BranchGroup();

  // Create two Transform3D objects
  Transform3D rotate1=new Transform3D();
  Transform3D rotate2=new Transform3D();
  rotate1.rotX(Math.PI/4.0d);
  rotate2.rotY(Math.PI/5.0d);
    
    // Combine the transform
   TransformGroup objRotate1=new TransformGroup(rotate1);
   TransformGroup objRotate2=new TransformGroup(rotate2);
  objRoot.addChild(objRotate1);
  objRotate1.addChild(objRotate2);
  objRotate2.addChild(new ColorCube(0.4));
    

  return objRoot;
}

Combining multi Transform3D objects to one object

 public BranchGroup createSceneGraph() {
  BranchGroup objRoot = new BranchGroup();

  // Create two Transform3D objects
  Transform3D rotate1=new Transform3D();
  Transform3D rotate2=new Transform3D();
  rotate1.rotX(Math.PI/4.0d);
  rotate2.rotY(Math.PI/5.0d);
    
    // Combine the transform
  
  rotate1.mul(rotate2);
  TransformGroup objRotate=new TransformGroup(rotate1);
  objRotate.addChild(new ColorCube(0.4));
  objRoot.addChild(objRotate);

  return objRoot;
}