Yeah it worked! Thank you very much!
----- Original Message -----
From: Silvano Maneck Malfatti <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 17, 2003 10:09 PM
Subject: Re: [JAVA3D] Calling a class error


> Try run it:
>
>
>
>
> 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;
> import com.sun.j3d.utils.universe.*;
> import javax.media.j3d.BranchGroup;
> import com.sun.j3d.utils.applet.MainFrame;
> import javax.media.j3d.*;
> import java.awt.*;
> import java.awt.BorderLayout;
> import com.sun.j3d.utils.applet.MainFrame;
>
>
>  class Polyhedron
>  {
>           TransformGroup tg;
>
>   Polyhedron()
>  {
>           Point3f[] pts=new Point3f[20];
>
>  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={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={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();
>
>   Shape3D shape = new Shape3D();
>
>   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=new TransformGroup();
>   tg.addChild(shape);
> }
>
>   TransformGroup getPolyhedron()
>   {
>           return tg;
>   }
>
> }//end class
>
> public class CallClass
> {
>
> CallClass ()
>  {
>
>
>         SimpleUniverse universe = new SimpleUniverse();
>
>         GraphicsConfiguration config =
universe.getPreferredConfiguration();
>
>
>         Canvas3D c = new Canvas3D(config);
>
>         Polyhedron polyhedron=new Polyhedron();
>
>         BranchGroup group = new BranchGroup();
>
>     group.addChild(polyhedron.getPolyhedron());
>
>         universe.getViewingPlatform().setNominalViewingTransform();
>
>         universe.addBranchGraph(group);
>
>  }
>
>  public static void main(String[] args)
>  {
>
>         new CallClass();
>  }
> }//end class CallClass
>
>
> /*********************************************
> SILVANO MALFATTI
> COMPUTER SCIENCE - URI University
> HOME - http://www.urisan.tche.br/~smalfatti
> ********************************************/
>
>
>
>
> -------------------------------------------------
> URI - Campus de Santo Angelo-RS
> http://www.urisan.tche.br
>
>
===========================================================================
> 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".
>

===========================================================================
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".

Reply via email to