LiquidSebbey Posted November 23, 2015 Share Posted November 23, 2015 Although I made quite some friction (see source code when running) some balls keep rolling untill they fall off.I want them to break faster... http://members.upc.nl/s.kimpe4/candy/ (sorry for the 320x240 upscaled low-res display, its too keep things smooth for now Quote Link to comment Share on other sites More sharing options...
fenomas Posted November 23, 2015 Share Posted November 23, 2015 You need air friction. (Ground friction doesn't stop spheres from rolling.) There was a thread about this a while ago - I think the conclusion was that oimo doesn't have air friction, so you may need to manually lower each body's velocity. (by multiplying them by 0.999 or whatever) Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 23, 2015 Share Posted November 23, 2015 Hi guys! Welcome to the forum, LiquidSebbey! There might be another way, but it is SUCH a ridiculous demented way, that maybe I shouldn't say it. Raanan was recently able to get Oimo heightMap/displaceMap physics activated (thx R!)... and thus you can set the roughness of the ground plane (go high subdivs). It would likely require "generating" a 2D image buffer (a dynamic texture)... maybe setting alternating colors per pixel. Maybe a pattern like #000, then #111, then #000, then #111, staggering each row of pixels so that there is never a #000 adjacent to a #111. In other words, black, dark gray, black, dark gray, etc. Once the texture is complete, use it as a physics-active heightMap. This will give SOME resistance to sphere roll, I would think. But... it also might make the sphere vibrate a bit as it rolls. And it also might not work at all. AND, it would need to be a very high resolution ground plane... lots of subdivs. This idea is probably implausible, and certainly far more complicated than Fenomas' idea/solve. But, I thought I'd mention it, and see if anyone wanted to do some experimenting or commenting. Be well, guys! Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 23, 2015 Share Posted November 23, 2015 Hey people, I really liked the "air friction" idea. I actually thought the physics engine do that internally, but I never tested. What a surprise... So, here is my suggestion - http://www.babylonjs-playground.com/#OJVVA. This is very prototypical, and should be improved. a LOT. but, it is working @Wingnut, my first idea was also a heightmap. something rough, like a grass texture that will keep friction always working. but that would require a lot of computation (i can only assume). I will give it a try thou, I think it might be a nicer solution. bill barsch 1 Quote Link to comment Share on other sites More sharing options...
LiquidSebbey Posted November 23, 2015 Author Share Posted November 23, 2015 Thanks wingnut for welcoming me to the forum ..-> Isn't there another way of smoothly stopping those candies from rolling as a alternative way? The air-way seems legit, but not supported by oimo and the height map seems to take a lot of unnecessary resources/computation. Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 23, 2015 Share Posted November 23, 2015 Wow, height map - working rather well :-) http://www.babylonjs-playground.com/#OJVVA#2 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 23, 2015 Share Posted November 23, 2015 Thanks wingnut for welcoming me to the forum ..-> Isn't there another way of smoothly stopping those candies from rolling as a alternative way? The air-way seems legit, but not supported by oimo and the height map seems to take a lot of unnecessary resources/computation.You are right. but oimo/cannon would probably calculate it the same as what I was doing in the first example (I can only guess). Dividing 3 number * numberOfBalls each frame should not cost too much CPU time, and, if it works, why not use it... It is a simple hack. I didn't dive into the engine's code to check if and how they do it, but it seems like they ignore friction when a constant connection has occurred. Quote Link to comment Share on other sites More sharing options...
LiquidSebbey Posted November 23, 2015 Author Share Posted November 23, 2015 Wow, that height map is awesome!!Thoughts about my first tv! But the grain heightmap keeps the balls only now running on the white spots i guess? (they keep 'alive')? Wingnut 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 23, 2015 Share Posted November 23, 2015 Yep, they seem like they never settle.... interesting :-)This are all just experiments, we are learning with you.Something I wrote on my last post made me wonder - the friction is used with every contact, but not with every constant contact. So, technically, if we have a lot of boxes, small ones, that will created a single visible ground, the friction will be calculated with each transfer between boxes.http://www.babylonjs-playground.com/#OJVVA#3Careful, very slow, as it created 30*30 ground boxes. But, it works... Now it should be optimized for your needs .I still like the first implementation - check if the balls have a velocity, divide it in a constant each frame, and you got yourself "air friction". Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 23, 2015 Share Posted November 23, 2015 Maybe Oimo needs a rigidBody.sleepThreshold value (not invented yet, I suspect). *shrug* Oimo sees these guys as active... and thus won't sleep them... I suspect. (duh, Wingy?) Thanks for the test PG's, Raanan! Quote Link to comment Share on other sites More sharing options...
fenomas Posted November 24, 2015 Share Posted November 24, 2015 (tap tap) Is this thing on? Folks, ground friction does not slow down a rolling (ideal) sphere! If you find a way to make it do so, I think it's a bug in the physics engine. Reason: typical physics engines only model sliding friction - the friction of one surface sliding along another. When a sphere is rolling, it's like a car tire with good traction - the sphere's surface and the ground are not sliding relative to each another. The only friction that applies then is rolling friction, which comes from factors most engines don't model (molecular forces, imperfect surfaces, etc). So unless someone implements rolling friction in oimo, air friction is really the answer here. Air friction force is proportional to velocity, so the easiest approach is to just apply a force to every body, equal to its velocity times some small negative constant. Vousk-prod. and jerome 2 Quote Link to comment Share on other sites More sharing options...
jerome Posted November 24, 2015 Share Posted November 24, 2015 Really smart explanation. Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 24, 2015 Share Posted November 24, 2015 So unless someone implements rolling friction in oimo, air friction is really the answer here. Air friction force is proportional to velocity, so the easiest approach is to just apply a force to every body, equal to its velocity times some small negative constant.yep, I agree with you (no reason to speak so loud :-) )This is why this solution (very prototypical) will work wonderfully (cannon.js code):var factor = 1.01;scene.registerBeforeRender(function () { meshesBodies.forEach(function ( { b.velocity.x /= factor; b.velocity.y /= factor; b.velocity.z /= factor; });});This simplifies the entire process, and might not be 100% correct. But, then again, so does thinking all physics-bodies are spheres or boxes... Quote Link to comment Share on other sites More sharing options...
fenomas Posted November 24, 2015 Share Posted November 24, 2015 Didn't mean to be loud. Just specific. I mean, I don't know anything about oimo.js - it might already have rolling friction, or some other feature like stickiness, in which case what I said doesn't apply. Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 24, 2015 Share Posted November 24, 2015 Didn't mean to be loud. Drop the mic Naa, just kidding. I just like the "tap tap" thingy. I havne't checked Oimo thoroughly, but I doubt this would not be a visible feature, if it was already integrated. If anyone else knows, would be wonderful to get an answer. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 24, 2015 Share Posted November 24, 2015 What's the issue, Fenomas? The bumpy ground test doesn't use friction whatsoever, and doesn't claim to. When I suggested rigidBody.sleepThreshold... I was speaking about the continuous movement seen on the bumpy ground demo. Let it be known that we all hear you when you teach us about sphere ground friction... and so far, it seems we all agree with you. (and thanks!) That doesn't mean we're going to quit trying methods to fake it, though. jerome 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 3, 2016 Share Posted January 3, 2016 Ahmm.... I don't mean to revive an old thread, but! Cannon.js has this feature integrated already. It is called linear damping. You can see how to use it here - http://www.babylonjs-playground.com/#OJVVA#5 , line 30. This will create a certain "friction". Setting this to "0" will create no constant friction. angularDamping does the same for rotation. Hope this will help someone Quote Link to comment Share on other sites More sharing options...
Tomm Huth Posted December 1, 2017 Share Posted December 1, 2017 @RaananW where has these two settings gone now? I can't find it reference anywhere? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 1, 2017 Share Posted December 1, 2017 On 11/23/2015 at 8:33 AM, fenomas said: You need air friction. (Ground friction doesn't stop spheres from rolling.) That's called drag, Ohhh my this is a 2 year old thread... nevermind I'm out of this one. adam 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted December 3, 2017 Share Posted December 3, 2017 https://www.babylonjs-playground.com/#OJVVA#18 (fresh playground) http://schteppe.github.io/cannon.js/docs/classes/Body.html (linearDamping & angularDamping, halfway down the parameters list) ----------------- For Oimo... hmm. You can do the "Raanan's Leather Boot" maneuver. He rubs his big fat work-boot... against the rolling mesh... like this... scene.beforeRender=()=>{ sphere.physicsImpostor.physicsBody.linearVelocity.XXXXX(.95) } // .05 'bootons' of linearDamping I don't understand the "syntax" of the two "scale" things allowed for Oimo Vec3 class objects. But here's what Wingy's bad Oimo api says... public function scale(v:Vec3, s:Number):Vec3 { or public function scaleEqual(s:Number):Vec3 { If i were to guess, I would say ... set XXXXX to scaleEqual. End result: scene.beforeRender=()=>{ sphere.physicsImpostor.physicsBody.linearVelocity.scaleEqual(.95) } (no promises, just speculation) Raanan's Leather Boot - "Oimo sphere brakes that YOU can count-on!" (guess) RaananW 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.