void controlPointsChanged() { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return; patchNode->getPatch().controlPointsChanged(); }
// Shader handling const std::string& getShader() const { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return _emptyShader; return patchNode->getPatch().getShader(); }
// Check whether all control vertices are in the same 3D spot (with minimal tolerance) bool isDegenerate() const { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return true; return patchNode->getPatch().isDegenerate(); }
void appendPoints(bool columns, bool beginning) { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return; return patchNode->getPatch().appendPoints(columns, beginning); }
void removePoints(bool columns, std::size_t index) { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return; return patchNode->getPatch().removePoints(columns, index); }
void setShader(const std::string& name) { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return; patchNode->getPatch().setShader(name); }
bool hasVisibleMaterial() { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return false; return patchNode->getPatch().hasVisibleMaterial(); }
void insertRows(std::size_t rowIndex) { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return; return patchNode->getPatch().insertRows(rowIndex); }
std::size_t getHeight() const { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return 0; return patchNode->getPatch().getHeight(); }
PatchMesh getTesselatedPatchMesh() const { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return PatchMesh(); return patchNode->getPatch().getTesselatedPatchMesh(); }
// Resizes the patch to the given dimensions void setDims(std::size_t width, std::size_t height) { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return; patchNode->getPatch().setDims(width, height); }
void setFixedSubdivisions(bool isFixed, const Subdivisions& divisions) { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return; patchNode->getPatch().setFixedSubdivisions(isFixed, divisions); }
Subdivisions getSubdivisions() const { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return Subdivisions(); return patchNode->getPatch().getSubdivisions(); }
bool subdivionsFixed() const { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return false; return patchNode->getPatch().subdivionsFixed(); }
// Return a defined patch control vertex at <row>,<col> PatchControl& ctrlAt(std::size_t row, std::size_t col) { IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(_node.lock()); if (patchNode == NULL) return _emptyPatchControl; IPatch& patch = patchNode->getPatch(); if (row > patch.getHeight() || col > patch.getWidth()) { rError() << "One or more patch control indices out of bounds: " << row << "," << col << std::endl; return _emptyPatchControl; } return patchNode->getPatch().ctrlAt(row, col); }
void WaveFrontExporter::visit(const scene::INodePtr& node) const { IBrushNodePtr brushNode = boost::dynamic_pointer_cast<IBrushNode>(node); if (brushNode != NULL) { // SelectionSystem Visitor is const, what a pain const_cast<WaveFrontExporter&>(*this).exportBrush(brushNode->getIBrush()); return; } IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(node); if (patchNode != NULL) { const_cast<WaveFrontExporter&>(*this).exportPatch(patchNode->getPatch()); return; } }
/* // Example Primitive { patchDef2 { "textures/darkmod/stone/brick/rough_big_blocks03" ( 5 3 0 0 0 ) ( ( ( 64 -88 108 0 0 ) ( 64 -88 184 0 -1.484375 ) ( 64 -88 184 0 -1.484375 ) ) ( ( 64 -88 184 1.484375 0 ) ( 64 -88 184 1.484375 -1.484375 ) ( 64 -88 184 1.484375 -1.484375 ) ) ( ( 112 -88 184 2.421875 0 ) ( 112 -88 184 2.421875 -1.484375 ) ( 112 -88 184 2.421875 -1.484375 ) ) ( ( 160 -88 184 3.359375 0 ) ( 160 -88 184 3.359375 -1.484375 ) ( 160 -88 184 3.359375 -1.484375 ) ) ( ( 160 -88 108 4.84375 0 ) ( 160 -88 184 4.84375 -1.484375 ) ( 160 -88 184 4.84375 -1.484375 ) ) ) } } */ scene::INodePtr PatchDef2Parser::parse(parser::DefTokeniser& tok) const { scene::INodePtr node = GlobalPatchCreator(DEF2).createPatch(); IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(node); assert(patchNode != NULL); IPatch& patch = patchNode->getPatch(); tok.assertNextToken("{"); // Parse shader patch.setShader(tok.nextToken()); // Parse parameters tok.assertNextToken("("); // parse matrix dimensions std::size_t cols = string::convert<std::size_t>(tok.nextToken()); std::size_t rows = string::convert<std::size_t>(tok.nextToken()); patch.setDims(cols, rows); // ignore contents/flags values tok.skipTokens(3); tok.assertNextToken(")"); // Parse Patch Matrix parseMatrix(tok, patch); // Parse Footer tok.assertNextToken("}"); tok.assertNextToken("}"); patch.controlPointsChanged(); return node; }