Jump to content
  • Advertisement
Sign in to follow this  
d07RiV

Cone/angle joints in impulse method

This topic is 1156 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm actually more interested in the 6-DOF constraint, that lets me specify different ranges per rotation axis. Using the same method as in Bullet source, I got something that kind of works here: http://www.d3planner.com/webgl/constraint (Alt+click to drag objects)

However, the 'chain' demo is extremely unstable and the slightest shake can break it. I'm not sure if its due to lack of proper position projection, or just a bug in my code.

Share this post


Link to post
Share on other sites
Advertisement

I found the 6-DOF constraint a save way to shoot yourself into the food. I never really implemented it and I use specif joint types (e.g. spherical, prismatic, cylindrical, revolute and rigid) .But I think that is a matter of taste and I don't want to sound religious about that decision.

 

Either way I recommend starting with a specific joint type. E.g. spherical joint with cone limit and revolute joint with unsymmetrical limits are two good exercises. This is much simpler than starting with a generic type.

Edited by Dirk Gregorius

Share this post


Link to post
Share on other sites
Eh the whole point starting the engine was to simulate a small ragdoll, and its constraints are apparently expressed in the angle limits per axis sad.png

Share this post


Link to post
Share on other sites

You should be able to model a small ragdoll this way. Ragdolls are usually spherical joints with cone limits and revolute joints. Did you look at the angle limits? It should be fairly easy to convert this data. I have done this many times. 

Share this post


Link to post
Share on other sites
Actually there are lots of different possible ragdolls, but I guess I could simplify the limits to cones. Any tips on adding a twist limit, though? I'm afraid I'll run into the same issue as with the 6-dof constraint if I try to express it in terms of the other two (four) axes.

Share this post


Link to post
Share on other sites

It goes along the same way. Assume u is the axis pointing down the joint axis. You would now measure the twist using the orthogonal axes v1, w1, v2, w2. You just need to be careful that your swing limit doesn't exceed 90 degrees as you get problems with projections then. The twist is much more complex than the swing and I use a framework of quaternion constraints for that. I really need to publish this!

 

I have some sketches for a simple twist constraint following the same approach as described above. Let me look it up when I am home later today.

Edited by Dirk Gregorius

Share this post


Link to post
Share on other sites

Assume we have a joint setup like in the picture above for the swing angle and you look along the u-axis. You would see something along the line like this:

 

Twist.PNG

 

Let's call the twist angle between v1 and v2 alpha. From basis trigonometry we get:

 

sin( alpha ) = dot( v2, w1 )

cos( alpha ) = dot( v2, v1 )

 

I am a little rusty here, but iirc when frame 2 swings relatively to frame 1 then the dot products are of course not sin and cos of the twist angle anymore, but their ratio is the tan. Therefore:

 

tan( alpha ) = dot( v2, w1 ) / dot( v2, v1 )

 

From there we can compute the angle:

 

alpha = atan(  dot( v2, w1 ) / dot( v2, v1 ) ) and dot( v2, v1 ) != 0

 

In an implementation you would of course use atan2 so you don't need to check for dot( v2, v1 ) =0. From here everything goes like for the swing above:

 

C = atan(  dot( v2, w1 ) / dot( v2, v1 ) )  

 

Build dC/dt and find the Jacobian by inspection. From there you can then enforce MinAlpha < Alpha < MaxAlpha easily.

 

Maybe try to find the Jacobian yourself and I happily have a look and will definitely help if you get stuck.

 

Cheers,

-Dirk

Edited by Dirk Gregorius

Share this post


Link to post
Share on other sites

Yup the 90 degree cone limit seems to be an issue here. As long as its not exceeded, then projection onto the V1W1 plane does the trick. Is there no way to get it to work with an arbitrary cone limit (or even no limit at all)?

Why do we only consider v2 and not w2? If U1 is not parallel to U2, then projections of v2 and w2 would not form a right angle, so they would yield different twist angles.

Edited by d07RiV

Share this post


Link to post
Share on other sites

Yes, you can use quaternions, but this is a whole different story.

 

Yes, you can of course use the full frame and this should indeed work. I was just sketching the basic approach. There is a lot of space for improvements here.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!