Small lib for creating ragdolls

Hello Necips! We can totally choose rotation directions with this lib. If the bone is rotating in a way that seems unrealistic, we can choose other rotation axes. In the examples I posted above, this is the ‘rotationAxis’ property in the config. We can also define rotation limits, with the ‘min’ and ‘max’ properties. But yes, the examples I gave could be more realistic (they were made in a hurry :cry:).

Now, rotation limits aren’t available for all the joints, and as far as I know, they’re only currently available if we choose OimoJS as a physics engine. However, I believe we can achieve something similar to rotation limits using other physics engines and/or joints. It’s probably gonna be a little bit tricky… but there are some tricks I believe could work, such as:

  1. Having some sort of callback after each physics step (something like the afterStep we see in the PhysicsImpostor Class) and reseting the rotation values if they go above a certain limit. I actually tried this, but failed miserably. But only because I’m super lazy… but hey, if there’s anyone out who really needs this, I can try it again :grin:.
  2. Another idea would be using some kind of stopper meshes. Wingnut talks about this method in some posts, like this one.

Another super valid criticism of this lib would be: well, if we’re using hinge joints (as in the examples I posted), we can only rotate in 1 axis… and there are clearly joints in our body that rotate in more than 1 direction (e.g. shoulder joint and knee joint). What if we want a joint that rotates in multiple directions AND has rotation limits like I described above?? For this issue, there are also some possible solutions:

  1. We can choose another joint that supports rotation in multiple directions (e.g. ball and socket joint), and use the rotation limit method I described above (using the afterStep in the PhysicsImpostor Class and adjusting angles when needed).
  2. Another solution would be using 2 or 3 hinge joints between bones (instead of just the usual 1 joint), and make each hinge joint rotate in different directions. Hinge joints already allow rotation limits (with OimoJS), so we’re good.

Ranaan talked about the afterStep physics solution and the multiple joints between bones solutions in this post.