diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-03-20 00:26:16 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-03-20 17:53:55 +0000 |
commit | b5db39e7de50cff669920ab1f279df223d257a51 (patch) | |
tree | 1fb620c7ad3d1df8bf31e7fb36a6373ff8594e69 | |
parent | Fix left/right swap of cuboid face names (diff) | |
download | ilt-b5db39e7de50cff669920ab1f279df223d257a51.tar.bz2 ilt-b5db39e7de50cff669920ab1f279df223d257a51.tar.xz ilt-b5db39e7de50cff669920ab1f279df223d257a51.zip |
Support applying a single face controller to multiple faces
-rw-r--r-- | assetFactory/faceController.cpp | 13 | ||||
-rw-r--r-- | assetFactory/faceController.h | 5 | ||||
-rw-r--r-- | res/brush47.xml | 12 |
3 files changed, 20 insertions, 10 deletions
diff --git a/assetFactory/faceController.cpp b/assetFactory/faceController.cpp index 1e563b2..6493300 100644 --- a/assetFactory/faceController.cpp +++ b/assetFactory/faceController.cpp @@ -4,7 +4,18 @@ #include "modelFactoryMesh.h" void -FaceController::apply(ModelFactoryMesh & mesh, const StyleStack & parents, const std::string & name, +FaceController::apply(ModelFactoryMesh & mesh, const StyleStack & parents, const std::string & names, + Shape::CreatedFaces & faces) const +{ + std::stringstream nameStream {names}; + std::for_each(std::istream_iterator<std::string>(nameStream), std::istream_iterator<std::string> {}, + [&](const auto & name) { + applySingle(mesh, parents, name, faces); + }); +} + +void +FaceController::applySingle(ModelFactoryMesh & mesh, const StyleStack & parents, const std::string & name, Shape::CreatedFaces & faces) const { const auto getAdjacentFaceName = [&mesh](const auto & ofrange, OpenMesh::FaceHandle nf) -> std::string { diff --git a/assetFactory/faceController.h b/assetFactory/faceController.h index 10a226a..890aafa 100644 --- a/assetFactory/faceController.h +++ b/assetFactory/faceController.h @@ -12,7 +12,7 @@ class FaceController : public Mutation, public Style, public Persistence::Persis public: using FaceControllers = std::map<std::string, std::unique_ptr<FaceController>>; - void apply(ModelFactoryMesh & mesh, const Style::StyleStack & parents, const std::string & name, + void apply(ModelFactoryMesh & mesh, const Style::StyleStack & parents, const std::string & names, Shape::CreatedFaces & faces) const; std::string id; @@ -28,4 +28,7 @@ private: { return {}; }; + + void applySingle(ModelFactoryMesh & mesh, const Style::StyleStack & parents, const std::string & name, + Shape::CreatedFaces & faces) const; }; diff --git a/res/brush47.xml b/res/brush47.xml index c345c82..f74cb29 100644 --- a/res/brush47.xml +++ b/res/brush47.xml @@ -2,8 +2,7 @@ <ilt p.id="assetFactory"> <object id="wheel"> <use type="cylinder" position="0,0,0.571" scale="1.142,1.142,0.07" rotation="0,0,1.5708" colour="silver"> - <face id="top" colour="#413b3a"/> - <face id="bottom" colour="#413b3a"/> + <face id="top bottom" colour="#413b3a"/> </use> <use type="cuboid" scale="0.3,0.5,0.3" position="0.2,0,0.421" colour="grey30"/> </object> @@ -66,15 +65,12 @@ <use type="cuboid" position="0,0,1.2" scale="2.69,19.38,0.3" colour="goldenrod"> <face id="bottom" colour="#2c3539"/> <face id="top" type="extrude" position="0,0,1.05" colour="#2c4f5a"> - <face id="front" colour="goldenrod"/> - <face id="back" colour="goldenrod"/> + <face id="front back" colour="goldenrod"/> <face id="top" type="extrude" scale="1,0.96,1" position="0,0,0.775"> - <face id="front" colour="#e1eff3"/> - <face id="back" colour="#e1eff3"/> + <face id="front back" colour="#e1eff3"/> <face id="top" type="extrude" scale="0.5,0.85,0" smooth="true" position="0,0,0.575" colour="#aeb0b0"> <face id="top" texture="roofTopWithVents"/> - <face id="left" texture="roofSideWithVents"/> - <face id="right" texture="roofSideWithVents"/> + <face id="right left" texture="roofSideWithVents"/> </face> </face> </face> |