OgreImporter: Fix UV flip for binary meshes. Fix exception XML parsing when positions are declared in a previous vertex buffer than the currentl parsed one (that has eg. UVs). Remove debug prints from material parser.
parent
f8e1dcb102
commit
43e620e04a
|
@ -217,8 +217,7 @@ aiMaterial* OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste
|
|||
// Skip commented lines
|
||||
if (linePart == partComment)
|
||||
{
|
||||
string postComment = NextAfterNewLine(ss, linePart);
|
||||
DefaultLogger::get()->debug("//" + postComment + " (comment line ignored)");
|
||||
NextAfterNewLine(ss, linePart);
|
||||
continue;
|
||||
}
|
||||
if (linePart != partMaterial)
|
||||
|
@ -361,8 +360,7 @@ bool OgreImporter::ReadTechnique(const std::string &techniqueName, stringstream
|
|||
// Skip commented lines
|
||||
if (linePart == partComment)
|
||||
{
|
||||
string postComment = SkipLine(ss);
|
||||
DefaultLogger::get()->debug(" //" + postComment + " (comment line ignored)");
|
||||
SkipLine(ss);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -402,8 +400,7 @@ bool OgreImporter::ReadPass(const std::string &passName, stringstream &ss, aiMat
|
|||
// Skip commented lines
|
||||
if (linePart == partComment)
|
||||
{
|
||||
string postComment = SkipLine(ss);
|
||||
DefaultLogger::get()->debug(" //" + postComment + " (comment line ignored)");
|
||||
SkipLine(ss);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -471,8 +468,7 @@ bool OgreImporter::ReadTextureUnit(const std::string &textureUnitName, stringstr
|
|||
// Skip commented lines
|
||||
if (linePart == partComment)
|
||||
{
|
||||
string postComment = SkipLine(ss);
|
||||
DefaultLogger::get()->debug(" //" + postComment + " (comment line ignored)");
|
||||
SkipLine(ss);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -346,6 +346,11 @@ VertexDataXml::VertexDataXml()
|
|||
{
|
||||
}
|
||||
|
||||
bool VertexDataXml::HasPositions() const
|
||||
{
|
||||
return !positions.empty();
|
||||
}
|
||||
|
||||
bool VertexDataXml::HasNormals() const
|
||||
{
|
||||
return !normals.empty();
|
||||
|
@ -672,12 +677,14 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent)
|
|||
{
|
||||
uv1->Seek((vWidthUv1 * ogreVertexIndex) + uv1Element->offset, aiOrigin_SET);
|
||||
uv1->Read(&uv1Dest[newIndex], sizeUv1, 1);
|
||||
uv1Dest[newIndex].y = (uv1Dest[newIndex].y * -1) + 1; // Flip UV from Ogre to Assimp form
|
||||
}
|
||||
// UV1
|
||||
if (uv2 && uv2Dest)
|
||||
{
|
||||
uv2->Seek((vWidthUv2 * ogreVertexIndex) + uv2Element->offset, aiOrigin_SET);
|
||||
uv2->Read(&uv2Dest[newIndex], sizeUv2, 1);
|
||||
uv2Dest[newIndex].y = (uv2Dest[newIndex].y * -1) + 1; // Flip UV from Ogre to Assimp form
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -601,6 +601,7 @@ class VertexDataXml : public IVertexData
|
|||
public:
|
||||
VertexDataXml();
|
||||
|
||||
bool HasPositions() const;
|
||||
bool HasNormals() const;
|
||||
bool HasTangents() const;
|
||||
bool HasUvs() const;
|
||||
|
|
|
@ -374,12 +374,16 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(VertexDataXml *dest)
|
|||
bool tangents = (HasAttribute("tangents") && ReadAttribute<bool>("tangents"));
|
||||
uint32_t uvs = (HasAttribute("texture_coords") ? ReadAttribute<uint32_t>("texture_coords") : 0);
|
||||
|
||||
if (!positions) {
|
||||
// Not having positions is a error only if a previous vertex buffer did not have them.
|
||||
if (!positions && !dest->HasPositions()) {
|
||||
throw DeadlyImportError("Vertex buffer does not contain positions!");
|
||||
}
|
||||
|
||||
if (positions)
|
||||
{
|
||||
DefaultLogger::get()->debug(" - Contains positions");
|
||||
dest->positions.reserve(dest->count);
|
||||
|
||||
}
|
||||
if (normals)
|
||||
{
|
||||
DefaultLogger::get()->debug(" - Contains normals");
|
||||
|
@ -454,7 +458,7 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(VertexDataXml *dest)
|
|||
|
||||
aiVector3D uv;
|
||||
uv.x = ReadAttribute<float>("u");
|
||||
uv.y = ReadAttribute<float>("v") * (-1)+1; //flip the uv vertikal, blender exports them so! (ahem... @todo ????)
|
||||
uv.y = (ReadAttribute<float>("v") * -1) + 1; // Flip UV from Ogre to Assimp form
|
||||
dest->uvs[i].push_back(uv);
|
||||
|
||||
NextNode();
|
||||
|
|
Loading…
Reference in New Issue