Hi,
I’ve been having a look at the HUD guide in the Xith in a Nutshell documentation and have been trying to
get some of the example code working. However I don’t seem to be able to find any compatible code /
libraries to get it working.
My code…
// Xith3D
import com.xith3d.scenegraph.Geometry;
import com.xith3d.scenegraph.Shape3D;
import com.xith3d.scenegraph.Appearance;
import com.xith3d.scenegraph.BranchGroup;
import org.xith3d.test.*;
import org.xith3d.ui.hud.*;
import org.xith3d.ui.swingui.*;
// use Jogl
import com.xith3d.render.*;
import com.xith3d.render.jsr231.*;
import org.xith3d.render.loop.*;
import org.xith3d.render.base.*;
import org.xith3d.render.canvas.*;
/**
*
* @author William
*/
public class MyHUD extends ExtRenderLoop implements WidgetActionListener {
public void actionPerformed(String actionCommand) {
if (actionCommand.equals("EXIT")) {
System.exit(0);
}
}
private HUD createHUD(Canvas3D canvas) {
HUD hud = new HUD(canvas, 1000, 1000,this);
//this.registerInputListner(hud);
Button button = new Button(300, 100, "Exit this app");
button.setActionCommand("EXIT");
button.addActionListener(this);
hud.addWidget(button, 400, 400);
return(hud);
}
public MyHUD() {
super(128L);
ExtXith3DEnvironment env = new ExtXith3DEnvironment();
Canvas3DWrapper canvas = Canvas3DWrapper.createStandalone(Canvas3DWrapper.Resolution.RES_800X600,"My HUD");
env.addCanvas(canvas);
this.registerKeyboardAndMouse(canvas);
RenderPassConfigProvider persConfigProvider = new RenderPassConfig(RenderPassConfig.PERSPECTIVE_PROJECTION);
Geometry geo = Cube.createCubeViaTriangles(0, 0, 0, 1, true);
Shape3D sh = new Shape3D(geo, new Appearance());
BranchGroup bg = new BranchGroup();
bg.addChild(sh);
RenderPass scenePass = new RenderPass(bg,persConfigProvider);
env.addRenderPass(scenePass);
RenderPassConfigProvider paraConfigProvider = new RenderPassConfig(RenderPassConfig.PARALLEL_PROJECTION);
BranchGroup parallelBranchGroup = new BranchGroup();
parallelBranchGroup.addChild(createHUD(canvas));
RenderPass hudPass = new RenderPass(parallelBranchGroup,paraConfigProvider);
env.addRenderPass(hudPass);
this.begin();
}
}
I had a lot of problems to begin with and have changed the code to try and update it. I checked out
a new copy of xith3d and xith-tk from CVS, built new jars and added them to my project but then I
got a missing class error from net.jtank.input.InputListener. I managed to fix this by finding the class
in an earlier release of xith. My project now compiles but when I try to run it I get the following error
Exception in thread "main" java.lang.NoSuchMethodError: javax.vecmath.Matrix4f.setTranslation(Ljavax/vecmath/Tuple3f;)V
at com.xith3d.scenegraph.Transform3D.lookAt(Transform3D.java:691)
at com.xith3d.scenegraph.View.lookAt(View.java:422)
at com.xith3d.scenegraph.View.<init>(View.java:781)
at org.xith3d.render.base.Xith3DEnvironment.<init>(Xith3DEnvironment.java:1381)
Is there a different version of vecmaths I need to download?
Also is there an easier way to try the examples from the “Xith in a nutshell” as I have found
it really difficult.
Thanks,
William