Error in collisions?

public class test extends SimplePhysicsGame {
    protected void simpleInitGame() {
        StaticPhysicsNode staticNode = getPhysicsSpace().createStaticNode();      
        Sphere s = new Sphere("floorSphere", new Vector3f(0,0,0), 10, 10, 10);
        //Box s = new Box("floorBox", new Vector3f(-5,-5,-5), new Vector3f(5,5,5));
        rootNode.attachChild( staticNode );

        DynamicPhysicsNode dynamicNode = getPhysicsSpace().createDynamicNode();
        Box b = new Box("fallingBox", new Vector3f(-0.5f,-0.5f,-0.5f), new Vector3f(0.5f,0.5f,0.5f));
        //Sphere b = new Sphere("fallingSphere", new Vector3f(0,0,0), 10, 10, 1);
        rootNode.attachChild( dynamicNode );

        showPhysics = true;

     * The main method to allow starting this class as application.
     * @param args command line arguments
    public static void main( String[] args ) {
        Logger.getLogger( PhysicsSpace.LOGGER_NAME ).setLevel( Level.WARNING ); // to see the important stuff
        new test().start();

I just want to ask about collisions from above example. It is just a "falling dynamic Shape on static Shape" program. It works fine exept one case and it is dynamic box falling on static sphere (the one uncommented now). I want to ask if it is a known bug, just founded bug, my fault or something else.
I'm doing spaceship-game and my collision with the Planet were terrible, so I trace this out.
Any comments are welcomed

Collisions are fine over here. Maybe you are confused by the 'wrong' visual representation of the sphere? It has a low poly count, thus the actual visual representation is not a sphere. Physically it's a perfect sphere.

You can change the initialization

Sphere s = new Sphere("floorSphere", new Vector3f(0,0,0), 10, 10, 10);


Sphere s = new Sphere("floorSphere", new Vector3f(0,0,0), 100, 100, 10);

to get a mesh with more polys (100 times more btw) which looks more like a sphere.

Hi Irrisor,

thanks for your concern. I tried your advise before I posted it and it really does not work for me:-(… even if I made the sphere (100,100,10) it makes the same. Falling box fell into the center of the Sphere(it is literally sucked in by the sphere) and vibrates there like it wants to be set back at the top of the sphere(on the surface) and simultanously it is pulled down.

I though it can be somehow caused by big gravity force, that it shifts the falling box too much into the sphere and therefore it makes crazy things but even if I lower gravity to the (0, -0.1, 0) it makes the same. So I have no ideas right now.

Did you try the code and it works for you? If yes, than I'm completely confused:-( and I'll be forced to try TriMesh instead of Sphere and load Spheres:-)

gorgor said:

Did you try the code and it works for you?

Yes. I'm using current CVS of jME and jME Physics 2 on Windows. What's your OS?

I'm on WinXP and using jME Physics2 from CVS and jME from CVS, both checkedout maybe a week ago.


right now I've tried to control the box from keyboard and tried to repeatedly bumb into the static Sphere and I must say that it sometime stops and rebounds me as I would expect and sometime it sucks me in. I cant say if it depends on angle, velocity or the color of my pants but it behave in such a way  on my machine. When I change the static Sphere to the static Box, then I was never successful in breaking in.

(of course I use addForce() and addTorque() and no setLocalTranslation() or setLocalRotation())

I used the physics picker to try that and it never sucks in anything :expressionless:

What does the test, which you posted, actually do on your side? Over here the box falls down and bounces off the perfect sphere (above the visual sphere) several times and then comes to a rest on it.

Here (I copied code from my first post, and recompiled) the test behave in this way :

Box falls on Sphere and when it touches the surface of the sphere it disappears. When I move camera into the big Sphere so I see the inside, there is that box and it moves up and back at the center(of sphere) very fast(it is probably not continuous move it rather seems to be a fast relocations). It vibrates along the sphere's center - there can be seen two velocities vectors(showPhysics = true) - one pointing to the top surface where box should rest and the second is opposite - it is poiting at the bottom surface. Those vectors are interchanging very fast and that's way it vibrates.

When I comment "fallingBox" and uncomment "fallingSphere" it behaves as you desribed - sphere falls at top of the big sphere and bounces few times and then rest on top of it (depends on resolution of graphical representation more or less above the representation).

To the my last post about the controled-box. However it seems unbelievably it seems that only Box can enter Sphere. Moreover if sphere is created at (0,0,0) with no rotation and box is trying to break in  from the plane (z = 0), then sphere seems to be open from -45 degrees to 135 degree and closed(I can get in there) in the rest hemisphere (135-315) (if 0 degrees is at direction (1,0,0)).

This fact definitely convinced me that fault is somewhere on my side, I should maybe try to checkout the project again…

That's really strange. Please double check that you really have the classes and natives from cvs, as I really cannot imagine much things that should cause such differences. A single thing that I can imagine is floating point precision. Please try again after rebooting your system, as some apps alter the precision (esp. DirectX apps).

Hi Irrisor,

so it's as you said. I checkedout current version of jmePhysics from CVS and make a project from it in eclipse. It throws exceptionsUnsatisfiedLinkError: ODEJAVA_VERSION_get so I overwrite my odejava.dll (1 097 728 B) with that one in the project (589 824 B) and it works fine!

Thanks for your time…

I'm trying to use a Quad object that will be my kind of court. But my copied Sphere doesn't collide with Quad. See my simple code:

Vector3f rotate = new Vector3f(0F, 0F, -1F);      
      field = getPhysicsSpace().createStaticNode();
      Quad quad = new Quad("Quad", 1000f, 500f);
      TextureState ts = display.getRenderer().createTextureState();
      field.attachChild( quad );
      // now we let jME Physics 2 generate the collision geometry for our box

And my "ball":

    private void setupBall() {
       // second we create a sphere that should fall down on the floor - analoguous to the box from Lesson1
        ball = getPhysicsSpace().createDynamicNode();
        ball.getLocalTranslation().set( 0, 20, 0 );

Maybe the static node only works with a Box, is that correct? I don't need to work with a box, a Quad will be perfect for me. There's another plane format, like a triMesh, that work as a field?

Thank you.

The bounding box of a quad is… not really a box. I believe JMEPhysics and ODE don't work well without volume (maybe because of colisions).

Also, createPhysicsGeometry creates bounding box only for some primitives, and Quad is not one of them. But even if createPhysicsGeometry created a boundig box for your quad, it would still be an ultra-thin bounding box.

Check if you are getting this message in your log file:

no model bound:

If you do, try switching to a trimesh and use triangle accuracy.

If that fails, or if you don't get that message, try using a box (you can also use a box for physics, which is fast, and a quad for visual representation).

Hope it helps.