Sign in to follow this  
amo yeh

physic joint with angle limit

Recommended Posts

I made a ragdoll experiment http://www.babylonjs-playground.com/#8PQK71

is it possible to add angle limit to make it more realistic?

for example to make elbow bend forward only, and upper arm to bend up and down and foward only.

also, the PointToPointJoint joint seems works better on cannon.js engine, (more like hip & thigh from my experiment)

thanks for the help~

Share this post


Link to post
Share on other sites

Hi!  I'm no expert, but Oimo hinge joints have a limit motor.

https://www.babylonjs-playground.com/#8PQK71#1

No major changes, but in line 145, I output hJointR2._physicsJoint... to console.

Go to browser console and click on the word Object.  Did an object inspector launch?  If so, you can scroll-down through properties... and find limitMotor object.

THAT object has angle, lowerLimit, upperLimit, assorted other crap.  I don't know how to use those things, but I think that would be the area-of-interest.

You might wish to do this same type of object-inspecting... with your point-to-point joints... see what adjustable things are on those, too.

I have a badly-done Oimo API doc... here.  http://urbanproductions.com/wingy/babylon/misc/j2h02.htm

Do in-document search for public var limitMotor:LimitMotor;

SECOND (2nd) hit is for hingeJoint.   (1st hit is for prismatic).

I THINK this is the way to set Oimo hingeJoint angle limits.  Not sure about Cannon hinge joints. 

No promises, and sorry I don't have a playground demo to show.  Love your raggy!  Good luck.  Others may comment soon.

Although you CAN simply do... hJointR2._physicsJoint.limitMotor.upperLimit = [whatever], you may be allowed to use nativeParams feature, instead/too. 

In lines 158-161 of this playground, you can see some nativeParams being set for a joint.  I'm not sure if it works, but you could try a native parameter of...  limitMotor.upperLimit: 0.3,  (an example).  I have never tried using something.something within a nativeParams block, nor have I seen others do it.  But maybe.  Holler if you have questions or discoveries.  Thx.

Share this post


Link to post
Share on other sites

My pleasure!  You should also look at the OimoJSplugin object.  Down near the bottom, there are some funcs... setMotor() and setLimit().

In fact, it might be wise to just do a playground search for 'motor':)

There's also a thing...   joint1 = new BABYLON.MotorEnabledJoint(BABYLON.PhysicsJoint.HingeJoint, jointData);  *shrug*

I found that... remarked-out... in some guy's messy demented experiments with lockJoints.  A playground search for 'BABYLON.MotorEnabledJoint' returns 11 hits, so maybe you can figure how THAT is used.  :)  I think it is a shortcut... to avoid needing to call setMotor().  All these physics engines... have a BabylonJS layer, and a native layer.  Both layers work great.  The BJS layer is friendliest, but less powerful than native.  Both layers sometimes require many experiments.  Bye again.  :)

PS:  If you come across playgrounds that say "setPhysicsState is not a function"... then that playground needs all its setPhysicsState() calls... converted to the NEW way... seen in the above working physics playgrounds.  setPhysicsState() went deprecated about a year ago, and there are still many playgrounds that haven't been updated to the new way.  Sorry for the inconvenience on that.

Share this post


Link to post
Share on other sites

Limits limits limits!

Well, Wingnut's suggestions is the best suggestion, if youare planning on using motors. Those limits are for the motors, but not for the object itself. 

You can, however, set a min / max values to each joint which will limit it's functionality. Here is a quick example:

http://www.babylonjs-playground.com/#8PQK71#2

Lines 129 and 150 are the interesting parts. 

Share this post


Link to post
Share on other sites

Ah ha, there ya go.

Thanks for the correction, @RaananW, and thanks for the new demos, guys. 

My apologies for sending you on a wild goose chase (telling you incorrect info), AY.

I have lots to learn, yet.  I need a better oimo api doc... or a better brain.  :) hmm.

Thx agn, guys.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.