protected static void addTriangleNormal(int a,int b,int c,FloatBuffer vertices,FloatBuffer normals){
  vertices.position(a);
  float ax=vertices.get();
  float ay=vertices.get();
  float az=vertices.get();
  vertices.position(b);
  float bx=vertices.get();
  float by=vertices.get();
  float bz=vertices.get();
  vertices.position(c);
  float cx=vertices.get();
  float cy=vertices.get();
  float cz=vertices.get();
  float x=((by - ay) * (cz - az)) - ((bz - az) * (cy - ay));
  float y=((bz - az) * (cx - ax)) - ((bx - ax) * (cz - az));
  float z=((bx - ax) * (cy - ay)) - ((by - ay) * (cx - ax));
  float length=(x * x) + (y * y) + (z * z);
  if (length > 0d) {
    length=(float)Math.sqrt(length);
    x/=length;
    y/=length;
    z/=length;
  }
  normals.position(a);
  float nx=normals.get();
  float ny=normals.get();
  float nz=normals.get();
  normals.position(a);
  normals.put(nx + x);
  normals.put(ny + y);
  normals.put(nz + z);
  normals.position(b);
  nx=normals.get();
  ny=normals.get();
  nz=normals.get();
  normals.position(b);
  normals.put(nx + x);
  normals.put(ny + y);
  normals.put(nz + z);
  normals.position(c);
  nx=normals.get();
  ny=normals.get();
  nz=normals.get();
  normals.position(c);
  normals.put(nx + x);
  normals.put(ny + y);
  normals.put(nz + z);
}

protected static void addTriangleNormal ( int a , int b , int c , FloatBuffer vertices , FloatBuffer normals ) { vertices . position ( a ) ; float ax = vertices . get ( ) ; float ay = vertices . get ( ) ; float az = vertices . get ( ) ; vertices . position ( b ) ; float bx = vertices . get ( ) ; float by = vertices . get ( ) ; float bz = vertices . get ( ) ; vertices . position ( c ) ; float cx = vertices . get ( ) ; float cy = vertices . get ( ) ; float cz = vertices . get ( ) ; float x = ( ( by - ay ) * ( cz - az ) ) - ( ( bz - az ) * ( cy - ay ) ) ; float y = ( ( bz - az ) * ( cx - ax ) ) - ( ( bx - ax ) * ( cz - az ) ) ; float z = ( ( bx - ax ) * ( cy - ay ) ) - ( ( by - ay ) * ( cx - ax ) ) ; float length = ( x * x ) + ( y * y ) + ( z * z ) ; if ( length > 0d ) { length = ( float ) Math . sqrt ( length ) ; x /= length ; y /= length ; z /= length ; } normals . position ( a ) ; float nx = normals . get ( ) ; float ny = normals . get ( ) ; float nz = normals . get ( ) ; normals . position ( a ) ; normals . put ( nx + x ) ; normals . put ( ny + y ) ; normals . put ( nz + z ) ; normals . position ( b ) ; nx = normals . get ( ) ; ny = normals . get ( ) ; nz = normals . get ( ) ; normals . position ( b ) ; normals . put ( nx + x ) ; normals . put ( ny + y ) ; normals . put ( nz + z ) ; normals . position ( c ) ; nx = normals . get ( ) ; ny = normals . get ( ) ; nz = normals . get ( ) ; normals . position ( c ) ; normals . put ( nx + x ) ; normals . put ( ny + y ) ; normals . put ( nz + z ) ; }
computes a triangle normal given the starting position of three tuples in the specified vertex buffer , and stores adds the result to three tuples in the specified normal buffer with the same positions .
