Java3D: how to transform an object loaded with obj loader

N

NickPick

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());
 
B

blabla

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)?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top