Jump to content

Physic position/rotation


Recommended Posts

deja vu!  :)

Steve, I think it IS impacting, but having a pair of update calls in the render loop... is just killing your ball speeds.


I moved the sphere to the outside and raised it, backed the camera out, did some other minor tweaks, and NOP'd lines 60 and 63.  Ball drops fairly fast, lands atop the now-not-updating impostor cube... all as-expected.

Now de-NOP 60 and 63, RUN again.  Believe it or not, the sphere is dropping.... but... oh so slow, at least on my box.  I noticed the same issue, earlier today, over in another thread.  UpdatePhysicsBodyPosition(), inside the render loop... is slooooooow for the physics.  I bet the ball IS bouncing-around inside the cube.  (at speeds beneath what our eyes can detect) :)

scene.createCompoundImpostor might be a better way to make the 6-plane physics cube.  Line 35 is NOP'd, so cube doesn't have physics state, but you try to update its physics body.  To make that method work, you might need to updatePhysicsBodyPosition on all 6 planes, instead.  Not sure.

Even if cube WAS physics-active, I doubt that cube.updatePhysicsBodyPosition would propagate down through the cube's children.

Ok, that's all I have.  I could be wrong.  Cool demo... interesting test.

Link to comment
Share on other sites

Yep.  It all sounds easy, eh?  Physics-active sphere inside of 6 physics-active planes, easy.  Impulse the sphere around, easy.  Somehow attaching those 6 planes together so they can be rotated as a whole... harder.


hehe.  That looks painful.  :)  More fun ahead.

Physics engine says:  "Do I LOOK like I care if something is parented to something else?  pfft"  heh

It sort-of makes a person want to cheat... by orbiting the camera around the box, and constantly adjusting the down-vector of gravity to match the down-vector of the camera.  :D  If not strong enough to flip the world upside-down, just stand on your head.  A different kind of "work-around".  heh

Link to comment
Share on other sites

Nope, that's working.  UpdatePhysicsBodyPosition updates both position and rotation, I hear.  I think it gets its rotation values from mesh.rotationQuaternion.  In my version of your demo, you will see some Euler to Quat massaging I did, in your animator.  :)  Then my dog threw-up.

Think about it.  UPBP updates the localSpace rotation of a wall panel.  The physics engine has no clue that this plane is a member of a cube.  (and so it's worldSpace rotation and position must be maintained... relative to a parent).  Physics engines don't care about parents/children (apparently).  In order to get all 6 planes to "act" like a single box to the physics engine, it has to be given a "master" physics impostor.

There are only two ways to get a master impostor for cube...

1. set its physics state and then somehow get 6 planes to child to it (as far as the physics engine is concerned, a physics engine which ignores .parent property).

2. compoundImpostor from the 6 planes, and then maybe use THAT compound... as the impostor for cube.setPhysicsState( {impostor: here...})

BUT... the physics engine might see the 6 planes as a closed volume.  If you have tested putting balls in standard boxes, you know that the physics engine rejects those balls with great energy.  :)  Physics engines seem to constantly try to avoid mesh overlap.  So, even with a 6-plane compoundImpostor, the physics engine might try to eject the ball... seeing it as overlapping mesh.  *shrug*  I could be wrong.

@RaananW ? :D

We need a term, here.  The act of a solid physics object... ejecting another physics object (because of mesh overlap)... what should we call that?  I'm thinking pVom.  Maybe PV.  Physics Vomit.   :)   Pushout Vector.  Privacy Violation.  heh

Link to comment
Share on other sites

as wingnut said, mesh.updatePhysicsBodyPosition is also taking the quaternion rotation into account. The minute the impostor is set, you need to use this variable and no the rotation variable. you can always use the mesh's rotate function, which changes the quaternion internally.

BTW, I just pushed a small change to 2.4 - the mesh has now a new function - updatePhysicsBody() which is the same as the old updatePhysicsBodyPosition, to avoid the confusion.

Wingnut - first I hope your dog is fine :) 

To make a ball move INSIDE a box, use the mesh impostor with a double-sided mesh. I made a demo with a sphere - http://www.babylonjs-playground.com/#1SZYKZ#13 , but doing that in a cube is simply changing the mesh type - http://www.babylonjs-playground.com/#1SZYKZ#14 . click on the box, the balls will start shaking inside. fun fun fun!

Link to comment
Share on other sites

You rock, Captain Steve!

Mind if I ruin it's simplistic beauty?


:)  Just goofy!  1.1 on both restitutions... is about all it can handle.  heh

I should REALLY learn to use the particleSystem.updateFunction feature, instead of wedging onto the prototype like that.  *shrug*

http://www.babylonjs-playground.com/#1FXRWT#3 There, that's better.  :)

I suppose the particle trail... should rotate with the box, eh?  *sigh*

Link to comment
Share on other sites

Oh, now, SEE?  I didn't even CONSIDER keeping the 6 sides together with physics LINKS!  I'm thinking compound, I'm thinking parenting, but I forgot all about linking.

Damn.  10 years, Raanan!  In 10 years, I'm going to be as smart as you.  Would you mind stopping your learning for a decade... while I catch up?  :)

Notice how I tried to use meshImposter with Oimo, yesterday?  sigh.  I'm an idiot.  :o

Link to comment
Share on other sites


The sphere is a box, the box is a sphere, everyone is confused!

"Weebles wobble but they don't fall down."  (even with 100,000 friction on both surfaces)

Fenomas taught us about this, though.  He said (loose quote)... "SphereImpostors ain't gots no friction, cuz theys gots no surface area"  :)

The Weeble stick inside the sphere... is a sphereImpostor... and thus it can't get enough friction... to tumble.  weird.

I was going to put egg-shaped sphericals inside, but that requires meshImpostor against meshImpostor, and that doesn't work.  Only sphereImpostors are allowed to interact with meshImpostors, so far.

Link to comment
Share on other sites

Ok, so, a snow globe.  hmm.

Well, we need to tip-over (invert) a snow globe, so... Step #1, we need a decent drag-rotater for a mesh.  Amarneethi recently asked for the same, and built a pretty good one in this thread.  Then Nockawa visited that thread, and wrote this beast.  I, of course, stole his code... and wedged it into YET ANOTHER rocks-in-a-box demo.  Yay!  Shift key is active in Nockawa's rotater.  Holding it while dragging... changes axes.


It doesn't work real well, but considering I don't understand Nockawa's code much at all, I guess I shouldn't complain.

See that gruesome line 124?  I actually had to research that, and compose that line myself.  There was no place to steal good code-from!  And therefore, THAT line is probably why this box-o-rocks works only marginally.  heh

Of course, my dog ran under the bed again, whimpering, when I started typing it.  :)  What a thin-skin.

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.

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.


  • Recently Browsing   0 members

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