williamsellick
Senior Newbie 
|
 |
«
Posted
2006-10-30 20:30:53 » |
|
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... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| 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.*; import com.xith3d.render.*; import com.xith3d.render.jsr231.*; import org.xith3d.render.loop.*; import org.xith3d.render.base.*; import org.xith3d.render.canvas.*;
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); 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 1 2 3 4 5
| 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
|
|
|
|
|
Amos Wenger
|
 |
«
Reply #1 - Posted
2006-10-30 20:41:18 » |
|
Two possible solutions : - You use Sun's vecmath whereas vecmath_kh.jar (Kenji Hiranabe's version) is recommended - You use java 1.5.0_07 which is buggy. Please upgrade to 1.5.0_09
|
"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
|
|
|
Marvin Fröhlich
|
 |
«
Reply #2 - Posted
2006-10-30 20:47:59 » |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| First of all some comments about imports:
[code]
import org.xith3d.test.*; import org.xith3d.ui.hud.HUD; import org.xith3d.ui.hud.widgets.*; import org.xith3d.ui.swingui.*; import com.xith3d.render.*; import com.xith3d.render.jsr231.*; import org.xith3d.render.loop.ExtRenderLoop; import org.xith3d.render.base.ExtXith3DEnvironment; import org.xith3d.render.canvas.Canvas3DWrapper; |
Uncomment this line to make the HUD able to hande input events. 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(); } } [/code]
It is necessary to also add the BranchGroup to the environment. I've updated the code to gat away from this necessarity. So this part of your code will be fine now. 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
Is there a different version of vecmaths I need to download?
The project is now hosted on sourceforge.net. Please recheckout SVN from sourceforge. Refer to this thread to know, how to. And make sure, you use vecmath-kh.jar and not vecmath.jar. I'd suggest, we remove vecmath.jar from SVN. Also is there an easier way to try the examples from the "Xith in a nutshell" as I have found it really difficult.
I very sorry for the insufficient HUD documentation in XIN. I'll update this chapter soon. Marvin
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
williamsellick
Senior Newbie 
|
 |
«
Reply #3 - Posted
2006-10-31 10:41:05 » |
|
I'm still having a few issues with xith-tk. I took your advise Marvin and checked out the latest build of xith-tk using subversion from sourceforge but when I imported the project into eclipse it gave me over 8000 errors. I double checked I had all the libraries and everything was referenced correctly and couldn't find any problem with them. I investigated the source of the problems and it seems they originate from the import statements in most files. I found that a lot com.xith3d.... had been changed to org.xith3d and in the majority of cases the required classes weren't in org (toolkit) so couldn't be referenced.
Could you please tell me where I can download a copy of xith-tk with the HUD code in it as I seem to be quite unlucky with the code at the moment.
Thanks, William
|
|
|
|
|
Amos Wenger
|
 |
«
Reply #4 - Posted
2006-10-31 13:57:25 » |
|
Also check out a fresh xith3d from subversion. (All com.xith3d have been changed to org.xith3d)
|
"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
|
|
|
rafa_es
|
 |
«
Reply #5 - Posted
2006-11-01 01:06:24 » |
|
... but when I try to run it I get the following error 1 2 3 4 5
| 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) |
Hi William, I think your problem is related with your video card. I got this same error when i tryed to run my game on college. It can be fixed by getting the latest driver for you card Rafael
|
|
|
|
|
Marvin Fröhlich
|
 |
«
Reply #6 - Posted
2006-11-01 01:44:50 » |
|
... but when I try to run it I get the following error 1 2 3 4 5
| 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) |
Hi William, I think your problem is related with your video card. I got this same error when i tryed to run my game on college. It can be fixed by getting the latest driver for you card Rafael Maybe you're right. But it looks exactly like he is using Sun's vecmath library. vecmath-kh.jar should be used. Marvin
|
|
|
|
|
williamsellick
Senior Newbie 
|
 |
