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. Advertisements

  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. Advertisements

  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. Advertisements

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. Mark Kamoski
    Replies:
    3
    Views:
    16,486
    Jay B. Harlow [MVP - Outlook]
    Aug 9, 2003
  2. P. Flavin
    Replies:
    0
    Views:
    6,789
    P. Flavin
    Oct 17, 2003
  3. java3d obj files

    , Jun 9, 2004, in forum: Java
    Replies:
    1
    Views:
    593
    Andrew Thompson
    Jun 9, 2004
  4. Phil Endecott

    Obj* ptr = new Obj(X)

    Phil Endecott, Jun 3, 2005, in forum: C++
    Replies:
    5
    Views:
    748
    Mark P
    Jun 3, 2005
  5. Shalabh Chaturvedi
    Replies:
    2
    Views:
    583
    Mike C. Fletcher
    Feb 20, 2004
  6. Karsten Wutzke
    Replies:
    0
    Views:
    515
    Karsten Wutzke
    Jun 29, 2007
  7. Thorsten Kiefer

    searching for vrml loader for java3d

    Thorsten Kiefer, Jun 22, 2009, in forum: Java
    Replies:
    0
    Views:
    491
    Thorsten Kiefer
    Jun 22, 2009
  8. Steven D'Aprano
    Replies:
    10
    Views:
    316
    Gregory Ewing
    Dec 18, 2013
Loading...