closes https://github.com/assimp/assimp/issues/1404: set name with merged meshes for output mesh.
This commit is contained in:
@@ -56,18 +56,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
static const unsigned int NotSet = 0xcdcdcdcd;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Setup final material indices, generae a default material if necessary
|
||||
void Discreet3DSImporter::ReplaceDefaultMaterial()
|
||||
{
|
||||
|
||||
// Try to find an existing material that matches the
|
||||
// typical default material setting:
|
||||
// - no textures
|
||||
// - diffuse color (in grey!)
|
||||
// NOTE: This is here to workaround the fact that some
|
||||
// exporters are writing a default material, too.
|
||||
unsigned int idx = 0xcdcdcdcd;
|
||||
unsigned int idx( NotSet );
|
||||
for (unsigned int i = 0; i < mScene->mMaterials.size();++i)
|
||||
{
|
||||
std::string s = mScene->mMaterials[i].mName;
|
||||
@@ -93,7 +94,9 @@ void Discreet3DSImporter::ReplaceDefaultMaterial()
|
||||
}
|
||||
idx = i;
|
||||
}
|
||||
if (0xcdcdcdcd == idx)idx = (unsigned int)mScene->mMaterials.size();
|
||||
if ( NotSet == idx ) {
|
||||
idx = ( unsigned int )mScene->mMaterials.size();
|
||||
}
|
||||
|
||||
// now iterate through all meshes and through all faces and
|
||||
// find all faces that are using the default material
|
||||
|
||||
+12
-4
@@ -58,6 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "time.h"
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/mesh.h>
|
||||
#include <stdio.h>
|
||||
#include "ScenePrivate.h"
|
||||
|
||||
@@ -757,7 +758,7 @@ void SceneCombiner::MergeBones(aiMesh* out,std::vector<aiMesh*>::const_iterator
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Merge a list of meshes
|
||||
void SceneCombiner::MergeMeshes(aiMesh** _out,unsigned int /*flags*/,
|
||||
void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/,
|
||||
std::vector<aiMesh*>::const_iterator begin,
|
||||
std::vector<aiMesh*>::const_iterator end)
|
||||
{
|
||||
@@ -772,8 +773,14 @@ void SceneCombiner::MergeMeshes(aiMesh** _out,unsigned int /*flags*/,
|
||||
aiMesh* out = *_out = new aiMesh();
|
||||
out->mMaterialIndex = (*begin)->mMaterialIndex;
|
||||
|
||||
std::string name;
|
||||
// Find out how much output storage we'll need
|
||||
for (std::vector<aiMesh*>::const_iterator it = begin; it != end;++it) {
|
||||
for (std::vector<aiMesh*>::const_iterator it = begin; it != end; ++it) {
|
||||
const char *meshName( (*it)->mName.C_Str() );
|
||||
name += std::string( meshName );
|
||||
if ( it != end - 1 ) {
|
||||
name += ".";
|
||||
}
|
||||
out->mNumVertices += (*it)->mNumVertices;
|
||||
out->mNumFaces += (*it)->mNumFaces;
|
||||
out->mNumBones += (*it)->mNumBones;
|
||||
@@ -781,6 +788,7 @@ void SceneCombiner::MergeMeshes(aiMesh** _out,unsigned int /*flags*/,
|
||||
// combine primitive type flags
|
||||
out->mPrimitiveTypes |= (*it)->mPrimitiveTypes;
|
||||
}
|
||||
out->mName.Set( name.c_str() );
|
||||
|
||||
if (out->mNumVertices) {
|
||||
aiVector3D* pv2;
|
||||
@@ -789,7 +797,7 @@ void SceneCombiner::MergeMeshes(aiMesh** _out,unsigned int /*flags*/,
|
||||
if ((**begin).HasPositions()) {
|
||||
|
||||
pv2 = out->mVertices = new aiVector3D[out->mNumVertices];
|
||||
for (std::vector<aiMesh*>::const_iterator it = begin; it != end;++it) {
|
||||
for (std::vector<aiMesh*>::const_iterator it = begin; it != end; ++it) {
|
||||
if ((*it)->mVertices) {
|
||||
::memcpy(pv2,(*it)->mVertices,(*it)->mNumVertices*sizeof(aiVector3D));
|
||||
}
|
||||
@@ -809,7 +817,7 @@ void SceneCombiner::MergeMeshes(aiMesh** _out,unsigned int /*flags*/,
|
||||
pv2 += (*it)->mNumVertices;
|
||||
}
|
||||
}
|
||||
// copy tangents and bitangents
|
||||
// copy tangents and bi-tangents
|
||||
if ((**begin).HasTangentsAndBitangents()) {
|
||||
|
||||
pv2 = out->mTangents = new aiVector3D[out->mNumVertices];
|
||||
|
||||
Reference in New Issue
Block a user