void MapExporter::post(const scene::INodePtr& node) { try { Entity* entity = Node_getEntity(node); if (entity != NULL) { _writer.endWriteEntity(*entity, _mapStream); return; } IBrush* brush = Node_getIBrush(node); if (brush != NULL && brush->hasContributingFaces()) { _writer.endWriteBrush(*brush, _mapStream); return; } IPatch* patch = Node_getIPatch(node); if (patch != NULL) { _writer.endWritePatch(*patch, _mapStream); return; } } catch (IMapWriter::FailureException& ex) { rError() << "Failure exporting a node (post): " << ex.what() << std::endl; } }
bool MapExporter::pre(const scene::INodePtr& node) { try { Entity* entity = Node_getEntity(node); if (entity != NULL) { // Progress dialog handling onNodeProgress(); _writer.beginWriteEntity(*entity, _mapStream); if (_infoFileExporter) _infoFileExporter->visit(node); return true; } IBrush* brush = Node_getIBrush(node); if (brush != NULL && brush->hasContributingFaces()) { // Progress dialog handling onNodeProgress(); _writer.beginWriteBrush(*brush, _mapStream); if (_infoFileExporter) _infoFileExporter->visit(node); return true; } IPatch* patch = Node_getIPatch(node); if (patch != NULL) { // Progress dialog handling onNodeProgress(); _writer.beginWritePatch(*patch, _mapStream); if (_infoFileExporter) _infoFileExporter->visit(node); return true; } } catch (IMapWriter::FailureException& ex) { rError() << "Failure exporting a node (pre): " << ex.what() << std::endl; } return true; // full traversal }
void ModelExporter::processPatch(const scene::INodePtr& node) { IPatch* patch = Node_getIPatch(node); if (patch == nullptr) return; const std::string& materialName = patch->getShader(); if (!isExportableMaterial(materialName)) return; PatchMesh mesh = patch->getTesselatedPatchMesh(); std::vector<model::ModelPolygon> polys; for (std::size_t h = 0; h < mesh.height - 1; ++h) { for (std::size_t w = 0; w < mesh.width - 1; ++w) { model::ModelPolygon poly; poly.a = convertPatchVertex(mesh.vertices[w + (h*mesh.width)]); poly.b = convertPatchVertex(mesh.vertices[w + 1 + (h*mesh.width)]); poly.c = convertPatchVertex(mesh.vertices[w + mesh.width + (h*mesh.width)]); polys.push_back(poly); poly.a = convertPatchVertex(mesh.vertices[w + 1 + (h*mesh.width)]); poly.b = convertPatchVertex(mesh.vertices[w + 1 + mesh.width + (h*mesh.width)]); poly.c = convertPatchVertex(mesh.vertices[w + mesh.width + (h*mesh.width)]); polys.push_back(poly); } } Matrix4 exportTransform = node->localToWorld().getPremultipliedBy(_centerTransform); _exporter->addPolygons(materialName, polys, exportTransform); }