void ModelDrawer::RenderObject (MdlObject *o, IView *v, int mapping) { // setup selector v->PushSelector (o->selector); // setup object transformation Matrix tmp, mat; o->GetTransform (mat); mat.transpose (&tmp); glPushMatrix (); glMultMatrixf ( (float*)&tmp ); // render object origin if (v->GetConfig (CFG_OBJCENTERS)!=0.0f) { glPointSize (ObjCenterSize); if (o->isSelected) glColor3ub (255,0,0); else glColor3ub (255,255,255); glBegin(GL_POINTS); glVertex3i(0,0,0); glEnd(); glPointSize (1); glColor3ub (255,255,255); } bool polySelect=v->GetConfig(CFG_POLYSELECT) != 0; // if(polySelect) { // render polygons for (int a=0;a<o->poly.size();a++) RenderPolygon (o, o->poly[a], v,mapping, polySelect); /* } else { // render geometry using drawing list if (!o->renderData) o->renderData = new RenderData; RenderData* rd = (RenderData*)o->renderData; if (rd->drawList) glCallList(rd->drawList); else { rd->drawList = glGenLists(1); glNewList(rd->drawList, GL_COMPILE_AND_EXECUTE); // render polygons for (int a=0;a<o->poly.size();a++) RenderPolygon (o, o->poly[a], v,mapping, polySelect); glEndList (); } }*/ for (int a=0;a<o->childs.size();a++) RenderObject (o->childs[a], v, mapping); glPopMatrix (); v->PopSelector (); }
/*------------------------------------------------------------------------- Recursively computes the shading colors and then renders an Entity list. EntityList : The list of Entities and sub-Entities to render. This pointer can be NULL (empty list). LightList : List of Ligths. This pointer can be NULL (empty list). World : Access to the world data such as view origin and orientation, etc. ------------------------------------------------------------------------*/ bool RenderShadeEntity(ListRec* EntityList, ListRec* LightList, WorldRec* World) { //---- Render each Entity ---- ListRec* EntityNode = EntityList; while (EntityNode != NULL) { #define Entity ((EntityRec*)EntityNode->Data) if (Entity == NULL) {return false;} //Determine the if shading is required bool ShadeFlag = ((Entity->Flags & ENTITY_SHADE) != ENTITY_NULL); if (ShadeFlag) { //Process every vertex ListRec* VertexNode = Entity->VertexList; while (VertexNode != NULL) { //Find the diffuse light color for this vertex if (!ShadeGouraud((VertexRec*)VertexNode->Data, LightList)) {return false;} VertexNode = VertexNode->Next; } } //Render each Polygon in the Entity ListRec* PolygonNode = Entity->PolygonList; while (PolygonNode != NULL) { //Find the rendering color for this Polygon if (ShadeFlag) { if (!ShadeGouraud((PolygonRec*)PolygonNode->Data, LightList)) {return false;} } /*//Shade flag debug else { ((PolygonRec*)PolygonNode->Data)->Shade[0] = ((PolygonRec*)PolygonNode->Data)->Shade[1] = ((PolygonRec*)PolygonNode->Data)->Shade[2] = 1.0f; }/**/ //Render the Polygon if (!RenderPolygon((PolygonRec*)PolygonNode->Data, World)) {return false;} PolygonNode = PolygonNode->Next; } //Recursively render the sub-Entities if (!RenderShadeEntity(Entity->EntityList, LightList, World)) {return false;} //Advance to the next Entity node EntityNode = EntityNode->Next; #undef Entity } return true; }
/********************************************************** * * RenderObject * * parameters IN: * ObjectCell * currentObject * * OBJECT_AXIS * OBJECT_SURFACE * OBJECT_PATCH bicubic Bezier patches * *********************************************************/ void RenderObject (ObjectCell * currentObject) { if (currentObject->type == OBJECT_SURFACE) { for (vector<SurfaceCell *>::iterator it = currentObject->surfaceCellList.begin(); it != currentObject->surfaceCellList.end(); ++it) { SurfaceCell * currentSurface = *it; for (vector<PolygonCell *>::iterator it = currentSurface->polygonCellList.begin(); it != currentSurface->polygonCellList.end(); ++it) { PolygonCell * currentPolygon = *it; if (currentPolygon->polyVisible) { RenderPolygon (currentPolygon); } } } } }