Hi Daniel:
geom.getCoordinates() is expecting Point3d objects to be in the coordinates
array ... so you could do something like:
Point3d[] coordinates = new Point3d[24];
for(int n = 0; n < 24; n++)
coordinates[n] = new Point3d();
geom.getCoordinates(0, coordinates);
Regards,
Geoff.
----- Original Message -----
From: "Daniel Balaguer Yagan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, April 28, 2001 2:48 PM
Subject: [JAVA3D] Simplest example I could think of
> hi there,
> I'm suspecting a bug in javax.media.j3d.GeometryArray. I can't get
> the coordinates of my geometry. To illustrate this, here's a very simple
> code:
>
>
> 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.ColorCube;
> import javax.media.j3d.*;
> import javax.vecmath.*;
>
>
> public class HelloJava3Da extends Applet {
> public HelloJava3Da() {
> setLayout(new BorderLayout());
> Canvas3D canvas3D = new
> Canvas3D(SimpleUniverse.getPreferredConfiguration());
> add("Center", canvas3D);
>
> BranchGroup scene = createSceneGraph();
> SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
> simpleU.getViewingPlatform().setNominalViewingTransform();
>
> simpleU.addBranchGraph(scene);
> }
>
> public BranchGroup createSceneGraph() {
>
> BranchGroup objRoot = new BranchGroup();
> objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
> ColorCube mycube = new ColorCube();
> mycube.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
>
> QuadArray geom = (QuadArray) mycube.getGeometry();
> geom.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
>
> //ColorCube has 24 points according to its source code.
> Point3d[] coordinates = new Point3d[24];
> geom.getCoordinates(0, coordinates);
> System.out.println("coordinateFirst =
"+coordinates[0].toString());
>
> objRoot.addChild(mycube);
> objRoot.compile();
> return objRoot;
> }
>
> public static void main(String[] args) {
> Frame frame = new MainFrame(new HelloJava3Da(), 256, 256);
> }
> }
>
> I want to get the coordinates of this very very simple ColorCube.
> but when I tried to run it, I got this NullPointerException.
>
> java.lang.NullPointerException
> at
>
javax.media.j3d.GeometryArrayRetained.getCoordinates(GeometryArrayRetained.j
> ava:4145)
> at
> javax.media.j3d.GeometryArray.getCoordinates(GeometryArray.java:2477)
> at HelloJava3Da.createSceneGraph(HelloJava3Da.java:70)
> at HelloJava3Da.<init>(HelloJava3Da.java:51)
> at HelloJava3Da.main(HelloJava3Da.java:79)
>
> Is this a bug? I tried it like 20 times, and it's the same thing
> (TRY IT). I suspected it at first in my original application. I'm running
on
> java1.3.1-rc1 and java3d 1.2.1
>
> daniel
>
>
===========================================================================
> 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".