Jump to content

How do I get PhysicsImpostor to update along with animation?


Knight
 Share

Recommended Posts

I have a mesh imported from .babylon file, and it has its animations. I put MeshImpostor in, expecting it to update with the animation, but it's not. It seems like it uses the first frame as the reference to the collision detection. Is there any way to update it?

Code is something like this: 

var mesh = scene.meshes[0];

mesh.physicsImpostor = new BABYLON.PhysicsImpostor(mesh, BABYLON.PhysicsImpostor.MeshImpostor);

//I tried to force it update it too, but doesn't seem to work.
function update()
{
    mesh.physicsImpostor.forceUpdate();
}

 

Link to comment
Share on other sites

Physics objects don't participate in animations like regular meshes. You may need to .sleep() your mesh.physicsImpostor and then .wakeUp() after.  The wakeUp() will activate again the physics.  If you want to move a physics object and keep the physics impostor properties then you need to apply impulses.  Creating a PG might help.

Link to comment
Share on other sites

Hi guys!  Forum friend @Raggar did a little playground work with rag dolls. (press A key).

I think RAG dolls is how RAGgar got his name.  :)

And of course... there is Sammy Girardin's ragdolls extraordinaire... but his site is now "down". 

But before it went away, I grabbed zips of his ragdoll and crowd-pathing [crowd.zip] demos.  Here's the ragdoll demo:

http://urbanproductions.com/wingy/babylon/oldman/Oldman_onefile/onefile01.htm

Does that work for anyone but me?  I hope so.  Zip available

Sam gave me permission to republish, so there's no problems there, but PLEASE give Sam some credit if anyone uses his code/techniques.  His ragdolls use an older version of BJS, and all typescript files are included in zip.  It is NOT easy code for average people.  And, my onefile version has SOME minor issues (skybox lighting?), but no show-stoppers.

I like choosing x30, and then, after "the fall", click F button to the beat of ANY song.  FUN!  Shoot the Geeks FAR-into the air, and when they land, they get stuck in the ground.  THEN click F to the beat of a song.  TOO funny!  I ALMOST HAD-TO make a Fraps music video... from that.  Thank goodness I was too lazy.  :)

I think the version that is included on the BJS website... is broken.  I don't know if it is wise or right to re-target the BJS website link... to my onefile01.htm.  We should probably talk to Sam, first. 

I hope he's okay.  He hasn't visited in quite a while, and we haven't heard much news on his new EnergyJS physics engine... for a long time.  Usually, when a guy "goes missing" like this, it means he got a girlfriend.  That POOR POOR man.  We might need to assemble a rescue team.  :)

Perhaps we should use the dude.babylon armature-animation available in many PG (playground) demos, and try to "attach" a couple of boxImpostors to his feet, and see if we can kick a sphereImpostor.  See if we can make the impostors on each of dude's feet... move/track WITH his feet bones.  Beginner-level ragdoll testing. :)  Thoughts, anyone?

Bones are not really mesh, they are 'transformations', so we can't attach one end of a physicsJoint to them (with other end on foot boxImpostors).  We must attach the joints onto the skin-mesh... near the ankle, I suppose.  I'm not very experienced, but forum friend @fenomas tells us that it is best to use a physicsJoint between the force-moved mesh, and the physicsImpostor that is trying to be moved ALONG-WITH the moved mesh.  The physics joint serves as an "insulator" between the force-moved mesh, and the come-along impostors.  The physics engine is able to stay in-sync with its impostors... BETTER... this way... I hear.  I haven't experimented with that, yet.  The theory makes sense, though, and has likely been used by many other physics experimenters. 

Sidenote:  The "spring" feature of physics joints is an often-forgotten way to START physics animations, too.  Springs (and physics 'motors') "launch" physics things... quite well.  Catapults/Slingshots, 101.  heh

Link to comment
Share on other sites

Hey, @AndyBeaulieu just visited the forum again!  Hi Andy... good to see you!

Andy holds a place in our Offsite Tutorials List, and guess what.  Andy did some very early experiments with rag dolls and other physics stuff.

He has kicked some balls! :o  http://www.spritehand.com/2014/08/babylonjs-physics-and-character.html

Sure, he's got a stale link to our BJS docs, but we can overlook that, I suspect.  :)

Perhaps he will have a moment to comment.  Also, Andy, feel free to edit the Offsite Tutorials List in any way you wish. 

I hope you have been well.

Link to comment
Share on other sites

*nod*  Yeah, I'm not sure how ragdolls do their physics.  I was just tickled pink that SOMEBODY (you) got ANY kind of ragdoll working... in a playground.

But yeah, the initial post didn't mention any skeleton/bone animation.  Just animation.  I jumped to a conclusion that the impostor needed to track a bone transformation.

Yuh yuh yuh.  I need to pay more attention.  :)

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