> Date: Mon, 9 Apr 2001 19:52:20 -0000
> From: R Vegan <[EMAIL PROTECTED]>
> Subject: [JAVA3D] NormalGenerator + Questions regarding Indices; Help !
> To: [EMAIL PROTECTED]
>
> Hi All
>
> I have a bunch of triangles (generated NOT by the Triangulator)
> represented by a coordinate array and an indexing array.
> I am interested in generating the normals
> for these triangles. So I put them in a GeometryInfo and pass that
> to a NormalGenerator. I then retrieve an IndexedTriangleArray
> from the GeometryInfo object. The questions I have with the
> above are as below:
>
> Q1:
> Does the GeometryInfo/NormalGenerator operations reorder the
> vertex indices ? That is, if "r" and "I" are the coordinate
> and its index in the arrays that I pass onto the GeometryInfo,
> then would the same correspondence also exist in the
> IndexedTriangleArray that I extract from the GeometryInfo
> after normal generation ?
In this specific case, your indices should be unchanged. The
NormalGenerator utility works on indexed triangles, so since
you are sending in indexed triangles, it doesn't need to
change them.
>
> Q2.
> The NormalGenerator may possibly increase the LENGTH of the
> index array depending upon the crease angle.
No, it may possible increase the length of the *coordinate*
array because the coordinate array, normal array, texture
coordinate array, and color array must all be the same length.
So if there are more normals than coordinates, it may have
to increase the length of the coordinate array.
The index array should remain the same length - numTriangles * 3.
> Now, would the
> NormalGenerator also possibly increase the range of indices ?
> That is, if my original indices were in the range {0..9},
> would the NormalGenerator produce indices in the range
> {0...15}, for example ?
In your case, the coordinate indices should remain the same. But, as I
said above, the normal indices could have a larger range.
This is better if we take an example. Let's consider a cube. It has
eight coordinate positions. The cube is made of six squares, so twelve
triangles, so 36 coordinate indices. The normal generator will hand
back your geometry with the same 36 coordinate indices and 8 coordinate
positions, and it will add 36 normal indices and 24 normals (each
corner of the box has one coordinate, but three different normals for
the three faces that share that coordinate). Since the coordinate
array and normal array must have the same length, your coordinate
array will now have a length of 24, even though still only 8
positions are being used.
>
> Q3.
> One of my objectives is to be able to update the vertex colors
> at run time, the colors being computed from the values
> of the different variables stored at the vertices.
> If the NormalGenerator does indeed reorder the
> vertex indices, or increase the index range, then is there
> a way to deduce a correspondence between the original and
> generated indices ? Of course, one could always make the
> floating point comparisons of the vertex coordinates, but is
> there a better way ?
So this question is moot now. Make sure you use geometry-by-
reference and set the applicable capability bit.
BTW the best way to do what you're asking is to use a Hashtable.
That's how GeometryInfo, for example, figures out which vertices
have the same position. If the two vertex values have the same
hashCode(), they are equal.
-Paul
===========================================================================
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".