Dumping core and I'm not sure why...

I was running through some of the getting started stuff for Xith3D just to make sure the Mac audience can run Xith because I’ve been pinged on it more than once recently. When I tried to put Xith into a JInternalFrame suddenly I get a funky exception and I can’t really figure out what Xith is trying to do here.

Basically I took the code from the Getting Started guide and slapped it into a cheesy rendering window class which simply encapsulates the functionality of the tutorial in a class:


public class RenderingWindow
{
    public static Logger logger = Logger.getLogger("RenderingWindow");

    private VirtualUniverse                     universe;
    private View                                view;
    private BranchGroup                         scene;
    private Canvas3D                            canvas;

    public RenderingWindow()
    {
        universe = new VirtualUniverse();

        view = new View();
        universe.addView( view );

        Locale locale = new Locale();
        universe.addLocale( locale );

        scene = new BranchGroup();
        locale.addBranchGraph( scene );

        Transform3D rotate = new Transform3D();
        rotate.rotXYZ( (float) Math.PI/4,
                       (float) Math.PI/5,
                       (float) Math.PI/2);

        TransformGroup objRotate = new TransformGroup( rotate );
        scene.addChild( objRotate );

        Geometry g = Cube.createCubeViaTriangles( 0, 0, 0, 1, true );
        Shape3D shape = new Shape3D( g );
        objRotate.addChild( shape );

        scene.compile();

        RenderPeer rp = new RenderPeerImpl();
        CanvasPeer cp = rp.makeCanvas( null, 640, 480, 32, false );
        canvas = new Canvas3D();
        canvas.set3DPeer(cp);
        view.addCanvas3D( canvas );

        view.getTransform().lookAt(
                new Vector3f( 0, 0, 5 ),
                new Vector3f( 0, 0, 0 ),
                new Vector3f( 0, 1, 0 )
        );

        view.startView();

    }

    public Canvas3D getCanvas()
    {
        return canvas;
    }
}

I then set up the cheesy rendering window in a JDesktop using the following


JInternalFrame frame = new JInternalFrame();
        RenderingWindow window = new RenderingWindow();
        frame.getContentPane().add( window.getCanvas() );
        Studio.getInstance().getWorkspaceArea().add( frame );

I’m not sure why, but this yields the following null pointer exception and I’m having a hard time tracking it down.


java.lang.NullPointerException
      at com.xith3d.render.jogl.ShapeAtomPeer.renderAtom(ShapeAtomPeer.java:688)
      at com.xith3d.render.CanvasPeerBase.render(CanvasPeerBase.java:102)
      at com.xith3d.render.jogl.CanvasPeerImpl.drawBin(CanvasPeerImpl.java:678)
      at com.xith3d.render.jogl.CanvasPeerImpl.display(CanvasPeerImpl.java:849)
      at net.java.games.jogl.impl.GLDrawableHelper.display(GLDrawableHelper.java:74)
      at net.java.games.jogl.GLCanvas$DisplayAction.run(GLCanvas.java:194)
      at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:235)
      at net.java.games.jogl.impl.macosx.MacOSXOnscreenGLContext.invokeGL(MacOSXOnscreenGLContext.java:79)
      at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:182)
      at net.java.games.jogl.GLCanvas.display(GLCanvas.java:82)
      at com.xith3d.render.jogl.CanvasPeerImpl.render(CanvasPeerImpl.java:950)
      at com.xith3d.scenegraph.View.renderOnce(View.java:732)
      at com.xith3d.scenegraph.View.renderOnce(View.java:665)
      at com.xith3d.scenegraph.View$ViewRunner.run(View.java:1334)
      at java.lang.Thread.run(Thread.java:552)

I’ve traced the problem to this offending line of code


                TextureUnitState tu[] = shape.getAppearance().getTextureUnitState();

The problem being that the shape I created didn’t have an appearance. So here is the problem, there needs to be a try/catch around the actual shape.getAppearance() so that it can catch a null appearance

  • or -

The constructor for shape that doesn’t take an appearance needs to be nuked.

Personally I think that the first option is the best and that the Xith layer should catch the null pointer exception and notify the developer that there is a problem with no Appearance being specified as this blows up the engine :slight_smile:

In addition, the documentation needs to be updated so that this is covered since this is a fairly critical error with the first 7 pages of doc. If anyone wants me to tackle any of this, lemme know.

See https://xith3d.dev.java.net/issues/show_bug.cgi?id=21. This issue is open for quite some time now.

I did make a change to the GSG, but only in the sourcecode, because I assumed most people download the sourcecode anyway and didn’t want to present “workarounds” in the GSG (the workaround is to use another constructor). You are the second person having this problem, so I’ll either update the guide or we fix this issue immediately (preferred).

OK, I fixed this issue now and added it as a patch to #21. It was a code structure error: Xith3D tried to draw a multitexture, when no appearance is specified.

There was also some discussion a while back regarding the current sitation with many Unchecked exceptions being thrown. In that case, Xith3D is noting a problem then throwing an Error. What is your stance on that? I wouldn’t mind reviving that discussion as nothing was decided in the end.

Will.