[SOLVED] Falling things

Hey guys, I have one problem here.
Here is my case: I have a table in house, then I place a thing on the table in the middle and it falls through it. And even the thing falls through the floor.
Both, the table and thing are rigid bodys.

Sometimes the catalogue on the table “disappear” and it’s really annoying.


So, how can I prevent falling things over objects?
Thank you.

Hey! First off: I like that screenshot because I can finally see the art style your game is going :slight_smile:

So you have two options:

  1. Don’t make it a physics body. Ask yourself if the user should ever be able to hit it away with something or some other physics effects (Note: You can also have it not physics until someone is dropping it from his/her hand, e.g).

  2. A) Turn on Physics Debug Mode which might help us in debugging (I have this pass through problem when objects are to fast, even though I already tried to mess with ccdMotionThreshold).
    B) Don’t place it in the “middle” of the table, as then it has already passed the table collision. Place it so it’s certainly on top. If I’m placing npcs I always put them a few centimeters above ground and they just drop down. that way I am sure they are on top of the floor

1 Like

Thank you very much :slight_smile:

  1. This is a genius idea. I don’t know why I didn’t it.

  2. I thought so placing it on top in the middle of the table, but I decribed it bad. Changing position didn’t help too. Placing it right on the top or few centimeters/milimeters above ground and still fell through.

Important Takeaway definitely is: As a GameDev you have to fake many things. Even when using physics for such a book would be more correct, most of the time you don’t need it and can hence save performance and inconsistent states.

But note that in 1) the book might still fall through the floor

1 Like

I already did few things that way.
You never exactly know what happens when you click on the play button, you only think. :smiley:

1 Like

If its falling through both the table and floor, are you sure you are adding the RBC to the “thing” before adding the “thing” to the physics space?

Yes, I’m sure. Here is the code:

 Spatial thing = assetManager.loadModel("Models/things/thing.j3o");
 RigidBodyControl thingMesh = new RigidBodyControl();
 thingMesh.setMass(1);
 thing.addControl(thingMesh);
 getPhysicsSpace().add(thingMesh);
 rootNode.attachChild(thing);

It still sometimes falls and sometimes not. I can set any conditions.

Nothing wrong with that.

Show an image with debug on like DarkChaos suggested.

Would like to see the whole code for the “thing” being added and the “table” also, including translations and geometry creation.

This is just a guess but did you add a triangulate modifier to your book before exporting? The book needs to be a triangle mesh.

Would it even render if it wasn’t a triangle mesh?

Yes.

Edit: I should say yes, but I don’t know if Ogre or the SDK Blender importer does something in the background upon export, import.

I don’t think OpenGL can even render non-triangular meshes (with the exception of lines and points, if those modes are set) without it being corrupted. If you render a mesh that was non-triangular in Blender I’d think that either the exporter or importer is triangulating it.

Yes, objects show as triangulated when viewing with wireframe mode on so must be happening like this.

1 Like

Hey guys, thank you for your advices.

Spatial thing = assetManager.loadModel("Models/things/thing.j3o");
RigidBodyControl thingMesh = new RigidBodyControl();
thingMesh.setMass(1);
thing.addControl(thingMesh);
thingMesh.setPhysicsLocation(new Vector3f(5, 1.005f, 2));
getPhysicsSpace().add(thingMesh);
rootNode.attachChild(thing);

That’s exacly my code. I copied the code from the table and did only rename so you can be sure the table is done the same.

I never use triangulate modifier in Blender. And I haven’t any problems before.
I’m now recording a video how it falls. I will upload it in few minutes.

Here is the video:

Try something like this,

        //Book
        Node thing = (Node) assetManager.loadModel("Models/book/book.j3o");
        thing.setLocalTranslation(new Vector3f(5, 1.1f, 2));
        RigidBodyControl thingMesh = new RigidBodyControl(1);
        thing.addControl(thingMesh);
        getPhysicsSpace().add(thingMesh);
        
        rootNode.attachChild(thing);

Set the translation before adding the RBC and set it .1 above the table. It looks lie you are to close to the table top setting it 1.005. Notice its vibrating.

1 Like

After 3 more seconds same sh*t happend :smiley: :joy:

Your books physics space is larger than the book. Its actually inside the table if you look.

https://jmonkeyengine.github.io/wiki/jme3/advanced/physics.html#changing-the-scale-of-a-physicscontrol

1 Like

Yeah but it’s weird that the Shape does not match. And you have to place it above, but it looks funny I have to admit how it dances

1 Like

I think he may of not applied scale before import?