Java3D: how to transform an object loaded with obj loader

Discussion in 'Java' started by NickPick, Mar 3, 2010.

  1. NickPick

    NickPick Guest

    How can I transform an object which I loaded with a loader as below?
    What is the code when I want to move it to (5,5,5)?

    thanks


    ObjectFile f = new ObjectFile();
    Scene loadedShip = null;
    try {
    loadedShip = f.load("C:/Users/Nicolas/Documents/
    NetBeansProjects/3dGame/src/Gamestar/obj.obj");
    } catch (FileNotFoundException e) {
    System.err.println(e);
    System.exit(1);
    } catch (ParsingErrorException e) {
    System.err.println(e);
    System.exit(1);
    } catch (IncorrectFormatException e) {
    System.err.println(e);
    System.exit(1);
    }

    // set colors
    Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);
    Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f);
    Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);

    // set light
    AmbientLight aLgt = new AmbientLight(alColor);
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,
    2.0, 0.0), 100.0);
    aLgt.setInfluencingBounds(bounds);
    DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);
    lgt1.setInfluencingBounds(bounds);

    objRoot.addChild(aLgt);
    objRoot.addChild(lgt1);
    Transform3D tr = new Transform3D();
    tr.set(new Vector3f(0.3f, 0.2f, 0.2f));

    objRoot.addChild(loadedShip.getSceneGroup());
     
    NickPick, Mar 3, 2010
    #1
    1. Advertising

  2. NickPick

    Jeff Higgins Guest

    NickPick wrote:
    > How can I transform an object which I loaded with a loader as below?
    > What is the code when I want to move it to (5,5,5)?
    >
    > thanks


    Here's another place to ask for help with the Java 3D related:
    <http://forums.java.net/jive/forum.jspa?forumID=70>
     
    Jeff Higgins, Mar 4, 2010
    #2
    1. Advertising

  3. NickPick

    blabla Guest


    > How can I transform an object which I loaded with a loader as below?
    > What is the code when I want to move it to (5,5,5)?
    >
    > Transform3D tr = new Transform3D();
    > tr.set(new Vector3f(0.3f, 0.2f, 0.2f));



    You already translated it by (0.3,0.2,0.2), did you try to change it to
    (5,5,5)?
     
    blabla, Mar 5, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. P. Flavin
    Replies:
    0
    Views:
    6,399
    P. Flavin
    Oct 17, 2003
  2. java3d obj files

    , Jun 9, 2004, in forum: Java
    Replies:
    1
    Views:
    478
    Andrew Thompson
    Jun 9, 2004
  3. Karsten Wutzke
    Replies:
    0
    Views:
    392
    Karsten Wutzke
    Jun 29, 2007
  4. Thorsten Kiefer

    searching for vrml loader for java3d

    Thorsten Kiefer, Jun 22, 2009, in forum: Java
    Replies:
    0
    Views:
    409
    Thorsten Kiefer
    Jun 22, 2009
  5. Ned Batchelder
    Replies:
    0
    Views:
    96
    Ned Batchelder
    Dec 16, 2013
Loading...

Share This Page