If you supply texture coordinates in your .obj file, they will
be in the geometry, even if no texture is specified in the
.obj file.  This should allow you to apply the texture at a
later time.

But the .obj file isn't going to generate texture coordinates
for you - must specify them yourself in the .obj file.
See the ObjectFile javadoc for details on how to do this
(it's easy - texture coordinates are specified exactly like
vertex positions and normals).

-Paul


> From: "richie" <[EMAIL PROTECTED]>
> To: "Paul Pantera" <[EMAIL PROTECTED]>
> Subject: Re:  texturing in .obj file
> Date: Sat, 6 Jan 2001 14:11:31 +0100
> MIME-Version: 1.0
> Content-Transfer-Encoding: 8bit
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
>
> Dear Paul Pantera
>
> I am also facing a similar problem like mentioned by somebody before.
> when i load the geometry from an .obj file and then give it a appearance(and
> texture)  the texture sure is loaded on it but not the whole image, since
> texture coordinates r not set.
> i tried to create a geometry in java3d itself as a quadarray and then set
> the same appearnce object in it along with texture coordinates, then it
> works fine. the code for both conditions is given below:
>
> //here since the texture coords r not set , the image is mapped only partly
> and not wholly on the object
>
>        Scene s = f.load(filename);
>        BranchGroup obj = s.getSceneGroup();
>        Shape3D shape = (Shape3D) obj.getChild(0);
>        GeometryArray g = (GeometryArray) shape.getGeometry();
>        shape.setGeometry(g);
>
>         Appearance appear = new Appearance();
>         appear.setCapability( TextureAttributes.ALLOW_MODE_WRITE );
>         TextureLoader myLoader = new TextureLoader( "image.gif", this );
>         ImageComponent2D myImage = myLoader.getImage( );
>                 Texture2D myTex = new Texture2D(Texture.BASE_LEVEL,
> Texture.RGBA,
>                                         image.getWidth(),
> image.getHeight());
>       myTex.setImage( 0, myImage );
>       myTex.setEnable( true );
>       appear.setTexture(myTex);
>
>       shape.setAppearance(appear2);
>       TG.addChild(obj);
> ----------------------------------------------------------------------------
> -----
> //here the geometry incorporates the texturecoordinates and hence the image
> is mapped fully
>
> Point3f[] myCoords = {new Point3f(  )....................         };
> Point2f[] myTexCoords = {new Point2f( )...............  };
> QuadArray myQuads = new QuadArray(myCoords.length,GeometryArray.COORDINATES
>         |GeometryArray.TEXTURE_COORDINATE_2 );
> myQuads.setCoordinates( 0, myCoords );
> myQuads.setTextureCoordinates( 0, myTexCoords );
> Shape3D myShape = new Shape3D( myQuads, appear );
> TG.addChild(myShape);
> ----------------------------------------------------------------------------
> ----------------------
> Is there someway to setTextureCoordinates to a geometry loaded from a .obj
> file or to covert the geometryarray into a Point3f[]  ???
>
> i tried setTextureCoordinates(0, Coords) on the geometry array but gives an
> error.
> Also i tried to look for objectfile javadoc as mentioned by u, but did not
> find it specifically..
> the ObjLoad file included along with the SDK demo progs, but there one
> doesnt assign any material props to the object so everythng comes with a
> default material somehow.
>
> thankx in advance
> R. Jindal
>
>
>
>
>
>
> ----- Original Message -----
> From: "Paul Pantera" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, January 02, 2001 9:59 PM
> Subject: Re: [JAVA3D] texturing in .obj file
>
>
> > Texturing is supported by the .obj file format and the loader.  You
> > don't need to add code to your program to support textures.  A texture
> > is simply a material property applied to parts of the model.  The .obj
> > file format is described in the ObjectFile javadoc (separate
> > download).  You can figure it out by reading that, or you can look at
> > the demo in the SDK:
> >
> > cd demo/java3d/ObjLoad
> > java ObjLoad ../geometry/minimart.obj
> >
> > Look at minimart.obj to see how it's done.
> >
> > The code of ObjLoad and ObjectFile is included in utils-src.jar
> > (included in the sdk).
> >
> > -Paul
> >
> > > MIME-Version: 1.0
> > > Date: Thu, 28 Dec 2000 19:25:06 +0900
> > > From: À̽ÂÁØ <[EMAIL PROTECTED]>
> > > Subject: [JAVA3D] texturing in .obj file
> > > To: [EMAIL PROTECTED]
> > >
> > > Please help me.
> > > how texturing in obj files.
> > >
> > >   Scene s = null;
> > >   s = f.load("c:/3ds_object/body.obj");
> > >   Transformgroup objScale = new TransformGroup();
> > >   objScale.addChild(s.getSceneGroup());
> > >
> > >   Appearance app = new Appearance();
> > >   Texture tex = new TextureLoader("front.jpg", this).getTexture();
> > >   app.setTexture(tex);
> > >   TextureAttributes texAttr = new TextureAttributes();
> > >   texAttr.setTextureMode(TextureAttributes.MODULATE);
> > >   app.setTextureAttributes(texAttr);
> > >
> > >    BranchGroup b1 = s.getSceneGroup();
> > >    Shape3D shape1 = (Shape3D) b1.getChild(0);
> > >    GeometryArray g1 = (GeometryArray) shape1.getGeometry();
> > >    shape1.setGeometry(g1);
> > >    shape1.setAppearance(app);
> > >
> > > I think must figure out about TEXTURE_COORDS
> > > help me.
> > >
> > >
> ===========================================================================
> > > 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".
>

===========================================================================
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