>

Hi,

I'm also trying to set the appearance of a scene created from a .obj file. I
tried to follow Dan Petersen's  instructions, but I couldn't work out how to
apply the appearance object to a scene read in from the file.

The problem is that when I read in the objects, they come as a hashtable
containing   String and  SceneGraphObject.. There aren't any functions on
SceneGraphObject to set the appearance.

My code looks like this:

Scene s = null;
 try {
   s = f.load(filename);
 }
 catch (Exception e) {
   System.err.println(e);
   System.exit(1);
 }
 Appearance appearance = createAppearance();
 Hashtable hash =  s.getNamedObjects();
        for (Enumeration e = hash.keys() ; e.hasMoreElements() ;) {
              String st = (String)e.nextElement();
              System.out.println(st);
              SceneGraphObject sgo = (SceneGraphObject)  hash.get(s);
      }

This displays the name of each part of the image, e.g. for a flower it prints:

tem_red
leaf_yellow
center_green
wrinkle_blue
petals_cyan

Can anyone tell me how I can set the appearance and display each part of the
image? Do I need to cast the SceneGraph object to some other class, or do I
need to create a Shape3D object from the SceneGraphObject and the appearance?

From,

Greg.


>
> >
> > Hi there,
> > i've got wavefront .obj file loaded into a scene. there are some shapes
> > where the front and the back must be visible. to solve this problem i want
> > to disable backface culling. how can i do this?
> > so long and ...
> > clemenTs
> >
>
> You need to create a PolygonAttributes object, turn off culling and add it
> to your Appearance object.  Something like:
>
>         PolygonAttributes pgonAttrs = new PolygonAttributes();
>         pa.setCullFace(pgonAttrs.CULL_NONE);
>         appearance.setPolygonAttributes(pgonAttrs);
>
> Dan Petersen
> Java 3D Team
> Sun Microsystems
>

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