hi all,

i have a problem, i just created a program to give create and render pot
like objects (basically surface of revolution). program works fine but the
object is not rendered as real world object. say if there is curvature
then i can see that curvature from one side only from other side that
curvature does not seen at all. all inside of pot is black. i am attaching
the jpg file which shows problems in rendering. Also i am giving source
code i used.

thnksin advance
sandeep munde

Source Code

/** SurfaceOfRevolution.java
 * Created on December 23, 2003, 8:55 PM
 */
/**
  * @author  sandeep
 */


public class SurfaceOfRevolution extends JFrame{

   Revolution pot;// object of class used to give vertices of facets of
the Pot

   double [] potVerts;
   double []xproftemp=new double[20];
   double []yproftemp=new double[20];
   double []xprof1=new double[20];
   double []yprof1=new double[20];
   double []xprof2=new double[20];
   double []yprof2=new double[20];

   sketcher surfaceofrevolution_sketcher;
   BSpline bspline_surfaceofrev;
   double basisfntemp;
   double[] xprof=new double[20];
   double[] yprof=new double[20];

   double xtemp;
   int AngleOfRev;// angel of revoution

   GeometryInfo potGeom;
   NormalGenerator potNorms;
   Shape3D potShape;

   private Color3f black = new Color3f(0.0f, 0.0f, 0.0f); // define black
color

   public SurfaceOfRevolution(sketcher skt) {
       surfaceofrevolution_sketcher=skt
      GraphicsConfiguration config =
SimpleUniverse.getPreferredConfiguration();
      Canvas3D c = new Canvas3D(config); // add canvas3d  on which j3d draws

      // Create a simple scene and attach it to the virtual universe
      BranchGroup scene = createSceneGraph(); // create scene graph
      SimpleUniverse u = new SimpleUniverse(c); // create simple universe

      // This will move the ViewingPlatform back so that objects in the
scene can be viewed.
      u.getViewingPlatform().setNominalViewingTransform();

      u.addBranchGraph(scene);  // add BranchGroup scene to universe
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add("Center", c);
   }

   private BranchGroup createSceneGraph() {

      BranchGroup objRoot = new BranchGroup();
      BoundingSphere bounds = new BoundingSphere(new
Point3d(0.0,0.0,0.0),10000.0);
      DirectionalLight light = new DirectionalLight(new Color3f(1.0f,
1.0f, 1.0f),  new Vector3f( 0f,0f,-1f));
      DirectionalLight light1 = new DirectionalLight(new Color3f(1.0f,
1.0f, 1.0f), new Vector3f( 0f,-1f,0f));
      DirectionalLight light2 = new DirectionalLight(new Color3f(1.0f,
1.0f, 1.0f), new Vector3f( -1f,0f,0f));

      light.setInfluencingBounds(bounds);  // area of light spread
      objRoot.addChild(light);             // add light to BG
      objRoot.addChild(light1);             // add light to BG
      objRoot.addChild(light2);             // add light to BG

      TransformGroup modelTrans = new TransformGroup();
      Transform3D trans = new Transform3D();
      trans.setTranslation(new Vector3d(0d, 0d, -10.0d));  // initially
move it away from camera
      trans.setScale(new Vector3d(0.01d, 0.01d, 0.01d)); // scales whole
model
      modelTrans.setTransform(trans);

      modelTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
      modelTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

      MouseRotate modelRot = new MouseRotate();
      modelRot.setTransformGroup(modelTrans);
      modelTrans.addChild(modelRot);
      modelRot.setSchedulingBounds(bounds);

      MouseZoom modelZoom = new MouseZoom();
      modelZoom.setTransformGroup(modelTrans);
      modelTrans.addChild(modelZoom);
      modelZoom.setSchedulingBounds(bounds);

      MouseTranslate modelTranslate = new MouseTranslate();
      modelTranslate.setTransformGroup(modelTrans);
      modelTrans.addChild(modelTranslate);
      modelTranslate.setSchedulingBounds(bounds);

      modelTrans.addChild(createpot());
      objRoot.addChild(modelTrans);
        return objRoot;
   }

   private TransformGroup createpot() {

      TransformGroup potTrans = new TransformGroup();
      Transform3D trans = new Transform3D();

      // construct profile
      AngleOfRev=surfaceofrevolution_sketcher.GetAngleofRevolution();
      xproftemp=surfaceofrevolution_sketcher.SymmetricProfileX();
      yproftemp=surfaceofrevolution_sketcher.SymmetricProfileY();
        for(int i=0;i<xproftemp.length;i++){
               xprof[i]=xproftemp[i]/75.0;
               yprof[i]=yproftemp[i]/75.0;
           }
          pot = new Revolution(xproftemp, yproftemp, 10.0,AngleOfRev);
//call the class set the object pot
          potVerts = pot.getVertices();                   // get the pot verteices

      }

      potGeom = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
      potGeom.setCoordinates(potVerts);

      potNorms = new NormalGenerator();   //normal are most important
      potNorms.generateNormals(potGeom);

      Appearance potApp = new Appearance();
      potApp.setMaterial(new Material(black, black, new
Color3f(1.0f,1.0f,0.0f), black, 0f));

      potShape = new Shape3D(potGeom.getGeometryArray(), potApp);
      potShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);

      potTrans.addChild(potShape);

      return potTrans;
   }

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

<<attachment: Rendering.jpg>>

Reply via email to