A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Neo » Fri Feb 01, 2013 3:59 am
Currently, the ball and socket joint is initialized with
0 cone angle and 0 twist angle. However, in some cases,
the joint has a non-zero angle when created.
Would it possible to modify initial cone angle and
twist angle?
-
Neo
-
- Posts: 127
- Joined: Fri May 11, 2012 12:29 pm
- Location: China,Sichuan
by JoeJ » Fri Feb 01, 2013 4:52 pm
It has those methods for that purpuse, which you can call at any time:
void SetConeAngle (dFloat angle);
void SetTwistAngle (dFloat minAngle, dFloat maxAngle);
This sets the limits of free movement.
To define default orientation of that limit cone and twist you need to set the pinsAndPivotFrame matrix accordingly.
-

JoeJ
-
- Posts: 1489
- Joined: Tue Dec 21, 2010 6:18 pm
by Neo » Sat Feb 02, 2013 8:38 am
JoeJ wrote:It has those methods for that purpuse, which you can call at any time:
void SetConeAngle (dFloat angle);
void SetTwistAngle (dFloat minAngle, dFloat maxAngle);
This sets the limits of free movement.
To define default orientation of that limit cone and twist you need to set the pinsAndPivotFrame matrix accordingly.
Thx.
But you haven't get me correctly... What I intend to do is not to set limits and oritation of pin. What I want to do is
to initialize the angle (to be other than 0) between two subjects that are initially connected at an angle to simulate the ball and socket joint
-
Neo
-
- Posts: 127
- Joined: Fri May 11, 2012 12:29 pm
- Location: China,Sichuan
by JoeJ » Sat Feb 02, 2013 9:50 am
Neo wrote:But you haven't get me correctly...
I expected that, but even after you rephrased the question, i don't get what you mean

I still think what you want is achieveable by setting the pinsAndPivotFrame matrix.
Maybe you can do a painting or a practical example describing what goes wrong and what should be different...
-

JoeJ
-
- Posts: 1489
- Joined: Tue Dec 21, 2010 6:18 pm
by Neo » Sat Feb 02, 2013 11:09 am
JoeJ wrote:I expected that, but even after you rephrased the question, i don't get what you mean

I still think what you want is achieveable by setting the pinsAndPivotFrame matrix.
Maybe you can do a painting or a practical example describing what goes wrong and what should be different...
Ok.. I've draw a picture to explain my intention...
Sorry for cost so much time to reply, there's somthing wrong with my dropbox uploader

-
Neo
-
- Posts: 127
- Joined: Fri May 11, 2012 12:29 pm
- Location: China,Sichuan
by JoeJ » Sat Feb 02, 2013 12:43 pm
That's what i thaught and you can setup this by using the pinsAndPivot matrix...
The math behind that:
At construction, newton calculates two local rotation offsets for each body based on pinsAndPivot matrix:
localMatrix0 = pinsAndPivotFrame * matrix0.Inverse();
localMatrix1 = pinsAndPivotFrame * matrix1.Inverse();
Then, at runtime in the submit callback it uses those offsets to build constraint space:
matrix0 = localMatrix0 * body0Matrix;
matrix1 = localMatrix1 * body1Matrix; // matrix0/1 = constraint space
It then measures cone angle by:
coneAngle = CalcAngle (matrix0.Xaxis, matrix1.Xaxis)
What all this means is that you should be able to setup anything at will by the right pinsAndPivot matrix.
But: Personally i think this is hard to imagine and i never used it this way.
What i do is: I set both localMatrix0 / 1 directly after construction with identity pinsAndPivot (don't know if C++ allows that easily, but let's ignore that for now).
Example:
We have a ragdoll in standing pose: Hip body with x axis sideways and a leg body with x axis pointing downwards.
For the leg body x axis is nicely aligned to it's length and so we can use identity for it's localMatrix.
But for hip body we want the x axis to be aligned with the desired limit cone, which is not the case.
Thus hip localMatrix must be the rotation that would rotate the hip orientation to the cone orientation.
If this is done correctly, the measured cone angle at runtime is zero, if the leg is exactly aligned with the limit cone axis.
I hope that gives you some clue - the whole thing is not so easy to adjust, because it's difficult to get visual feedback.
What really helps is to visualize the constraint spaces in the submit function, but to do that you need to modify and recompile joint lib,
and do an extra call to the submit function from the thread that has rendering context just to do the visuals,
or - more easy - recreate some of the submit code to build constraint space and do the visuals.
-

JoeJ
-
- Posts: 1489
- Joined: Tue Dec 21, 2010 6:18 pm
by Neo » Sat Feb 02, 2013 1:43 pm
I see, a little bit hard to understand, I'll think of it for a while.
Actuallly, I do this just for ragdoll system. The limits were designed for stand pose(the same pose in your discription)
but the program switch the player to ragdoll system when he is running. That means every joint is not in the 'standard'
pose.
Maybe in my case, I should not only rotate the pin matrix, but also modify the local matirx..Because according to your words,
no matter how the matrix is, at run time, if there were no position and rotation change to the joint, the cone angle measurement
would be 0, however, in my condition it's not zero initially.
-
Neo
-
- Posts: 127
- Joined: Fri May 11, 2012 12:29 pm
- Location: China,Sichuan
by JoeJ » Sat Feb 02, 2013 4:24 pm
One thing forgot is that those local matrices also contain a translation which defines the positional offset from body center to joint center.
So all i wrote about orientation / rotation also applies to position / translation.
It's not really hard, especially if you already have all data in worldspace from an editor.
Than you can do for each joint:
sMat4 pmatrix, cmatrix;
// the parent / child matrices defining the joint in worldspace you get from editor - usually both their positions are at the same skeleteons joint position, parent rotation defines the limit cone and child rotation defines child orientation in actual rest pose
sMat4 pbody; BodyGetMatrix (bodyP, pbody);
sMat4 cbody; BodyGetMatrix (bodyC, cbody);
// body or bone matrices - i have the bodies already handy at that moment - they match up the skeleton in world space
pLocalMatrix = pbody.Inversed() * pmatrix;
cLocalMatrix = cbody.Inversed() * cmatrix;
// the Inversed() is standart 4x4 matrix inversion available in most math libs
note that multiplication order varies - with newton math lib you'd need to use cmatrix * cbody.Inversed()
-

JoeJ
-
- Posts: 1489
- Joined: Tue Dec 21, 2010 6:18 pm
by Neo » Sun Feb 03, 2013 11:59 am
@@
OK,thx. But I prefer irrlicht's matrix class, it has more member functions...
-
Neo
-
- Posts: 127
- Joined: Fri May 11, 2012 12:29 pm
- Location: China,Sichuan
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 2 guests