From a1b9e8c2ed239c7f33f03379112ca91d6e6a0e4d Mon Sep 17 00:00:00 2001 From: cutealien Date: Wed, 22 Jul 2020 22:12:05 +0000 Subject: [PATCH] ply meshloader now also supports textures with names texture_u/texture_v. Thx @acy for bugreport and test-model (http://irrlicht.sourceforge.net/forum/viewtopic.php?f=4&t=52646) git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6133 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 2 ++ source/Irrlicht/CPLYMeshFileLoader.cpp | 28 ++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/changes.txt b/changes.txt index 29aafd92..507cd14d 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,7 @@ -------------------------- Changes in 1.9 (not yet released) +- ply meshloader now also supports textures with names texture_u/texture_v. + Thx @acy for bugreport and test-model (http://irrlicht.sourceforge.net/forum/viewtopic.php?f=4&t=52646) - Fix potential reading/writing 1 byte behind it's own buffer in PLY loader. Thanks @wolfgang for report and patch (http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=52627&p=305573#p305573) - ICursorControl::isVisible is now always returning the flag set in setVisible. diff --git a/source/Irrlicht/CPLYMeshFileLoader.cpp b/source/Irrlicht/CPLYMeshFileLoader.cpp index 94cbaceb..26541e10 100644 --- a/source/Irrlicht/CPLYMeshFileLoader.cpp +++ b/source/Irrlicht/CPLYMeshFileLoader.cpp @@ -302,49 +302,51 @@ bool CPLYMeshFileLoader::readVertex(const SPLYElement &Element, scene::CDynamicM for (u32 i=0; i < Element.Properties.size(); ++i) { E_PLY_PROPERTY_TYPE t = Element.Properties[i].Type; + const core::stringc& name = Element.Properties[i].Name; - if (Element.Properties[i].Name == "x") + if (name == "x") vert.Pos.X = getFloat(t); - else if (Element.Properties[i].Name == "y") + else if (name == "y") vert.Pos.Z = getFloat(t); - else if (Element.Properties[i].Name == "z") + else if (name == "z") vert.Pos.Y = getFloat(t); - else if (Element.Properties[i].Name == "nx") + else if (name == "nx") { vert.Normal.X = getFloat(t); result=true; } - else if (Element.Properties[i].Name == "ny") + else if (name == "ny") { vert.Normal.Z = getFloat(t); result=true; } - else if (Element.Properties[i].Name == "nz") + else if (name == "nz") { vert.Normal.Y = getFloat(t); result=true; } - // there isn't a single convention for the UV, some software like Blender or Assimp uses "st" instead of "uv" - else if (Element.Properties[i].Name == "u" || Element.Properties[i].Name == "s") + // There isn't a single convention for the UV, some software like Blender or Assimp uses "st" instead of "uv" + // Not sure which tool creates texture_u/texture_v, but those exist as well. + else if (name == "u" || name == "s" || name == "texture_u") vert.TCoords.X = getFloat(t); - else if (Element.Properties[i].Name == "v" || Element.Properties[i].Name == "t") + else if (name == "v" || name == "t" || name == "texture_v") vert.TCoords.Y = getFloat(t); - else if (Element.Properties[i].Name == "red") + else if (name == "red") { u32 value = Element.Properties[i].isFloat() ? (u32)(getFloat(t)*255.0f) : getInt(t); vert.Color.setRed(value); } - else if (Element.Properties[i].Name == "green") + else if (name == "green") { u32 value = Element.Properties[i].isFloat() ? (u32)(getFloat(t)*255.0f) : getInt(t); vert.Color.setGreen(value); } - else if (Element.Properties[i].Name == "blue") + else if (name == "blue") { u32 value = Element.Properties[i].isFloat() ? (u32)(getFloat(t)*255.0f) : getInt(t); vert.Color.setBlue(value); } - else if (Element.Properties[i].Name == "alpha") + else if (name == "alpha") { u32 value = Element.Properties[i].isFloat() ? (u32)(getFloat(t)*255.0f) : getInt(t); vert.Color.setAlpha(value);