A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by endasil » Tue Aug 16, 2011 5:54 pm
I am trying to get draw a box with the rotation and position of a newton body. But can't figure out how to do it. My assumption was that i could just put in the Matrix from NewtonBodyGetMatrix with glMultMatrixf(mat); to apply the rotation and translation, but apparantly not. I would be very thankful if someone could show me how to do this.
Box::Render()
{
glPushMatrix();
NewtonBodyGetMatrix(m_ntBody, &matrix[0][0]);
glMultMatrixf(mat);
glBegin (GL_TRIANGLE_STRIP);
...
glEnd();
glPopMatrix();
}
-
endasil
-
- Posts: 2
- Joined: Tue Aug 16, 2011 5:25 pm
by Julio Jerez » Tue Aug 16, 2011 6:34 pm
the function you have should work, Netwon Matrices conforms to OpenGl matrices.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by JoeJ » Wed Aug 17, 2011 3:43 pm
Have you tried to replace glMultMatrixf(mat) with glLoadMatrixf(mat)?
-

JoeJ
-
- Posts: 1489
- Joined: Tue Dec 21, 2010 6:18 pm
by Julio Jerez » Wed Aug 17, 2011 3:53 pm
yes they both work, but in general you only uses glLoadMatrix at the begining of the render frame, otherwise you lose your view matrix
See the demos they all use OpenGl.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by endasil » Thu Aug 18, 2011 5:43 am
Thanks for your help guys. Knowing that newton matrix conform to the opengl ones without modification made it easier to solve the problem. When initially setting the matrix for my body, i just created a dMatrix and then set it's ntMatrix.m_posit values. For some reason i assumed that the matrix would set itself up as an identity matrix when created. Looking in the constructor convinced me otherwise.
Anyway setting dMatrix ntMatrix = GetIdentityMatrix(); Fixed the problem.
-
endasil
-
- Posts: 2
- Joined: Tue Aug 16, 2011 5:25 pm
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest