try this. I havent tested it but it should work


       Scene s = null;
       s = f.load(filename);  //filename is the name of the file, cube.obj
for ex.


       BranchGroup b = s.getSceneGroup();
       Shape3D shape = (Shape3D) b.getChild(0);
       GeometryArray g = (GeometryArray) shape.getGeometry();
       shape.setGeometry(g);
       Appearance app = shape.getAppearance();

         >>> your original code <<<<<
       TextureLoader tex = new TextureLoader("Image.jpg", this);
       app.setTexture(tex.getTexture());
       TextureAttributes texAttr = new TextureAttributes();
       texAttr.setTextureMode(TextureAttributes.MODULATE);
       app.setTextureAttributes(texAttr);
       app.setMaterial(new Material(white, black, white, black, 1.0f));
       >>>>>>>>>><<<<<<<<<<<<<<<<<<

       shape.setAppearance(app);
       objTrans.addChild(s.getSceneGroup());     //objTrans is the
TransfromGroup


thanks

Ahmed

-----Original Message-----
From: PK [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 08, 2000 10:06 AM
To: [EMAIL PROTECTED]
Subject: [JAVA3D] Texturing Object File


Hi All,

      I've loaded an Object file(.obj) and I now want to texture it with
a .jpg file. Can anyone help me with this?

  Here's the important bit of my code for loading the file:

Scene s = null;
s = f.load(filename);  //filename is the name of the file, cube.obj for ex.
objTrans.addChild(s.getSceneGroup());     //objTrans is the TransfromGroup

Here's the code for texturing..

Appearance app = new Appearance();
TextureLoader tex = new TextureLoader("Image.jpg", this);
app.setTexture(tex.getTexture());
TextureAttributes texAttr = new TextureAttributes();
texAttr.setTextureMode(TextureAttributes.MODULATE);
app.setTextureAttributes(texAttr);
app.setMaterial(new Material(white, black, white, black, 1.0f));


Both bits of code work OK independantly, I just don't know how to
combine them.

I hope someone can help me,

Thanks,

Phelim

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to