/* read_gmsh: read the gmsh II file and output a pointer to mesh structure ckecked: ok */ mesh *read_gmsh(const char *fname) { id i; // index cell id j; // index for face in all faces id k; // index for faces in one cell gmsh_raw *gmsh; mesh *m; // open mesh file and allocate gmsh strucut fp = sfopen(fname, "in read_gmsh() for fp"); gmsh = smalloc(sizeof(gmsh_raw)*1, "in read_gmsh, for gmsh"); /*find the opening mark, and read the text blocks*/ while(fgets(line, MAXLINE, fp) != NULL){ // read line by line if (sscanf(line, "%s", w) == 1){ if (strcmp(w, "$PhysicalNames") == 0) read_physicalNames(fp, gmsh); if (strcmp(w, "$Nodes") == 0) read_nodes(fp, gmsh); if (strcmp(w, "$Elements") == 0) read_elems(fp, gmsh); } } /* construct mesh from elements*/ m = elems_to_mesh(gmsh); /* sort the faces according to its 3 types: boundary, salve, nb*/ sort_faces(); /*clean up*/ fclose(fp); free(facetypes); return m; }
void render_objects(r_context_t *c) { int i; c->r_leafcount = 0; #if 0 /* Useful for exploring face culling effectiveness */ if (g->r_lockpvs) { render_backend(&facelist); return; } #endif c->cos_fov = cos(g->r_eyefov/2.0f * DEG2RAD); /* Get clip coordinate transformation matrix */ gen_clipmat(c); c->facelist.numfaces = c->translist.numfaces = 0; c->numsky = 0; /* Clear "included" faces list */ memset(c->r_faceinc, 0, g->r_numfaces * sizeof(int)); /* "Walk" the BSP tree to generate a list of faces to render */ /* FIXME: include other models */ render_walk_model(c, 0); /* Sort the face list */ sort_faces(c); /* FIXME: Reset depth buffer range based on max/min Z in facelist */ /* Draw sky first -- on first pipe if geometry decomposed */ if (c->numsky && g->r_sky && c->range[0] == 0.0) render_backend_sky(c); /* Draw normal faces */ render_backend(c, &(c->facelist)); /* Draw visible mapents (md3 models) -- on last pipe if geometry decomposed */ if (g->r_drawitems && c->range[1] == 1.0) { for(i=0; i < g->g_mapent_numinst; i++) { if (c->r_eyecluster < 0 || BSP_TESTVIS(c->r_eyecluster, g->g_mapent_inst[i].cluster)) render_backend_mapent(c, i); } } /* Draw transparent faces last */ if (c->translist.numfaces) render_backend(c, &(c->translist)); }