Merge branch 'master' of https://github.com/assimp/assimp into gltf_o3dgc

pull/972/head
Alexandr Arutjunov 2016-09-10 09:05:36 +03:00
commit ac1bcaa4cc
28 changed files with 279 additions and 267 deletions

View File

@ -156,7 +156,7 @@ ENDIF()
# Ensure that we do not run into issues like http://www.tcm.phy.cam.ac.uk/sw/inodes64.html on 32 bit linux # Ensure that we do not run into issues like http://www.tcm.phy.cam.ac.uk/sw/inodes64.html on 32 bit linux
IF( UNIX ) IF( UNIX )
IF (BUILD_SHARED_LIBS AND CMAKE_SIZEOF_VOID_P EQUAL 4) # only necessary for 32-bit linux IF ( CMAKE_SIZEOF_VOID_P EQUAL 4) # only necessary for 32-bit linux
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 ) ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 )
ENDIF() ENDIF()
ENDIF() ENDIF()
@ -164,6 +164,7 @@ ENDIF()
IF((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_IS_MINGW) IF((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_IS_MINGW)
IF (BUILD_SHARED_LIBS AND CMAKE_SIZEOF_VOID_P EQUAL 8) # -fPIC is only required for shared libs on 64 bit IF (BUILD_SHARED_LIBS AND CMAKE_SIZEOF_VOID_P EQUAL 8) # -fPIC is only required for shared libs on 64 bit
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
ENDIF() ENDIF()
# hide all not-exported symbols # hide all not-exported symbols
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -std=c++0x" ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -std=c++0x" )

View File

@ -7,13 +7,13 @@ The following is a non-exhaustive list of all constributors over the years.
If you think your name should be listed here, drop us a line and we'll add you. If you think your name should be listed here, drop us a line and we'll add you.
- Alexander Gessler, - Alexander Gessler,
3DS-, BLEND-, ASE-, DXF-, HMP-, MDL-, MD2-, MD3-, MD5-, MDC-, NFF-, PLY-, STL-, RAW-, OFF-, MS3D-, Q3D- and LWO-Loader, Assimp-Viewer, assimp-cmd, -noboost, Website (Admin and Design). 3DS-, BLEND-, ASE-, DXF-, HMP-, MDL-, MD2-, MD3-, MD5-, MDC-, NFF-, PLY-, STL-, RAW-, OFF-, MS3D-, Q3D- and LWO-Loader, Assimp-Viewer, assimp-cmd, -noboost, Website (Design).
- Thomas Schulze, - Thomas Schulze,
X-, Collada-, BVH-Loader, Postprocessing framework. Data structure & Interface design, documentation. X-, Collada-, BVH-Loader, Postprocessing framework. Data structure & Interface design, documentation.
- Kim Kulling, - Kim Kulling,
Obj-Loader, Logging system, Scons-build environment, CMake build environment, Linux build. Obj-, Q3BSD-, OpenGEX-Loader, Logging system, CMake-build-environment, Linux-build, Website ( Admin ), Coverity ( Admin ), Glitter ( Admin ).
- R.Schmidt, - R.Schmidt,
Linux build, eclipse support. Linux build, eclipse support.

View File

@ -25,8 +25,8 @@ conditions are met:
derived from this software without specific prior derived from this software without specific prior
written permission of the assimp team. written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
@ -1463,31 +1463,30 @@ void Parser::ParseLV2MeshBlock(ASE::Mesh& mesh)
continue; continue;
} }
// another mesh UV channel ... // another mesh UV channel ...
if (TokenMatch(filePtr,"MESH_MAPPINGCHANNEL" ,19)) if (TokenMatch(filePtr,"MESH_MAPPINGCHANNEL" ,19)) {
{ unsigned int iIndex( 0 );
unsigned int iIndex = 0;
ParseLV4MeshLong(iIndex); ParseLV4MeshLong(iIndex);
if ( 0 == iIndex ) {
if (iIndex < 2) LogWarning( "Mapping channel has an invalid index. Skipping UV channel" );
{ // skip it ...
LogWarning("Mapping channel has an invalid index. Skipping UV channel"); SkipSection();
} else {
if ( iIndex < 2 ) {
LogWarning( "Mapping channel has an invalid index. Skipping UV channel" );
// skip it ... // skip it ...
SkipSection(); SkipSection();
} }
if (iIndex > AI_MAX_NUMBER_OF_TEXTURECOORDS) if ( iIndex > AI_MAX_NUMBER_OF_TEXTURECOORDS ) {
{ LogWarning( "Too many UV channels specified. Skipping channel .." );
LogWarning("Too many UV channels specified. Skipping channel ..");
// skip it ... // skip it ...
SkipSection(); SkipSection();
} } else {
else
{
// parse the mapping channel // parse the mapping channel
ParseLV3MappingChannel(iIndex-1,mesh); ParseLV3MappingChannel( iIndex - 1, mesh );
} }
continue; continue;
} }
}
// mesh animation keyframe. Not supported // mesh animation keyframe. Not supported
if (TokenMatch(filePtr,"MESH_ANIMATION" ,14)) if (TokenMatch(filePtr,"MESH_ANIMATION" ,14))
{ {

View File

@ -123,7 +123,6 @@ namespace Blender {
struct ObjectCompare { struct ObjectCompare {
bool operator() (const Object* left, const Object* right) const { bool operator() (const Object* left, const Object* right) const {
printf( "left: %s, right: %s\n", left->id.name, right->id.name );
return ::strncmp(left->id.name, right->id.name, strlen( left->id.name ) ) == 0; return ::strncmp(left->id.name, right->id.name, strlen( left->id.name ) ) == 0;
} }
}; };
@ -145,7 +144,6 @@ namespace Blender {
struct ObjectCompare { struct ObjectCompare {
bool operator() (const Object* left, const Object* right) const { bool operator() (const Object* left, const Object* right) const {
printf( "left: %s, right: %s\n", left->id.name, right->id.name );
return ::strncmp( left->id.name, right->id.name, strlen( left->id.name ) ) == 0; return ::strncmp( left->id.name, right->id.name, strlen( left->id.name ) ) == 0;
} }
}; };

View File

@ -437,7 +437,7 @@ void ComputeUVMappingProcess::Execute( aiScene* pScene)
} }
} }
unsigned int idx; unsigned int idx( 99999999 );
// Check whether we have this mapping mode already // Check whether we have this mapping mode already
std::list<MappingInfo>::iterator it = std::find (mappingStack.begin(),mappingStack.end(), info); std::list<MappingInfo>::iterator it = std::find (mappingStack.begin(),mappingStack.end(), info);

