Cannon mesh imposters

I am looking into babylon and am trying to use the mesh imposter for cannonjs physics. obviously it says “Cannon’s mesh impostor only collides against spheres and planes” but you can get mesh on mesh using cannon by itself (i am currently doing that with threejs)

Is there a work around for the integrated cannon, or do i need to handle physics manually with cannon outside of babylon and update everything manually, or just move towards ammo/oimo?

Pinging @cedric and @RaananW

This is just a warning, because cannon states that they don’t support it:

MeshImpostor (Trimesh) does not collide against another Trimesh. But if you are able to do it with three, you are able to do it with babylon. we don’t limit the physics engine at all.

I was not using trimesh i was just passing a shape into the CANNON.Body({ shape:physicsShape}) and that is how it worked when working with it in threejs

Am i doing it wrong? should i not be using a mesh imposter?

I am using the ConvexPolyhedron to set the physicsShape

@RaananW Does Babylon support that on Cannon?

Not directly.
If you create your own cannon impostors and update them yourself, it’ll work just like with any other framework.

Babylon offers s higher level abstraction of physics engines to make the integration easier. You don’t have to use it thou…

1 Like

Hi guys, sorry for butt-in. There’s a playground which has “brought-in” the Cannon plugin to the playground. It looks like someone wanted to modify part of BJS “higher level abstraction”.

Anyway, inside there, you can see the “connection” of BJS-level physicsImpostor to Cannon native object physicsBody. It is fairly easy to communicate with Cannon “native objects” including World and all world shapes, joints, etc… and observe broad/narrow phase ops… I think it is ALL exposed… once you know how to speak “native”.

So, anyone who knows of Cannon playgrounds that use lots of native calls… could you sling the urls here… for Wigen to borrow techniques-from. I was trying to think-up more keywords to search for Cannon native-heavy playgrounds-with, but… I couldn’t think of any. ooh, here’s a playground with the Cannon plugin AND the for-many-physics-engines BJS PhysicsImpostor class, also.

You can learn MUCH by studying the BJS CannonPlugin and BJS PhysicsImpostorClass. Don’t count-on the code in these playgrounds… to be “default” core code. I think the kids have been playing in there. :slight_smile:

Where’s @Raggar… he has some gruesome nearly-all-native-Cannon playgrounds in his toybox, I know he does. Got some URL’s, R? (thx)

Wigen - something tells me that activating meshImpostor-to-meshImpostor collisions… in CannonJS… might be a simple “switch”. It works by default… in AmmoJS.

Wigen… do you know about things like… collision FilterMasks and FilterGroups and that kind of stuff? It might be as simple as making sure both/all meshImpostors are members of the same collisionFilterGroup or mask. Another playground search.

It needs some deep investigating… but I think it is “near”, and maybe simple. (they ALL say that, eh?)

Ok, I hope I’ve been helpful, or at least noisy. :slight_smile:

Thank you @RaananW, i got a version working, i took the CannonJSPlugin and created a CustomImposter to create the ConvexPolyhedron bassed off of config values. and now its creating what i expect and colliding how i expect.

Thank you @Wingnut Thanks for the playgrounds, ill check them out! 2 reasons why i’m trying to get everything working inside of Cannon is that all of our code is based off of Cannon since we are switching from Threejs. And the size of cannon is so much smaller than Ammo. Ammo mesh imposter works for sure. its just that 1.7mb vs 130kb, it doesnt sound bad but every little bit helps what what we are doing.

and yup, already have all of the collision stuff set up . Thanks again!

1 Like

Unfortunately I’ve had some hardware issues resulting in a full drive-wipe. I’ve been able to recover my most recent project, but not my bookmarks and offline Playground links. 3TB is a lot to scan through, and it doesn’t help when I’m actively using the same drive :stuck_out_tongue:

1 Like