diff --git a/code/OgreImporter.cpp b/code/OgreImporter.cpp index 1a51489d9..eb3b569f5 100644 --- a/code/OgreImporter.cpp +++ b/code/OgreImporter.cpp @@ -110,12 +110,12 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass throw DeadlyImportError("Root node is not but <" + string(reader->getNodeName()) + ">"); // Node names - string nnSharedGeometry = "sharedgeometry"; - string nnVertexBuffer = "vertexbuffer"; - string nnSubMeshes = "submeshes"; - string nnSubMesh = "submesh"; - string nnSubMeshNames = "submeshnames"; - string nnSkeletonLink = "skeletonlink"; + const string nnSharedGeometry = "sharedgeometry"; + const string nnVertexBuffer = "vertexbuffer"; + const string nnSubMeshes = "submeshes"; + const string nnSubMesh = "submesh"; + const string nnSubMeshNames = "submeshnames"; + const string nnSkeletonLink = "skeletonlink"; // -------------------- Shared Geometry -------------------- // This can be used to share geometry between submeshes @@ -123,7 +123,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass NextNode(reader.get()); if (CurrentNodeNameEquals(reader, nnSharedGeometry)) { - DefaultLogger::get()->debug("Reading shader geometry"); + DefaultLogger::get()->debug("Reading shared geometry"); unsigned int NumVertices = GetAttribute(reader.get(), "vertexcount"); NextNode(reader.get()); @@ -147,15 +147,16 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass // Just a index in a array, we add a mesh in each loop cycle, so we get indicies like 0, 1, 2 ... n; // so it is important to do this before pushing the mesh in the vector! + /// @todo Not sure if this really is needed, refactor out if possible. submesh->MaterialIndex = subMeshes.size(); subMeshes.push_back(boost::shared_ptr(submesh)); - // Load the Material: - aiMaterial* MeshMat = LoadMaterial(submesh->MaterialName); - - // Set the Material: - materials.push_back(MeshMat); + /** @todo What is the correct way of handling empty ref here. + Does Assimp require there to be a valid material index for each mesh, + even if its a dummy material. */ + aiMaterial* material = LoadMaterial(submesh->MaterialName); + materials.push_back(material); } if (subMeshes.empty()) diff --git a/code/OgreImporter.hpp b/code/OgreImporter.hpp index cf1d0bda2..d946081da 100644 --- a/code/OgreImporter.hpp +++ b/code/OgreImporter.hpp @@ -5,10 +5,6 @@ #include -/** @todo Read Vertex Colors - @todo Read multiple TexCoords -*/ - namespace Assimp { namespace Ogre @@ -63,10 +59,9 @@ struct SubMesh } }; -// ------------------------------------------------------------------------------------------------ -/// \class OgreImporter -/// \brief Importer for Ogre mesh, skeleton and material formats. -// ------------------------------------------------------------------------------------------------ +/** Importer for Ogre mesh, skeleton and material formats. + @todo Support vertex colors + @todo Support multiple TexCoords (this is already done??) */ class OgreImporter : public BaseImporter { public: diff --git a/code/OgreMesh.cpp b/code/OgreMesh.cpp index e4fba43d3..5ca51e583 100644 --- a/code/OgreMesh.cpp +++ b/code/OgreMesh.cpp @@ -73,11 +73,11 @@ void OgreImporter::ReadSubMesh(const unsigned int submeshIndex, SubMesh &submesh NextNode(reader); string currentNodeName = reader->getNodeName(); - string nnFaces = "faces"; - string nnFace = "face"; - string nnGeometry = "geometry"; - string nnBoneAssignments = "boneassignments"; - string nnVertexBuffer = "vertexbuffer"; + const string nnFaces = "faces"; + const string nnFace = "face"; + const string nnGeometry = "geometry"; + const string nnBoneAssignments = "boneassignments"; + const string nnVertexBuffer = "vertexbuffer"; bool quadWarned = false; @@ -165,14 +165,14 @@ void OgreImporter::ReadVertexBuffer(SubMesh &submesh, XmlReader *reader, const u if (!submesh.HasPositions) throw DeadlyImportError("Vertex buffer does not contain positions!"); - string nnVertex = "vertex"; - string nnPosition = "position"; - string nnNormal = "normal"; - string nnTangent = "tangent"; - string nnBinormal = "binormal"; - string nnTexCoord = "texcoord"; - string nnColorDiffuse = "colour_diffuse"; - string nnColorSpecular = "colour_specular"; + const string nnVertex = "vertex"; + const string nnPosition = "position"; + const string nnNormal = "normal"; + const string nnTangent = "tangent"; + const string nnBinormal = "binormal"; + const string nnTexCoord = "texcoord"; + const string nnColorDiffuse = "colour_diffuse"; + const string nnColorSpecular = "colour_specular"; bool warnBinormal = true; bool warnColorDiffuse = true; @@ -299,7 +299,7 @@ void OgreImporter::ReadBoneWeights(SubMesh &submesh, XmlReader *reader) submesh.Weights.resize(submesh.Positions.size()); unsigned int numRead = 0; - string nnVertexBoneAssignment = "vertexboneassignment"; + const string nnVertexBoneAssignment = "vertexboneassignment"; NextNode(reader); while(CurrentNodeNameEquals(reader, nnVertexBoneAssignment))