«
Reply #7 - Posted
2006-11-12 15:00:38 » |
|
Thanks for everyones help with the HUD code. I got it working a while ago but have been bogged down with work so haven't managed to post recently. I found that the code in XIN may need adjusting as I had to change 1 2 3 4 5
| RenderPass scenePass = new RenderPass(RenderPass.PERSPECTIVE_PROJECTION); env.addChild(create3DScene(), scenePass); RenderPass hudPass = new RenderPass(RenderPass.PARALLEL_PROJECTION); env.addChild(createHUD(canvas), hudPass); |
to 1 2 3 4
| env.addParallelChild(createHUD(canvas)); BranchGroup b = new BranchGroup(); b.addChild(this.create3DScene()); env.addPerspectiveBranch(b); |
As a side point everytime I run my code I get an exception from the getTheme method in HUD. I thought this might be because I hadn't set a Theme but even if I set one I still get the same error. 1 2 3 4 5 6
| java.io.IOException: mark/reset not supported at java.io.InputStream.reset(InputStream.java:331) at org.xith3d.loaders.texture.TextureStreamLocatorZip.cacheNames(TextureStreamLocatorZip.java:106) at org.xith3d.loaders.texture.TextureStreamLocatorZip.<init>(TextureStreamLocatorZip.java:134) at org.xith3d.ui.hud.utils.WidgetTheme.<init>(WidgetTheme.java:485) at net.worship.ui.MyHUD.createHUD(MyHUD.java:48) |
It doesn't seem to effect the actual running of the code but I'm guessing when I want to theme components I may run into problems. Does anyone know the cause of this problem? Thanks, Wiliam
|
|
|
|
|
Marvin Fröhlich
|
 |
«
Reply #8 - Posted
2006-11-12 21:34:51 » |
|
I found that the code in XIN may need adjusting as I had to change 1 2 3 4 5
| RenderPass scenePass = new RenderPass(RenderPass.PERSPECTIVE_PROJECTION); env.addChild(create3DScene(), scenePass); RenderPass hudPass = new RenderPass(RenderPass.PARALLEL_PROJECTION); env.addChild(createHUD(canvas), hudPass); |
to 1 2 3 4
| env.addParallelChild(createHUD(canvas)); BranchGroup b = new BranchGroup(); b.addChild(this.create3DScene()); env.addPerspectiveBranch(b); |
I updated the HUD section in XIN today. Please reread the new version (the new Multipass rendering chapter, too), if it now fits your needs. Curiously it should have worked before, too  . I'll update the HUD chapter again later to explain each single Widget in detail. As a side point everytime I run my code I get an exception from the getTheme method in HUD. I thought this might be because I hadn't set a Theme but even if I set one I still get the same error. 1 2 3 4 5 6
| java.io.IOException: mark/reset not supported at java.io.InputStream.reset(InputStream.java:331) at org.xith3d.loaders.texture.TextureStreamLocatorZip.cacheNames(TextureStreamLocatorZip.java:106) at org.xith3d.loaders.texture.TextureStreamLocatorZip.<init>(TextureStreamLocatorZip.java:134) at org.xith3d.ui.hud.utils.WidgetTheme.<init>(WidgetTheme.java:485) at net.worship.ui.MyHUD.createHUD(MyHUD.java:48) |
It doesn't seem to effect the actual running of the code but I'm guessing when I want to theme components I may run into problems. Does anyone know the cause of this problem? Strange  . It is not necessary to add a theme to the HUD, if you don't use one. Could you please quote, how you add the Theme to the HUD? Marvin
|
|
|
|
|
Amos Wenger
|
 |
«
Reply #9 - Posted
2006-11-13 18:49:42 » |
|
addParallelChild() and addPerspectiveBranch() should be harmonized. I tend for the branch version.
|
"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
|
|
|
Games published by our own members! Check 'em out!
|
|
Marvin Fröhlich
|
 |
«
Reply #10 - Posted
2006-11-13 19:33:41 » |
|
addParallelChild() and addPerspectiveBranch() should be harmonized. I tend for the branch version.
These two methods behave differently. addParallelChild() adds a Node to an existing BranchGroup and only creates a new one if not breviously done. It will try to reuse a previously created one. addParallelChild() will always use the given BranchGroup as a new branch and RenderPass. Marvin
|
|
|
|
|
Amos Wenger
|
 |
«
Reply #11 - Posted
2006-11-14 18:31:07 » |
|
addParallelChild() and addPerspectiveBranch() should be harmonized. I tend for the branch version.
These two methods behave differently. addParallelChild() adds a Node to an existing BranchGroup and only creates a new one if not breviously done. It will try to reuse a previously created one. addParallelChild() will always use the given BranchGroup as a new branch and RenderPass. Marvin That's confusing.
|
"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
|
|
|
Marvin Fröhlich
|
 |
«
Reply #12 - Posted
2006-11-14 21:37:56 » |
|
That's confusing.
Yes, maybe it is  . But these are two methods, that both make sense and have a reason to be there. Maybe you have a better name for one of them? Marvin
|
|
|
|
|
Amos Wenger
|
 |
