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; } }
void IFillBSpline::draw (Canvas* c, Graphic* gs) { IBrush* brush = (IBrush*) gs->GetBrush(); IPattern* pattern = (IPattern*) gs->GetPattern(); if (!brush->LeftArrow() && !brush->RightArrow() && !pattern->None()) { FillBSpline::draw(c, gs); } }
IFillBSpline::IFillBSpline (Coord* ax, Coord* ay, int n, Graphic* gs) : (ax, ay, n, gs) { delete x; delete y; count = n + 4; x = new Coord[count]; y = new Coord[count]; x[0] = ax[0]; x[1] = ax[0]; x[count - 1] = ax[n - 1]; x[count - 2] = ax[n - 1]; y[0] = ay[0]; y[1] = ay[0]; y[count - 1] = ay[n - 1]; y[count - 2] = ay[n - 1]; CopyArray(ax, ay, n, &x[2], &y[2]); } // contains returns true if the IFillBSpline contains the given point // unless the brush is an arrow or the pattern is the "none" pattern. boolean IFillBSpline::contains (PointObj& po, Graphic* gs) { boolean contains = false; IBrush* brush = (IBrush*) gs->GetBrush(); IPattern* pattern = (IPattern*) gs->GetPattern(); if (!brush->LeftArrow() && !brush->RightArrow() && !pattern->None()) { contains = FillBSpline::contains(po, gs); } return contains; }
boolean IFillBSpline::intersects (BoxObj& userb, Graphic* gs) { boolean intersects = false; IBrush* brush = (IBrush*) gs->GetBrush(); IPattern* pattern = (IPattern*) gs->GetPattern(); if (!brush->LeftArrow() && !brush->RightArrow() && !pattern->None()) { intersects = FillBSpline::intersects(userb, gs); } return intersects; }
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 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 ModelExporter::processBrush(const scene::INodePtr& node) { IBrush* brush = Node_getIBrush(node); if (brush == nullptr) return; Matrix4 exportTransform = node->localToWorld().getPremultipliedBy(_centerTransform); for (std::size_t b = 0; b < brush->getNumFaces(); ++b) { const IFace& face = brush->getFace(b); const std::string& materialName = face.getShader(); if (!isExportableMaterial(materialName)) continue; const IWinding& winding = face.getWinding(); std::vector<model::ModelPolygon> polys; if (winding.size() < 3) { rWarning() << "Skipping face with less than 3 winding verts" << std::endl; continue; } // Create triangles for this winding for (std::size_t i = 1; i < winding.size() - 1; ++i) { model::ModelPolygon poly; poly.a = convertWindingVertex(winding[i + 1]); poly.b = convertWindingVertex(winding[i]); poly.c = convertWindingVertex(winding[0]); polys.push_back(poly); } _exporter->addPolygons(materialName, polys, exportTransform); } }