Jump to content

Showing colliders for dynamic meshes


altreality
 Share

Recommended Posts

Hi,

 

I saw this example where colliders are shown for static objects using :

 

    function onChangePhysics(id, event) {        if (!meshesColliderList[id].checkCollisions) {            meshesColliderList[id].checkCollisions = true;            meshesColliderList[id].setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, { mass: 0, friction: 0.5, restitution: 0.7 });        }        else {            meshesColliderList[id].checkCollisions = false;            meshesColliderList[id].setPhysicsState(BABYLON.PhysicsEngine.NoImpostor);

So basically a collision box mesh is registered for the walls etc & made visible. This is fine because the wall mesh itself need not be registered inside the physics plugin, as it does not move. So no position and quaternion need to be copied to it.

 

But if we consider the example of a moving train engine. The engine would have its own engine mesh, It would have physics enabled using a box impostor that roughly covers its volume. Internally the engine mesh is registered with the plugin. At each physics turn, the babylon physics plugin copies the position of a physics cube to the engine mesh visible to the user.

 

But then how do I register the physics impostor to itself be visible too ? If I make a babylon box mesh and register it with a box impostor, then how do I register the engine mesh. Inside the plugin we can register only one babylon mesh per physics object.

 

The babylon engine mesh and the additional babylon collider mesh(that's created solely for debugging), both need to be linked to the same physics cube inside the engine. Both need to be visible and moving in perfect sync.

 

I am thinking maybe I ll just parent/unparent the collider mesh to the engine mesh based on collider on/off by the user. But if there is a better idea then please let me know.

 

Link to comment
Share on other sites

Hi AR, good to hear from you again!  Um, I think parenting is exactly correct, and I used that method to do just what you talked about.  I use an invisble collider box that is as big as the entire vehicle, and parent the vehicle to it.

 

http://urbanproductions.com/wingy/babylon/thruster/t26/flyer26.htm

 

Hold down your mouse button on the Position +X button (or any other buttons) to fly the vehicle into the walls.  You'll see that the invisible box works quite well.  All the thrusters are doing their applyImpulse against that invisible box, too.  The vehicle follows along because it is the child of that box (like you talked about). 

 

The thrusting is done near the center of the box, and not where the particle emitters are located.  Some things are fake.  :)  This also allows other users of this flying machine... to place their particle thrusters anywhere on their models.  The flying machine is actually the invisible box.

 

Yep, I think you have the right idea.  I think it's wise to avoid using compound imposters for complicated models, if possible.  I don't know if you've played with compound imposters or not.  I haven't.  A single box is much easier, and I suspect faster.

 

I have rather limited experience with physics.  Hopefully, others will comment.  Be well!

Link to comment
Share on other sites

Ok, so, I was trying to stay un-interested.... but... I'm a rail fan.  Can I ask what you have for models?  Will they have animated wheels and maybe even moving pistons?  Will they be somewhat historically accurate? 

 

This is a pretty cool project.  Different.  And you could get famous... because the scene will be cherished as a historical re-enactment of something rather important.  There is a lot of opportunity in projects like this, and lots of other historical re-enactments that could be born, based upon this.

 

cool!  My questions are not high priority... answer only if plausible.  :)

Link to comment
Share on other sites

hehe so right now my model is a cube and cylinders for wheels :P  http://synth2014.github.io/Age-of-Steam/babylon/indexLoco.html

(keys: w forward, s backwards, d for dynamic braking, x/z for varying braking strength after d is pressed, b for simple brakes but is unstable at the moment)

 

I have got the logic for the track following done and am planning to put in a better mesh for the loco. Just getting familiar with Blender and the exporter.

 

The plan is to have steam engines for now and capture some of the famous engines of that era. I do intend it to be historically accurate and have some fun scenarios too. I will need to find a good simulation model that relates steam pressure with engine force. I am planning to allow cutaway views that allow visiblity into a running engine just like the combustion engine demo in the babylon samples page. But for that I will need to find a good simulation model that relates the steam pressure, piston position etc correctly. 

 

I simply use the cannon raycast vehicle for the actual vehicle itself.

 

lol there have already been re-enactments :

 

14603546.jpg

Link to comment
Share on other sites

Nice!  I grabbed your whole package with a "save entire webpage" option of my browser.  I hope you don't mind.  :)

 

This is some nice stuff!  RailVehicle.js is a work of art, and so is loco.js and WheelInfo.js.  This is quite a nice toolkit of train tools and physics.  Cooool!

 

When I first set out to rape your train project, I was going to simply add a few more cars onto your train, hook them together with physics links, and then drag them around your track circuit to see how much laughing it might generate.  But then I discover this real fine railroad-making kit you have assembled here, and it replaced my goofy mood with "holy crap!" mood.

 

I don't think I'm going to hook-up any rolling stock, now.  YOU should be the first to do that to YOUR loco, right?  :)  I'll watch.

 

There's some SERIOUS fun to be had, here.  No hurry installing advanced models, eh?  There is plenty of train physics toys to play-with, already installed!  Nice!  Thanks!  Keep me/us posted on what parts you're working-on, when you get time, ok?

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...