Пример #1
0
 /** prints the 3 vertex Coordinates(x,y,z) to the array */
 void write(float v[]) {
   if (level == 0) {
     a.write(v);
     b.write(v);
     c.write(v);
   } else {
     child0.write(v);
     child1.write(v);
     child2.write(v);
   }
 }
Пример #2
0
 public Gasket(int depth) {
   vSize = 3;
   level = depth;
   vCount = 3;
   for (int i = 0; i < level; i++) {
     vCount *= 3;
   }
   initial = new Vertex[3];
   initial[0] = new Vertex(-0.8f, -0.6f, 0.0f);
   initial[1] = new Vertex(0.8f, -0.6f, 0.0f);
   initial[2] = new Vertex(0.0f, 0.6f, 0.0f);
   vertexCoordinates = new float[vCount * 3];
   Triangle triangle = new Triangle(initial[0], initial[1], initial[2], level);
   place = 0;
   triangle.write(vertexCoordinates);
   // allocate a buffer with space for vCount vertexCoordinates
   ByteBuffer byteBuf = ByteBuffer.allocateDirect(vertexCoordinates.length * 4);
   byteBuf.order(ByteOrder.nativeOrder());
   vertexBuffer = byteBuf.asFloatBuffer();
   vertexBuffer.put(vertexCoordinates);
 }