|
'n ddrylliog
|
 |
« Reply #30 on: 22. August 2007, 04:56:29 PM » |
|
Yep, but I'd like to implement that in a generic way. Don't we have a triangulator class somewhere ? (I remember we were talking about that).
Well, we talked about it. But nobody (including myself) has written one or ported. We weren't sure, if we could simply port the one from Java3D because of license issues. And a really generic triangulator is a quite complicated thing and highly expensive. Triangulating quads is very cheap and can be done on the fly. I would suggest to do on_the-fly triangulation for quads and use the future-triangulator for more complicated geoms. In fact it's much simpler to say users to enable the "Triangles" option in Blender exporter 
|
|
|
|
|
Logged
|
|
|
|
|
BrazilianBoy
|
 |
« Reply #31 on: 22. August 2007, 08:12:24 PM » |
|
Is the test code in "Installing Xith form SVN.pdf" (or something like this  ) up-to-date with the svn trunk? I had some problems with it. Where's the Resolution enum by now? EDIT: Resolution problem fixed (no need anymore). But the current xith-tk trunk doesn't seem to be compatible with the latest xith3d trunk. I can't compile the app (rotating cube test). There are problems with FPIHandler, and when I try to remove it, other errors show up, in CollisionEngine.java (org.openmali.spatial package doesn't exist!!) Any help would be aprecciated. Some quick questions: 1> What's a TriMesh? A mesh composed of triangles? 2> Is the physics engine compatible with shared groups (and links)?
|
|
|
|
« Last Edit: 22. August 2007, 09:21:45 PM by BrazilianBoy »
|
Logged
|
Getting my hands dirty 
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4337
May the 4th, be with you...
|
 |
