Jump to content

Babylon/Physics: Angular drag?


Hazardus
 Share

Recommended Posts

This is my 1st post here, so I want to say that I've been working with Babylon JS for the past week or so and I have been really happy to see all of the community support - particularly from the devs. Usually I don't touch a 3rd party software, *especially one backed by Microsoft*, given their history of questionable coding and not sticking to standards. In any case, deltakosh and RaananW, you guys are doing some awesome work!

 

One thing I'm having trouble with is the physics.. or lack thereof. I cannot seem to find any atmospheric physics in Babylon, Oimo, Cannon, or any other js physics engine for that matter..

 

Take for example, a sphere rolling on a plane: the sphere rolls forever as there are no atmospheric forces at play (pressure, wind) and the point of contact to the plane is so small friction has no effect.

 

Am I missing something? I saw another post on here dealing with it in code, and I could write my own I suppose, but is there anything built-in that will gradually stop that sphere?

Link to comment
Share on other sites

Hi!

Thanks for your feedback on our little baby. Even if we're working for Microsoft, we're not that evil ;) and it's now as much out project and our great community's project also.

Temechon is our physics expert who wrote the oimo.js plugin. As far as I know, the physics engines we're using don't expose the feature you're looking for. Temechon will confirm that. Generally speaking, it's really difficult to map c++ physics engines feature to JS for performance reasons as we don't have multithreading capabilities in JS (workers are too limited).

David

Link to comment
Share on other sites

http://playground.babylonjs.com/#1FR0VN#9

I have 25000 friction on the green wireframe sphere and 20000 friction on the ground... and the green sphere "mallet" just rolls and rolls and rolls. 

It's almost like friction for sphere imposters... is non-existent. Or maybe ground friction is the failing part.  Read on, please.

Welcome to the forum, Haz... you have found an interesting anomaly.  I will do some more tests when I have a moment, and I hope everyone else does tests, too.  I'm not sure our ground friction is working at all.  An earlier test in that series... did prove that sphere-to-sphere friction was operating.  http://playground.babylonjs.com/#1FR0VN#5  (used for this thread)  The spin on the green mallet causes the red sphere to deflect leftward.  Good friction affect.

It's the same small friction contact point as used for sphere-to-ground friction, but the red sphere deflection shows that there is still plenty of friction affect.  That's why I suspect there is a sphere-to-ground problem/bug.

Speaking of affect, I am a person who is VERY sensitive to corporate influences on community projects... and Haz... there is no friction there, either.  :)  If Microsoft is involved in Babylon.JS, it's truly insignificant.  The Microsoft kids that help dev BJS as a hobby... actually strive to avoid corporate influencing... not JUST from MS, but from ANY corporate entity.  If there is corporate influencing happening to BJS... you'll be hard-pressed to find/feel it.

Nope, the biggest danger around here... is Wingnut's forum posts.  Those things can suck the life-force from anything that gets too near.  :)

Link to comment
Share on other sites

I have 25000 friction on the green wireframe sphere and 20000 friction on the ground... and the green sphere "mallet" just rolls and rolls and rolls. 

 

Don't blame oimo folks, blame physics. Ground friction doesn't stop spheres from rolling, it causes them to roll (instead of sliding). If ground friction wasn't working then the sphere would just slide across the plane without spinning.

 

If you want a sphere on a plane to slow down, what you're looking for is drag, aka air friction.

Link to comment
Share on other sites

Don't blame oimo folks, blame physics. Ground friction doesn't stop spheres from rolling, it causes them to roll (instead of sliding). If ground friction wasn't working then the sphere would just slide across the plane without spinning.

 

If you want a sphere on a plane to slow down, what you're looking for is drag, aka air friction.

 

Exactly. As mentioned in the OP, *the sphere rolls forever as there are no atmospheric forces at play (pressure, wind)*.

 

I was messing around with materials when I created this scene and discovered it:Ou3CwwI.jpg

 

I googled around and saw the physics issue, but I didn't know if maybe I had just missed something in the source code that would yield the same results.

 

Interestingly, if you create multiple spheres with physics applied simultaneously and with restitution, they spring into the air *vertical space* exponentially before stacking one on top of the other in a perfect line (it's quite a site to see!') :lol:

 

__

 

@dravous and @wingnut: I appreciate the insight. This software really is great (wow, I haven't been able to say that about MS since Win7 ;)). I may even contribute to it before long - there's nothing even close to how powerful BabylonJS is.

Link to comment
Share on other sites

hahaha... yeah, I've seen a giant stack of balls... and the bounce oscillations that can travel up/down the stack.  It's marvelous, eh?  Have you gotten to play-with physics "links", yet?  U have now.

 

That demo stutters in my Firefox FF 39... looks like a garbage collection every 2 seconds.  Not sure why.  It might be something in one of the 1100 other windows I have open right now.  :)

 

In IE... it's as smooth as silk.

 

Sorry for misleading you about friction, Haz.  Fenomas totally blew my mind with his comment.  What he said was absolutely ridiculous and absolutely correct.  heh.  Ahhh... gotta love it.  Yeah, BJS and the physics engines... and the people... are great around here.  Yep, show us your playgrounds and toys, Haz... and teach us what you learn, if you please.  Your code will be part of the framework in no time... I bet.  Party on!

 

What's that?  Another, you say?  Ok fine:)

Link to comment
Share on other sites

Maybe I am naive here, but couldn't the OP get the desired effect simply by applying a small force in opposite direction to the movement vector and with a value directly proportional to the current speed? That would fake drag, no?

 

Yep, but the force is small and scales with velocity, so in practice I just multiply every object's velocity by 0.995 each frame, or something along those lines.

Link to comment
Share on other sites

Yep, but the force is small and scales with velocity, so in practice I just multiply every object's velocity by 0.995 each frame, or something along those lines.

 

How can I adjust the object's velocity? I can locate moving meshes just fine, but I'm unsure how to intercept the upcoming positions.

Link to comment
Share on other sites

How can I adjust the object's velocity? I can locate moving meshes just fine, but I'm unsure how to intercept the upcoming positions.

 

No idea, I use my own engine. Can someone who knows oimo.js comment?

 

(I'd say "check the API docs" but I don't think they exist - which is partly why I use my own engine..)

Link to comment
Share on other sites

What do you need from me ? Velocity is detailed here: http://pixelcodr.com/tutos/physics/physics.html

 

You know, I've spent many hours in the docs and never stumbled across your site. This link should really be more prominent.. right now, the Oimo chapter (http://doc.babylonjs.com/tutorials/11._Using_the_Oimo.js_Physics_Engine) points only to http://blogs.msdn.com/b/davrous/archive/2014/11/18/understanding-collisions-amp-physics-by-building-a-cool-webgl-babylon-js-demo-with-oimo-js.asp. While useful in it's own way.. your link should really be added to chapter 11!

 

Thanks for the response. I noticed 'scaleEqual' while looking through the source - now I know where to apply it!

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