Dear all,

  I'm trying to create a simple 3 by 3 grid of vertices, and I'm going
to use
IndexedTriangleStripArray.

 Here's how I set the vertices:


 v(0) ------ v(1) ------ v(2)
  |                 |                |
  |                 |                |
  |                 |                |
 v(3) ------ v(4) ------ v(5)
  |                 |                |
  |                 |                |
  |                 |                |
 v(6) ------ v(7) ------ v(8)


  n = k = 0;
  double[] coordinates = new double[3*3*3];
  for ( z = 0; z < 3; z++ ){
    for ( x = 0; x < 3; x++ ){
         coordinates[n++] = x;
         coordinates[n++] = e.getElevation(x,z); // y is the height
         coordinates[n++] = z;
    }
  }

 Now, assume that I want two triangle strips, each going along the
X-axis:

  // Create a list of triangle strip indexes.  Each strip goes
  // down one row (X direction) of the elevation grid.
  int[] indexes = new int[3*(3-1)*2];
  int[] stripCounts = new int[3-1];
  n = 0;
  k = 0;
  for ( int i = 0; i < 3-1; i++ ) {
       stripCounts[i] = 3*2;
       for ( int j = 0; j < 3; j++ ) {
              indexes[n++] = k+3;
              indexes[n++] = k;
              k++;
      }
  }


 What I'm confused about is how to set the normals (i.e.,
IndexedTriangleStripArray.setNormals).

  I know how to calculate a normal given two vectors (i.e., cross
product), and I know that
  I need a "normals" array that is the same size as the coordinates
array above, i.e.,

 float[] normals = new float[3*3*3].

 I guess my first question is: where are the triangle in these two
strips?  Am I correct in
 assuming that the first triangle is: v(0) -> v(3) -> v(1)?  The second
is: v(3) -> v(4) -> v(1),
 and so on?

 If so, how would you calculate the normal vector at v(1)?  Is it the
average of two normal
 vectors calculated from two triangles that share v(1)?

 Thoughts, advice, lifejackets, etc. would be greatly appreciated.
Thanks.

  - Cheers,
       Christopher Currie


--
 Christopher Currie       | EMAIL: [EMAIL PROTECTED]
 http://kahuna.psych.uiuc.edu/~ccurrie/homePage.html
 |
         Laboratory for Computational Astrophysics (LCA)
  at the NCSA and Beckman Institute at the University of Illinois
    INTERNET INTERFACE TO NUMERICALY SIMULATED GALAXY CLUSTERS:
                 http://sca.ncsa.uiuc.edu/
                           and
   Imaging Systems Laboratory INTERACTIVE 3-D FOREST ENVIRONMENT:
         http://imlab9.landarch.uiuc.edu/smartforest/
----


=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to