void WaveFrontExporter::exportPatch(IPatch& patch) { _output << "\ng " << "Patch" << _exportedPatches << "\n"; std::string vertexBuf; std::string texCoordBuf; std::string faceBuf; // Get hold of the fully tesselated patch mesh, not just the control vertices PatchMesh mesh = patch.getTesselatedPatchMesh(); // Remember the vertex count offset std::size_t firstVertex = _vertexCount; for (std::size_t h = 0; h < mesh.height; ++h) { for (std::size_t w = 0; w < mesh.width; ++w) { const PatchMesh::Vertex& v = mesh.vertices[mesh.width*h + w]; // Write coordinates into the export buffers vertexBuf += "v " + std::string(v.vertex) + "\n"; texCoordBuf += "vt " + std::string(v.texcoord) + "\n"; // Count the exported vertices ++_vertexCount; // Starting from the second row, we're gathering the faces if (h > 0 && w > 0) { // Gather the indices forming a quad std::size_t v1 = 1 + firstVertex + h*mesh.width + w; std::size_t v2 = 1 + firstVertex + (h-1)*mesh.width + w; std::size_t v3 = 1 + firstVertex + (h-1)*mesh.width + (w-1); std::size_t v4 = 1 + firstVertex + h*mesh.width + (w-1); // Construct the quad faceBuf += "f"; faceBuf += " " + sizetToStr(v1) + "/" + sizetToStr(v1); faceBuf += " " + sizetToStr(v4) + "/" + sizetToStr(v4); faceBuf += " " + sizetToStr(v3) + "/" + sizetToStr(v3); faceBuf += " " + sizetToStr(v2) + "/" + sizetToStr(v2); faceBuf += "\n"; } } } _output << vertexBuf << "\n"; _output << texCoordBuf << "\n"; _output << faceBuf << "\n"; ++_exportedPatches; }
void WaveFrontExporter::exportBrush(IBrush& brush) { _output << "\ng " << "Brush" << _exportedBrushes << "\n"; std::string vertexBuf; std::string texCoordBuf; std::string faceBuf; for (std::size_t faceIdx = 0; faceIdx < brush.getNumFaces(); ++faceIdx) { IFace& face = brush.getFace(faceIdx); // Remember the index of the first vertex std::size_t firstVertex = _vertexCount; const IWinding& winding = face.getWinding(); for (std::size_t i = 0; i < winding.size(); ++i) { // Write coordinates into the export buffers vertexBuf += "v " + std::string(winding[i].vertex) + "\n"; texCoordBuf += "vt " + std::string(winding[i].texcoord) + "\n"; // Count the exported vertices ++_vertexCount; } // Construct the face section faceBuf += "\nf"; for (std::size_t i = firstVertex; i < _vertexCount; ++i) { faceBuf += " " + sizetToStr(i+1) + "/" + sizetToStr(i+1); } } _output << vertexBuf << "\n"; _output << texCoordBuf; _output << faceBuf << "\n"; ++_exportedBrushes; }
void DoFind(const cmd::ArgumentList& args) { ui::IDialogPtr dialog = GlobalDialogManager().createDialog(_("Find Brush")); ui::IDialog::Handle entityEntry = dialog->addEntryBox(_("Entity Number:")); ui::IDialog::Handle brushEntry = dialog->addEntryBox(_("Brush Number:")); std::size_t ent(0), br(0); GetSelectionIndex(ent, br); dialog->setElementValue(entityEntry, sizetToStr(ent)); dialog->setElementValue(brushEntry, sizetToStr(br)); if (dialog->run() == ui::IDialog::RESULT_OK) { std::string entityValue = dialog->getElementValue(entityEntry); std::string brushValue = dialog->getElementValue(brushEntry); SelectBrush(strToInt(entityValue), strToInt(brushValue)); } }
void EntityInfoTab::populateTab() { // Set the outer space of the vbox gtk_container_set_border_width(GTK_CONTAINER(_widget), 12); // Create the list store that contains the eclass => count map _listStore = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); // Create the treeview and pack two columns into it _treeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(_listStore)); gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(_treeView), TRUE); GtkTreeViewColumn* eclassCol = gtkutil::TextColumn(_("Entity Class"), ECLASS_COL); gtk_tree_view_column_set_sort_column_id(eclassCol, ECLASS_COL); GtkTreeViewColumn* countCol = gtkutil::TextColumn(_("Count"), COUNT_COL); gtk_tree_view_column_set_sort_column_id(countCol, COUNT_COL); gtk_tree_view_append_column(GTK_TREE_VIEW(_treeView), eclassCol); gtk_tree_view_append_column(GTK_TREE_VIEW(_treeView), countCol); gtk_box_pack_start(GTK_BOX(_widget), gtkutil::ScrolledFrame(_treeView), TRUE, TRUE, 0); // Populate the liststore with the entity count information for (map::EntityBreakdown::Map::const_iterator i = _entityBreakdown.begin(); i != _entityBreakdown.end(); i++) { GtkTreeIter iter; gtk_list_store_append(_listStore, &iter); gtk_list_store_set(_listStore, &iter, ECLASS_COL, i->first.c_str(), COUNT_COL, i->second, -1); } // The table containing the primitive statistics GtkTable* table = GTK_TABLE(gtk_table_new(3, 2, FALSE)); gtk_box_pack_start(GTK_BOX(_widget), GTK_WIDGET(table), FALSE, FALSE, 0); _brushCount = gtkutil::LeftAlignedLabel(""); _patchCount = gtkutil::LeftAlignedLabel(""); _entityCount = gtkutil::LeftAlignedLabel(""); GtkWidget* brushLabel = gtkutil::LeftAlignedLabel(_("Brushes:")); GtkWidget* patchLabel = gtkutil::LeftAlignedLabel(_("Patches:")); GtkWidget* entityLabel = gtkutil::LeftAlignedLabel(_("Entities:")); gtk_widget_set_size_request(brushLabel, 75, -1); gtk_widget_set_size_request(patchLabel, 75, -1); gtk_widget_set_size_request(entityLabel, 75, -1); gtk_table_attach(table, brushLabel, 0, 1, 0, 1, (GtkAttachOptions) (0), (GtkAttachOptions) (0), 0, 0); gtk_table_attach(table, patchLabel, 0, 1, 1, 2, (GtkAttachOptions) (0), (GtkAttachOptions) (0), 0, 0); gtk_table_attach(table, entityLabel, 0, 1, 2, 3, (GtkAttachOptions) (0), (GtkAttachOptions) (0), 0, 0); std::string bc = "<b>" + sizetToStr(GlobalCounters().getCounter(counterBrushes).get()) + "</b>"; std::string pc = "<b>" + sizetToStr(GlobalCounters().getCounter(counterPatches).get()) + "</b>"; std::string ec = "<b>" + sizetToStr(GlobalCounters().getCounter(counterEntities).get()) + "</b>"; gtk_label_set_markup(GTK_LABEL(_brushCount), bc.c_str()); gtk_label_set_markup(GTK_LABEL(_patchCount), pc.c_str()); gtk_label_set_markup(GTK_LABEL(_entityCount), ec.c_str()); gtk_table_attach_defaults(table, _brushCount, 1, 2, 0, 1); gtk_table_attach_defaults(table, _patchCount, 1, 2, 1, 2); gtk_table_attach_defaults(table, _entityCount, 1, 2, 2, 3); }
void ModelInfoTab::populateTab() { // Set the outer space of the vbox gtk_container_set_border_width(GTK_CONTAINER(_widget), 12); // Create the list store that contains the model => info map _listStore = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT); // Create the treeview and pack two columns into it _treeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(_listStore)); gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(_treeView), TRUE); GtkTreeViewColumn* modelCol = gtkutil::TextColumn(_("Model"), MODEL_COL); gtk_tree_view_column_set_sort_column_id(modelCol, MODEL_COL); GtkTreeViewColumn* polyCountCol = gtkutil::TextColumn(_("Polys"), POLYCOUNT_COL); gtk_tree_view_column_set_sort_column_id(polyCountCol, POLYCOUNT_COL); GtkTreeViewColumn* modelCountCol = gtkutil::TextColumn(_("Count"), MODELCOUNT_COL); gtk_tree_view_column_set_sort_column_id(modelCountCol, MODELCOUNT_COL); GtkTreeViewColumn* skinCountCol = gtkutil::TextColumn(_("Skins"), SKINCOUNT_COL); gtk_tree_view_column_set_sort_column_id(skinCountCol, SKINCOUNT_COL); gtk_tree_view_append_column(GTK_TREE_VIEW(_treeView), modelCol); gtk_tree_view_append_column(GTK_TREE_VIEW(_treeView), polyCountCol); gtk_tree_view_append_column(GTK_TREE_VIEW(_treeView), modelCountCol); gtk_tree_view_append_column(GTK_TREE_VIEW(_treeView), skinCountCol); gtk_box_pack_start(GTK_BOX(_widget), gtkutil::ScrolledFrame(_treeView), TRUE, TRUE, 0); // Populate the liststore with the entity count information for (map::ModelBreakdown::Map::const_iterator i = _modelBreakdown.begin(); i != _modelBreakdown.end(); ++i) { GtkTreeIter iter; gtk_list_store_append(_listStore, &iter); gtk_list_store_set(_listStore, &iter, MODEL_COL, i->first.c_str(), POLYCOUNT_COL, i->second.polyCount, MODELCOUNT_COL, i->second.count, SKINCOUNT_COL, i->second.skinCount.size(), -1); } // The table containing the primitive statistics GtkTable* table = GTK_TABLE(gtk_table_new(2, 2, FALSE)); gtk_box_pack_start(GTK_BOX(_widget), GTK_WIDGET(table), FALSE, FALSE, 0); _modelCount = gtkutil::LeftAlignedLabel(""); _skinCount = gtkutil::LeftAlignedLabel(""); GtkWidget* modelsLabel = gtkutil::LeftAlignedLabel(_("Models used:")); GtkWidget* skinsLabel = gtkutil::LeftAlignedLabel(_("Named Skins used:")); gtk_widget_set_size_request(modelsLabel, 120, -1); gtk_widget_set_size_request(skinsLabel, 120, -1); gtk_table_attach(table, modelsLabel, 0, 1, 0, 1, (GtkAttachOptions) (0), (GtkAttachOptions) (0), 0, 0); gtk_table_attach(table, skinsLabel, 0, 1, 1, 2, (GtkAttachOptions) (0), (GtkAttachOptions) (0), 0, 0); std::string mc = "<b>" + sizetToStr(_modelBreakdown.getMap().size()) + "</b>"; std::string sc = "<b>" + sizetToStr(_modelBreakdown.getNumSkins()) + "</b>"; gtk_label_set_markup(GTK_LABEL(_modelCount), mc.c_str()); gtk_label_set_markup(GTK_LABEL(_skinCount), sc.c_str()); gtk_table_attach_defaults(table, _modelCount, 1, 2, 0, 1); gtk_table_attach_defaults(table, _skinCount, 1, 2, 1, 2); }