View File

@ -1916,18 +1916,26 @@ void Converter::TrySetTextureProperties( aiMaterial* out_mat, const LayeredTextu
return; return;
} }
const Texture* const tex = ( *it ).second->getTexture(); int texCount = (*it).second->textureCount();
// Set the blend mode for layered textures
int blendmode= (*it).second->GetBlendMode();
out_mat->AddProperty(&blendmode,1,_AI_MATKEY_TEXOP_BASE,target,0);
for(int texIndex = 0; texIndex < texCount; texIndex++){
const Texture* const tex = ( *it ).second->getTexture(texIndex);
aiString path; aiString path;
path.Set( tex->RelativeFilename() ); path.Set( tex->RelativeFilename() );
out_mat->AddProperty( &path, _AI_MATKEY_TEXTURE_BASE, target, 0 ); out_mat->AddProperty( &path, _AI_MATKEY_TEXTURE_BASE, target, texIndex );
aiUVTransform uvTrafo; aiUVTransform uvTrafo;
// XXX handle all kinds of UV transformations // XXX handle all kinds of UV transformations
uvTrafo.mScaling = tex->UVScaling(); uvTrafo.mScaling = tex->UVScaling();
uvTrafo.mTranslation = tex->UVTranslation(); uvTrafo.mTranslation = tex->UVTranslation();
out_mat->AddProperty( &uvTrafo, 1, _AI_MATKEY_UVTRANSFORM_BASE, target, 0 ); out_mat->AddProperty( &uvTrafo, 1, _AI_MATKEY_UVTRANSFORM_BASE, target, texIndex );
const PropertyTable& props = tex->Props(); const PropertyTable& props = tex->Props();
@ -2021,7 +2029,8 @@ void Converter::TrySetTextureProperties( aiMaterial* out_mat, const LayeredTextu
} }
} }
out_mat->AddProperty( &uvIndex, 1, _AI_MATKEY_UVWSRC_BASE, target, 0 ); out_mat->AddProperty( &uvIndex, 1, _AI_MATKEY_UVWSRC_BASE, target, texIndex );
}
} }
void Converter::SetTextureProperties( aiMaterial* out_mat, const TextureMap& textures, const MeshGeometry* const mesh ) void Converter::SetTextureProperties( aiMaterial* out_mat, const TextureMap& textures, const MeshGeometry* const mesh )
@ -2030,6 +2039,7 @@ void Converter::SetTextureProperties( aiMaterial* out_mat, const TextureMap& tex
TrySetTextureProperties( out_mat, textures, "AmbientColor", aiTextureType_AMBIENT, mesh ); TrySetTextureProperties( out_mat, textures, "AmbientColor", aiTextureType_AMBIENT, mesh );
TrySetTextureProperties( out_mat, textures, "EmissiveColor", aiTextureType_EMISSIVE, mesh ); TrySetTextureProperties( out_mat, textures, "EmissiveColor", aiTextureType_EMISSIVE, mesh );
TrySetTextureProperties( out_mat, textures, "SpecularColor", aiTextureType_SPECULAR, mesh ); TrySetTextureProperties( out_mat, textures, "SpecularColor", aiTextureType_SPECULAR, mesh );
TrySetTextureProperties( out_mat, textures, "SpecularFactor", aiTextureType_SPECULAR, mesh);
TrySetTextureProperties( out_mat, textures, "TransparentColor", aiTextureType_OPACITY, mesh ); TrySetTextureProperties( out_mat, textures, "TransparentColor", aiTextureType_OPACITY, mesh );
TrySetTextureProperties( out_mat, textures, "ReflectionColor", aiTextureType_REFLECTION, mesh ); TrySetTextureProperties( out_mat, textures, "ReflectionColor", aiTextureType_REFLECTION, mesh );
TrySetTextureProperties( out_mat, textures, "DisplacementColor", aiTextureType_DISPLACEMENT, mesh ); TrySetTextureProperties( out_mat, textures, "DisplacementColor", aiTextureType_DISPLACEMENT, mesh );
@ -2044,6 +2054,7 @@ void Converter::SetTextureProperties( aiMaterial* out_mat, const LayeredTextureM
TrySetTextureProperties( out_mat, layeredTextures, "AmbientColor", aiTextureType_AMBIENT, mesh ); TrySetTextureProperties( out_mat, layeredTextures, "AmbientColor", aiTextureType_AMBIENT, mesh );
TrySetTextureProperties( out_mat, layeredTextures, "EmissiveColor", aiTextureType_EMISSIVE, mesh ); TrySetTextureProperties( out_mat, layeredTextures, "EmissiveColor", aiTextureType_EMISSIVE, mesh );
TrySetTextureProperties( out_mat, layeredTextures, "SpecularColor", aiTextureType_SPECULAR, mesh ); TrySetTextureProperties( out_mat, layeredTextures, "SpecularColor", aiTextureType_SPECULAR, mesh );
TrySetTextureProperties( out_mat, layeredTextures, "SpecularFactor", aiTextureType_SPECULAR, mesh);
TrySetTextureProperties( out_mat, layeredTextures, "TransparentColor", aiTextureType_OPACITY, mesh ); TrySetTextureProperties( out_mat, layeredTextures, "TransparentColor", aiTextureType_OPACITY, mesh );
TrySetTextureProperties( out_mat, layeredTextures, "ReflectionColor", aiTextureType_REFLECTION, mesh ); TrySetTextureProperties( out_mat, layeredTextures, "ReflectionColor", aiTextureType_REFLECTION, mesh );
TrySetTextureProperties( out_mat, layeredTextures, "DisplacementColor", aiTextureType_DISPLACEMENT, mesh ); TrySetTextureProperties( out_mat, layeredTextures, "DisplacementColor", aiTextureType_DISPLACEMENT, mesh );

View File

@ -594,23 +594,24 @@ public:
BlendMode_BlendModeCount BlendMode_BlendModeCount
}; };
const Texture* getTexture() const const Texture* getTexture(int index=0) const
{ {
return texture; return textures[index];
}
BlendMode GetBlendMode() }
const int textureCount() const {
return textures.size();
}
const BlendMode GetBlendMode() const
{ {
return blendMode; return blendMode;
} }
float Alpha() float Alpha()
{ {
return alpha; return alpha;
} }
private: private:
const Texture* texture; std::vector<const Texture*> textures;
BlendMode blendMode; BlendMode blendMode;
float alpha; float alpha;
}; };

