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
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 )
ENDIF()
ENDIF()
@ -164,6 +164,7 @@ ENDIF()
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
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
ENDIF()
# hide all not-exported symbols
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.
- 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,
X-, Collada-, BVH-Loader, Postprocessing framework. Data structure & Interface design, documentation.
- 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,
Linux build, eclipse support.

View File

@ -1463,31 +1463,30 @@ void Parser::ParseLV2MeshBlock(ASE::Mesh& mesh)
continue;
}
// another mesh UV channel ...
if (TokenMatch(filePtr,"MESH_MAPPINGCHANNEL" ,19))
{
unsigned int iIndex = 0;
if (TokenMatch(filePtr,"MESH_MAPPINGCHANNEL" ,19)) {
unsigned int iIndex( 0 );
ParseLV4MeshLong(iIndex);
if (iIndex < 2)
{
if ( 0 == iIndex ) {
LogWarning( "Mapping channel has an invalid index. Skipping UV channel" );
// skip it ...
SkipSection();
} else {
if ( iIndex < 2 ) {
LogWarning( "Mapping channel has an invalid index. Skipping UV channel" );
// skip it ...
SkipSection();
}
if (iIndex > AI_MAX_NUMBER_OF_TEXTURECOORDS)
{
if ( iIndex > AI_MAX_NUMBER_OF_TEXTURECOORDS ) {
LogWarning( "Too many UV channels specified. Skipping channel .." );
// skip it ...
SkipSection();
}
else
{
} else {
// parse the mapping channel
ParseLV3MappingChannel( iIndex - 1, mesh );
}
continue;
}
}
// mesh animation keyframe. Not supported
if (TokenMatch(filePtr,"MESH_ANIMATION" ,14))
{

View File

@ -123,7 +123,6 @@ namespace Blender {
struct ObjectCompare {
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;
}
};
@ -145,7 +144,6 @@ namespace Blender {
struct ObjectCompare {
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;
}
};

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
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;
}
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;
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;
// XXX handle all kinds of UV transformations
uvTrafo.mScaling = tex->UVScaling();
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();
@ -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 )
@ -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, "EmissiveColor", aiTextureType_EMISSIVE, 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, "ReflectionColor", aiTextureType_REFLECTION, 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, "EmissiveColor", aiTextureType_EMISSIVE, 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, "ReflectionColor", aiTextureType_REFLECTION, mesh );
TrySetTextureProperties( out_mat, layeredTextures, "DisplacementColor", aiTextureType_DISPLACEMENT, mesh );

View File

@ -594,23 +594,24 @@ public:
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;
}
float Alpha()
{
return alpha;
}
private:
const Texture* texture;
std::vector<const Texture*> textures;
BlendMode blendMode;
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)
: Object(id,element,name)
,texture(0)
,blendMode(BlendMode_Modulate)
,alpha(1)
{
@ -267,7 +266,7 @@ void LayeredTexture::fillTexture(const Document& doc)
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;
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_1);

View File

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

View File

