Advice on Physics of FBX Import Model

My standard disclaimer over here is that I know nothing about any of this stuff, I apologize.

On the advice of Leonidas and Yaustar, I am learning Blender to create my gallery room into a single mesh instead of doing it this weird Minecraft-style primitive construction I used.

As a bit of a Hello World kind of thing I made a weird shape in Blender and imported it into PlayCanvas. I know I’m working toward getting the whole room built as a mesh but this was just a test since I’ve never used Blender.

The whole process went surprisingly well but can you take a look and see what I did wrong with the physics of the imported model? Not that that’s a big issue for my project, but I obviously did something wrong because this imported shape doesn’t move like it ought to. The best way I can describe it is that my imported model moves as if its calculated center of gravity is down below the floor in this scene. It’s like the collision mesh of the model is up in my room here, but the actual weight of it is connected by an invisible rigid arm down through the floor. If you kick it around a little in first-person view you can see what I mean and you can see how unlike the two native PlayCanvas primitives move in the scene when you kick them.

At the very least this model should roll over onto its heavier side.

The model I’m talking about is the red odd-shaped ball on the floor, you’ll see it.

What did I do wrong setting up the physics of this?

https://playcanvas.com/editor/scene/883888

Thank you for your continued support.

Scott

1 Like

Haven’t looked into the issue you are having but that room model is VERY high in the polycount and shouldn’t be used for physics and I don’t think it should be used for the render mesh either. Leonidas would have more practical advice here.

If you want to use a mesh for physics for a similar complex layout, it should be a lot simpler to make it less expensive for the physics engine to test against. I would even look at splitting the meshes by rooms and have them load/unload as you walk around.

1 Like

Thank you, yes, I’m remaking the room itself as a simple mesh as you advised last week.

During the process of remaking the room, as a test I first made that little red polyhedron in Blender and imported it into my room. I will remake the room but haven’t yet because I wanted to see if that small model would import.

All the other physics in that room work fine. The character works fine and the other two balls work fine. The one ball I imported from Blender works pretty well but it behaves as if its weight is not in the right place. But as far as the room itself goes (and I am definitely going to replace the room soon) it works fine with the physics engine because everything else in it works.

What I am noticing is that that one model imported from Blender behaves differently than everything else in the room which is native PlayCanvas.

https://playcanvas.com/editor/scene/883888

Hi @Scott_Boyan,

Edit: I realized that you have imported the level.json model from the FPS with touch controls project, but that’s not the actual model rendered in the scene.

As a first step could you try enabling batching in your scene? This will greatly improve your performance, even when using minecraft like cubes.

You can check here what is batching and how to enable it in your project:

https://developer.playcanvas.com/en/user-manual/optimization/batching/

Basically you will have to create a static batch group in your project settings and assign it to all of your building blocks. This will generate batches on runtime greatly improving performance.

@Scott_Boyan for your physics issue, which is the model you imported from Blender that doesn’t behave correctly? The only imported FBX model I see in the assets panel is the level.fbx

Hi Leonidas.

I think we may not be looking at the same thing because I deleted the level.json model many builds ago. I don’t see that model in there anywhere. The model I imported is called weirdthing.json.

I’m definitely going to remake the room in a single mesh and learn about things like batching. Thanks for the suggestion. At this point, the room performs surprisingly well though except for this one imported model. The actual performance of its movement seems smooth and appropriate, but its behavior is not appropriate. It behaves as if its weight is down below the floor.

https://playcanvas.com/editor/scene/883888

That’s strange, opening the link you provided leads to this scene:

This isn’t your current project?

No, that’s a very old one! I just grabbed the URL from the editor, did I do something wrong?

No you did everything right, that’s strange.

Invoking @will and @vaios to take a look at.

Are you in a branch @Scott_Boyan?

1 Like

I am in a branch, yes.

I am in Branch 001. That’s where the model weirdthing.json is. Maybe you guys were looking in the master branch?

For some reason, non project members can’t view non master branches.

Not sure if bug or deliberate :sweat_smile:

That’s weird. I’d be happy to add you to the project if that would help.

In any case you could walk around in here and see that the world performs alright, and the physics work for everything except the red model. That one behaves as if its weight is lower down than the model itself.

Hi @Scott_Boyan, indeed the behavior of the sphere like object is strange. Are you able to merge with the master branch so we can take a look on how it’s configured?

Sure. If I can figure out how to merge with the master branch I will, otherwise I will import the sphere-like object into the master branch.

I switched to the Master branch and reimported the .fbx. The json model behaves exactly like it did in the branch that I’m working on. The weight of it seems to be below the surface it’s sitting on, keeping it from ever rolling.

https://playcanvas.com/editor/scene/883888

Good, now this makes sense, the reason for that behavior is the pivot point (origin center) of your model not being in the center of the body mass:

As a result, making the physics engine trying to simulate the object around an offset center point. I’ve imported your model in Blender and set the origin to the center of the body mass:

Now the simulation is correct and the body behaves as expected. Though if you can handle less precision in your project do try out compound shapes, they will perform much better.

Here is the update project:

https://playcanvas.com/editor/scene/886491

Also, if you plan on having more dynamic or static rigid bodies use a Mesh collider, take note that these objects can’t interact.

Right now there is no mesh to mesh collision support in Playcanvas/Ammo.js

Wow, that is so cool!!! Thank you Leonidas! I haven’t got that far in the Blender tutorials yet because you guys only got me onto modeling last week. Thank you! I’ll definitely study setting the origin appropriately. That’s exactly what the behavior seemed like, as if the center of mass was not in the right place. I’m glad that’s something fixable in Blender before I export.

Thanks for the very good tip on the no mesh-to-mesh collisions! I am sure I would have been scratching my head over that one. No doubt!

This is stuff is so cool. I’m going to get the rest of my “gallery” set up this week.

I just imported the one you fixed into the branch I use and published it. It’s fun to knock it around in there. I made it kind of like heavy rubber.

1 Like