bool Model::buildList(RenderPass pass) { if (!_needBuild[pass]) return false; if (_lists == 0) _lists = glGenLists(kRenderPassAll); glNewList(_lists + pass, GL_COMPILE); // Apply our global model transformation glScalef(_modelScale[0], _modelScale[1], _modelScale[2]); if (_type == kModelTypeObject) // Aurora world objects have a rotated axis glRotatef(90.0, -1.0, 0.0, 0.0); glTranslatef(_position[0], _position[1], _position[2]); glRotatef( _rotation[0], 1.0, 0.0, 0.0); glRotatef( _rotation[1], 0.0, 1.0, 0.0); glRotatef(-_rotation[2], 0.0, 0.0, 1.0); // Draw the bounding box, if requested doDrawBound(); // Draw the nodes for (NodeList::iterator n = _currentState->rootNodes.begin(); n != _currentState->rootNodes.end(); n++) { glPushMatrix(); (*n)->render(pass); glPopMatrix(); } glEndList(); _needBuild[pass] = false; return true; }
void Model::render(RenderPass pass) { if (!_currentState || (pass > kRenderPassAll)) return; if (pass == kRenderPassAll) { Model::render(kRenderPassOpaque); Model::render(kRenderPassTransparent); return; } // Apply our global model transformation glScalef(_modelScale[0], _modelScale[1], _modelScale[2]); if (_type == kModelTypeObject) // Aurora world objects have a rotated axis glRotatef(90.0, -1.0, 0.0, 0.0); glTranslatef(_position[0], _position[1], _position[2]); glRotatef( _rotation[0], 1.0, 0.0, 0.0); glRotatef( _rotation[1], 0.0, 1.0, 0.0); glRotatef(-_rotation[2], 0.0, 0.0, 1.0); // Draw the bounding box, if requested doDrawBound(); // Draw the nodes for (NodeList::iterator n = _currentState->rootNodes.begin(); n != _currentState->rootNodes.end(); ++n) { glPushMatrix(); (*n)->render(pass); glPopMatrix(); } // Reset the first texture units TextureMan.reset(); }
void Model_Sonic::render(RenderPass pass) { /* We're overriding Model::render() here, because Model_Sonic keeps the geometry, * while in other Model classes, the geometry is inside the ModelNodes. * * TODO: Find a way to merge this back into Model? */ if (!_currentState || (pass > kRenderPassAll)) return; if (pass == kRenderPassAll) { Model_Sonic::render(kRenderPassOpaque); Model_Sonic::render(kRenderPassTransparent); return; } // Apply our global model transformation glTranslatef(_position[0], _position[1], _position[2]); glRotatef(_orientation[3], _orientation[0], _orientation[1], _orientation[2]); glScalef(_scale[0], _scale[1], _scale[2]); // Draw the bounding box, if requested doDrawBound(); TextureMan.reset(); for (Geometries::const_iterator g = _geometries.begin(); g != _geometries.end(); ++g) { TextureMan.set(g->texture); for (Primitives::const_iterator p = g->primitives.begin(); p != g->primitives.end(); ++p) p->vertexBuffer.draw(GL_TRIANGLES, p->indexBuffer); } TextureMan.reset(); // Draw the skeleton, if requested doDrawSkeleton(); }