[SOLVED] Mogrenewt joint callback


14-02-2009 06:08:35


Can anobody please explain me how to register an callback to a joint?
Help would be very much appreciated :)


18-02-2009 14:30:12

Maybe here you find usefull information:
http://www.ogre3d.org/wiki/index.php/Co ... ith_Newton


11-03-2009 15:56:15

Can't still figure out this.
Nobody that have used this function in MogreNewt??


11-03-2009 16:43:30

* Set MaterialIDs 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).

Important question:
Do you use physically functions of Newton?


11-03-2009 21:15:56

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.


12-03-2009 02:54:30

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:
http://www.newtondynamics.com/wiki/inde ... tom_joints
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.


09-04-2009 19:36:10

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 :)


12-04-2009 15:12:47

nice to hear that you found the solution
and thanks for posting it :)