Hi,
It is not enough to allocate
Point3d[] vertices = new Point3d[TOTAL_NUM_OF_VALUES];
and then invoke,
tsa.setCoordinates(0, vertices);
Use,
Point3d[] vertices = new Point3d[TOTAL_NUM_OF_VALUES];
for (int i=0; i < vertices.length; i++) {
vertice[i] = new Point3d();
}
tsa.setCoordinates(0, vertices);
instead.
- Kelvin
-------------
Java 3D Team
Sun Microsystems Inc.
>X-Unix-From: [EMAIL PROTECTED] Mon Sep 18 10:01:29 2000
>MIME-Version: 1.0
>Content-Transfer-Encoding: 8bit
>X-Priority: 3 (Normal)
>X-MSMail-Priority: Normal
>Importance: Normal
>X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
>Date: Mon, 18 Sep 2000 18:54:58 +0200
>From: "D. Green" <[EMAIL PROTECTED]>
>Subject: [JAVA3D] java.lang.NullPointerException
>To: [EMAIL PROTECTED]
>
>Hi,
>
>can anybody tell my what�s wrong with this code:
>
>if the matrix is 2 x 2 everything is alright but when it�s bigger I get the
>exception:
>
>java.lang.NullPointerException:
>at
>javax.media.j3d.GeometryArrayRetained.setCoordinates(GeometryArrayRetained.j
>ava:1879) at
>javax.media.j3d.GeometryArray.setCoordinates(GeometryArray.java:934) at
>j3dtest.Plot.<init>(Plot.java, Compiled Code) at
>j3dtest.Matrix3dplot.createSceneGraph(Matrix3dplot.java:16) at
>j3dtest.Matrix3dplot.<init>(Matrix3dplot.java:27) at
>j3dtest.Matrix3dplot.main(Matrix3dplot.java:36)
>
>what�s false?
>
>
>double[][] matrix =
> {
> {0.1,0.2,0.5},
> {0.3,-0.4,0.6}
> };
>
>Point3d[] vertices = new Point3d[TOTAL_NUM_OF_VALUES];
>
> for (int ROW = 0; ROW < SIZE_Y ; ROW++)
> {
> for (int COL = 0; COL < SIZE_X; COL++)
>
>
> int N = 0;
> double stepsize = 0.5;
> vertices[N] = new Point3d(0, matrix[ROW][COL], 0.0);
> N++
> vertices[N] = new Point3d(0, matrix[ROW++][COL], 0.5);
> N++;
> vertices[N] = new Point3d(0, matrix[ROW][COL++], 0.0);
> N++;
> vertices[N] = new Point3d(0.5,matrix[ROW++][COL++], 0.5);
> N++;
> int[] StripCount = {vertices.length};
> // TriangleStripArray
> TriangleStripArray tsa = new TriangleStripArray(vertices.length,
>
>GeometryArray.COORDINATES,
> StripCount);
> tsa.setCoordinates(0, vertices);
> // Shape3D with TriangleStripInformationen
> Shape3D t = new Shape3D();
> t.setAppearance(createTriangleAppearance());
> t.setGeometry(tsa);
> mouse.addChild(t);
> }
> }
>Thanks!
>
>===========================================================================
>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".