Jump to content

physic joint with angle limit


amo yeh
 Share

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~

Link to comment
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.

Link to comment
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.

Link to comment
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. 

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