At a glance, it does not look like you have
instantiated each coordinates value in your for loop;
you only instantiated the array itself.  Come to think
of it, you could not possibly be even entering the for
loop or you would get a null-pointer exception when
you try to set the x and y...bvol must be equal to
zero.  You really try try some of the java debugging
tools, they probably would made this clear very
quickly.

--- Andy Tay <[EMAIL PROTECTED]> wrote:
> This is a part of my source code for my project...
> It is giving me alot of problem and i still couldn't
> figure how to correct it.. Can any one help me.. It
> is quite urgent cause my deadline is coming soon...
>
> private Geometry sphereGeometry() {
>
>   int f;
>
>   int r = 50;
>   int xc = 100;
>   int yc = 100;
>   int zc = 100;
>   int v;
>   int bvol;
>   float rx, ry, rz, spanx, spany, spanz, randx,
> randy, randz;
>
>   bvol =
> ((xc+r)-(xc-r))*((yc+r)-(yc-r))*((zc+r)-(zc-r));
>
>   v = bvol*(60/100);
>
>   Point3f[] coordinates;
>
>   coordinates = new Point3f[bvol];
>
>   for(f = 0; f < v; f++){
>    randx = 0.0f + (float) (Math.random() * 1.0f);
>    randy = 0.0f + (float) (Math.random() * 1.0f);
>    randz = 0.0f + (float) (Math.random() * 1.0f);
>
>    spanx = (xc+r)-(xc-r);
>    spany = (yc+r)-(yc-r);
>    spanz = (zc+r)-(zc-r);
>
>    rx = (randx*spanx)+(xc-r);
>    ry = (randy*spany)+(yc-r);
>    rz = (randz*spanz)+(zc-r);
>
>    if
>
(((rx-xc)*(rx-xc))+((ry-yc)*(ry-yc))+((rz-zc)*(rz-zc))
> <= r) {
>     coordinates[f].x = rx;
>     coordinates[f].y = ry;
>     coordinates[f].z = rz;
>    }
>   }
>
>   PointArray point = new PointArray(bvol,
> PointArray.COORDINATES);
>   point.setCoordinates(0, coordinates);
>
>         return point;
>
>  } // end of method SphereGeometry in class Bone
>
> When i compile, it doesn't show any problem but when
> i run, i show me this errors.... I really hope that
> anyone out that can help me with this problem
> thanks....
>
> java.lang.NullPointerException
>             at
>
javax.media.j3d.GeometryArrayRetained.setCoordinates<CompiledCode>
>             at
>
javax.media.j3d.GeometryArray.setCoordinates<GeometryArray.java:333>
>             at
> FinalProject$Bone.sphereGeometry<Compiled Code>
>             at
> FinalProject$Bone.<init><FinalProject.java:27>
>             at
> FinalProject.createSceneGraph<FinalProject.java:114>
>             at
> FinalProject.<init><FinalProject.java:142>
>             at java.lang.Class.newInstance0<Native
> Method>
>             at
> java.lang.Class.newInstance<Class.java:239>
>             at
>
sun.applet.AppletPanel.createApplet<AppletPanel.java:532>
>             at
>
sun.applet.AppletPanel.runLoader<AppletPanel.java:468>
>             at sun.applet.AppletPanel.run<Compiled
> Code>
>             at java.lang.Thread.run<Thread.java:479>
>
> Andy
>


__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/

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