« Reply #32 on: 22. August 2007, 09:55:18 PM » |
|
In fact it's much simpler to say users to enable the "Triangles" option in Blender exporter  Yeah, that's true. The problem is only for models, that you downloaded from somewhere, that aren't triangulized. Is the test code in "Installing Xith form SVN.pdf" (or something like this  ) up-to-date with the svn trunk? I had some problems with it. Where's the Resolution enum by now? EDIT: Resolution problem fixed (no need anymore). But the current xith-tk trunk doesn't seem to be compatible with the latest xith3d trunk. I can't compile the app (rotating cube test). There are problems with FPIHandler, and when I try to remove it, other errors show up, in CollisionEngine.java (org.openmali.spatial package doesn't exist!!) Any help would be aprecciated. Some quick questions: 1> What's a TriMesh? A mesh composed of triangles? 2> Is the physics engine compatible with shared groups (and links)? No, the code from he Installation guide pdf is not compatible with the current SVN trunks. It needs an update. But you can simply ignore it and use the code from XIN, which is compatible. Resolution is replaced by DisplayMode. I checked the SVN trunks. And everything is fine with them. Please check, if you checked out everything correctly. Especially the latest openmali.jar in xith3d SVN. I guess, the prblems with these classes above all result from your damaged checkout. They should be solved after you fixed that. The classes do work. You're right about the TriMesh. Marvin
|
|
|
|
|
Logged
|
|
|
|
|
BrazilianBoy
|
 |
« Reply #33 on: 24. August 2007, 07:42:02 PM » |
|
I guess, the problems with these classes above all result from your damaged checkout. They should be solved after you fixed that. The classes do work.
Yeah, the problem is solved, and it runs smoothly here. It's time to finish some art and start the basic engine... I won't use bsp maps anymore (they're hard to make). I'll model the pieces of the scenario as obj files and then use them like tiles. That's much simpler, because they're automatically frustum culled and it's easier to expand the levels too. Is the remaining of your game working ?  Okay, I shut up.. I wish there was too... But I don't have much spare time and i'm quite inexperienced (this project is very ambicious). Can I use collisions with .obj models? Is it posiible to apply a cube map on them? How can I implement physics?
|
|
|
|
« Last Edit: 24. August 2007, 09:43:03 PM by BrazilianBoy »
|
Logged
|
Getting my hands dirty 
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4337
May the 4th, be with you...
|
 |
« Reply #34 on: 24. August 2007, 11:37:24 PM » |
|
Yeah, the problem is solved, and it runs smoothly here. It's time to finish some art and start the basic engine...
Good to know  . I won't use bsp maps anymore (they're hard to make). I'll model the pieces of the scenario as obj files and then use them like tiles. That's much simpler, because they're automatically frustum culled and it's easier to expand the levels too.
Bsp Maps are frustum culled as well. In the end there is absolutely no differnce in how they are frustum culled. BSP maps are simply more efficient, since they use a BSP-Tree (the name says it  ) to efficiently sort out shapes, that are definitely not in the frustum. In the future I will want to add generic OcTree support for the static parts of a scene to improve frustum culling performance by far. Can I use collisions with .obj models?
Yes. You can use it with arbitrary shapes. And an OBJ model is built of shapes just as any other Xith3D "rendered thing". Is it posiible to apply a cube map on them?
Yes, of course. Though I don't know, if a cube map is used, if defined in the model, if you meant that. But it wouldn't be too hard to implement that in the loader. How can I implement physics?
You can either use JOODE, ODEJava or (preferably) XPAL. Have a look at org.xith3d.test.input.FirstPersonInputHandlerTest, org.xith3d.test.game.BSPGameTest and org.xith3d.w3g.Physics for reference. If you need extensions, just post here[/quote].
Marvin
|
|
|
|
|
Logged
|
|
|
|
|
hawkwind
|
 |
« Reply #35 on: 25. August 2007, 02:52:21 AM » |
|
Joode is the way to go. I make extensive use of it in my game.
1 - Examine Physics example, note the use of collision listeners, see where they use spheres as collision shape and replace with cubes
2 - to replace with cubes use the CollidableBox (I think, don't have code with me). You need to know where you shapes are and they're bounds. Remember default bounds from Xith are spheres, need to replace with Boxes. I can post code in a day
3 Use the defaultGFX option to display your collision boxes and xith shapes, arrange to toggle these to display/not display on a live scene to make sure all of your game objects are completely obscured by the DefaultGFX shapes. This will affect you display performance only because additional shapes are in the scene. This is critcal, in my use it showed some unintentional rotations in my scene because the actual shape position was not what a I thought, having the defaultGFX (representing the collison object) only partially covering the actual game object exposed design problems for me.
4 - Definitely check out how avatars are added and handled in the BSPGameTest, this tied in with what is done to slide your avatar during a collision (see the listener handling in Physics) is all you need. Thanx to Marvin and Amos it took about 15 minutes to add a avatar/collision handling system to my game.
|
|
|
|
|
Logged
|
|
|
|
|
'n ddrylliog
|
 |
« Reply #36 on: 25. August 2007, 08:24:48 AM » |
|
@hawkwind : You're talking about using JOODE via XPAL, right ?
|
|
|
|
|
Logged
|
|
|
|
|
BrazilianBoy
|
 |
« Reply #37 on: 25. August 2007, 01:42:00 PM » |
|
JOODE via XPAL is the way to go. It's simpler to use, and integrated with xith-tk.
Does xith use XPAL to calculate frustum-culling and collisions?
|
|
|
|
|
Logged
|
Getting my hands dirty 
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4337
May the 4th, be with you...
|
 |
« Reply #38 on: 25. August 2007, 01:55:19 PM » |
|
Does xith use XPAL to calculate frustum-culling and collisions?
XPAL has nothing to do with frustum culling. But for collisions: yes. Marvin
|
|
|
|
|
Logged
|
|
|
|
|
BrazilianBoy
|
 |
« Reply #39 on: 25. August 2007, 02:27:09 PM » |
|
Isn't onFPSCountIntervalHit() working anymore? I can't see the fps on the title bar... package br.lucas.xithtest;
import java.io.File;
import org.openmali.vecmath.*; import net.jtank.input.KeyCode;
import org.xith3d.render.Canvas3D; import org.xith3d.render.Canvas3DFactory; import org.xith3d.shapes.Cube; import org.xith3d.base.Xith3DEnvironment; import org.xith3d.loaders.texture.TextureLoader; import org.xith3d.loaders.texture.TextureStreamLocatorFile; import org.xith3d.loop.RenderLoop; import org.xith3d.scenegraph.BranchGroup; import org.xith3d.scenegraph.TransparencyAttributes;
public class XithTest extends RenderLoop { private Canvas3D canvas; public void onKeyReleased(int key) { switch (key) { case KeyCode.VK_ESCAPE: this.end(); break; } } private BranchGroup createScene() { Cube cube = new Cube(1, new Color4f(0.1f,0.4f,0.8f,1)); BranchGroup bg = new BranchGroup(); bg.addChild( cube ); return( bg ); } public XithTest() { super( 128L ); Xith3DEnvironment env = new Xith3DEnvironment( new Vector3f( 3f, 2f, 5f ), new Vector3f( 0f, 0f, 0f ), new Vector3f( 0f, 1f, 0f ), this ); canvas = Canvas3DFactory.createWindowed(640, 480, "Example App"); this.getInputManager().registerKeyboardAndMouse( canvas ); env.addCanvas( canvas ); TextureLoader.getInstance().addTextureStreamLocator( new TextureStreamLocatorFile( new File( "demo/textures") ) ); for(int i = 1;i<=5;i++)env.addPerspectiveBranch( createScene() ); this.begin(); } public static void main(String[] args) { new XithTest(); } public void onFPSCountIntervalHit(int fps){ canvas.setTitle("Example App fps: "+fps); System.out.println(fps); } }
|
|
|
|
|
Logged
|
Getting my hands dirty 
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4337
May the 4th, be with you...
|
 |
« Reply #40 on: 25. August 2007, 03:01:57 PM » |
|
It is still working. But the fps parameter is a float, but not an int. You simply didn't override the method. (Tip of the day: You should always use the @Override annotation for overridden methods. This way you will be noticed, if you don't actually override a method.) Even better: You don't have to do al that: Override this method, store the Canvas3D instance in a global variable and set the canvas title manually. Simply use this: this.addFPSListener( new CanvasFPSListener( canvas ) );
and the result will be the same, but much simpler to handle. Why are you adding the main BranchGroup 5 times  You should replace this: TextureLoader.getInstance().addTextureStreamLocator( new TextureStreamLocatorFile( new File( "demo/textures") ) );
by this: ResourceLocator resLoc = ResourceLocator.crate( "demo/" ); resLoc.useAsSingletonInstance(); // optional resLoc.createAndAddTSL( "textures" );
It is way more flexible (works with files AND URLs, i.e also from a jar) and a little better to read. And additionally you will want to use the ResourceLocator for many other things. Marvin
|
|
|
|
« Last Edit: 25. August 2007, 03:06:11 PM by Marvin Fröhlich »
|
Logged
|
|
|
|
|
BrazilianBoy
|
 |
« Reply #41 on: 25. August 2007, 03:24:07 PM » |
|
Thanks, man  Why are you adding the main BranchGroup 5 times  Just for performance testing... The ResourceLocator is very useful. Thanks. Is it harder to create loaders for non-triangulated models?
|
|
|
|
|
Logged
|
Getting my hands dirty 
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4337
May the 4th, be with you...
|
 |
« Reply #42 on: 25. August 2007, 03:37:42 PM » |
|
Is it harder to create loaders for non-triangulated models?
It depends. It is fairly simple to triangulate quads on-the-fly. So this could be implemented. But it is very difficult and especially CPU-expensive to triangulate arbitrary (convex/concav) geometries. So you should better just trigger the triangulate function in blender (or what ever you're using) and store the model triangulated. Marvin PS: Glad to hear, that you find the ResourceLocator useful. If you want to use it as a singleton, you should consider to use the ResLoc class, whcih provides static methods, that simply forward to the singleton ResourceLocator instance. It is a shortcut for ResourceLocator.getInstance().
|
|
|
|
« Last Edit: 25. August 2007, 03:39:23 PM by Marvin Fröhlich »
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4337
May the 4th, be with you...
|
 |
« Reply #43 on: 25. August 2007, 03:42:08 PM » |
|
You might also find the ResourceLoader useful. Please read XIN chapter 12 about it.
Marvin
|
|
|
|
|
Logged
|
|
|
|
|
hawkwind
|
 |
« Reply #44 on: 25. August 2007, 04:10:03 PM » |
|
@hawkwind : You're talking about using JOODE via XPAL, right ? Danged if I know, I create a new box using JoodeCollisionEngine.newBox(bounds) and listen using new CollisionListener() { public void onCollision(Collision collision) { What would I use for XPAL??
|
|
|
|
|
Logged
|
|
|
|
|