Hi

I am using the VRMLloader to load objects from various sources. Some of the
data is rather suspect. I would like to clean up the data on import
(regenerate normals) and stripify and any other conditioning that is easily
available.

I am having trouble getting my hands on the data at an appropriate stage in
the process.  Is this in some subtle way directly controllable from the
loader (at loader creation time) or is there some way I can hang the extra
processing into the load activity.

At the moment I am trying to post clean up the data with something like

public static void cleanup(Group group) {

      for (int i=0;i<group.numChildren();i++) {
        Node node=group.getChild(i);
        if        (node instanceof javax.media.j3d.Group) {
          cleanup((Group)node);
        } else if (node instanceof javax.media.j3d.Link) {

          ((Link)node).setCapability(Link.ALLOW_SHARED_GROUP_READ);
          cleanup((Group)((Link)node).getSharedGroup());
        } else if (node instanceof javax.media.j3d.Shape3D) {

Shape3D part = (Shape3D)node;

NormalGenerator ng = new NormalGenerator();

          Enumeration allGeometries = ((Shape3D)node).getAllGeometries();
          while (allGeometries.hasMoreElements()) {
            Object obj = allGeometries.nextElement();
if (obj instanceof javax.media.j3d.TriangleArray) {
              GeometryInfo geometryInfo = new
GeometryInfo(GeometryInfo.TRIANGLE_ARRAY);

              TriangleArray geometry = (TriangleArray)obj;

              Point3f[] coordinates = new
Point3f[geometry.getVertexCount()];

              geometry.getCoordinates(0, coordinates); // << null pointer
error here

              geometryInfo.setCoordinates(coordinates);

              ng.generateNormals(geometryInfo);

              geometry.setNormals(0, geometryInfo.getNormals());
            }
          }
        }
      }
    }

but I get  a java.lang.NullPointerException on trying to read the
coordinates.

at
javax.media.j3d.GeometryArrayRetained.getCoordinates(GeometryArrayRetained.j
ava:4127)
at javax.media.j3d.GeometryArray.getCoordinates(GeometryArray.java:2454)

The vertex count is real so why does the geometry fail on being read.

Any pointers gratefully received.

        Thanks

                [EMAIL PROTECTED]

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