void mlMatrixTranspose(mlMatrix4x4 & result, const mlMatrix4x4 & source) { result = mlMatrix4x4( mlVector4D(source.I.x, source.J.x, source.K.x, source.T.x), mlVector4D(source.I.y, source.J.y, source.K.y, source.T.y), mlVector4D(source.I.z, source.J.z, source.K.z, source.T.z), mlVector4D(source.I.w, source.J.w, source.K.w, source.T.w) ); }
void gxSceneNode::Render() { glPushMatrix(); mlMatrix4x4 mMatrix = mlMatrix4x4(m_localToParentTransform.GetMatrix()); mlMatrix4x4 * pMatrix = &mMatrix; mlFloat * pafMatrix = reinterpret_cast<mlFloat*>(pMatrix); glMultMatrixf(pafMatrix); if(m_model) { m_model->Render(); } for(gxSceneNode * child = GetFirstChild(); child != NULL; child = GetNextChild(child)) { child->Render(); } glPopMatrix(); }
void Solid::Render() { glPushMatrix(); mlMatrix4x4 mMatrix = mlMatrix4x4(m_correctionalTransform.GetMatrix()); mlMatrix4x4 * pMatrix = &mMatrix; mlFloat * pafMatrix = reinterpret_cast<mlFloat*>(pMatrix); glMultMatrixf(pafMatrix); glEnable (GL_POLYGON_OFFSET_FILL); glPolygonOffset (1., 1.); glLineWidth(1); glBegin(GL_TRIANGLES); int nNumTriangles = indices.GetSize() / 3; for(int i = 0; i < nNumTriangles; i++) { int nIndex1 = indices.GetInt(i * 3 + 0); int nIndex2 = indices.GetInt(i * 3 + 1); int nIndex3 = indices.GetInt(i * 3 + 2); mlVector3D vP1 = vertices.GetVector(nIndex1); mlVector3D vP2 = vertices.GetVector(nIndex2); mlVector3D vP3 = vertices.GetVector(nIndex3); float fScale = 40.0f; vP1 *= fScale; vP2 *= fScale; vP3 *= fScale; mlVector3D vTranslation(50,20,50); vP1 += vTranslation; vP2 += vTranslation; vP3 += vTranslation; gxColor col1 = colors.GetColor(nIndex1); gxColor col2 = colors.GetColor(nIndex2); gxColor col3 = colors.GetColor(nIndex3); glColor4ub(col1.red, col1.green, col1.blue, 255); glVertex3d(vP1.x, vP1.y, vP1.z); glColor4ub(col2.red, col2.green, col2.blue, 255); glVertex3d(vP2.x, vP2.y, vP2.z); glColor4ub(col3.red, col3.green, col3.blue, 255); glVertex3d(vP3.x, vP3.y, vP3.z); } glEnd(); glLineWidth(1); glBegin(GL_LINES); for(int i = 0; i < nNumTriangles; i++) { int nIndex1 = indices.GetInt(i * 3 + 0); int nIndex2 = indices.GetInt(i * 3 + 1); int nIndex3 = indices.GetInt(i * 3 + 2); mlVector3D vP1 = vertices.GetVector(nIndex1); mlVector3D vP2 = vertices.GetVector(nIndex2); mlVector3D vP3 = vertices.GetVector(nIndex3); float fScale = 40.0f; vP1 *= fScale; vP2 *= fScale; vP3 *= fScale; mlVector3D vTranslation(50,20,50); vP1 += vTranslation; vP2 += vTranslation; vP3 += vTranslation; gxColor col1 = colors.GetColor(nIndex1); gxColor col2 = colors.GetColor(nIndex2); gxColor col3 = colors.GetColor(nIndex3); //glColor4ub(255,255,255, 255); //glColor4ub(127,127,127, 255); glColor4ub(200,200,200, 255); //glColor4ub(0,0,0, 255); glVertex3d(vP1.x, vP1.y, vP1.z); glVertex3d(vP2.x, vP2.y, vP2.z); glVertex3d(vP2.x, vP2.y, vP2.z); glVertex3d(vP3.x, vP3.y, vP3.z); glVertex3d(vP3.x, vP3.y, vP3.z); glVertex3d(vP1.x, vP1.y, vP1.z); } glEnd(); glLineWidth(1); glColor4ub(255,255,255, 255); glPopMatrix(); }