void GfxOpenGL::drawModel(Model *m) { glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)_screenWidth/(GLfloat)_screenHeight,0.01f,10.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor4ub(255, 255, 255, 255); gluLookAt( 0, 0, 1, 0, 0, 0, 0, 1, 0 ); glPushMatrix(); glTranslatef((_cameraX/(float)_screenWidth), -(_cameraY/(float)_screenHeight), (_cameraZ/(float)_screenHeight)); glRotatef(_rotY, 1, 0, 0); glRotatef(_rotX, 0, 1, 0); for (uint j = 0; j < m->_numPolygons; j++) { Polygon *p = &m->_polygons[j]; glBegin(GL_POLYGON); for (int i = 0; i < m->_polygons->_num; ++i) { uint32 vert = p->_data[i]; if (vert > m->_numVerticies || vert == 0) { break; } glColor4ub(_palette->_palette[p->_colour]._r, _palette->_palette[p->_colour]._g, _palette->_palette[p->_colour]._b, 255); Vertex *v = &m->_verticies[vert]; if (v->_bone == 0) { continue; } Math::Vector3d mv = v->getPos(m); Normal *n = &m->_normals[vert]; glNormal3f(n->_x, n->_y, n->_z); glVertex3fv(mv.getData()); } glEnd(); } for (uint j = 0; j < m->_numPoints; j++) { Point *p = &m->_points[j]; glColor4ub(_palette->_palette[p->_colour]._r, _palette->_palette[p->_colour]._g, _palette->_palette[p->_colour]._b, 255); Vertex *v1 = &m->_verticies[p->_v1]; Math::Vector3d vec1 = v1->getPos(m); Vertex *v2 = &m->_verticies[p->_v2]; Math::Vector3d vec2 = v2->getPos(m); glBegin(GL_LINES); glVertex3fv(vec1.getData()); glVertex3fv(vec2.getData()); glEnd(); } for (uint j = 0; j < m->_numSpheres; j++) { Sphere *s = &m->_spheres[j]; Vertex *v = &m->_verticies[s->_vertex]; Math::Vector3d vec = v->getPos(m); glColor4ub(_palette->_palette[s->_colour]._r, _palette->_palette[s->_colour]._g, _palette->_palette[s->_colour]._b, 255); glPushMatrix(); glTranslatef(vec.x(), vec.y(), vec.z()); drawSphere(s->_size, 8, 8); glPopMatrix(); } glPopMatrix(); glDisable(GL_DEPTH_TEST); }