«
Reply #13 - Posted
2006-11-14 23:35:06 » |
|
That's confusing.
Yes, maybe it is  . But these are two methods, that both make sense and have a reason to be there. Maybe you have a better name for one of them? No but what about creating addPerspectiveChild() and addParallelBranch() so that the confusion is partly gone (the remaining is up to the users to read the javadoc... or not).
|
"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
|
|
|
Marvin Fröhlich
|
 |
«
Reply #14 - Posted
2006-11-14 23:45:41 » |
|
No but what about creating addPerspectiveChild() and addParallelBranch() so that the confusion is partly gone (the remaining is up to the users to read the javadoc... or not).
Do I understand you right, that you actually want addPerspectiveBranch() and addParallelChild() to be removed  Wouldn't this confuse even more? And what if I want to add a HUD to the environment and don't want to handle the BranchGroup stuff myself? Then I do need addParallelChild(). But I will anyway check the JavaDoc and maybe add some lines... Marvin
|
|
|
|
|
Amos Wenger
|
 |
«
Reply #15 - Posted
2006-11-15 00:09:38 » |
|
No but what about creating addPerspectiveChild() and addParallelBranch() so that the confusion is partly gone (the remaining is up to the users to read the javadoc... or not).
Do I understand you right, that you actually want addPerspectiveBranch() and addParallelChild() to be removed  Wouldn't this confuse even more? And what if I want to add a HUD to the environment and don't want to handle the BranchGroup stuff myself? Then I do need addParallelChild(). But I will anyway check the JavaDoc and maybe add some lines... I mean to leave the existing addPerspectiveBranch() and addParallelChild() functions AND to add their counterpart ( addPerspectiveChild() and addParallelBranch() )
|
"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
|
|
|
Marvin Fröhlich
|
 |
«
Reply #16 - Posted
2006-11-15 00:13:21 » |
|
I mean to leave the existing addPerspectiveBranch() and addParallelChild() functions AND to add their counterpart ( addPerspectiveChild() and addParallelBranch() )
Ooops! You're partly right  . addParallelBranch() already existed, but addPerspectiveChild() didn't  . I'll commit the change together with the improved JavaDoc. Thanks for the hint. Marvin
|
|
|
|
|
Amos Wenger
|
 |
«
Reply #17 - Posted
2006-11-15 00:27:13 » |
|
Good.
|
"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
|
|
|
williamsellick
Senior Newbie 
|
 |
«
Reply #18 - Posted
2006-11-18 22:19:41 » |
|
Hi, I am using the following code to set the theme 1 2 3 4 5 6 7
| try { FileInputStream fis = new FileInputStream("net/worship/GTK.xwt"); System.out.println("is null::" + (fis == null)); HUD.setTheme(new WidgetTheme(fis)); } catch(Exception e){ e.printStackTrace(); } |
where I have put the file in "src.net.worship" and set the classpath to my src directory. I get the same error if I set the theme or not.
|
|
|
|
|
Marvin Fröhlich
|
 |
«
Reply #19 - Posted
2006-11-18 22:46:18 » |
|
Hi, I am using the following code to set the theme 1 2 3 4 5 6 7
| try { FileInputStream fis = new FileInputStream("net/worship/GTK.xwt"); System.out.println("is null::" + (fis == null)); HUD.setTheme(new WidgetTheme(fis)); } catch(Exception e){ e.printStackTrace(); } |
where I have put the file in "src.net.worship" and set the classpath to my src directory. I get the same error if I set the theme or not. Well, do I get you right, that you have created a new theme and called it "GTK"? I guess I haven't catched the case, that someone tries to add two themes with the same name. So I don't know how it could behave. The default theme's name is "GTK" and your theme's name seems to be "GTK" also. Please rename your theme to something different. And keep in mind, that the name base of the file "ABC.xwt" must equal the name set in the theme properties file (in this case "ABC"). I'm currently working on the ZIP texture loader. I hope this will solve your problem. Please do a checkout, when I post, that I've fixed the loader (possibly this night). Marvin
|
|
|
|
|
Marvin Fröhlich
|
 |
«
Reply #20 - Posted
2006-11-18 23:10:06 » |
|
I've fixed the TextureStreamLocatorZIP. Please check if it works now. Unfortunately I had to break the API to do it. You now have to pass a URL to the WidgetTheme constructor instead of an InputStream. But it is only one line to change. Here is the new code to use: 1 2 3 4 5 6 7
| try { URL url = myClassLoader.getResource("net/worship/GTK.xwt"); System.out.println("is null::" + (url == null)); HUD.setTheme(new WidgetTheme(url)); } catch(Exception e){ e.printStackTrace(); } |
Hope this fixed you problem. Marvin
|
|
|
|
|
|