Quote:Original post by daniel_i_lOpenGL uses column vectors, which is reflected in the fact that OpenGL transform function calls must be issued 'backwards' from the order in which you want them to be applied. So if you want rotate->translate, you call glTranslate() first, and the rotation function second.
But isn't the glMultMatrix like a rotation call, if that is true then the glTranslate should come after (like you said, rotation then translation)?
rotating to a normal
I implemented it like this:
And it worked Great! I don't even have to translate cause of the vPosition input.
I just have a little question, when I set the forward to
CVector3 vForward2D = {1,0,0};
the triangle points to the left instead of to the right, only when I set the x to -1 it points right. Also, when the z is set to 1 it point into the screen instead of out of it? Why does this happen?
Thanks.
glLoadIdentity(); Camera.Look(); glColor3f(0.5,1,0.5); CVector3 vForward2D = {1,0,0}; CVector3 vNormal; vNormal = NormalToMap(g_HeightMap, ((Map.BestPoint.x)/SCALE_SIDE), ((Map.BestPoint.z)/SCALE_SIDE)); CVector3 vSide = Normalize(Cross(vNormal, vForward2D)); CVector3 vForward = Cross(vSide, vNormal); CVector3 vPosition = Map.BestPoint; float m[16]; m[0] = vSide.x; m[1] = vSide.y; m[2] = vSide.z; m[3] = 0.0f; m[4] = vNormal.x; m[5] = vNormal.y; m[6] = vNormal.z; m[7] = 0.0f; m[8] = vForward.x; m[9] = vForward.y; m[10] = vForward.z; m[11] = 0.0f; m[12] = vPosition.x; m[13] = vPosition.y; m[14] = vPosition.z; m[15] = 1.0f; glMultMatrixf(m); glLineWidth(2); glBegin(GL_TRIANGLES); glVertex3f(-15, 1, 15); glVertex3f( 20, 1, 20); glVertex3f( 0, 1, -20); glEnd(); glLineWidth(1);
And it worked Great! I don't even have to translate cause of the vPosition input.
I just have a little question, when I set the forward to
CVector3 vForward2D = {1,0,0};
the triangle points to the left instead of to the right, only when I set the x to -1 it points right. Also, when the z is set to 1 it point into the screen instead of out of it? Why does this happen?
Thanks.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement