hiramajo
14-02-2009 06:08:35
Hi.
Can anobody please explain me how to register an callback to a joint?
Help would be very much appreciated
Beauty
18-02-2009 14:30:12
hiramajo
11-03-2009 15:56:15
Can't still figure out this.
Nobody that have used this function in MogreNewt??
Beauty
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?
hiramajo
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.
Beauty
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.
hiramajo
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);
hinge.SetCallbackAccel(stopAcc);
}
if (hinge.JointAngle.ValueRadians <= -limit)
{
float stopAcc = hinge.CalculateStopAlpha(-limit);
hinge.SetCallbackAccel(stopAcc);
}
}
And now i can set the limits, break force ++ in the hinge.UserData
Beauty
12-04-2009 15:12:47
nice to hear that you found the solution
and thanks for posting it