Can anobody please explain me how to register an callback to a joint?
Help would be very much appreciated
Can't still figure out this.
Nobody that have used this function in MogreNewt??
* Set MaterialID
s to the collidable objects (property Body.Collission
* Define a MaterialPair
for the MaterialIDs
* Create a ContactCallback
for the MaterialPair
If there is a callback, then userProcess()
will be called.
Inside of this you can read out the joint properties of the colliding body pairs.
For more details look to the wiki link of my last post. (Did you read it?)
Also the links at the end of page are helpful (look here
There is also a link to a thread with Mogre example
I can send you an example application which I created. You need to send me your e-mail address (via pm).
Do you use physically functions of Newton?
Yes i have read all the links and posts, but all this is about materials and collisions.
What i need is a callback for the joints(hinge, slider, balljoint and so on...) so i can set limits and make motors for the joints.
ah ok, I misunderstood. I thought you mean the contact joints. (the name is also joint
Sorry, for this case I don't know.
Maybe you find an answer in the OgreNewt forum
or ask there, too.
The base technique is the same.
If you know how to do it with OgreNewt, than you can use it similar with MogreNewt.
A description of the CustomJoint
basics I found in the Newton wiki:
The little problem is to find out where the functions are hidden in OgreNewt / MogreNewt.
I think with Visual Studio you can search for strings of class members.
So it could be easier to find it.
Finaly found th solution
It was just a question of typecasting:
Construct the joint:
MogreNewt.BasicJoints.Hinge hJoint = new MogreNewt.BasicJoints.Hinge(mWorld, body2, body1, position, pin);
//Register the event
hJoint.WorldUpdated += new EventHandler(hJoint_WorldUpdated);
Then in hJoint_WorldUpdated:
void hJoint_WorldUpdated(object sender, EventArgs e)
//Typecast the sender
MogreNewt.BasicJoints.Hinge hinge = (MogreNewt.BasicJoints.Hinge)sender;
Radian limit = new Radian(new Degree(90.0f));
//limit the joint swing
if (hinge.JointAngle.ValueRadians >= limit)
float stopAcc = hinge.CalculateStopAlpha(limit);
if (hinge.JointAngle.ValueRadians <= -limit)
float stopAcc = hinge.CalculateStopAlpha(-limit);
And now i can set the limits, break force ++ in the hinge.UserData
nice to hear that you found the solution
and thanks for posting it