The GeometryInfo (com.sun.j3d.utils.geometry.GeometryInfo) documentation states
it supports Polygon triangulation with holes using setContourCounts(int[]).
But it doesn't (or I did something wrong).
Here is a complete example which should show a rectangular area with an hole in
it. Instead, a plain solid rectangular area is shown:

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.event.*;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.geometry.GeometryInfo;

public class HoleTest extends Applet {

    private SimpleUniverse u = null;

    public BranchGroup createSceneGraph() {
     // Create the root of the branch graph
     BranchGroup objRoot = new BranchGroup();

        GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
        double[] coordData = new double[] {
          0.0, 0.0, 0.0,
          0.4, 0.0, 0.0,
          0.4, 0.4, 0.0,
          0.0, 0.4, 0.0,
          0.0, 0.0, 0.0,

          0.2, 0.2, 0.0,
          0.4, 0.2, 0.0,
          0.4, 0.4, 0.0,
          0.2, 0.4, 0.0,
          0.2, 0.2, 0.0,
        };
        gi.setCoordinates(coordData);

       int[] stripCount = new int[] {5, 5};
       gi.setStripCounts(stripCount);

       int[] contourCount = new int[] {1,1};
       gi.setContourCounts(contourCount);

       Geometry geometry3d = gi.getGeometryArray();

       Shape3D shape3d = new Shape3D(geometry3d);

       objRoot.addChild(shape3d);

      return objRoot;
    }

    public HoleTest() {
    }

    public void init() {
     setLayout(new BorderLayout());
        GraphicsConfiguration config =
           SimpleUniverse.getPreferredConfiguration();

     Canvas3D c = new Canvas3D(config);
     add("Center", c);

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

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

     u.addBranchGraph(scene);
    }

    public void destroy() {
     u.removeAllLocales();
    }

    public static void main(String[] args) {
     new MainFrame(new HoleTest(), 256, 256);
    }
}

If you have any idea why this is not working please let me know.
Thanks.
Jean-Marie.

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