Jump to content

[SOLVED] - Newbie Collision System Boxes Question


MackeyK24
 Share

Recommended Posts

From what i see in the debug layer, there is ALWAYS a bounding box around meshes. I assume this is the bounding box used for camera collisions against the camera.ellipsoid. My question is, If this is the case then how come ALL meshes wouldn't automatically have a 'SIMPLE' collision box WHY would you need to create a simplified mesh for collisions if every mesh automatically get a very simple bounding box.

 

Now i use a separate simplified mesh for terrains, so i understand the collision system being impacted by the detail of the terrain mesh. I even have support (in my BabylonJS Toolkit For Unity) the Mesh Collider component so you can more easily attach a simplified mesh directly on the game object (just as you would in unity) and it works great... I simply take the 'Simplied Mesh' and enable collisions on that mesh, set its alpha to 75% and isvisible to false. I then set it as the child of the original mesh and reset its transform (because it parented in original mesh). Looks good, works great for both terrains and everyday meshes... I just don't quite understand why i would need these separate simplified meshes IF simple bounding boxes for EVERY mesh AUTOMATICALLY get created and used for collisions ???

P.S. - Even though i wrote (what i think) is an awesome Managed Scene Component API and a KICK-ASS Game Editor Toolkit (almost ready)... I am still new to some of the 3D game concepts. That is the main reason i built the toolkit... was so i can use 'Unity' as my game concept learning tool... So if i want to make some kind of racing game... Ill go find some in-depth training on making a racing game in unity (follow all the tutorials) but use my toolkit to actually implement those concepts in BabylonJS.

So again... Sorry for the real newbie questions sometimes :)

 

Link to comment
Share on other sites

Hi people,

no, it isn't.

Babylon has an internal collision system with a simple collide algorithm. No physics is taken into account. This is a wonderful solution for walking on top of a surface or making sure you are not going through walls. This is why we have mesh.checkCollisions . 

The physics is on when you add an impostor to a mesh and enable the physics engine (actually in a reversed order :) . Enable first!). If you dispose the physics impostor, the physics collisions won't work.

The two systems won't really collide, unless you try really hard. Meshes won't constantly check for collisions between them (only if you use mesh.moveWithCollision) and camera's can't have a physics impostor attached directly to them.

Now, about the initial question (this):

22 hours ago, MackeyK24 said:

I assume this is the bounding box used for camera collisions against the camera.ellipsoid. My question is, If this is the case then how come ALL meshes wouldn't automatically have a 'SIMPLE' collision box WHY would you need to create a simplified mesh for collisions if every mesh automatically get a very simple bounding box.

The bounding box you see in the (new, amazing, wonderful, godly, 1337) inspector is just a standard bounding box. It is being used for many many things, but, surprisingly it's not being used for collisions. At least not in the sense you are describing. The ellipsoid is NOT the bounding box. Is is defined by you (and can be the same, if this is what you wish).

When calculating collisions between meshes Babylon will use the bounding boxes to check if the two meshes are anywhere near each other, but it will continue checking the meshes themselves. The physics engine will create a box impostor which is probably the same size as the bounding box, if you choose the BoxImpostor. But it won't constantly use the bounding boxes you see. If you rescale the mesh after creating the impostor, the bounding box will change, but the impostor will stay the same.

I hope it helps!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...