Jump to content

[oimo.js] weird falling behavior


saltemishel
 Share

Recommended Posts

Hello,

 

Has anyone experience the following weird falling pattern using oimo engine? Also, is there a way to make the imposter to ignore the gravity other than setting the mass to 0?

 

this is when the pivot is right in the center, it's not falling smoothly instead it's falling like a staircase.

https://www.dropbox.com/s/e07n9vx5ytcrtn5/centerpivot.mov?dl=0

 

and when I offset the pivot, it'll make a flip before falling down, and some times it just snap to the side for around 3-5 times before it starts to flip to drop down

this.mesh.setPivotMatrix(BABYLON.Matrix.Translation(this.width*0.5, 0, this.depth*0.5));           

https://www.dropbox.com/s/odb4r9vks5a5j5v/pivotoffseted.mov?dl=0

 

the only physics codes that I'm using is as below:

this.scene.enablePhysics(new BABYLON.Vector3(0, -0.1, 0), new BABYLON.OimoJSPlugin());
 

this.body = new BABYLON.PhysicsImpostor(this.mesh, BABYLON.PhysicsImpostor.BoxImpostor, {mass:0, friction:0.5,restitution:0}, this.main.scene);
 

before clicking I use this code to move the box.

this.mesh.position[this.moveAxis]+=this.speed;

after clicking I stop moving the mesh and use the following code to set the mass after clicking to make it fall

this.body.setMass(0.1);

 

Thanks

 

Link to comment
Share on other sites

Seems something wrong with your BoundingBox "info", its pretty straight forward a Box against Box, nothing exiting here, what leads to strange behaviors

https://doc.babylonjs.com/overviews/Using_The_Physics_Engine

If your models exported through a 3 Modeling Programs, make sure you apply Scale, Rotation.

You can also easy recompute the BoundingBox shrink it down etc.It dont even has to be a box.

 Here in this forum, are already good examples of that. 

Maybe also you found a serious bug, please share those 2 Models with your Scene in a playground! (Search this forum for how to)

 

Link to comment
Share on other sites

:)  Delegation time limit exceeded.  Delegation fails.  4th-string crew attempts assistance...

http://www.babylonjs-playground.com/#BEFOO#38

I don't know if this helps.  I changed box2 location slightly... with NO pivot point change.  (NOP-out line 25 to see that).  Without line 25, box2 stays on that corner about the right amount of time, then falls.  Seems normal. 

(Re-)Activate line 25... moves the pivot point forward and left a tiny amount... and box2 stays balanced much better.  Seems normal.  Pivot point = center of gravity.

I think Oimo has an issue with body.allowSleep (to avoid "Brownian jitter").  That jitter causes box2 to eventually fall.

Aside:  Is "pimp" a good abbreviation for physicsImpostor?  :o:D

Link to comment
Share on other sites

Yes, the setPivotMatrix is causing problems with the physics impostor.  There's no way that I know-of... to view the impostor.  I tried a box2.refreshBoundingInfo() just after the pivot adjustment, no change.

I DID find something in the BJS impostor source... https://github.com/BabylonJS/Babylon.js/blob/master/src/Physics/babylon.physicsImpostor.js#L30

setPhysicsBodyTransformation().  I did not try it.  Not sure how to use it.  I'm not very experienced in physics things... sorry.  I'll keep thinking... maybe try some tests.

It almost acts-like the impostor is sized incorrectly.  Perhaps it is transformed correctly (good position and orientation)... just too small.  Strange.  hmm.

Link to comment
Share on other sites

Hi, sorry for a late answer.

So! An interesting subject. Yeah, the physics engine is not taking the pivot into account. But I like it as a feature! Let me see how I can integrate it in the system. Maybe give the possibility to set the center of mass as well. Need to check if it's possible in all engines. Until then, try avoiding pivot matrix with physics. 

Link to comment
Share on other sites

Hiya @RaananW.  It's possibly a little worse than you might suspect. 

We're seeing stuff sink into the floor.... but not fall through. Did you see the post about "leverage"?  Well, in that thread/pg series, I saw the pushed-over tile (a mesh) sink into the floor... yet not falling through. 

If you can, use MY version of the demo (it's with an arcCam) for easier viewing.  The tile tips over, and lays there nicely... about 1 meter/unit below the floor... and that's without any pivot point setting. 

For easy troublehshooting, just set mesh.impostor.ghostMode = true... and you will "see" the impostor's ghostly image... pardon?  What's that?  No such thing as ghosted impostors?  Well hrmph.  ;)

Did you know that the official abbreviation for 'Physics IMPostor'... is now 'pimp'?  Let's try it out.

"There's no such thing as pimp ghosts."

Yeah, I like the sound of that.  heh    Anyway, enough attempting comedy.  :)

In THIS thread, a changed pivotMatrix seems to make the impostor be a different shape or size.  It seems that the impostor becomes a tiny cube or sphere positioned at the new pivot point.  SO, the impostor falls exactly halfway thru the floor... stopping only when the pivot point itself... hits the floor.  Strange.  :) 

Just for fun, here's the train wheel demo that Raanan helped build with me.  I really like it.  I went studying the Oimo/Ammo/Bullet worlds... to see if I could remove the wobble.  I can't seem to find a "joint tightener" property yet, but it's good reading... about all the different types of physics joints that folks have invented.

And look how "clean" those joint creation constructors are... in that PG.  That's SO nice... you can include Oimo "native parameters"... AS one of the many BJS parameters used in the constructor.  That... is hot hot hot, and Raanan's refactor of the physics plugins... let that all happen.

It might have a few glitches, but it is SO properly poised for the future... it's wonderful.  That boy knows how to code, no doubt about it.

More later... busy day for Mr. Wingy.  Good to see you again, Admiral Raanan!   Hope you (and everyone) are well.

Link to comment
Share on other sites

Hi @Wingnut, had some spare time and I decided to spend it on positive things :) So I came here!

The problem with the pivot is the way the physics engine calculates the position of the object. With a pivot, the problem is what happens when rotation is applied. 

I have been thinking about this quite a lot - I think the best way to have pivots pivots is using joints and setting the pivot axis correctly. Otherwise the object's rotation is applied wrong, and what you get is this fun : http://www.babylonjs-playground.com/#BEFOO#40 

The train wheel demo shows it very nicely (line 134). This is the equivalent of giving the red object a translation pivot, using a physics engine. So in this case, The physics engine wins over Babylon's native implementation.

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