From 3182c75f14685ab3e01951389099134bece678a9 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 9 Jan 2021 15:08:30 +0100 Subject: [PATCH] Some changes after #1155 --- src/ifcconvert/IfcConvert.cpp | 6 +++--- src/serializers/GeometrySerializer.h | 4 ++-- src/serializers/WavefrontObjSerializer.cpp | 13 +++++-------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 227557ed8f..79bc01e01c 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -402,7 +402,7 @@ int main(int argc, char** argv) { ("site-local-placement", "Place elements locally in the IfcSite coordinate system, instead of placing " "them in the IFC global coords. Applicable for OBJ and DAE output.") - ("use-z-up", "Z UP. default Y UP,Applicable for OBJ output.") + ("y-up", "Change the 'up' axis to positive Y, default is Z UP,Applicable for OBJ output.") ("building-local-placement", "Similar to --site-local-placement, but placing elements in locally in the parent IfcBuilding coord system") ("precision", po::value(&precision)->default_value(SerializerSettings::DEFAULT_PRECISION), @@ -468,7 +468,7 @@ int main(int argc, char** argv) { const bool use_material_names = vmap.count("use-material-names") != 0; const bool use_element_types = vmap.count("use-element-types") != 0; const bool use_element_hierarchy = vmap.count("use-element-hierarchy") != 0; - const bool use_z_up = vmap.count("use-z-up") != 0; + const bool use_y_up = vmap.count("y-up") != 0; const bool no_normals = vmap.count("no-normals") != 0; const bool center_model = vmap.count("center-model") != 0; const bool center_model_geometry = vmap.count("center-model-geometry") != 0; @@ -742,7 +742,7 @@ int main(int argc, char** argv) { settings.set(SerializerSettings::USE_ELEMENT_NAMES, use_element_names); settings.set(SerializerSettings::USE_ELEMENT_GUIDS, use_element_guids); - settings.set(SerializerSettings::USE_Z_UP, use_z_up); + settings.set(SerializerSettings::USE_Y_UP, use_y_up); settings.set(SerializerSettings::USE_ELEMENT_STEPIDS, use_element_stepids); settings.set(SerializerSettings::USE_MATERIAL_NAMES, use_material_names); settings.set(SerializerSettings::USE_ELEMENT_TYPES, use_element_types); diff --git a/src/serializers/GeometrySerializer.h b/src/serializers/GeometrySerializer.h index 5bcf8d1854..9ff10aaf6c 100644 --- a/src/serializers/GeometrySerializer.h +++ b/src/serializers/GeometrySerializer.h @@ -53,9 +53,9 @@ public: /// Use step ids for naming elements. /// Applicable for OBJ, DAE, and SVG output. USE_ELEMENT_STEPIDS = 1 << (IfcGeom::IteratorSettings::NUM_SETTINGS + 6), - /// Use step Z UP . + /// Use Y UP . /// Applicable for OBJ output. - USE_Z_UP = 1 << (IfcGeom::IteratorSettings::NUM_SETTINGS + 7), + USE_Y_UP = 1 << (IfcGeom::IteratorSettings::NUM_SETTINGS + 7), /// Number of different setting flags. NUM_SETTINGS = 7 }; diff --git a/src/serializers/WavefrontObjSerializer.cpp b/src/serializers/WavefrontObjSerializer.cpp index 2ffd24cad6..7fcad7fb32 100644 --- a/src/serializers/WavefrontObjSerializer.cpp +++ b/src/serializers/WavefrontObjSerializer.cpp @@ -88,11 +88,8 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* { obj_stream << "g " << object_id(o) << "\n"; obj_stream << "s 1" << "\n"; - bool isyup = true; - if (settings().get(SerializerSettings::USE_Z_UP) ){ //settings().get(SerializerSettings::USE_Z_UP) - isyup = false; - } - + const bool isyup = settings().get(SerializerSettings::USE_Y_UP); + const IfcGeom::Representation::Triangulation& mesh = o->geometry(); const int vcount = (int)mesh.verts().size() / 3; @@ -101,10 +98,10 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* const real_t y = *(it++); const real_t z = *(it++); - if(isyup){ + if (isyup) { + obj_stream << "v " << x << " " << z << " " << -y << "\n"; + } else { obj_stream << "v " << x << " " << y << " " << z << "\n"; - }else{ - obj_stream << "v " << -x << " " << z << " " << y << "\n"; } }