Venkata Mahadevan wrote:
> Let's say I have a cube with a hole in the top
> composed of 5 faces/square poygons. I want to assign a
> different Material to each face of the cube. Does each
> face have to be a separate Shape3d node for this to
> work?
Java 3D v1.2 lets you assign multiple geometries to
a single Shape3D, but only one Appearance (and hence
Material) that applies to all.
If you really don't want to use multiple Shape3D
nodes you might try the following:
- Use a single Shape3D, but make each face an
independent quad.
- For each quad, set all four of its per-vertex
colors to your desired ambient and diffuse
reflections. These will be used in place
of your Material's ambinet and diffuse parameters.
Don't forget to set normals too.
- Assign an Appearance with a Material object.
The emisive, specular, and shininess values
will be applied to all faces.
Using this method, you can also create a RenderingAttributes
object, call its setIgnoreVertexColors with true, and assign
it to the Appearance object. Now the cube will be lit using
ONLY the Material's values, not the per-vertex colors that
you've set.
> Also, I want to assign a different Material to the
> front and back of each face. Is this possible and how
> would I go about doing it?
Not possible, and workarounds are tedious. An outline
of a possible (not tested by me) workaround follows.
I develop a similar example in my book, but instead
of opaque, co-registered geometry, one is rendered as
lines (so you can "see through" to the other geometry).
This gets really nasty because you need to use polygon
offsets to make sure the lines "lie on top of" the
inderlying geometry.
- Create one Shape3D as above. Then, create an idential
Shape3D except for different per-vertex colors (if you
want a different material on each inside face too). The
first Shape3D represents the outside faces, the second
represents the inside faces.
- Set the outer faces' PolygonAttributes to CULL_BACK.
Set the inner faces' to CULL_FRONT and enable back-face
lighting (as above).
Have fun, and let me know if it works (or if you have any
questions).
--
Allen McPherson
[EMAIL PROTECTED]
===========================================================================
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".