Hi Alex,

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

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

You need to allocate coordinates for each Point3f before
passing it into the function getCoordinates().

i.e.
 Point3f[] coordinates = new Point3f[geometry.getVertexCount()];
 for (int i=0; i < coordinates.length; i++) {
    coordintes[i] = new Point3f();
 }
 geometry.getCoordinates(0, coordinates);

- Kelvin
------------
Java 3D Team
Sun Microsystems Inc.





>Delivered-To: [EMAIL PROTECTED]
>MIME-Version: 1.0
>Content-Transfer-Encoding: 7bit
>X-Priority: 3 (Normal)
>X-MSMail-Priority: Normal
>X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700
>Importance: Normal
>Date: Mon, 28 Jan 2002 18:29:06 -0000
>From: Alex Bowden <[EMAIL PROTECTED]>
>Subject: [JAVA3D] Problems trying to use NormalGenerator while reading data
from VRMLLoader
>To: [EMAIL PROTECTED]
>
>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".

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