Download physics demo using jme (and odejava)

If you are interested on physic engine using Java then check the following url:

http://cray.tuug.org/~jani/odejava



Download the odejava-0.1.1-test.zip, extract it and execute the demos by clicking on of four bat files. One of the bat files starts a demo using jme engine (newer jme).



Sorry but this works only for windows people as I have only compiled odejava’s native library for windows. This will change in the near future (linux, macos libraries).



Below is a short help for the Xith3d related demos, jme has it’s help on the screen:



On the BoxApp you can change simulations by pressing 1,2 or 3. Keys q,w,e,a,s,d change box sizes (select new simulation after this). Mouse drag with left mouse button adds some spin to boxes and plain left click to bottom or top of the screen gives big force to last object (try it with tower simulation as all boxes are connected to each other, snaky).



On the CarApp you can try to drive around with a,d,w,s keys. b is handbrake (on/off) and keys 1,2,3 change the camera position. Space resets the simulation. Ode’s parameters are bit hairy, fix if you want.



runOdeHelloWorld.bat runs console based test with couple objects falling to a ground, with no rendered attached to it, so this is a bit dull demo.





Cheers, Jani!

Hmm, well I just downloaded the latest. Running the jme version pulls up the display settings dialog, creates a window then shutsdown. I wonder if you just found a jme bug for me. :slight_smile:



Going to play around with it and see if I can tell what the issue is.

"mojomonk" wrote:
Hmm, well I just downloaded the latest. Running the jme version pulls up the display settings dialog, creates a window then shutsdown. I wonder if you just found a jme bug for me. :)

Going to play around with it and see if I can tell what the issue is.

I tried the package only with my home computer and with my work laptop (this is not highend, P3 933MHz, intel integrated graphics card).

Could it be a problem with the textures? I am using following parameters as they are visually better than MM_LINEAR/FM_LINEAR.


TextureManager.loadTexture(
            "data/images/crate.png",
            Texture.MM_LINEAR_NEAREST,
            Texture.FM_LINEAR,
            true));



Another thing, my order of jme execution (state changes etc.) might be completely wrong? The class is however very simple..

PS. I updated odejava package with latest jme straight from the cvs.

PS2. I am sure that you know this but if jme does not find a texture that user requests, the error message is a bit akward.

Well, I got it working by using a different computer. I love it!

There must have been something wrong with the first computer.



Man this physics stuff is really cool.

I just realized that I think there is something wrong with the tower simulation. The botton of the tower leaps into the air. It’s like the boxes are very bouncy or something.

"mojomonk" wrote:
I just realized that I think there is something wrong with the tower simulation. The botton of the tower leaps into the air. It's like the boxes are very bouncy or something.

Do you mean this:


private void setForce() {
      forceAngle += 0.02;
      odeBoxes.getBody(odeBoxes.getObjectCount() - 1).addForce(
         0f,
         0f,
         (float) (600 * Math.sin(forceAngle) + 1));
      odeBoxes.getBody(0).addForce(
         0f,
         0f,
         (float) - (600 * Math.sin(forceAngle) + 1));
   }



setForce method is called on each step. That puts major Z-axis force (upward or downwards) regulated by sin function. It causes the whole lot of boxes (snake) to constantly move up and down as they are tied to each other with joints. That just seemed a nice demonstration effect..

In other words, I am tampering with the simulation by constantly dragging the snakes head and tail. Try tying one object of complex 'tied' construction to mouse and start swinging.. :)

Or do you mean an actual bug?

Oh ok, the effect was intentional then. What I meant is the jme version is different than the xith3d version. But if you meant to do that, then it’s fine. I just thought that they were supposed to be the same.

One thing that might be fun to play with, is you can use a CameraNode to attach a camera to a box. You could then have the point of view of the box as it falls down. :slight_smile:



Secondly, you might get a performance boost by turrning backface culling on.



renderer.setCullingMode(Renderer.CULL_BACK);

I compiled libodejava.so for Linux platform. I tested it succesfully with console demo.


  1. Download linux library



    http://cray.tuug.org/~jani/odejava/libodejava.tgz




  2. Install library



    gunzip libodejava.so.gz

    mv libodejava.so odejava/lib/linux




  3. Run console test



    java -cp .:./lib/vecmath.jar -Djava.library.path="./lib/linux" net.java.dev.odejava.test.OdeHelloWorld





    Other tests are trivial to run, I am sure that they work. However, I could not test those under linux platform because I compiled this library on a remote server.



    If this library get’s good feedback, I’ll add it to odejava packages.





    PS. Thanks for the odejava link on the jME’s frontpage, I hope the project get’s more developers.

Hey Jani,



I’ve made some improvements coming into the 0.3 release. I think a couple of the following might make for some interesting things in the jme version of the boxes demo.



First, lighting is fixed. You’ll get for free if you rebuild the jar.



Second, there is a concept of the CameraNode. You place a camera in a spatial node and stick that node where you want it. Now the camera is controlled by anything in the world. So you could place this on one of the top most boxes and feel like you are falling with the box. Might be kind of neat.



Third, backface culling is in place. That might improve the fps by a couple. But it’s really important if you use the camera node. Because now you’d be looking out of the box.



Forth, Picking is enabled. Maybe you could pick a box and apply some force to it or something. Collision detection is also in, but you probably don’t need it as you use OPCODE.



Just a couple thoughts. Might make things a little more interesting.

Nice additions, I try to snatch some time on weekend to do something with these. First priority is to work with odejava’s own www-page and package contents + setting up cvs.



Can you tell me when the texture state is fixed, or is it already? How can I apply different textures on different objects?



What is the state with loaders, e.g. ASE loader, I assume these are on the todo list for the newer jME. Can I load my rag doll human body that I made with 3d Studio (ASE)?



By the way, using odejava is simple, at least if you care to check few things from ode’s own www-site. Feel free to ask from me also if you need help with ode basics.



jME demo’s source code is a bit cleaner than Xith3d’s, so it’s best to start checking jME’s demo.

Can you tell me when the texture state is fixed, or is it already? How can I apply different textures on different objects?


Create a TextureState object for each texture you want to apply. Add the appropriate texture state to the node you wish to use it on. Note to make things the most efficient, if there is one texture that you are using for the majority of your objects, then add it to the parent node of these objects, that way the state only has to change once. The com.jme.test.renderer.state.TestRenderStateList shows this pretty well.


What is the state with loaders, e.g. ASE loader, I assume these are on the todo list for the newer jME. Can I load my rag doll human body that I made with 3d Studio (ASE)?


Not yet. That's version 0.5, 0.3 is almost done. 0.4 is curves and surfaces, so hopefully, with any luck, it won't be much longer. I realize this is a big feature that people want, so I'm trying to get to that point as fast as possible. However... all the model loaders will do is create a TriMesh from the model file (with animation, but that's not important now), so it "shouldn't" be too difficult.

[/quote]

odejava.dev.java.net