Hi,
   Consider a normal as an arrow pointing directly away from a surface.  For
your desktop the normal would be straight up.  For an infitessimally thin
object, like most computer shapes, it is important to decide which side of the
object is "out" because we want all our normals to point "out" when calculating
lighting.  Like looking in a mirror, as the angle between your line of sight
and the normal of the mirror increases you get a different image.  When you get
to the point where you are looking down the edge of the mirror, perpendicular
to the normal, you see nothing.
   For triangles, by definition, all the corners lie in the same plane (but it
might not be simply horizontal or vertical) so the normal at every vertex is
the same as the surface of the plane.  You can figure the normal once and apply
it everywhere.  For quadralaterals (and more complex polygons) the surface may
be twisted so the normals at each vertex may vary.  In this case, you must
calculate or assign the normals to each vertex.  There are several methods to
determine the value, the most common is to compute the cross product of a pair
of vectors from the points connected adjacent to the vertex in question.  To
ensure the normals point outward you must consistently use the same
method/sequence at each vertex.  Based on your question I suspect you need to
look at an introductory graphics or math book on how to do cross products as
well although the Java3D API has methods for calculating them given the input
vectors.
   For you code, you don't have to explicitly specify the normals.  Java3D will
calculate them for you if they are not provided.  To do this, the vertex data
must be presented as a list of connected points which run around the rim of the
polygon in a counterclockwise direction when viewed from the "outside" of the
polygon.  In your vertex data it appears that some are clockwise and others
counterclockwise.  If the shape is displayed, you will see holes were triangles
are missing.  Acutally, they are present but culled out of the scene because
j3d thinks you are looking at the "back" of the object and not the front.
   Hope it gives you a little insight.  I would recommend getting a good
introductory graphics book though because if you understand it better you can
generate some pretty cool effects.
                -Gary

Thomas M Clarke wrote:

> What exactly are Normals? (I know there used to calculate which face gets
> lighting)
> And How do I define normals for example for the following TriangleArray:
>
>  private static final float[] verts =
>  {
>   -1.0f, 0.0f, 0.0f,
>   1.0f, 0.0f, 0.0f,
>   0.0f, 1.0f, 0.5f,
>
>   -1.0f, 0.0f, 0.0f,
>   0.0f, 0.0f, 1.0f,
>   0.0f, 1.0f, 0.5f,
>
>   1.0f, 0.0f, 0.0f,
>   0.0f, 0.0f, 1.0f,
>   0.0f, 1.0f, 0.5f,
>
>   -1.0f, 0.0f, 0.0f,
>   1.0f, 0.0f, 0.0f,
>   0.0f, 0.0f, 1.0f,
>  };
>
> (this is a shape that has four faces and makes up something like a pyramid)
> I just copy and pasted the above verts into the normal array to see what
> happened and it didnt exactly work:
>
>  private static final float[] normals =
>  {
>   -1.0f, 0.0f, 0.0f,
>   1.0f, 0.0f, 0.0f,
>   0.0f, 1.0f, 0.5f,
>
>   -1.0f, 0.0f, 0.0f,
>   0.0f, 0.0f, 1.0f,
>   0.0f, 1.0f, 0.5f,
>
>   1.0f, 0.0f, 0.0f,
>   0.0f, 0.0f, 1.0f,
>   0.0f, 1.0f, 0.5f,
>
>   -1.0f, 0.0f, 0.0f,
>   1.0f, 0.0f, 0.0f,
>   0.0f, 0.0f, 1.0f,
>  };
>
> I then created the shape with the following code:
>
>   Tarray = new TriangleArray(12, TriangleArray.COLOR_3 |
> TriangleArray.COORDINATES | TriangleArray.NORMALS);
>   Tarray.setCoordinates(0, verts);
>   Tarray.setNormals(0, normals);
>   app = new Appearance();
>   mat = new Material(aColor, eColor, dColor, sColor, shinyness);
>   app.setMaterial(mat);
>   shp = new Shape3D(Tarray, app);
>
> Thank you
>
> Thomas M Clarke
>
> ===========================================================================
> 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