View File

@ -227,7 +227,6 @@ Texture::~Texture()
LayeredTexture::LayeredTexture(uint64_t id, const Element& element, const Document& /*doc*/, const std::string& name) LayeredTexture::LayeredTexture(uint64_t id, const Element& element, const Document& /*doc*/, const std::string& name)
: Object(id,element,name) : Object(id,element,name)
,texture(0)
,blendMode(BlendMode_Modulate) ,blendMode(BlendMode_Modulate)
,alpha(1) ,alpha(1)
{ {
@ -267,7 +266,7 @@ void LayeredTexture::fillTexture(const Document& doc)
const Texture* const tex = dynamic_cast<const Texture*>(ob); const Texture* const tex = dynamic_cast<const Texture*>(ob);
texture = tex; textures.push_back(tex);
} }
} }

View File

@ -282,7 +282,7 @@ void ProcessRevolvedAreaSolid(const IfcRevolvedAreaSolid& solid, TempMesh& resul
const size_t next = (i+1)%size; const size_t next = (i+1)%size;
result.vertcnt.push_back(4); result.vertcnt.push_back(4);
const IfcVector3& base_0 = out[base+i*4+3],base_1 = out[base+next*4+3]; const IfcVector3 base_0 = out[base+i*4+3],base_1 = out[base+next*4+3];
out.push_back(base_0); out.push_back(base_0);
out.push_back(base_1); out.push_back(base_1);

View File

@ -715,14 +715,14 @@ void FindAdjacentContours(ContourVector::iterator current, const ContourVector&
const Contour& mcontour = (*it).contour; const Contour& mcontour = (*it).contour;
for (size_t n = 0; n < ncontour.size(); ++n) { for (size_t n = 0; n < ncontour.size(); ++n) {
const IfcVector2& n0 = ncontour[n]; const IfcVector2 n0 = ncontour[n];
const IfcVector2& n1 = ncontour[(n+1) % ncontour.size()]; const IfcVector2 n1 = ncontour[(n+1) % ncontour.size()];
for (size_t m = 0, mend = (is_me ? n : mcontour.size()); m < mend; ++m) { for (size_t m = 0, mend = (is_me ? n : mcontour.size()); m < mend; ++m) {
ai_assert(&mcontour != &ncontour || m < n); ai_assert(&mcontour != &ncontour || m < n);
const IfcVector2& m0 = mcontour[m]; const IfcVector2 m0 = mcontour[m];
const IfcVector2& m1 = mcontour[(m+1) % mcontour.size()]; const IfcVector2 m1 = mcontour[(m+1) % mcontour.size()];
IfcVector2 isect0, isect1; IfcVector2 isect0, isect1;
if (IntersectingLineSegments(n0,n1, m0, m1, isect0, isect1)) { if (IntersectingLineSegments(n0,n1, m0, m1, isect0, isect1)) {

View File

@ -116,6 +116,16 @@ const aiImporterDesc* IRRMeshImporter::GetInfo () const
return &desc; return &desc;
} }
static void releaseMaterial( aiMaterial *mat ) {
delete mat;
mat = nullptr;
}
static void releaseMesh( aiMesh *mesh ) {
delete mesh;
mesh = nullptr;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure. // Imports the given file into the given scene structure.
void IRRMeshImporter::InternReadFile( const std::string& pFile, void IRRMeshImporter::InternReadFile( const std::string& pFile,
@ -135,7 +145,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
std::vector<aiMaterial*> materials; std::vector<aiMaterial*> materials;
std::vector<aiMesh*> meshes; std::vector<aiMesh*> meshes;
materials.reserve (5); materials.reserve (5);
meshes.reserve (5); meshes.reserve(5);
// temporary data - current mesh buffer // temporary data - current mesh buffer
aiMaterial* curMat = NULL; aiMaterial* curMat = NULL;
@ -160,10 +170,9 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
// end of previous buffer. A material and a mesh should be there // end of previous buffer. A material and a mesh should be there
if ( !curMat || !curMesh) { if ( !curMat || !curMesh) {
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material"); DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
delete curMat; releaseMaterial( curMat );
delete curMesh; releaseMesh( curMesh );
} } else {
else {
materials.push_back(curMat); materials.push_back(curMat);
meshes.push_back(curMesh); meshes.push_back(curMesh);
} }
@ -183,7 +192,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
if (!ASSIMP_stricmp(reader->getNodeName(),"material")) { if (!ASSIMP_stricmp(reader->getNodeName(),"material")) {
if (curMat) { if (curMat) {
DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please"); DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please");
delete curMat;curMat = NULL; releaseMaterial( curMat );
} }
curMat = ParseMaterial(curMatFlags); curMat = ParseMaterial(curMatFlags);
} }
@ -195,17 +204,16 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
// This is possible ... remove the mesh from the list and skip further reading // This is possible ... remove the mesh from the list and skip further reading
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero vertices"); DefaultLogger::get()->warn("IRRMESH: Found mesh with zero vertices");
delete curMat;curMat = NULL; releaseMaterial( curMat );
releaseMesh( curMesh );
curMesh = NULL;
textMeaning = 0; textMeaning = 0;
continue; continue;
} }
curVertices.reserve (num); curVertices.reserve(num);
curNormals.reserve (num); curNormals.reserve(num);
curColors.reserve (num); curColors.reserve(num);
curUVs.reserve (num); curUVs.reserve(num);
// Determine the file format // Determine the file format
const char* t = reader->getAttributeValueSafe("type"); const char* t = reader->getAttributeValueSafe("type");
@ -240,7 +248,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
vertexFormat = 2; vertexFormat = 2;
} }
else if (ASSIMP_stricmp("standard", t)) { else if (ASSIMP_stricmp("standard", t)) {
delete curMat; releaseMaterial( curMat );
DefaultLogger::get()->warn("IRRMESH: Unknown vertex format"); DefaultLogger::get()->warn("IRRMESH: Unknown vertex format");
} }
else vertexFormat = 0; else vertexFormat = 0;
@ -248,7 +256,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
} }
else if (!ASSIMP_stricmp(reader->getNodeName(),"indices")) { else if (!ASSIMP_stricmp(reader->getNodeName(),"indices")) {
if (curVertices.empty() && curMat) { if (curVertices.empty() && curMat) {
delete curMat; releaseMaterial( curMat );
throw DeadlyImportError("IRRMESH: indices must come after vertices"); throw DeadlyImportError("IRRMESH: indices must come after vertices");
} }
@ -264,10 +272,10 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero indices"); DefaultLogger::get()->warn("IRRMESH: Found mesh with zero indices");
// mesh - away // mesh - away
delete curMesh; curMesh = NULL; releaseMesh( curMesh );
// material - away // material - away
delete curMat;curMat = NULL; releaseMaterial( curMat );
textMeaning = 0; textMeaning = 0;
continue; continue;
@ -469,7 +477,6 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
break; break;
default: default:
// GCC complains here ... // GCC complains here ...
break; break;
@ -480,8 +487,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
if (curMat || curMesh) { if (curMat || curMesh) {
if ( !curMat || !curMesh) { if ( !curMat || !curMesh) {
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material"); DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
delete curMat; releaseMaterial( curMat );
delete curMesh; releaseMesh( curMesh );
} }
else { else {
materials.push_back(curMat); materials.push_back(curMat);

View File

@ -731,6 +731,9 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
} }
VALIDATE_FILE_SIZE(szCurrent); VALIDATE_FILE_SIZE(szCurrent);
*szCurrentOut = szCurrent; *szCurrentOut = szCurrent;
if ( nullptr != pcNew ) {
delete pcNew;
}
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -171,7 +171,7 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh)
// build output vertex weights // build output vertex weights
for (unsigned int i = 0;i < pcMesh->mNumBones;++i) for (unsigned int i = 0;i < pcMesh->mNumBones;++i)
{ {
delete pcMesh->mBones[i]->mWeights; delete [] pcMesh->mBones[i]->mWeights;
if (!newWeights[i].empty()) { if (!newWeights[i].empty()) {
pcMesh->mBones[i]->mWeights = new aiVertexWeight[newWeights[i].size()]; pcMesh->mBones[i]->mWeights = new aiVertexWeight[newWeights[i].size()];
aiVertexWeight *weightToCopy = &( newWeights[i][0] ); aiVertexWeight *weightToCopy = &( newWeights[i][0] );

View File

@ -285,8 +285,6 @@ struct Model
ObjFile::Material *m_pDefaultMaterial; ObjFile::Material *m_pDefaultMaterial;
//! Vector with all generated materials //! Vector with all generated materials
std::vector<std::string> m_MaterialLib; std::vector<std::string> m_MaterialLib;
//! Vector with all generated group
std::vector<std::string> m_GroupLib;
//! Vector with all generated vertices //! Vector with all generated vertices
std::vector<aiVector3D> m_Vertices; std::vector<aiVector3D> m_Vertices;
//! vector with all generated normals //! vector with all generated normals

View File

@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
#ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER #ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER
#include "DefaultIOSystem.h" #include "DefaultIOSystem.h"
@ -52,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/ai_assert.h> #include <assimp/ai_assert.h>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
static const aiImporterDesc desc = { static const aiImporterDesc desc = {
"Wavefront Object Importer", "Wavefront Object Importer",
"", "",
@ -389,8 +387,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
const ObjFile::Object* pCurrentObject, const ObjFile::Object* pCurrentObject,
unsigned int uiMeshIndex, unsigned int uiMeshIndex,
aiMesh* pMesh, aiMesh* pMesh,
unsigned int numIndices) unsigned int numIndices) {
{
// Checking preconditions // Checking preconditions
ai_assert( NULL != pCurrentObject ); ai_assert( NULL != pCurrentObject );
@ -400,8 +397,9 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
// Get current mesh // Get current mesh
ObjFile::Mesh *pObjMesh = pModel->m_Meshes[ uiMeshIndex ]; ObjFile::Mesh *pObjMesh = pModel->m_Meshes[ uiMeshIndex ];
if ( NULL == pObjMesh || pObjMesh->m_uiNumIndices < 1) if ( NULL == pObjMesh || pObjMesh->m_uiNumIndices < 1 ) {
return; return;
}
// Copy vertices of this mesh instance // Copy vertices of this mesh instance
pMesh->mNumVertices = numIndices; pMesh->mNumVertices = numIndices;
@ -429,27 +427,25 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
// Copy vertices, normals and textures into aiMesh instance // Copy vertices, normals and textures into aiMesh instance
unsigned int newIndex = 0, outIndex = 0; unsigned int newIndex = 0, outIndex = 0;
for ( size_t index=0; index < pObjMesh->m_Faces.size(); index++ ) for ( size_t index=0; index < pObjMesh->m_Faces.size(); index++ ) {
{
// Get source face // Get source face
ObjFile::Face *pSourceFace = pObjMesh->m_Faces[ index ]; ObjFile::Face *pSourceFace = pObjMesh->m_Faces[ index ];
// Copy all index arrays // Copy all index arrays
for ( size_t vertexIndex = 0, outVertexIndex = 0; vertexIndex < pSourceFace->m_pVertices->size(); vertexIndex++ ) for ( size_t vertexIndex = 0, outVertexIndex = 0; vertexIndex < pSourceFace->m_pVertices->size(); vertexIndex++ ) {
{
const unsigned int vertex = pSourceFace->m_pVertices->at( vertexIndex ); const unsigned int vertex = pSourceFace->m_pVertices->at( vertexIndex );
if ( vertex >= pModel->m_Vertices.size() ) if ( vertex >= pModel->m_Vertices.size() ) {
throw DeadlyImportError( "OBJ: vertex index out of range" ); throw DeadlyImportError( "OBJ: vertex index out of range" );
}
pMesh->mVertices[ newIndex ] = pModel->m_Vertices[ vertex ]; pMesh->mVertices[ newIndex ] = pModel->m_Vertices[ vertex ];
// Copy all normals // Copy all normals
if ( !pModel->m_Normals.empty() && vertexIndex < pSourceFace->m_pNormals->size()) if ( !pModel->m_Normals.empty() && vertexIndex < pSourceFace->m_pNormals->size()) {
{
const unsigned int normal = pSourceFace->m_pNormals->at( vertexIndex ); const unsigned int normal = pSourceFace->m_pNormals->at( vertexIndex );
if ( normal >= pModel->m_Normals.size() ) if ( normal >= pModel->m_Normals.size() ) {
throw DeadlyImportError("OBJ: vertex normal index out of range"); throw DeadlyImportError( "OBJ: vertex normal index out of range" );
}
pMesh->mNormals[ newIndex ] = pModel->m_Normals[ normal ]; pMesh->mNormals[ newIndex ] = pModel->m_Normals[ normal ];
} }
@ -546,20 +542,21 @@ void ObjFileImporter::countObjects(const std::vector<ObjFile::Object*> &rObjects
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Add clamp mode property to material if necessary // Add clamp mode property to material if necessary
void ObjFileImporter::addTextureMappingModeProperty(aiMaterial* mat, aiTextureType type, int clampMode) void ObjFileImporter::addTextureMappingModeProperty( aiMaterial* mat, aiTextureType type, int clampMode) {
{ if ( nullptr == mat ) {
ai_assert( NULL != mat); return;
mat->AddProperty<int>(&clampMode, 1, AI_MATKEY_MAPPINGMODE_U(type, 0)); }
mat->AddProperty<int>(&clampMode, 1, AI_MATKEY_MAPPINGMODE_V(type, 0));
mat->AddProperty<int>( &clampMode, 1, AI_MATKEY_MAPPINGMODE_U( type, 0 ) );
mat->AddProperty<int>( &clampMode, 1, AI_MATKEY_MAPPINGMODE_V( type, 0 ) );
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Creates the material // Creates the material
void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pScene ) void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pScene ) {
{ if ( NULL == pScene ) {
ai_assert( NULL != pScene );
if ( NULL == pScene )
return; return;
}
const unsigned int numMaterials = (unsigned int) pModel->m_MaterialLib.size(); const unsigned int numMaterials = (unsigned int) pModel->m_MaterialLib.size();
pScene->mNumMaterials = 0; pScene->mNumMaterials = 0;

View File

@ -37,8 +37,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
#ifndef OBJ_FILE_IMPORTER_H_INC #ifndef OBJ_FILE_IMPORTER_H_INC
#define OBJ_FILE_IMPORTER_H_INC #define OBJ_FILE_IMPORTER_H_INC
@ -49,11 +47,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct aiMesh; struct aiMesh;
struct aiNode; struct aiNode;
namespace Assimp namespace Assimp {
{
namespace ObjFile namespace ObjFile {
{
struct Object; struct Object;
struct Model; struct Model;
} }
@ -62,8 +58,7 @@ struct Model;
/// \class ObjFileImporter /// \class ObjFileImporter
/// \brief Imports a waveform obj file /// \brief Imports a waveform obj file
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
class ObjFileImporter : public BaseImporter class ObjFileImporter : public BaseImporter {
{
public: public:
/// \brief Default constructor /// \brief Default constructor
ObjFileImporter(); ObjFileImporter();
@ -77,7 +72,6 @@ public:
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const; bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const;
private: private:
//! \brief Appends the supported extension. //! \brief Appends the supported extension.
const aiImporterDesc* GetInfo () const; const aiImporterDesc* GetInfo () const;

View File

@ -692,38 +692,36 @@ int ObjFileParser::getMaterialIndex( const std::string &strMaterialName )
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Getter for a group name. // Getter for a group name.
void ObjFileParser::getGroupName() void ObjFileParser::getGroupName() {
{ std::string groupName;
std::string strGroupName;
// here we skip 'g ' from line // here we skip 'g ' from line
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd); m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
m_DataIt = getName<DataArrayIt>(m_DataIt, m_DataItEnd, strGroupName); m_DataIt = getName<DataArrayIt>(m_DataIt, m_DataItEnd, groupName);
if( isEndOfBuffer( m_DataIt, m_DataItEnd ) ) { if( isEndOfBuffer( m_DataIt, m_DataItEnd ) ) {
return; return;
} }
// Change active group, if necessary // Change active group, if necessary
if ( m_pModel->m_strActiveGroup != strGroupName ) if ( m_pModel->m_strActiveGroup != groupName ) {
{
// Search for already existing entry // Search for already existing entry
ObjFile::Model::ConstGroupMapIt it = m_pModel->m_Groups.find(strGroupName); ObjFile::Model::ConstGroupMapIt it = m_pModel->m_Groups.find(groupName);
// We are mapping groups into the object structure // We are mapping groups into the object structure
createObject( strGroupName ); createObject( groupName );
// New group name, creating a new entry // New group name, creating a new entry
if (it == m_pModel->m_Groups.end()) if (it == m_pModel->m_Groups.end())
{ {
std::vector<unsigned int> *pFaceIDArray = new std::vector<unsigned int>; std::vector<unsigned int> *pFaceIDArray = new std::vector<unsigned int>;
m_pModel->m_Groups[ strGroupName ] = pFaceIDArray; m_pModel->m_Groups[ groupName ] = pFaceIDArray;
m_pModel->m_pGroupFaceIDs = (pFaceIDArray); m_pModel->m_pGroupFaceIDs = (pFaceIDArray);
} }
else else
{ {
m_pModel->m_pGroupFaceIDs = (*it).second; m_pModel->m_pGroupFaceIDs = (*it).second;
} }
m_pModel->m_strActiveGroup = strGroupName; m_pModel->m_strActiveGroup = groupName;
} }
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine ); m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
} }

View File

@ -74,20 +74,22 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
SMDImporter::SMDImporter() SMDImporter::SMDImporter()
: configFrameID(), : configFrameID(),
mBuffer(), mBuffer(),
pScene(), pScene( nullptr ),
iFileSize(), iFileSize( 0 ),
iSmallestFrame(), iSmallestFrame( -1 ),
dLengthOfAnim(), dLengthOfAnim( 0.0 ),
bHasUVs(), bHasUVs(false ),
iLineNumber() iLineNumber(-1) {
{} // empty
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Destructor, private as well // Destructor, private as well
SMDImporter::~SMDImporter() SMDImporter::~SMDImporter() {
{} // empty
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file. // Returns whether the class can handle the format of the given file.
@ -133,9 +135,8 @@ void SMDImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
// Allocate storage and copy the contents of the file to a memory buffer // Allocate storage and copy the contents of the file to a memory buffer
this->pScene = pScene; this->pScene = pScene;
std::vector<char> buff(iFileSize+1); mBuffer.resize( iFileSize + 1 );
TextFileToBuffer(file.get(),buff); TextFileToBuffer(file.get(), mBuffer );
mBuffer = &buff[0];
iSmallestFrame = (1 << 31); iSmallestFrame = (1 << 31);
bHasUVs = true; bHasUVs = true;
@ -694,7 +695,7 @@ void SMDImporter::CreateOutputMaterials()
// Parse the file // Parse the file
void SMDImporter::ParseFile() void SMDImporter::ParseFile()
{ {
const char* szCurrent = mBuffer; const char* szCurrent = &mBuffer[0];
// read line per line ... // read line per line ...
for ( ;; ) for ( ;; )

View File

@ -372,7 +372,7 @@ private:
unsigned int configFrameID; unsigned int configFrameID;
/** Buffer to hold the loaded file */ /** Buffer to hold the loaded file */
const char* mBuffer; std::vector<char> mBuffer;
/** Output scene to be filled /** Output scene to be filled
*/ */

View File

@ -102,12 +102,16 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
XGLImporter::XGLImporter() XGLImporter::XGLImporter()
{} : m_reader( nullptr )
, m_scene( nullptr ) {
// empty
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Destructor, private as well // Destructor, private as well
XGLImporter::~XGLImporter() XGLImporter::~XGLImporter() {
{} // empty
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file. // Returns whether the class can handle the format of the given file.
@ -149,7 +153,7 @@ void XGLImporter::InternReadFile( const std::string& pFile,
free_it free_it_really(dest); free_it free_it_really(dest);
#endif #endif
scene = pScene; m_scene = pScene;
std::shared_ptr<IOStream> stream( pIOHandler->Open( pFile, "rb")); std::shared_ptr<IOStream> stream( pIOHandler->Open( pFile, "rb"));
// check whether we can read from the file // check whether we can read from the file
@ -211,14 +215,13 @@ void XGLImporter::InternReadFile( const std::string& pFile,
// construct the irrXML parser // construct the irrXML parser
CIrrXML_IOStreamReader st(stream.get()); CIrrXML_IOStreamReader st(stream.get());
std::unique_ptr<IrrXMLReader> read( createIrrXMLReader((IFileReadCallBack*) &st) ); m_reader.reset( createIrrXMLReader( ( IFileReadCallBack* ) &st ) );
reader = read.get();
// parse the XML file // parse the XML file
TempScope scope; TempScope scope;
while (ReadElement()) { while (ReadElement()) {
if (!ASSIMP_stricmp(reader->getNodeName(),"world")) { if (!ASSIMP_stricmp(m_reader->getNodeName(),"world")) {
ReadWorld(scope); ReadWorld(scope);
} }
} }
@ -231,21 +234,21 @@ void XGLImporter::InternReadFile( const std::string& pFile,
} }
// copy meshes // copy meshes
scene->mNumMeshes = static_cast<unsigned int>(meshes.size()); m_scene->mNumMeshes = static_cast<unsigned int>(meshes.size());
scene->mMeshes = new aiMesh*[scene->mNumMeshes](); m_scene->mMeshes = new aiMesh*[m_scene->mNumMeshes]();
std::copy(meshes.begin(),meshes.end(),scene->mMeshes); std::copy(meshes.begin(),meshes.end(),m_scene->mMeshes);
// copy materials // copy materials
scene->mNumMaterials = static_cast<unsigned int>(materials.size()); m_scene->mNumMaterials = static_cast<unsigned int>(materials.size());
scene->mMaterials = new aiMaterial*[scene->mNumMaterials](); m_scene->mMaterials = new aiMaterial*[m_scene->mNumMaterials]();
std::copy(materials.begin(),materials.end(),scene->mMaterials); std::copy(materials.begin(),materials.end(),m_scene->mMaterials);
if (scope.light) { if (scope.light) {
scene->mNumLights = 1; m_scene->mNumLights = 1;
scene->mLights = new aiLight*[1]; m_scene->mLights = new aiLight*[1];
scene->mLights[0] = scope.light; m_scene->mLights[0] = scope.light;
scope.light->mName = scene->mRootNode->mName; scope.light->mName = m_scene->mRootNode->mName;
} }
scope.dismiss(); scope.dismiss();
@ -254,8 +257,8 @@ void XGLImporter::InternReadFile( const std::string& pFile,
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool XGLImporter::ReadElement() bool XGLImporter::ReadElement()
{ {
while(reader->read()) { while(m_reader->read()) {
if (reader->getNodeType() == EXN_ELEMENT) { if (m_reader->getNodeType() == EXN_ELEMENT) {
return true; return true;
} }
} }
@ -265,11 +268,11 @@ bool XGLImporter::ReadElement()
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool XGLImporter::ReadElementUpToClosing(const char* closetag) bool XGLImporter::ReadElementUpToClosing(const char* closetag)
{ {
while(reader->read()) { while(m_reader->read()) {
if (reader->getNodeType() == EXN_ELEMENT) { if (m_reader->getNodeType() == EXN_ELEMENT) {
return true; return true;
} }
else if (reader->getNodeType() == EXN_ELEMENT_END && !ASSIMP_stricmp(reader->getNodeName(),closetag)) { else if (m_reader->getNodeType() == EXN_ELEMENT_END && !ASSIMP_stricmp(m_reader->getNodeName(),closetag)) {
return false; return false;
} }
} }
@ -280,11 +283,11 @@ bool XGLImporter::ReadElementUpToClosing(const char* closetag)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool XGLImporter::SkipToText() bool XGLImporter::SkipToText()
{ {
while(reader->read()) { while(m_reader->read()) {
if (reader->getNodeType() == EXN_TEXT) { if (m_reader->getNodeType() == EXN_TEXT) {
return true; return true;
} }
else if (reader->getNodeType() == EXN_ELEMENT || reader->getNodeType() == EXN_ELEMENT_END) { else if (m_reader->getNodeType() == EXN_ELEMENT || m_reader->getNodeType() == EXN_ELEMENT_END) {
ThrowException("expected text contents but found another element (or element end)"); ThrowException("expected text contents but found another element (or element end)");
} }
} }
@ -294,7 +297,7 @@ bool XGLImporter::SkipToText()
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
std::string XGLImporter::GetElementName() std::string XGLImporter::GetElementName()
{ {
const char* s = reader->getNodeName(); const char* s = m_reader->getNodeName();
size_t len = strlen(s); size_t len = strlen(s);
std::string ret; std::string ret;
@ -328,7 +331,7 @@ void XGLImporter::ReadWorld(TempScope& scope)
nd->mName.Set("WORLD"); nd->mName.Set("WORLD");
} }
scene->mRootNode = nd; m_scene->mRootNode = nd;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -586,29 +589,29 @@ bool XGLImporter::ReadMesh(TempScope& scope)
ReadMaterial(scope); ReadMaterial(scope);
} }
else if (s == "p") { else if (s == "p") {
if (!reader->getAttributeValue("ID")) { if (!m_reader->getAttributeValue("ID")) {
LogWarn("no ID attribute on <p>, ignoring"); LogWarn("no ID attribute on <p>, ignoring");
} }
else { else {
int id = reader->getAttributeValueAsInt("ID"); int id = m_reader->getAttributeValueAsInt("ID");
t.points[id] = ReadVec3(); t.points[id] = ReadVec3();
} }
} }
else if (s == "n") { else if (s == "n") {
if (!reader->getAttributeValue("ID")) { if (!m_reader->getAttributeValue("ID")) {
LogWarn("no ID attribute on <n>, ignoring"); LogWarn("no ID attribute on <n>, ignoring");
} }
else { else {
int id = reader->getAttributeValueAsInt("ID"); int id = m_reader->getAttributeValueAsInt("ID");
t.normals[id] = ReadVec3(); t.normals[id] = ReadVec3();
} }
} }
else if (s == "tc") { else if (s == "tc") {
if (!reader->getAttributeValue("ID")) { if (!m_reader->getAttributeValue("ID")) {
LogWarn("no ID attribute on <tc>, ignoring"); LogWarn("no ID attribute on <tc>, ignoring");
} }
else { else {
int id = reader->getAttributeValueAsInt("ID"); int id = m_reader->getAttributeValueAsInt("ID");
t.uvs[id] = ReadVec2(); t.uvs[id] = ReadVec2();
} }
} }
@ -828,10 +831,10 @@ void XGLImporter::ReadFaceVertex(const TempMesh& t, TempFace& out)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
unsigned int XGLImporter::ReadIDAttr() unsigned int XGLImporter::ReadIDAttr()
{ {
for(int i = 0, e = reader->getAttributeCount(); i < e; ++i) { for(int i = 0, e = m_reader->getAttributeCount(); i < e; ++i) {
if(!ASSIMP_stricmp(reader->getAttributeName(i),"id")) { if(!ASSIMP_stricmp(m_reader->getAttributeName(i),"id")) {
return reader->getAttributeValueAsInt(i); return m_reader->getAttributeValueAsInt(i);
} }
} }
return ~0u; return ~0u;
@ -844,7 +847,7 @@ float XGLImporter::ReadFloat()
LogError("unexpected EOF reading float element contents"); LogError("unexpected EOF reading float element contents");
return 0.f; return 0.f;
} }
const char* s = reader->getNodeData(), *se; const char* s = m_reader->getNodeData(), *se;
if(!SkipSpaces(&s)) { if(!SkipSpaces(&s)) {
LogError("unexpected EOL, failed to parse float"); LogError("unexpected EOL, failed to parse float");
@ -869,7 +872,7 @@ unsigned int XGLImporter::ReadIndexFromText()
LogError("unexpected EOF reading index element contents"); LogError("unexpected EOF reading index element contents");
return ~0u; return ~0u;
} }
const char* s = reader->getNodeData(), *se; const char* s = m_reader->getNodeData(), *se;
if(!SkipSpaces(&s)) { if(!SkipSpaces(&s)) {
LogError("unexpected EOL, failed to parse index element"); LogError("unexpected EOL, failed to parse index element");
return ~0u; return ~0u;
@ -894,7 +897,7 @@ aiVector2D XGLImporter::ReadVec2()
LogError("unexpected EOF reading vec2 contents"); LogError("unexpected EOF reading vec2 contents");
return vec; return vec;
} }
const char* s = reader->getNodeData(); const char* s = m_reader->getNodeData();
for(int i = 0; i < 2; ++i) { for(int i = 0; i < 2; ++i) {
if(!SkipSpaces(&s)) { if(!SkipSpaces(&s)) {
@ -923,7 +926,7 @@ aiVector3D XGLImporter::ReadVec3()
LogError("unexpected EOF reading vec3 contents"); LogError("unexpected EOF reading vec3 contents");
return vec; return vec;
} }
const char* s = reader->getNodeData(); const char* s = m_reader->getNodeData();
for(int i = 0; i < 3; ++i) { for(int i = 0; i < 3; ++i) {
if(!SkipSpaces(&s)) { if(!SkipSpaces(&s)) {

View File

@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
#include <assimp/mesh.h> #include <assimp/mesh.h>
#include <assimp/light.h> #include <assimp/light.h>
#include <memory>
struct aiNode; struct aiNode;
@ -203,12 +204,8 @@ private:
unsigned int ResolveMaterialRef(TempScope& scope); unsigned int ResolveMaterialRef(TempScope& scope);
private: private:
std::shared_ptr<irr::io::IrrXMLReader> m_reader;
aiScene* m_scene;
private:
irr::io::IrrXMLReader* reader;
aiScene* scene;
}; };
} // end of namespace Assimp } // end of namespace Assimp

View File

@ -48,6 +48,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# include <Open3DGC/o3dgcSC3DMCDecoder.h> # include <Open3DGC/o3dgcSC3DMCDecoder.h>
#endif #endif
using namespace Assimp;
namespace glTF { namespace glTF {
namespace { namespace {

View File

@ -105,7 +105,7 @@ namespace glTF {
type = "arraybuffer"; type = "arraybuffer";
} }
obj.AddMember("byteLength", b.byteLength, w.mAl); obj.AddMember("byteLength", static_cast<uint64_t>(b.byteLength), w.mAl);
obj.AddMember("type", StringRef(type), w.mAl); obj.AddMember("type", StringRef(type), w.mAl);
obj.AddMember("uri", Value(dataURI, w.mAl).Move(), w.mAl); obj.AddMember("uri", Value(dataURI, w.mAl).Move(), w.mAl);
} }
@ -113,8 +113,8 @@ namespace glTF {
inline void Write(Value& obj, BufferView& bv, AssetWriter& w) inline void Write(Value& obj, BufferView& bv, AssetWriter& w)
{ {
obj.AddMember("buffer", Value(bv.buffer->id, w.mAl).Move(), w.mAl); obj.AddMember("buffer", Value(bv.buffer->id, w.mAl).Move(), w.mAl);
obj.AddMember("byteOffset", bv.byteOffset, w.mAl); obj.AddMember("byteOffset", static_cast<uint64_t>(bv.byteOffset), w.mAl);
obj.AddMember("byteLength", bv.byteLength, w.mAl); obj.AddMember("byteLength", static_cast<uint64_t>(bv.byteLength), w.mAl);
obj.AddMember("target", int(bv.target), w.mAl); obj.AddMember("target", int(bv.target), w.mAl);
} }

View File

@ -49,6 +49,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "StringComparison.h" #include "StringComparison.h"
#include "ByteSwapper.h" #include "ByteSwapper.h"
#include "SplitLargeMeshes.h"
#include "SceneCombiner.h"
#include <assimp/version.h> #include <assimp/version.h>
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/Exporter.hpp> #include <assimp/Exporter.hpp>
@ -77,8 +80,20 @@ namespace Assimp {
// Worker function for exporting a scene to GLTF. Prototyped and registered in Exporter.cpp // Worker function for exporting a scene to GLTF. Prototyped and registered in Exporter.cpp
void ExportSceneGLTF(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) void ExportSceneGLTF(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
{ {
aiScene* sceneCopy_tmp;
SceneCombiner::CopyScene(&sceneCopy_tmp, pScene);
std::unique_ptr<aiScene> sceneCopy(sceneCopy_tmp);
SplitLargeMeshesProcess_Triangle tri_splitter;
tri_splitter.SetLimit(0xffff);
tri_splitter.Execute(sceneCopy.get());
SplitLargeMeshesProcess_Vertex vert_splitter;
vert_splitter.SetLimit(0xffff);
vert_splitter.Execute(sceneCopy.get());
// invoke the exporter // invoke the exporter
glTFExporter exporter(pFile, pIOSystem, pScene, pProperties, false); glTFExporter exporter(pFile, pIOSystem, sceneCopy.get(), pProperties, false);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -100,11 +115,11 @@ glTFExporter::glTFExporter(const char* filename, IOSystem* pIOSystem, const aiSc
, mScene(pScene) , mScene(pScene)
, mProperties(pProperties) , mProperties(pProperties)
{ {
std::unique_ptr<Asset> asset(new glTF::Asset(pIOSystem)); std::unique_ptr<Asset> asset();
mAsset = asset.get(); mAsset.reset( new glTF::Asset( pIOSystem ) );
if (isBinary) { if (isBinary) {
asset->SetAsBinary(); mAsset->SetAsBinary();
} }
ExportMetadata(); ExportMetadata();

View File

@ -46,13 +46,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/types.h> #include <assimp/types.h>
#include <assimp/material.h> #include <assimp/material.h>
#include <sstream> #include <sstream>
#include <vector> #include <vector>
#include <map> #include <map>
#include <memory> #include <memory>
struct aiScene; struct aiScene;
struct aiNode; struct aiNode;
struct aiMaterial; struct aiMaterial;
@ -89,7 +88,7 @@ namespace Assimp
std::map<std::string, unsigned int> mTexturesByPath; std::map<std::string, unsigned int> mTexturesByPath;
glTF::Asset* mAsset; std::shared_ptr<glTF::Asset> mAsset;
std::vector<unsigned char> mBodyData; std::vector<unsigned char> mBodyData;

View File

@ -334,7 +334,7 @@ void glTFImporter::ImportMeshes(glTF::Asset& r)
if (attr.normal.size() > 0 && attr.normal[0]) attr.normal[0]->ExtractData(aim->mNormals); if (attr.normal.size() > 0 && attr.normal[0]) attr.normal[0]->ExtractData(aim->mNormals);
for (size_t tc = 0; tc < attr.texcoord.size() && tc <= AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) { for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) {
attr.texcoord[tc]->ExtractData(aim->mTextureCoords[tc]); attr.texcoord[tc]->ExtractData(aim->mTextureCoords[tc]);
aim->mNumUVComponents[tc] = attr.texcoord[tc]->GetNumComponents(); aim->mNumUVComponents[tc] = attr.texcoord[tc]->GetNumComponents();

View File

@ -494,21 +494,11 @@ more information can be found in the <tt>aiPostProcess.h</tt> header.
<td><tt>--transform-uv-coords</tt></td> <td><tt>--transform-uv-coords</tt></td>
<td>Will transform uv-coordinates if possible.</td> <td>Will transform uv-coordinates if possible.</td>
</tr> </tr>
<tr>
<td><tt>-guv</tt></td>
<td><tt>--gen-uvcoords</tt></td>
<td>Will generate uv-coordinates for textures if possible.</td>
</tr>
<tr> <tr>
<td><tt>-fid</tt></td> <td><tt>-fid</tt></td>
<td><tt>--find-invalid-data</tt></td> <td><tt>--find-invalid-data</tt></td>
<td>Will look for invalid data in the imported model structure.</td> <td>Will look for invalid data in the imported model structure.</td>
</tr> </tr>
<tr>
<td><tt>-fixn</tt></td>
<td><tt>--fix normals</tt></td>
<td>Imported normal vector will be fixed.</td>
</tr>
<tr> <tr>
<td><tt>-db</tt></td> <td><tt>-db</tt></td>
<td><tt>--debone</tt></td> <td><tt>--debone</tt></td>

View File

@ -160,7 +160,6 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
// Call ASSIMPs C-API to load the file // Call ASSIMPs C-API to load the file
g_pcAsset->pcScene = (aiScene*)aiImportFileExWithProperties(g_szFileName, g_pcAsset->pcScene = (aiScene*)aiImportFileExWithProperties(g_szFileName,
ppsteps | /* configurable pp steps */ ppsteps | /* configurable pp steps */
aiProcess_GenSmoothNormals | // generate smooth normal vectors if not existing aiProcess_GenSmoothNormals | // generate smooth normal vectors if not existing
aiProcess_SplitLargeMeshes | // split large, unrenderable meshes into submeshes aiProcess_SplitLargeMeshes | // split large, unrenderable meshes into submeshes