A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by funbidoux » Tue Nov 11, 2008 7:40 pm
Hi everybody!
I would like to know if there is a way to set the angle of a NewtonBody?
Example:
I have a NewtonBody (player) and I would like to turn it of 45 degrees.
I tried with SetTorque but it did not worked as expected...
thank,
-
funbidoux
-
- Posts: 3
- Joined: Tue Nov 11, 2008 7:37 pm
by Dave Gravel » Tue Nov 11, 2008 8:13 pm
If you use the Custom joint UpVector it's simple.
Just to call on the desired direction.
// bu animating the orientation of the pin vector the application can change the orientation of the picked object
void CustomUpVector::SetPinDir (const dVector& pin)
{
m_localMatrix1 = dgGrammSchmidt(pin);
}
-
Dave Gravel
-
- Posts: 800
- Joined: Sat Apr 01, 2006 9:31 pm
- Location: Quebec in Canada.
-
by funbidoux » Tue Nov 11, 2008 10:14 pm
Thank for your reply but I'm not sure if I understand... pin is my angle (0,45,0)? and what is dgGrammSchmidt? is it part of newton?
-
funbidoux
-
- Posts: 3
- Joined: Tue Nov 11, 2008 7:37 pm
by Dave Gravel » Tue Nov 11, 2008 11:53 pm
It's a math utility, but yes you can find the command in newton file utils.
And maybe if you have some math utils in coming with your 3d system this can have it already.
Yes you can change the joint pin angle with this command I don't remember the format if it is in degre or in angle.
Maybe you need to use value*180/PI but I really don't remember sorry.
It make a long time that I have test it.
Remember you this work only if you use the custom joint UpVector.
-
Dave Gravel
-
- Posts: 800
- Joined: Sat Apr 01, 2006 9:31 pm
- Location: Quebec in Canada.
-
by JernejL » Wed Nov 12, 2008 8:14 am
You can manipulate and set the newton object matrix directly to rotate objects instantly to any dersired rotation and / or location.
-
JernejL
-
- Posts: 1578
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by funbidoux » Wed Nov 12, 2008 2:23 pm
I tried what you told me but it is not working...
- Code: Select all
float matrix[4][4];
NewtonBodyGetMatrix(model.m_body,&matrix[0][0]);
matrix4 mat;
memcpy(mat.M, matrix, sizeof(float)*16);
mat.setRotationDegrees(mat.getRotationDegrees()+core::vector3df(0,15,0));
NewtonBodySetMatrix(model.m_body,&mat.M[0]);
Is there a way to get an exemple or a tutorial?
thank,
-
funbidoux
-
- Posts: 3
- Joined: Tue Nov 11, 2008 7:37 pm
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 18 guests