 import com.sun.j3d.utils.geometry.*;
 import javax.media.j3d.*;
 import java.awt.*;
 import javax.vecmath.*;
 import javax.media.j3d.GeometryArray;
 import java.applet.Applet;
 import com.sun.j3d.utils.geometry.GeometryInfo;
 
 
 public class Polyhedron extends Applet
 {
        Shape3D shape = new Shape3D();
        TransformGroup tg=new TransformGroup();
 	
        public Polyhedron()

 {}
 //float points[][], int vertices[]
TransformGroup getPolyedron(double Vertices[][][], int Facets[][], int VertexNo[][],int VerticesNo,int SumOfFacets,int SumOfFacetsNo,int PolyedronNo)
  { 
  
  Point3d[] pts=new Point3d[VerticesNo];
  
  

for(int i=0;i<VerticesNo;i++) {
	
        pts[i]=new Point3d(Vertices[PolyedronNo][i][0],Vertices[PolyedronNo][i][1],Vertices[PolyedronNo][i][2]);
                        }
	
	
	
        /*
 pts[0]= new Point3f(  0.0f,    0.0f,  1.1547f);
 pts[1]= new Point3f(  1.0f,  0.0f,  0.57735f);
 pts[2]= new Point3f( 0.333333f,  0.942809f,         0.57735f);
 pts[3]= new Point3f( -1.0f, 0.0f,  0.57735f);
 pts[4]= new Point3f(  -0.333333f,   -0.942809f,  0.57735f);
 pts[5]= new Point3f(  1.0f,   0.0f,  -0.57735f);
 pts[6]= new Point3f(  0.666667f,  -0.942809f, 0.0f);
 pts[7]= new Point3f( -0.666667f,  0.942809f,  0.0f);
 pts[8]= new Point3f( 0.333333f,   0.942809f, -0.57735f);
 pts[9]= new Point3f( -1.0f,    0.0f,          -0.57735f);
 pts[10]= new Point3f( -0.333333f,  -0.942809f, -0.57735f);
 pts[11]= new Point3f( 0.0f, 0.0f,    -1.1547f);*/
 

 // the faces
 
  int[] indices=new int[SumOfFacets];
  
  for(int i=0;i<SumOfFacets;i++) {
  	
        indices[i]=Facets[PolyedronNo][i];
  }
 
 
 /*
  int[] indices={2, 1, 0,
                 0, 3, 4,
                 1, 6, 5,
                 2,8,7,
                 3,7,9,
                 4,10,6,
                 5,11,8,
                 9,11,10,
                 0,2,7,3,
                 0,4,6,1,
                 1,5,8,2,
                 3,9,10,4,
                 5,6,10,11,
                 7,8,11,9
                 
                 };*/
                 
                 
                 
                 

 // the number of vertices of each face
 int[] stripCounts=new int[SumOfFacetsNo];
 
 for(int i=0;i<SumOfFacetsNo;i++) {
  	
        stripCounts[i]=VertexNo[PolyedronNo][i];
  	
  }
 
 
 
 
 /*
 int[] stripCounts={3,3,3,3,3,3,3,3,4,4,4,4,4,4};*/

 
  // I like Geometry Info. It's easier to create shapes ;-)
  GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
 // initialize the geometry info here

  gi.setCoordinateIndices(indices);
  gi.setCoordinates(pts);
  gi.setStripCounts(stripCounts);
  gi.recomputeIndices();


  NormalGenerator ng = new NormalGenerator();
  ng.generateNormals(gi);
  gi.recomputeIndices();
  // stripify
  Stripifier st = new Stripifier();
  st.stripify(gi);
  gi.recomputeIndices();

  GeometryArray myPolyhedron = gi.getGeometryArray();

  

  shape.setGeometry(myPolyhedron);

  Appearance app = new Appearance();
  Material mat = new Material();
  PolygonAttributes polyAtt= new
PolygonAttributes(PolygonAttributes.POLYGON_FILL,PolygonAttributes.CULL_BACK
, 0.0f);

  app.setMaterial(mat);
  app.setPolygonAttributes(polyAtt);

  shape.setAppearance(app);

  
  tg.addChild(shape);	
  return tg;
  }


}//end class