From 2e21d40ce4ef494e73da44a00aaa113a67708294 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Fri, 17 Jan 2014 19:33:54 -0500 Subject: [PATCH] Support tangent meshes in MeshTools --- src/graphics/mesh_tools.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/graphics/mesh_tools.cpp b/src/graphics/mesh_tools.cpp index ff44674e3..49c7814a0 100644 --- a/src/graphics/mesh_tools.cpp +++ b/src/graphics/mesh_tools.cpp @@ -19,20 +19,23 @@ #include "graphics/mesh_tools.hpp" #include #include +#include "utils/log.hpp" void MeshTools::minMax3D(scene::IMesh* mesh, Vec3 *min, Vec3 *max) { Vec3 extend; *min = Vec3( 999999.9f); *max = Vec3(-999999.9f); - for(unsigned int i=0; igetMeshBufferCount(); i++) { + for(unsigned int i=0; igetMeshBufferCount(); i++) + { scene::IMeshBuffer *mb = mesh->getMeshBuffer(i); if (mb->getVertexType() == video::EVT_STANDARD) { u16 *mbIndices = mb->getIndices(); video::S3DVertex* mbVertices=(irr::video::S3DVertex*)mb->getVertices(); - for(unsigned int j=0; jgetIndexCount(); j+=1) { + for (unsigned int j=0; jgetIndexCount(); j+=1) + { int indx=mbIndices[j]; Vec3 c(mbVertices[indx].Pos.X, mbVertices[indx].Pos.Y, @@ -45,7 +48,22 @@ void MeshTools::minMax3D(scene::IMesh* mesh, Vec3 *min, Vec3 *max) { { u16 *mbIndices = mb->getIndices(); video::S3DVertex2TCoords* mbVertices=(irr::video::S3DVertex2TCoords*)mb->getVertices(); - for(unsigned int j=0; jgetIndexCount(); j+=1) { + for (unsigned int j=0; jgetIndexCount(); j+=1) + { + int indx=mbIndices[j]; + Vec3 c(mbVertices[indx].Pos.X, + mbVertices[indx].Pos.Y, + mbVertices[indx].Pos.Z ); + min->min(c); + max->max(c); + } // for j + } + else if (mb->getVertexType() == video::EVT_TANGENTS) + { + u16 *mbIndices = mb->getIndices(); + video::S3DVertexTangents* mbVertices=(irr::video::S3DVertexTangents*)mb->getVertices(); + for (unsigned int j=0; jgetIndexCount(); j+=1) + { int indx=mbIndices[j]; Vec3 c(mbVertices[indx].Pos.X, mbVertices[indx].Pos.Y, @@ -56,8 +74,8 @@ void MeshTools::minMax3D(scene::IMesh* mesh, Vec3 *min, Vec3 *max) { } else { - fprintf(stderr, "Tools::minMax3D: Ignoring type '%d'!\n", - mb->getVertexType()); + Log::warn("Tools", "minMax3D: Ignoring type '%d'!\n", + mb->getVertexType()); } } // for i