| 61 | } |
| 62 | |
| 63 | void buildMaterials(Model model, std::vector<ThreeMaterial>& materials, std::map<std::string, std::string>& materialMap) { |
| 64 | // make construction materials |
| 65 | for (auto& construction : model.getModelObjects<ConstructionBase>()) { |
| 66 | // If it's ConstructionAirBoundary, we'll later use the standard material "AirWall" |
| 67 | if (!construction.optionalCast<ConstructionAirBoundary>()) { |
| 68 | std::string name = getObjectThreeMaterialName(construction); |
| 69 | boost::optional<RenderingColor> color = construction.renderingColor(); |
| 70 | if (!color) { |
| 71 | color = RenderingColor(model); |
| 72 | color->setName(name); |
| 73 | construction.setRenderingColor(*color); |
| 74 | } |
| 75 | addThreeMaterial(materials, materialMap, |
| 76 | makeThreeMaterial(name, toThreeColor(color->renderingRedValue(), color->renderingBlueValue(), color->renderingGreenValue()), |
| 77 | 1, ThreeSide::DoubleSide)); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | // make thermal zone materials |
| 82 | for (auto& thermalZone : model.getConcreteModelObjects<ThermalZone>()) { |
| 83 | std::string name = getObjectThreeMaterialName(thermalZone); |
| 84 | boost::optional<RenderingColor> color = thermalZone.renderingColor(); |
| 85 | if (!color) { |
| 86 | color = RenderingColor(model); |
| 87 | color->setName(name); |
| 88 | thermalZone.setRenderingColor(*color); |
| 89 | } |
| 90 | addThreeMaterial(materials, materialMap, |
| 91 | makeThreeMaterial(name, toThreeColor(color->renderingRedValue(), color->renderingBlueValue(), color->renderingGreenValue()), 1, |
| 92 | ThreeSide::DoubleSide)); |
| 93 | } |
| 94 | |
| 95 | // make space type materials |
| 96 | for (auto& spaceType : model.getConcreteModelObjects<SpaceType>()) { |
| 97 | std::string name = getObjectThreeMaterialName(spaceType); |
| 98 | boost::optional<RenderingColor> color = spaceType.renderingColor(); |
| 99 | if (!color) { |
| 100 | color = RenderingColor(model); |
| 101 | color->setName(name); |
| 102 | spaceType.setRenderingColor(*color); |
| 103 | } |
| 104 | addThreeMaterial(materials, materialMap, |
| 105 | makeThreeMaterial(name, toThreeColor(color->renderingRedValue(), color->renderingBlueValue(), color->renderingGreenValue()), 1, |
| 106 | ThreeSide::DoubleSide)); |
| 107 | } |
| 108 | |
| 109 | // make building story materials |
| 110 | for (auto& buildingStory : model.getConcreteModelObjects<BuildingStory>()) { |
| 111 | std::string name = getObjectThreeMaterialName(buildingStory); |
| 112 | boost::optional<RenderingColor> color = buildingStory.renderingColor(); |
| 113 | if (!color) { |
| 114 | color = RenderingColor(model); |
| 115 | color->setName(name); |
| 116 | buildingStory.setRenderingColor(*color); |
| 117 | } |
| 118 | addThreeMaterial(materials, materialMap, |
| 119 | makeThreeMaterial(name, toThreeColor(color->renderingRedValue(), color->renderingBlueValue(), color->renderingGreenValue()), 1, |
| 120 | ThreeSide::DoubleSide)); |
no test coverage detected