@ -116,6 +116,16 @@ const aiImporterDesc* IRRMeshImporter::GetInfo () const
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.
void IRRMeshImporter::InternReadFile( const std::string& pFile,
@ -160,10 +170,9 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
// end of previous buffer. A material and a mesh should be there
if ( !curMat || !curMesh) {
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
delete curMat;
delete curMesh;
}
else {
releaseMaterial( curMat );
releaseMesh( curMesh );
} else {
materials.push_back(curMat);
meshes.push_back(curMesh);
}
@ -183,7 +192,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
if (!ASSIMP_stricmp(reader->getNodeName(),"material")) {
if (curMat) {
DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please");
delete curMat;curMat = NULL;
releaseMaterial( curMat );
}
curMat = ParseMaterial(curMatFlags);
}
@ -195,9 +204,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
// This is possible ... remove the mesh from the list and skip further reading
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero vertices");
delete curMat;curMat = NULL;
curMesh = NULL;
releaseMaterial( curMat );
releaseMesh( curMesh );
textMeaning = 0;
continue;
}
@ -240,7 +248,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
vertexFormat = 2;
}
else if (ASSIMP_stricmp("standard", t)) {
delete curMat;
releaseMaterial( curMat );
DefaultLogger::get()->warn("IRRMESH: Unknown vertex format");
}
else vertexFormat = 0;
@ -248,7 +256,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
}
else if (!ASSIMP_stricmp(reader->getNodeName(),"indices")) {
if (curVertices.empty() && curMat) {
delete curMat;
releaseMaterial( curMat );
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");
// mesh - away
delete curMesh; curMesh = NULL;
releaseMesh( curMesh );
// material - away
delete curMat;curMat = NULL;
releaseMaterial( curMat );
textMeaning = 0;
continue;
@ -469,7 +477,6 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
break;
default:
// GCC complains here ...
break;
@ -480,8 +487,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
if (curMat || curMesh) {
if ( !curMat || !curMesh) {
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
delete curMat;
delete curMesh;
releaseMaterial( curMat );
releaseMesh( curMesh );
}
else {
materials.push_back(curMat);

View File

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

View File

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

View File

@ -285,8 +285,6 @@ struct Model
ObjFile::Material *m_pDefaultMaterial;
//! Vector with all generated materials
std::vector<std::string> m_MaterialLib;
//! Vector with all generated group
std::vector<std::string> m_GroupLib;
//! Vector with all generated vertices
std::vector<aiVector3D> m_Vertices;
//! 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
#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/DefaultLogger.hpp>
static const aiImporterDesc desc = {
"Wavefront Object Importer",
"",
@ -389,8 +387,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
const ObjFile::Object* pCurrentObject,
unsigned int uiMeshIndex,
aiMesh* pMesh,
unsigned int numIndices)
{
unsigned int numIndices) {
// Checking preconditions
ai_assert( NULL != pCurrentObject );
@ -400,8 +397,9 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
// Get current mesh
ObjFile::Mesh *pObjMesh = pModel->m_Meshes[ uiMeshIndex ];
if ( NULL == pObjMesh || pObjMesh->m_uiNumIndices < 1)
if ( NULL == pObjMesh || pObjMesh->m_uiNumIndices < 1 ) {
return;
}
// Copy vertices of this mesh instance
pMesh->mNumVertices = numIndices;
@ -429,27 +427,25 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
// Copy vertices, normals and textures into aiMesh instance
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
ObjFile::Face *pSourceFace = pObjMesh->m_Faces[ index ];
// 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 );
if ( vertex >= pModel->m_Vertices.size() )
if ( vertex >= pModel->m_Vertices.size() ) {
throw DeadlyImportError( "OBJ: vertex index out of range" );
}
pMesh->mVertices[ newIndex ] = pModel->m_Vertices[ vertex ];
// 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 );
if ( normal >= pModel->m_Normals.size() )
if ( normal >= pModel->m_Normals.size() ) {
throw DeadlyImportError( "OBJ: vertex normal index out of range" );
}
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
void ObjFileImporter::addTextureMappingModeProperty(aiMaterial* mat, aiTextureType type, int clampMode)
{
ai_assert( NULL != mat);
void ObjFileImporter::addTextureMappingModeProperty( aiMaterial* mat, aiTextureType type, int clampMode) {
if ( nullptr == mat ) {
return;
}
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
void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pScene )
{
ai_assert( NULL != pScene );
if ( NULL == pScene )
void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pScene ) {
if ( NULL == pScene ) {
return;
}
const unsigned int numMaterials = (unsigned int) pModel->m_MaterialLib.size();
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
#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 aiNode;
namespace Assimp
{
namespace Assimp {
namespace ObjFile
{
namespace ObjFile {
struct Object;
struct Model;
}
@ -62,8 +58,7 @@ struct Model;
/// \class ObjFileImporter
/// \brief Imports a waveform obj file
// ------------------------------------------------------------------------------------------------
class ObjFileImporter : public BaseImporter
{
class ObjFileImporter : public BaseImporter {
public:
/// \brief Default constructor
ObjFileImporter();
@ -77,7 +72,6 @@ public:
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const;
private:
//! \brief Appends the supported extension.
const aiImporterDesc* GetInfo () const;

View File

@ -692,38 +692,36 @@ int ObjFileParser::getMaterialIndex( const std::string &strMaterialName )
// -------------------------------------------------------------------
// Getter for a group name.
void ObjFileParser::getGroupName()
{
std::string strGroupName;
void ObjFileParser::getGroupName() {
std::string groupName;
// here we skip 'g ' from line
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 ) ) {
return;
}
// Change active group, if necessary
if ( m_pModel->m_strActiveGroup != strGroupName )
{
if ( m_pModel->m_strActiveGroup != groupName ) {
// 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
createObject( strGroupName );
createObject( groupName );
// New group name, creating a new entry
if (it == m_pModel->m_Groups.end())
{
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);
}
else
{
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 );
}

View File

@ -76,18 +76,20 @@ static const aiImporterDesc desc = {
SMDImporter::SMDImporter()
: configFrameID(),
mBuffer(),
pScene(),
iFileSize(),
iSmallestFrame(),
dLengthOfAnim(),
bHasUVs(),
iLineNumber()
{}
pScene( nullptr ),
iFileSize( 0 ),
iSmallestFrame( -1 ),
dLengthOfAnim( 0.0 ),
bHasUVs(false ),
iLineNumber(-1) {
// empty
}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
SMDImporter::~SMDImporter()
{}
SMDImporter::~SMDImporter() {
// empty
}
// ------------------------------------------------------------------------------------------------
// 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
this->pScene = pScene;
std::vector<char> buff(iFileSize+1);
TextFileToBuffer(file.get(),buff);
mBuffer = &buff[0];
mBuffer.resize( iFileSize + 1 );
TextFileToBuffer(file.get(), mBuffer );
iSmallestFrame = (1 << 31);
bHasUVs = true;
@ -694,7 +695,7 @@ void SMDImporter::CreateOutputMaterials()
// Parse the file
void SMDImporter::ParseFile()
{
const char* szCurrent = mBuffer;
const char* szCurrent = &mBuffer[0];
// read line per line ...
for ( ;; )

View File

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

View File

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

View File

@ -105,7 +105,7 @@ namespace glTF {
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("uri", Value(dataURI, w.mAl).Move(), w.mAl);
}
@ -113,8 +113,8 @@ namespace glTF {
inline void Write(Value& obj, BufferView& bv, AssetWriter& w)
{
obj.AddMember("buffer", Value(bv.buffer->id, w.mAl).Move(), w.mAl);
obj.AddMember("byteOffset", bv.byteOffset, w.mAl);
obj.AddMember("byteLength", bv.byteLength, w.mAl);
obj.AddMember("byteOffset", static_cast<uint64_t>(bv.byteOffset), w.mAl);
obj.AddMember("byteLength", static_cast<uint64_t>(bv.byteLength), 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 "ByteSwapper.h"
#include "SplitLargeMeshes.h"
#include "SceneCombiner.h"
#include <assimp/version.h>
#include <assimp/IOSystem.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
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
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)
, mProperties(pProperties)
{
std::unique_ptr<Asset> asset(new glTF::Asset(pIOSystem));
mAsset = asset.get();
std::unique_ptr<Asset> asset();
mAsset.reset( new glTF::Asset( pIOSystem ) );
if (isBinary) {
asset->SetAsBinary();
mAsset->SetAsBinary();
}
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/material.h>
#include <sstream>
#include <vector>
#include <map>
#include <memory>
struct aiScene;
struct aiNode;
struct aiMaterial;
@ -89,7 +88,7 @@ namespace Assimp
std::map<std::string, unsigned int> mTexturesByPath;
glTF::Asset* mAsset;
std::shared_ptr<glTF::Asset> mAsset;
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);
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]);
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>Will transform uv-coordinates if possible.</td>
</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>
<td><tt>-fid</tt></td>
<td><tt>--find-invalid-data</tt></td>
<td>Will look for invalid data in the imported model structure.</td>
</tr>
<tr>
<td><tt>-fixn</tt></td>
<td><tt>--fix normals</tt></td>
<td>Imported normal vector will be fixed.</td>
</tr>
<tr>
<td><tt>-db</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
g_pcAsset->pcScene = (aiScene*)aiImportFileExWithProperties(g_szFileName,
ppsteps | /* configurable pp steps */
aiProcess_GenSmoothNormals | // generate smooth normal vectors if not existing
aiProcess_SplitLargeMeshes | // split large, unrenderable meshes into submeshes