// Why do I get a negative radius when I enquire about the bounds of the shape3D 
object in this
// simple test program?  Thanks for all the help.  Geometry consists of  triangular 
facets of a cube.
//                                                           Ram P Kochhar

//

> import java.applet.Applet;
> import java.awt.BorderLayout;
> import java.awt.Frame;
> import java.awt.event.*;
> import com.sun.j3d.utils.applet.MainFrame;
> import com.sun.j3d.utils.universe.*;
> import com.sun.j3d.utils.geometry.GeometryInfo;
> import com.sun.j3d.utils.geometry.Triangulator;
> import javax.media.j3d.*;
> import javax.vecmath.*;
> import java.awt.BorderLayout;
>
> public class test4 extends Applet{
>   Geometry    voGeometry;
>
>   public test4() {
>     setLayout(new BorderLayout());
>     Canvas3D   canv3D = new Canvas3D(null);
>     add("Center", canv3D);
>
>     voGeometry = createGeometry();
>     BranchGroup scene = CreateSceneGraph(voGeometry);
>
>     scene.compile();
>
>     SimpleUniverse simpU=new SimpleUniverse(canv3D);
>
>     simpU.getViewingPlatform().setNominalViewingTransform();
>
>     simpU.addBranchGraph(scene);
>   }
>
>   public BranchGroup CreateSceneGraph(Geometry geom) {
>     BranchGroup objRoot = new BranchGroup();
>
>
>     Shape3D shape = new Shape3D();
>     shape.setCapability(shape.ALLOW_BOUNDS_READ);
>     shape.setGeometry(geom);
>
//********************************************************************************************
>     BoundingSphere sceneBounds = (BoundingSphere) shape.getBounds();
>
>     System.out.println(" " + sceneBounds);
>     Point3d center = new  Point3d();
>     sceneBounds.getCenter(center);
>     double radius = sceneBounds.getRadius();
>     Vector3d temp = new Vector3d(center);
//*****************************************************************************************

> //To draw polygon outline
>
>
>     Appearance appearance = new Appearance();
>
>     PolygonAttributes polyAttrib = new PolygonAttributes();
>     polyAttrib.setPolygonMode(PolygonAttributes.POLYGON_LINE);
>     polyAttrib.setCullFace(PolygonAttributes.CULL_NONE);
>     appearance.setPolygonAttributes(polyAttrib);
>
>     shape.setAppearance(appearance);
>
>     Transform3D rotate = new Transform3D();
>     Transform3D tempRotate = new Transform3D();
>
>     rotate.rotX(Math.PI/4.0d);
>     tempRotate.rotY(Math.PI/5.0d);
>
>     rotate.mul(tempRotate);
>     rotate.setScale(0.4);
>
>     TransformGroup objRotate = new TransformGroup(rotate);
>
>     objRoot.addChild(objRotate);
>
>     objRotate.addChild(shape);
>
>
>     return(objRoot);
>   }
>
>   public Geometry createGeometry() {
>
>     Point3f[]  coord = new Point3f[10];
>     int[] stripCount ={3,3,4};
>
>     coord[0] = new Point3f(0.0f,0.0f,0.0f);
>     coord[1] = new Point3f(1.0f,0.0f,0.0f);
>     coord[2] = new Point3f(1.0f,1.0f,0.0f);
>
>     coord[3] = new Point3f(0.0f,0.0f,0.0f);
>     coord[4] = new Point3f(1.0f,1.0f,0.0f);
>     coord[5] = new Point3f(0.0f,0.0f,1.0f);
>
>     coord[6] = new Point3f(0.0f,0.0f,0.0f);
>     coord[7] = new Point3f(0.0f,0.0f,1.0f);
>     coord[8] = new Point3f(1.0f,0.0f,1.0f);
>     coord[9] = new Point3f(1.0f,0.0f,0.0f);
>
>
>     TriangleFanArray tfa = new TriangleFanArray(10,
>                TriangleFanArray.COORDINATES,stripCount);
>     tfa.setCoordinates(0,coord);
>     return(tfa);
>   }
>
>   public static void main(String[] args) {
>     Frame frame = new MainFrame(new test4(),500,500);
>   }
> }
>

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