Bug in Xith3D tutorial

I coded up the ‘HelloXith3D’ code in the getting_started_guide.pdf file.

On two different machines I have compiled this code (both against the CVS HEAD and the last stable release) And on both machines I get a NullPointerException:

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:192)
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(Unknown Source)

The main bit of the code is like so:

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

    View view = new View();
    universe.addView(view);
    Locale locale = new Locale();
    universe.addLocale(locale);

    BranchGroup 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);

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

    scene.compile();

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

    view.getTransform().lookAt(new Vector3f(0, 0, 2.41f), // location of eye
    new Vector3f(0, 0, 0), // center of view
    new Vector3f(0, 1, 0)); // vector pointing up
    view.startView();

}

Can anyone suggest what might be going wrong? I’ve compared the code with the CubeTest.java demo code and I couldn’t find any obvious architectural faults from what I know of how it should be working.

I’m a newbie trying to learn Xith3D, and I’d like to be able to work through the rest of the tutorials.

Any help would be greatly appreciated.

Neato, another post in My Very Own Thread…

I’ve really enjoyed talking to myself :slight_smile:

Anyway, I’ve figured out what the problem was by working through the com.xith3d.render.jogl.ShapeAtomPeer.renderAtom() code. The problem is that the tutorial doesn’t define an appearance for the cube and the renderAtom code assumes that the shape will have an appearance (on line 688)

This is either a bug with the code or the tutorial. Someone who knows better than I should fix one or the other - it’s obviously not desirable to have newbs fail on the first tutorial :slight_smile:

Cheers,

Peter.

Na, I’m listening, honest ;D

Well done for finding the bug, its actually in the tutorial although some extra debug might be nice in the code.

I think currently a shape without an Appearance won’t be displayed, I didn’t realise it crashed but I guess so :slight_smile:

Well done again,

Kev

Sorry just looked in on this or I would have replied sooner.

I had this problem when I first looked at it as well. I think that the actual code that you can downlod is ok but the text in the tutorial is wrong.

Still at least you’ve got it sorted now :wink:

Dan.

I fixed this issue and committed the changes to CVS (the sourcecode in the GSG example is not wrong).

Additionally I fixed another Joal compile error. I wonder why no one complained about this one or didn’t you get any error when compiling Xith3D with ant?

No, I didn’t get any errors compiling at all - worked straight out of the box :slight_smile:

Having just spent days trying to get OpenSceneGraph to compile and spitting tacks at *&^#^!@ing template errors, Xith3D’s swift and error-free compile was a welcome relief :slight_smile:

Jens, something definitely went wrong with JOAL driver…

[quote]Additionally I fixed another Joal compile error. I wonder why no one complained about this one or didn’t you get any error when compiling Xith3D with ant?
[/quote]
I just triple-checked the JOAL source, and it still throws an exception in ALFactory.getAL():

  public static AL getAL() throws OpenALException

Can you pls check this again, because of I am not sure if current CVS version is OK… or maybe I am doing something wrong or using wrong version [I use JOAL from JOAL CVS]?

Yuri

Hello Yuri,

it’s my fault. :-/ I wasn’t aware of Will’s temporary hack some days ago and somehow didn’t update the jar’s properly. I reverted to the last version of the sound driver in CVS now. I’m really sorry. It should work fine for you again, now.

Jens

Hi,

[quote]I’m really sorry. It should work fine for you again, now.
[/quote]
Thanks for a quick fix. And don’t worry about this - we have CVS anyway, so this is not a big problem.

Yuri

[quote]Hello Yuri,

it’s my fault. :-/ I wasn’t aware of Will’s temporary hack some days ago and somehow didn’t update the jar’s properly. I reverted to the last version of the sound driver in CVS now. I’m really sorry. It should work fine for you again, now.

Jens
[/quote]
Yes, thanks for fixing it quick - in fact it was fixed before I even saw it was broken :). I was surprised so few things broke when I updated the JOGL and JOAL libraries for xith3d considering how out of date they were.

Incidently that “temporary” hack will pretty much have to be permanent unless enough people want checked exceptions (as per my old thread).

Will.