
// MovedShape.java
// Andrew Davison, ad@coe.psu.ac.th, October 2021


import org.jogamp.java3d.*;
import org.jogamp.vecmath.*;


public class MovedShape
{

  public static void main(String[] args)
  /*
     sceneBG --> pos --> scale --> text
          |
          -----> pos --> rot --> car
  */
  {  
    Simple3D j3d = new Simple3D("Moved Text", true, true);

    // scaled, positioned 3D text:  pos --> scale --> text
    BranchGroup text = Simple3D.text3D("Simple3D", "red");
    TransformGroup scaleTG = Simple3D.scale(0.3);
    scaleTG.addChild(text);  
    TransformGroup pos1TG = Simple3D.setTranslation(1, 0.1, 1);
    pos1TG.addChild(scaleTG);  

    // rotated, positioned car:  pos --> rot --> car
    BranchGroup modelBG = Simple3D.loadModel("models/car/car.obj");
    TransformGroup rotTG = Simple3D.rotY(-45);
    rotTG.addChild(modelBG);  
    TransformGroup pos2TG = Simple3D.setTranslation(-1, 0, 1);
    pos2TG.addChild(rotTG);  

    // build scene
    BranchGroup sceneBG = Simple3D.createBG();
    sceneBG.addChild(pos1TG);
    sceneBG.addChild(pos2TG); 
 
    j3d.rootBG.addChild(sceneBG);
  }  // end of main()

}  // end of MovedShape class
