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
This commit is contained in:
cutealien 2020-07-22 22:12:05 +00:00
parent d7a1a35339
commit a1b9e8c2ed
2 changed files with 17 additions and 13 deletions

View File

@ -1,5 +1,7 @@
-------------------------- --------------------------
Changes in 1.9 (not yet released) 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. - 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) 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. - ICursorControl::isVisible is now always returning the flag set in setVisible.

View File

@ -302,49 +302,51 @@ bool CPLYMeshFileLoader::readVertex(const SPLYElement &Element, scene::CDynamicM
for (u32 i=0; i < Element.Properties.size(); ++i) for (u32 i=0; i < Element.Properties.size(); ++i)
{ {
E_PLY_PROPERTY_TYPE t = Element.Properties[i].Type; 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); vert.Pos.X = getFloat(t);
else if (Element.Properties[i].Name == "y") else if (name == "y")
vert.Pos.Z = getFloat(t); vert.Pos.Z = getFloat(t);
else if (Element.Properties[i].Name == "z") else if (name == "z")
vert.Pos.Y = getFloat(t); vert.Pos.Y = getFloat(t);
else if (Element.Properties[i].Name == "nx") else if (name == "nx")
{ {
vert.Normal.X = getFloat(t); vert.Normal.X = getFloat(t);
result=true; result=true;
} }
else if (Element.Properties[i].Name == "ny") else if (name == "ny")
{ {
vert.Normal.Z = getFloat(t); vert.Normal.Z = getFloat(t);
result=true; result=true;
} }
else if (Element.Properties[i].Name == "nz") else if (name == "nz")
{ {
vert.Normal.Y = getFloat(t); vert.Normal.Y = getFloat(t);
result=true; result=true;
} }
// there isn't a single convention for the UV, some software like Blender or Assimp uses "st" instead of "uv" // 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") // 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); 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); 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); u32 value = Element.Properties[i].isFloat() ? (u32)(getFloat(t)*255.0f) : getInt(t);
vert.Color.setRed(value); 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); u32 value = Element.Properties[i].isFloat() ? (u32)(getFloat(t)*255.0f) : getInt(t);
vert.Color.setGreen(value); 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); u32 value = Element.Properties[i].isFloat() ? (u32)(getFloat(t)*255.0f) : getInt(t);
vert.Color.setBlue(value); 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); u32 value = Element.Properties[i].isFloat() ? (u32)(getFloat(t)*255.0f) : getInt(t);
vert.Color.setAlpha(value); vert.Color.setAlpha(value);