merge upstream/master and fix conflicts
commit
6ce2a37b82
|
@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// Header files, Assimp.
|
// Header files, Assimp.
|
||||||
#include "SceneCombiner.h"
|
#include "SceneCombiner.h"
|
||||||
#include "StandardShapes.h"
|
#include "StandardShapes.h"
|
||||||
|
#include "StringUtils.h"
|
||||||
|
|
||||||
// Header files, stdlib.
|
// Header files, stdlib.
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -950,7 +951,7 @@ nl_clean_loop:
|
||||||
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
|
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
|
||||||
for(const SPP_Texture& tex_convd: mTexture_Converted)
|
for(const SPP_Texture& tex_convd: mTexture_Converted)
|
||||||
{
|
{
|
||||||
const aiString texture_id(AI_EMBEDDED_TEXNAME_PREFIX + std::to_string(idx));
|
const aiString texture_id(AI_EMBEDDED_TEXNAME_PREFIX + to_string(idx));
|
||||||
const int mode = aiTextureOp_Multiply;
|
const int mode = aiTextureOp_Multiply;
|
||||||
const int repeat = tex_convd.Tiled ? 1 : 0;
|
const int repeat = tex_convd.Tiled ? 1 : 0;
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "fast_atof.h"
|
#include "fast_atof.h"
|
||||||
#include "SceneCombiner.h"
|
#include "SceneCombiner.h"
|
||||||
#include "DefaultIOSystem.h"
|
#include "DefaultIOSystem.h"
|
||||||
|
#include "StringUtils.h"
|
||||||
#include "XMLTools.h"
|
#include "XMLTools.h"
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <assimp/Exporter.hpp>
|
#include <assimp/Exporter.hpp>
|
||||||
|
@ -637,7 +638,7 @@ void ColladaExporter::WriteMaterials()
|
||||||
aiString name;
|
aiString name;
|
||||||
if( mat->Get( AI_MATKEY_NAME, name) != aiReturn_SUCCESS )
|
if( mat->Get( AI_MATKEY_NAME, name) != aiReturn_SUCCESS )
|
||||||
name = "mat";
|
name = "mat";
|
||||||
materials[a].name = std::string( "m") + std::to_string(a) + name.C_Str();
|
materials[a].name = std::string( "m") + to_string(a) + name.C_Str();
|
||||||
for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it ) {
|
for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it ) {
|
||||||
if( !isalnum_C( *it ) ) {
|
if( !isalnum_C( *it ) ) {
|
||||||
*it = '_';
|
*it = '_';
|
||||||
|
@ -813,7 +814,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
|
||||||
{
|
{
|
||||||
if( mesh->HasTextureCoords( a) )
|
if( mesh->HasTextureCoords( a) )
|
||||||
{
|
{
|
||||||
WriteFloatArray( idstr + "-tex" + std::to_string(a), mesh->mNumUVComponents[a] == 3 ? FloatType_TexCoord3 : FloatType_TexCoord2,
|
WriteFloatArray( idstr + "-tex" + to_string(a), mesh->mNumUVComponents[a] == 3 ? FloatType_TexCoord3 : FloatType_TexCoord2,
|
||||||
(ai_real*) mesh->mTextureCoords[a], mesh->mNumVertices);
|
(ai_real*) mesh->mTextureCoords[a], mesh->mNumVertices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -822,7 +823,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
|
||||||
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a)
|
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a)
|
||||||
{
|
{
|
||||||
if( mesh->HasVertexColors( a) )
|
if( mesh->HasVertexColors( a) )
|
||||||
WriteFloatArray( idstr + "-color" + std::to_string(a), FloatType_Color, (ai_real*) mesh->mColors[a], mesh->mNumVertices);
|
WriteFloatArray( idstr + "-color" + to_string(a), FloatType_Color, (ai_real*) mesh->mColors[a], mesh->mNumVertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
// assemble vertex structure
|
// assemble vertex structure
|
||||||
|
|
|
@ -53,6 +53,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include "StringUtils.h"
|
||||||
|
|
||||||
struct aiScene;
|
struct aiScene;
|
||||||
struct aiNode;
|
struct aiNode;
|
||||||
|
|
||||||
|
@ -122,7 +124,9 @@ protected:
|
||||||
void PopTag() { ai_assert( startstr.length() > 1); startstr.erase( startstr.length() - 2); }
|
void PopTag() { ai_assert( startstr.length() > 1); startstr.erase( startstr.length() - 2); }
|
||||||
|
|
||||||
/// Creates a mesh ID for the given mesh
|
/// Creates a mesh ID for the given mesh
|
||||||
std::string GetMeshId( size_t pIndex) const { return std::string( "meshId" ) + std::to_string(pIndex); }
|
std::string GetMeshId( size_t pIndex) const {
|
||||||
|
return std::string( "meshId" ) + to_string(pIndex);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Stringstream to write all output into
|
/// Stringstream to write all output into
|
||||||
|
|
|
@ -300,7 +300,7 @@ void ColladaParser::ReadAnimationClipLibrary()
|
||||||
else if (indexID >= 0)
|
else if (indexID >= 0)
|
||||||
animName = mReader->getAttributeValue(indexID);
|
animName = mReader->getAttributeValue(indexID);
|
||||||
else
|
else
|
||||||
animName = std::string("animation_") + std::to_string(mAnimationClipLibrary.size());
|
animName = std::string("animation_") + to_string(mAnimationClipLibrary.size());
|
||||||
|
|
||||||
std::pair<std::string, std::vector<std::string> > clip;
|
std::pair<std::string, std::vector<std::string> > clip;
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/IOStream.hpp>
|
#include <assimp/IOStream.hpp>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <contrib/unzip/unzip.h>
|
|
||||||
#include "irrXMLWrapper.h"
|
|
||||||
#include "StringComparison.h"
|
#include "StringComparison.h"
|
||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
|
|
||||||
|
@ -61,10 +59,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <assimp/ai_assert.h>
|
#include <assimp/ai_assert.h>
|
||||||
|
|
||||||
#include "D3MFOpcPackage.h"
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
|
||||||
|
|
||||||
|
#include "D3MFOpcPackage.h"
|
||||||
|
#include <contrib/unzip/unzip.h>
|
||||||
|
#include "irrXMLWrapper.h"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace D3MF {
|
namespace D3MF {
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "D3MFOpcPackage.h"
|
#include "D3MFOpcPackage.h"
|
||||||
#include "Exceptional.h"
|
#include "Exceptional.h"
|
||||||
|
|
||||||
#include <contrib/unzip/unzip.h>
|
|
||||||
#include <assimp/IOStream.hpp>
|
#include <assimp/IOStream.hpp>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
|
@ -57,6 +56,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
|
||||||
|
|
||||||
|
#include <contrib/unzip/unzip.h>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
namespace D3MF {
|
namespace D3MF {
|
||||||
|
|
|
@ -120,7 +120,7 @@ size_t DefaultIOStream::FileSize() const
|
||||||
//
|
//
|
||||||
// See here for details:
|
// See here for details:
|
||||||
// https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file
|
// https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file
|
||||||
#if defined _WIN32 && !defined __GNUC__
|
#if defined _WIN32
|
||||||
struct __stat64 fileStat;
|
struct __stat64 fileStat;
|
||||||
int err = _stat64( mFilename.c_str(), &fileStat );
|
int err = _stat64( mFilename.c_str(), &fileStat );
|
||||||
if (0 != err)
|
if (0 != err)
|
||||||
|
|
|
@ -195,7 +195,7 @@ bool MD5Parser::ParseSection(Section& out)
|
||||||
#define AI_MD5_SKIP_SPACES() if(!SkipSpaces(&sz)) \
|
#define AI_MD5_SKIP_SPACES() if(!SkipSpaces(&sz)) \
|
||||||
MD5Parser::ReportWarning("Unexpected end of line",elem.iLineNumber);
|
MD5Parser::ReportWarning("Unexpected end of line",elem.iLineNumber);
|
||||||
|
|
||||||
// read a triple float in brackets: (1.0 1.0 1.0)
|
// read a triple float in brackets: (1.0 1.0 1.0)
|
||||||
#define AI_MD5_READ_TRIPLE(vec) \
|
#define AI_MD5_READ_TRIPLE(vec) \
|
||||||
AI_MD5_SKIP_SPACES(); \
|
AI_MD5_SKIP_SPACES(); \
|
||||||
if ('(' != *sz++) \
|
if ('(' != *sz++) \
|
||||||
|
@ -210,7 +210,7 @@ bool MD5Parser::ParseSection(Section& out)
|
||||||
if (')' != *sz++) \
|
if (')' != *sz++) \
|
||||||
MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber);
|
MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber);
|
||||||
|
|
||||||
// parse a string, enclosed in quotation marks or not
|
// parse a string, enclosed in quotation marks or not
|
||||||
#define AI_MD5_PARSE_STRING(out) \
|
#define AI_MD5_PARSE_STRING(out) \
|
||||||
bool bQuota = (*sz == '\"'); \
|
bool bQuota = (*sz == '\"'); \
|
||||||
const char* szStart = sz; \
|
const char* szStart = sz; \
|
||||||
|
@ -228,6 +228,15 @@ bool MD5Parser::ParseSection(Section& out)
|
||||||
::memcpy(out.data,szStart,out.length); \
|
::memcpy(out.data,szStart,out.length); \
|
||||||
out.data[out.length] = '\0';
|
out.data[out.length] = '\0';
|
||||||
|
|
||||||
|
// parse a string, enclosed in quotation marks
|
||||||
|
#define AI_MD5_PARSE_STRING_IN_QUOTATION(out) \
|
||||||
|
while('\"'!=*sz)++sz; \
|
||||||
|
const char* szStart = ++sz; \
|
||||||
|
while('\"'!=*sz)++sz; \
|
||||||
|
const char* szEnd = (sz++); \
|
||||||
|
out.length = (size_t)(szEnd - szStart); \
|
||||||
|
::memcpy(out.data,szStart,out.length); \
|
||||||
|
out.data[out.length] = '\0';
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// .MD5MESH parsing function
|
// .MD5MESH parsing function
|
||||||
MD5MeshParser::MD5MeshParser(SectionList& mSections)
|
MD5MeshParser::MD5MeshParser(SectionList& mSections)
|
||||||
|
@ -247,9 +256,9 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
|
||||||
for (const auto & elem : (*iter).mElements){
|
for (const auto & elem : (*iter).mElements){
|
||||||
mJoints.push_back(BoneDesc());
|
mJoints.push_back(BoneDesc());
|
||||||
BoneDesc& desc = mJoints.back();
|
BoneDesc& desc = mJoints.back();
|
||||||
|
|
||||||
const char* sz = elem.szStart;
|
const char* sz = elem.szStart;
|
||||||
AI_MD5_PARSE_STRING(desc.mName);
|
AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
|
|
||||||
// negative values, at least -1, is allowed here
|
// negative values, at least -1, is allowed here
|
||||||
|
@ -269,7 +278,7 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
|
||||||
// shader attribute
|
// shader attribute
|
||||||
if (TokenMatch(sz,"shader",6)) {
|
if (TokenMatch(sz,"shader",6)) {
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
AI_MD5_PARSE_STRING(desc.mShader);
|
AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mShader);
|
||||||
}
|
}
|
||||||
// numverts attribute
|
// numverts attribute
|
||||||
else if (TokenMatch(sz,"numverts",8)) {
|
else if (TokenMatch(sz,"numverts",8)) {
|
||||||
|
@ -362,7 +371,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
|
||||||
AnimBoneDesc& desc = mAnimatedBones.back();
|
AnimBoneDesc& desc = mAnimatedBones.back();
|
||||||
|
|
||||||
const char* sz = elem.szStart;
|
const char* sz = elem.szStart;
|
||||||
AI_MD5_PARSE_STRING(desc.mName);
|
AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
|
|
||||||
// parent index - negative values are allowed (at least -1)
|
// parent index - negative values are allowed (at least -1)
|
||||||
|
|
|
@ -182,10 +182,15 @@ void ObjFileParser::parseFile()
|
||||||
|
|
||||||
case 'm': // Parse a material library or merging group ('mg')
|
case 'm': // Parse a material library or merging group ('mg')
|
||||||
{
|
{
|
||||||
if (*(m_DataIt + 1) == 'g')
|
std::string name;
|
||||||
|
|
||||||
|
getName(m_DataIt, m_DataItEnd, name);
|
||||||
|
if (name == "mg")
|
||||||
getGroupNumberAndResolution();
|
getGroupNumberAndResolution();
|
||||||
else
|
else if(name == "mtllib")
|
||||||
getMaterialLib();
|
getMaterialLib();
|
||||||
|
else
|
||||||
|
goto pf_skip_line;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -209,6 +214,8 @@ void ObjFileParser::parseFile()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
pf_skip_line:
|
||||||
|
|
||||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -625,6 +632,10 @@ void ObjFileParser::getMaterialLib()
|
||||||
// Check for existence
|
// Check for existence
|
||||||
const std::string strMatName(pStart, &(*m_DataIt));
|
const std::string strMatName(pStart, &(*m_DataIt));
|
||||||
std::string absName;
|
std::string absName;
|
||||||
|
|
||||||
|
// Check if directive is valid.
|
||||||
|
if(!strMatName.length()) throw DeadlyImportError("File name of the material is absent.");
|
||||||
|
|
||||||
if ( m_pIO->StackSize() > 0 ) {
|
if ( m_pIO->StackSize() > 0 ) {
|
||||||
std::string path = m_pIO->CurrentDirectory();
|
std::string path = m_pIO->CurrentDirectory();
|
||||||
if ( '/' != *path.rbegin() ) {
|
if ( '/' != *path.rbegin() ) {
|
||||||
|
|
|
@ -124,7 +124,7 @@ namespace Grammar {
|
||||||
MaterialToken,
|
MaterialToken,
|
||||||
ColorToken,
|
ColorToken,
|
||||||
ParamToken,
|
ParamToken,
|
||||||
TextureToken,
|
TextureToken,
|
||||||
AttenToken
|
AttenToken
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ OpenGEXImporter::VertexContainer::~VertexContainer() {
|
||||||
delete[] m_vertices;
|
delete[] m_vertices;
|
||||||
delete[] m_colors;
|
delete[] m_colors;
|
||||||
delete[] m_normals;
|
delete[] m_normals;
|
||||||
|
|
||||||
for(auto &texcoords : m_textureCoords) {
|
for(auto &texcoords : m_textureCoords) {
|
||||||
delete [] texcoords;
|
delete [] texcoords;
|
||||||
}
|
}
|
||||||
|
@ -413,7 +413,7 @@ void OpenGEXImporter::handleNodes( DDLNode *node, aiScene *pScene ) {
|
||||||
case Grammar::ColorToken:
|
case Grammar::ColorToken:
|
||||||
handleColorNode( *it, pScene );
|
handleColorNode( *it, pScene );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Grammar::ParamToken:
|
case Grammar::ParamToken:
|
||||||
handleParamNode( *it, pScene );
|
handleParamNode( *it, pScene );
|
||||||
break;
|
break;
|
||||||
|
@ -479,7 +479,7 @@ void OpenGEXImporter::handleNameNode( DDLNode *node, aiScene *pScene ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string name( val->getString() );
|
const std::string name( val->getString() );
|
||||||
if( m_tokenType == Grammar::GeometryNodeToken || m_tokenType == Grammar::LightNodeToken
|
if( m_tokenType == Grammar::GeometryNodeToken || m_tokenType == Grammar::LightNodeToken
|
||||||
|| m_tokenType == Grammar::CameraNodeToken ) {
|
|| m_tokenType == Grammar::CameraNodeToken ) {
|
||||||
m_currentNode->mName.Set( name.c_str() );
|
m_currentNode->mName.Set( name.c_str() );
|
||||||
} else if( m_tokenType == Grammar::MaterialToken ) {
|
} else if( m_tokenType == Grammar::MaterialToken ) {
|
||||||
|
@ -515,7 +515,7 @@ void OpenGEXImporter::handleObjectRefNode( DDLNode *node, aiScene *pScene ) {
|
||||||
|
|
||||||
std::vector<std::string> objRefNames;
|
std::vector<std::string> objRefNames;
|
||||||
getRefNames( node, objRefNames );
|
getRefNames( node, objRefNames );
|
||||||
|
|
||||||
// when we are dealing with a geometry node prepare the mesh cache
|
// when we are dealing with a geometry node prepare the mesh cache
|
||||||
if ( m_tokenType == Grammar::GeometryNodeToken ) {
|
if ( m_tokenType == Grammar::GeometryNodeToken ) {
|
||||||
m_currentNode->mNumMeshes = objRefNames.size();
|
m_currentNode->mNumMeshes = objRefNames.size();
|
||||||
|
@ -596,7 +596,7 @@ void OpenGEXImporter::handleGeometryObject( DDLNode *node, aiScene *pScene ) {
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
void OpenGEXImporter::handleCameraObject( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
void OpenGEXImporter::handleCameraObject( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
||||||
// parameters will be parsed normally in the tree, so just go for it
|
// parameters will be parsed normally in the tree, so just go for it
|
||||||
|
|
||||||
handleNodes( node, pScene );
|
handleNodes( node, pScene );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,7 +757,6 @@ static void fillColor4( aiColor4D *col4, Value *vals ) {
|
||||||
ai_assert( nullptr != col4 );
|
ai_assert( nullptr != col4 );
|
||||||
ai_assert( nullptr != vals );
|
ai_assert( nullptr != vals );
|
||||||
|
|
||||||
float r( 0.0f ), g( 0.0f ), b( 0.0f ), a ( 1.0f );
|
|
||||||
Value *next( vals );
|
Value *next( vals );
|
||||||
col4->r = next->getFloat();
|
col4->r = next->getFloat();
|
||||||
next = next->m_next;
|
next = next->m_next;
|
||||||
|
@ -1169,7 +1168,7 @@ void OpenGEXImporter::pushNode( aiNode *node, aiScene *pScene ) {
|
||||||
if ( nullptr == node ) {
|
if ( nullptr == node ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChildInfo *info( nullptr );
|
ChildInfo *info( nullptr );
|
||||||
if( m_nodeStack.empty() ) {
|
if( m_nodeStack.empty() ) {
|
||||||
node->mParent = pScene->mRootNode;
|
node->mParent = pScene->mRootNode;
|
||||||
|
|
|
@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -103,7 +104,7 @@ float ai_strtof( const char *begin, const char *end ) {
|
||||||
std::string token( begin, len );
|
std::string token( begin, len );
|
||||||
val = static_cast< float >( ::atof( token.c_str() ) );
|
val = static_cast< float >( ::atof( token.c_str() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
// Header files, Assimp.
|
// Header files, Assimp.
|
||||||
#include "Exceptional.h"
|
#include "Exceptional.h"
|
||||||
|
#include "StringUtils.h"
|
||||||
#include <assimp/Exporter.hpp>
|
#include <assimp/Exporter.hpp>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "X3DImporter.hpp"
|
#include "X3DImporter.hpp"
|
||||||
#include "X3DImporter_Macro.hpp"
|
#include "X3DImporter_Macro.hpp"
|
||||||
|
#include "StringUtils.h"
|
||||||
|
|
||||||
// Header files, Assimp.
|
// Header files, Assimp.
|
||||||
#include "DefaultIOSystem.h"
|
#include "DefaultIOSystem.h"
|
||||||
|
@ -55,11 +56,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp {
|
||||||
{
|
|
||||||
|
|
||||||
/// \var aiImporterDesc X3DImporter::Description
|
/// \var aiImporterDesc X3DImporter::Description
|
||||||
/// Conastant which hold importer description
|
/// Constant which holds the importer description
|
||||||
const aiImporterDesc X3DImporter::Description = {
|
const aiImporterDesc X3DImporter::Description = {
|
||||||
"Extensible 3D(X3D) Importer",
|
"Extensible 3D(X3D) Importer",
|
||||||
"smalcom",
|
"smalcom",
|
||||||
|
@ -87,7 +87,7 @@ void X3DImporter::Clear()
|
||||||
|
|
||||||
X3DImporter::~X3DImporter()
|
X3DImporter::~X3DImporter()
|
||||||
{
|
{
|
||||||
if(mReader != nullptr) delete mReader;
|
delete mReader;
|
||||||
// Clear() is accounting if data already is deleted. So, just check again if all data is deleted.
|
// Clear() is accounting if data already is deleted. So, just check again if all data is deleted.
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
@ -114,13 +114,16 @@ bool X3DImporter::FindNodeElement_FromRoot(const std::string& pID, const CX3DImp
|
||||||
bool X3DImporter::FindNodeElement_FromNode(CX3DImporter_NodeElement* pStartNode, const std::string& pID,
|
bool X3DImporter::FindNodeElement_FromNode(CX3DImporter_NodeElement* pStartNode, const std::string& pID,
|
||||||
const CX3DImporter_NodeElement::EType pType, CX3DImporter_NodeElement** pElement)
|
const CX3DImporter_NodeElement::EType pType, CX3DImporter_NodeElement** pElement)
|
||||||
{
|
{
|
||||||
bool found = false;// flag: true - if requested element is found.
|
bool found = false;// flag: true - if requested element is found.
|
||||||
|
|
||||||
// Check if pStartNode - this is the element, we are looking for.
|
// Check if pStartNode - this is the element, we are looking for.
|
||||||
if((pStartNode->Type == pType) && (pStartNode->ID == pID))
|
if((pStartNode->Type == pType) && (pStartNode->ID == pID))
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
if(pElement != nullptr) *pElement = pStartNode;
|
if ( pElement != nullptr )
|
||||||
|
{
|
||||||
|
*pElement = pStartNode;
|
||||||
|
}
|
||||||
|
|
||||||
goto fne_fn_end;
|
goto fne_fn_end;
|
||||||
}// if((pStartNode->Type() == pType) && (pStartNode->ID() == pID))
|
}// if((pStartNode->Type() == pType) && (pStartNode->ID() == pID))
|
||||||
|
@ -129,7 +132,10 @@ bool found = false;// flag: true - if requested element is found.
|
||||||
for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = pStartNode->Child.begin(); ch_it != pStartNode->Child.end(); ch_it++)
|
for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = pStartNode->Child.begin(); ch_it != pStartNode->Child.end(); ch_it++)
|
||||||
{
|
{
|
||||||
found = FindNodeElement_FromNode(*ch_it, pID, pType, pElement);
|
found = FindNodeElement_FromNode(*ch_it, pID, pType, pElement);
|
||||||
if(found) break;
|
if ( found )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = it->Child.begin(); ch_it != it->Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = it->Child.begin(); ch_it != it->Child.end(); ch_it++)
|
||||||
|
|
||||||
fne_fn_end:
|
fne_fn_end:
|
||||||
|
@ -150,7 +156,6 @@ bool X3DImporter::FindNodeElement(const std::string& pID, const CX3DImporter_Nod
|
||||||
if(((CX3DImporter_NodeElement_Group*)tnd)->Static)
|
if(((CX3DImporter_NodeElement_Group*)tnd)->Static)
|
||||||
{
|
{
|
||||||
static_search = true;// Flag found, stop walking up. Node with static flag will holded in tnd variable.
|
static_search = true;// Flag found, stop walking up. Node with static flag will holded in tnd variable.
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,10 +164,14 @@ bool X3DImporter::FindNodeElement(const std::string& pID, const CX3DImporter_Nod
|
||||||
}// while(tnd != nullptr)
|
}// while(tnd != nullptr)
|
||||||
|
|
||||||
// at now call appropriate search function.
|
// at now call appropriate search function.
|
||||||
if(static_search)
|
if ( static_search )
|
||||||
return FindNodeElement_FromNode(tnd, pID, pType, pElement);
|
{
|
||||||
else
|
return FindNodeElement_FromNode( tnd, pID, pType, pElement );
|
||||||
return FindNodeElement_FromRoot(pID, pType, pElement);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FindNodeElement_FromRoot( pID, pType, pElement );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************************************************************************/
|
/*********************************************************************************************************************************************/
|
||||||
|
@ -786,7 +795,7 @@ void X3DImporter::GeometryHelper_Make_Arc2D(const float pStartAngle, const float
|
||||||
{
|
{
|
||||||
Throw_ArgOutOfRange( "GeometryHelper_Make_Arc2D.pStartAngle" );
|
Throw_ArgOutOfRange( "GeometryHelper_Make_Arc2D.pStartAngle" );
|
||||||
}
|
}
|
||||||
if ( ( pEndAngle < -AI_MATH_TWO_PI_F ) || ( pEndAngle > AI_MATH_TWO_PI_F ) )
|
if ( ( pEndAngle < -AI_MATH_TWO_PI_F ) || ( pEndAngle > AI_MATH_TWO_PI_F ) )
|
||||||
{
|
{
|
||||||
Throw_ArgOutOfRange( "GeometryHelper_Make_Arc2D.pEndAngle" );
|
Throw_ArgOutOfRange( "GeometryHelper_Make_Arc2D.pEndAngle" );
|
||||||
}
|
}
|
||||||
|
@ -968,8 +977,8 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<aiColor4D
|
||||||
{
|
{
|
||||||
if(pColors.size() < pMesh.mNumVertices)
|
if(pColors.size() < pMesh.mNumVertices)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError("MeshGeometry_AddColor1. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Vertices count(" +
|
throw DeadlyImportError("MeshGeometry_AddColor1. Colors count(" + to_string(pColors.size()) + ") can not be less than Vertices count(" +
|
||||||
std::to_string(pMesh.mNumVertices) + ").");
|
to_string(pMesh.mNumVertices) + ").");
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy colors to mesh
|
// copy colors to mesh
|
||||||
|
@ -980,8 +989,8 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<aiColor4D
|
||||||
{
|
{
|
||||||
if(pColors.size() < pMesh.mNumFaces)
|
if(pColors.size() < pMesh.mNumFaces)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError("MeshGeometry_AddColor1. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Faces count(" +
|
throw DeadlyImportError("MeshGeometry_AddColor1. Colors count(" + to_string(pColors.size()) + ") can not be less than Faces count(" +
|
||||||
std::to_string(pMesh.mNumFaces) + ").");
|
to_string(pMesh.mNumFaces) + ").");
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy colors to mesh
|
// copy colors to mesh
|
||||||
|
@ -989,7 +998,10 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<aiColor4D
|
||||||
for(size_t fi = 0; fi < pMesh.mNumFaces; fi++)
|
for(size_t fi = 0; fi < pMesh.mNumFaces; fi++)
|
||||||
{
|
{
|
||||||
// apply color to all vertices of face
|
// apply color to all vertices of face
|
||||||
for(size_t vi = 0, vi_e = pMesh.mFaces[fi].mNumIndices; vi < vi_e; vi++) pMesh.mColors[0][pMesh.mFaces[fi].mIndices[vi]] = *col_it;
|
for ( size_t vi = 0, vi_e = pMesh.mFaces[ fi ].mNumIndices; vi < vi_e; vi++ )
|
||||||
|
{
|
||||||
|
pMesh.mColors[ 0 ][ pMesh.mFaces[ fi ].mIndices[ vi ] ] = *col_it;
|
||||||
|
}
|
||||||
|
|
||||||
col_it++;
|
col_it++;
|
||||||
}
|
}
|
||||||
|
@ -1037,16 +1049,25 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>&
|
||||||
// check indices array count.
|
// check indices array count.
|
||||||
if(pColorIdx.size() < pCoordIdx.size())
|
if(pColorIdx.size() < pCoordIdx.size())
|
||||||
{
|
{
|
||||||
throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + std::to_string(pColorIdx.size()) +
|
throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + to_string(pColorIdx.size()) +
|
||||||
") can not be less than Coords inidces count(" + std::to_string(pCoordIdx.size()) + ").");
|
") can not be less than Coords inidces count(" + to_string(pCoordIdx.size()) + ").");
|
||||||
}
|
}
|
||||||
// create list with colors for every vertex.
|
// create list with colors for every vertex.
|
||||||
col_tgt_arr.resize(pMesh.mNumVertices);
|
col_tgt_arr.resize(pMesh.mNumVertices);
|
||||||
for(std::list<int32_t>::const_iterator colidx_it = pColorIdx.begin(), coordidx_it = pCoordIdx.begin(); colidx_it != pColorIdx.end(); colidx_it++, coordidx_it++)
|
for(std::list<int32_t>::const_iterator colidx_it = pColorIdx.begin(), coordidx_it = pCoordIdx.begin(); colidx_it != pColorIdx.end(); colidx_it++, coordidx_it++)
|
||||||
{
|
{
|
||||||
if(*colidx_it == (-1)) continue;// skip faces delimiter
|
if ( *colidx_it == ( -1 ) )
|
||||||
if((unsigned int)(*coordidx_it) > pMesh.mNumVertices) throw DeadlyImportError("MeshGeometry_AddColor2. Coordinate idx is out of range.");
|
{
|
||||||
if((unsigned int)*colidx_it > pMesh.mNumVertices) throw DeadlyImportError("MeshGeometry_AddColor2. Color idx is out of range.");
|
continue;// skip faces delimiter
|
||||||
|
}
|
||||||
|
if ( ( unsigned int ) ( *coordidx_it ) > pMesh.mNumVertices )
|
||||||
|
{
|
||||||
|
throw DeadlyImportError( "MeshGeometry_AddColor2. Coordinate idx is out of range." );
|
||||||
|
}
|
||||||
|
if ( ( unsigned int ) *colidx_it > pMesh.mNumVertices )
|
||||||
|
{
|
||||||
|
throw DeadlyImportError( "MeshGeometry_AddColor2. Color idx is out of range." );
|
||||||
|
}
|
||||||
|
|
||||||
col_tgt_arr[*coordidx_it] = col_arr_copy[*colidx_it];
|
col_tgt_arr[*coordidx_it] = col_arr_copy[*colidx_it];
|
||||||
}
|
}
|
||||||
|
@ -1057,12 +1078,15 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>&
|
||||||
// check indices array count.
|
// check indices array count.
|
||||||
if(pColors.size() < pMesh.mNumVertices)
|
if(pColors.size() < pMesh.mNumVertices)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Vertices count(" +
|
throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + to_string(pColors.size()) + ") can not be less than Vertices count(" +
|
||||||
std::to_string(pMesh.mNumVertices) + ").");
|
to_string(pMesh.mNumVertices) + ").");
|
||||||
}
|
}
|
||||||
// create list with colors for every vertex.
|
// create list with colors for every vertex.
|
||||||
col_tgt_arr.resize(pMesh.mNumVertices);
|
col_tgt_arr.resize(pMesh.mNumVertices);
|
||||||
for(size_t i = 0; i < pMesh.mNumVertices; i++) col_tgt_arr[i] = col_arr_copy[i];
|
for ( size_t i = 0; i < pMesh.mNumVertices; i++ )
|
||||||
|
{
|
||||||
|
col_tgt_arr[ i ] = col_arr_copy[ i ];
|
||||||
|
}
|
||||||
}// if(pColorIdx.size() > 0) else
|
}// if(pColorIdx.size() > 0) else
|
||||||
}// if(pColorPerVertex)
|
}// if(pColorPerVertex)
|
||||||
else
|
else
|
||||||
|
@ -1072,8 +1096,8 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>&
|
||||||
// check indices array count.
|
// check indices array count.
|
||||||
if(pColorIdx.size() < pMesh.mNumFaces)
|
if(pColorIdx.size() < pMesh.mNumFaces)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + std::to_string(pColorIdx.size()) +
|
throw DeadlyImportError("MeshGeometry_AddColor2. Colors indices count(" + to_string(pColorIdx.size()) +
|
||||||
") can not be less than Faces count(" + std::to_string(pMesh.mNumFaces) + ").");
|
") can not be less than Faces count(" + to_string(pMesh.mNumFaces) + ").");
|
||||||
}
|
}
|
||||||
// create list with colors for every vertex using faces indices.
|
// create list with colors for every vertex using faces indices.
|
||||||
col_tgt_arr.resize(pMesh.mNumFaces);
|
col_tgt_arr.resize(pMesh.mNumFaces);
|
||||||
|
@ -1092,8 +1116,8 @@ void X3DImporter::MeshGeometry_AddColor(aiMesh& pMesh, const std::list<int32_t>&
|
||||||
// check indices array count.
|
// check indices array count.
|
||||||
if(pColors.size() < pMesh.mNumFaces)
|
if(pColors.size() < pMesh.mNumFaces)
|
||||||
{
|
{
|
||||||
throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + std::to_string(pColors.size()) + ") can not be less than Faces count(" +
|
throw DeadlyImportError("MeshGeometry_AddColor2. Colors count(" + to_string(pColors.size()) + ") can not be less than Faces count(" +
|
||||||
std::to_string(pMesh.mNumFaces) + ").");
|
to_string(pMesh.mNumFaces) + ").");
|
||||||
}
|
}
|
||||||
// create list with colors for every vertex using faces indices.
|
// create list with colors for every vertex using faces indices.
|
||||||
col_tgt_arr.resize(pMesh.mNumFaces);
|
col_tgt_arr.resize(pMesh.mNumFaces);
|
||||||
|
@ -1148,8 +1172,8 @@ void X3DImporter::MeshGeometry_AddNormal(aiMesh& pMesh, const std::list<int32_t>
|
||||||
for(size_t i = 0; (i < pMesh.mNumVertices) && (i < tind.size()); i++)
|
for(size_t i = 0; (i < pMesh.mNumVertices) && (i < tind.size()); i++)
|
||||||
{
|
{
|
||||||
if(tind[i] >= norm_arr_copy.size())
|
if(tind[i] >= norm_arr_copy.size())
|
||||||
throw DeadlyImportError("MeshGeometry_AddNormal. Normal index(" + std::to_string(tind[i]) +
|
throw DeadlyImportError("MeshGeometry_AddNormal. Normal index(" + to_string(tind[i]) +
|
||||||
") is out of range. Normals count: " + std::to_string(norm_arr_copy.size()) + ".");
|
") is out of range. Normals count: " + to_string(norm_arr_copy.size()) + ".");
|
||||||
|
|
||||||
pMesh.mNormals[i] = norm_arr_copy[tind[i]];
|
pMesh.mNormals[i] = norm_arr_copy[tind[i]];
|
||||||
}
|
}
|
||||||
|
@ -1249,7 +1273,7 @@ void X3DImporter::MeshGeometry_AddTexCoord(aiMesh& pMesh, const std::list<int32_
|
||||||
for(size_t fi = 0, fi_e = faces.size(); fi < fi_e; fi++)
|
for(size_t fi = 0, fi_e = faces.size(); fi < fi_e; fi++)
|
||||||
{
|
{
|
||||||
if(pMesh.mFaces[fi].mNumIndices != faces.at(fi).mNumIndices)
|
if(pMesh.mFaces[fi].mNumIndices != faces.at(fi).mNumIndices)
|
||||||
throw DeadlyImportError("Number of indices in texture face and mesh face must be equal. Invalid face index: " + std::to_string(fi) + ".");
|
throw DeadlyImportError("Number of indices in texture face and mesh face must be equal. Invalid face index: " + to_string(fi) + ".");
|
||||||
|
|
||||||
for(size_t ii = 0; ii < pMesh.mFaces[fi].mNumIndices; ii++)
|
for(size_t ii = 0; ii < pMesh.mFaces[fi].mNumIndices; ii++)
|
||||||
{
|
{
|
||||||
|
@ -1288,10 +1312,8 @@ void X3DImporter::MeshGeometry_AddTexCoord(aiMesh& pMesh, const std::list<aiVect
|
||||||
|
|
||||||
aiMesh* X3DImporter::GeometryHelper_MakeMesh(const std::list<int32_t>& pCoordIdx, const std::list<aiVector3D>& pVertices) const
|
aiMesh* X3DImporter::GeometryHelper_MakeMesh(const std::list<int32_t>& pCoordIdx, const std::list<aiVector3D>& pVertices) const
|
||||||
{
|
{
|
||||||
aiMesh* tmesh( nullptr );
|
|
||||||
std::vector<aiFace> faces;
|
std::vector<aiFace> faces;
|
||||||
unsigned int prim_type = 0;
|
unsigned int prim_type = 0;
|
||||||
size_t ts;
|
|
||||||
|
|
||||||
// create faces array from input string with vertices indices.
|
// create faces array from input string with vertices indices.
|
||||||
GeometryHelper_CoordIdxStr2FacesArr(pCoordIdx, faces, prim_type);
|
GeometryHelper_CoordIdxStr2FacesArr(pCoordIdx, faces, prim_type);
|
||||||
|
@ -1303,8 +1325,8 @@ aiMesh* X3DImporter::GeometryHelper_MakeMesh(const std::list<int32_t>& pCoordIdx
|
||||||
//
|
//
|
||||||
// Create new mesh and copy geometry data.
|
// Create new mesh and copy geometry data.
|
||||||
//
|
//
|
||||||
tmesh = new aiMesh;
|
aiMesh *tmesh = new aiMesh;
|
||||||
ts = faces.size();
|
size_t ts = faces.size();
|
||||||
// faces
|
// faces
|
||||||
tmesh->mFaces = new aiFace[ts];
|
tmesh->mFaces = new aiFace[ts];
|
||||||
tmesh->mNumFaces = ts;
|
tmesh->mNumFaces = ts;
|
||||||
|
@ -1457,7 +1479,7 @@ void X3DImporter::ParseNode_Head()
|
||||||
{
|
{
|
||||||
XML_CheckNode_MustBeEmpty();
|
XML_CheckNode_MustBeEmpty();
|
||||||
|
|
||||||
// adding metada from <head> as MetaString from <Scene>
|
// adding metadata from <head> as MetaString from <Scene>
|
||||||
CX3DImporter_NodeElement_MetaString* ms = new CX3DImporter_NodeElement_MetaString(NodeElement_Cur);
|
CX3DImporter_NodeElement_MetaString* ms = new CX3DImporter_NodeElement_MetaString(NodeElement_Cur);
|
||||||
|
|
||||||
ms->Name = mReader->getAttributeValueSafe("name");
|
ms->Name = mReader->getAttributeValueSafe("name");
|
||||||
|
@ -1466,8 +1488,10 @@ void X3DImporter::ParseNode_Head()
|
||||||
{
|
{
|
||||||
ms->Value.push_back(mReader->getAttributeValueSafe("content"));
|
ms->Value.push_back(mReader->getAttributeValueSafe("content"));
|
||||||
NodeElement_List.push_back(ms);
|
NodeElement_List.push_back(ms);
|
||||||
if(NodeElement_Cur != nullptr) NodeElement_Cur->Child.push_back(ms);
|
if ( NodeElement_Cur != nullptr )
|
||||||
|
{
|
||||||
|
NodeElement_Cur->Child.push_back( ms );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}// if(XML_CheckNode_NameEqual("meta"))
|
}// if(XML_CheckNode_NameEqual("meta"))
|
||||||
}// if(mReader->getNodeType() == irr::io::EXN_ELEMENT)
|
}// if(mReader->getNodeType() == irr::io::EXN_ELEMENT)
|
||||||
|
@ -1476,14 +1500,15 @@ void X3DImporter::ParseNode_Head()
|
||||||
if(XML_CheckNode_NameEqual("head"))
|
if(XML_CheckNode_NameEqual("head"))
|
||||||
{
|
{
|
||||||
close_found = true;
|
close_found = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}// if(mReader->getNodeType() == irr::io::EXN_ELEMENT) else
|
}// if(mReader->getNodeType() == irr::io::EXN_ELEMENT) else
|
||||||
}// while(mReader->read())
|
}// while(mReader->read())
|
||||||
|
|
||||||
if(!close_found) Throw_CloseNotFound("head");
|
if ( !close_found )
|
||||||
|
{
|
||||||
|
Throw_CloseNotFound( "head" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::ParseNode_Scene()
|
void X3DImporter::ParseNode_Scene()
|
||||||
|
@ -1501,10 +1526,10 @@ auto GroupCounter_Decrease = [&](size_t& pCounter, const char* pGroupName) -> vo
|
||||||
pCounter--;
|
pCounter--;
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* GroupName_Group = "Group";
|
static const char* GroupName_Group = "Group";
|
||||||
const char* GroupName_StaticGroup = "StaticGroup";
|
static const char* GroupName_StaticGroup = "StaticGroup";
|
||||||
const char* GroupName_Transform = "Transform";
|
static const char* GroupName_Transform = "Transform";
|
||||||
const char* GroupName_Switch = "Switch";
|
static const char* GroupName_Switch = "Switch";
|
||||||
|
|
||||||
bool close_found = false;
|
bool close_found = false;
|
||||||
size_t counter_group = 0;
|
size_t counter_group = 0;
|
||||||
|
@ -1550,7 +1575,7 @@ size_t counter_switch = 0;
|
||||||
if(mReader->isEmptyElement()) GroupCounter_Decrease(counter_switch, GroupName_Switch);
|
if(mReader->isEmptyElement()) GroupCounter_Decrease(counter_switch, GroupName_Switch);
|
||||||
}
|
}
|
||||||
else if(XML_CheckNode_NameEqual("DirectionalLight"))
|
else if(XML_CheckNode_NameEqual("DirectionalLight"))
|
||||||
{
|
{
|
||||||
ParseNode_Lighting_DirectionalLight();
|
ParseNode_Lighting_DirectionalLight();
|
||||||
}
|
}
|
||||||
else if(XML_CheckNode_NameEqual("PointLight"))
|
else if(XML_CheckNode_NameEqual("PointLight"))
|
||||||
|
|
|
@ -46,9 +46,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "X3DImporter.hpp"
|
#include "X3DImporter.hpp"
|
||||||
#include "X3DImporter_Macro.hpp"
|
#include "X3DImporter_Macro.hpp"
|
||||||
|
#include "StringUtils.h"
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp {
|
||||||
{
|
|
||||||
|
|
||||||
// <DirectionalLight
|
// <DirectionalLight
|
||||||
// DEF="" ID
|
// DEF="" ID
|
||||||
|
@ -95,7 +95,7 @@ void X3DImporter::ParseNode_Lighting_DirectionalLight()
|
||||||
if(!def.empty())
|
if(!def.empty())
|
||||||
ne->ID = def;
|
ne->ID = def;
|
||||||
else
|
else
|
||||||
ne->ID = "DirectionalLight_" + std::to_string((size_t)ne);// make random name
|
ne->ID = "DirectionalLight_" + to_string((size_t)ne);// make random name
|
||||||
|
|
||||||
((CX3DImporter_NodeElement_Light*)ne)->AmbientIntensity = ambientIntensity;
|
((CX3DImporter_NodeElement_Light*)ne)->AmbientIntensity = ambientIntensity;
|
||||||
((CX3DImporter_NodeElement_Light*)ne)->Color = color;
|
((CX3DImporter_NodeElement_Light*)ne)->Color = color;
|
||||||
|
@ -178,7 +178,7 @@ void X3DImporter::ParseNode_Lighting_PointLight()
|
||||||
// Assimp want a node with name similar to a light. "Why? I don't no." )
|
// Assimp want a node with name similar to a light. "Why? I don't no." )
|
||||||
ParseHelper_Group_Begin(false);
|
ParseHelper_Group_Begin(false);
|
||||||
// make random name
|
// make random name
|
||||||
if(ne->ID.empty()) ne->ID = "PointLight_" + std::to_string((size_t)ne);
|
if(ne->ID.empty()) ne->ID = "PointLight_" + to_string((size_t)ne);
|
||||||
|
|
||||||
NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element.
|
NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element.
|
||||||
ParseHelper_Node_Exit();
|
ParseHelper_Node_Exit();
|
||||||
|
@ -268,7 +268,7 @@ void X3DImporter::ParseNode_Lighting_SpotLight()
|
||||||
// Assimp want a node with name similar to a light. "Why? I don't no." )
|
// Assimp want a node with name similar to a light. "Why? I don't no." )
|
||||||
ParseHelper_Group_Begin(false);
|
ParseHelper_Group_Begin(false);
|
||||||
// make random name
|
// make random name
|
||||||
if(ne->ID.empty()) ne->ID = "SpotLight_" + std::to_string((size_t)ne);
|
if(ne->ID.empty()) ne->ID = "SpotLight_" + to_string((size_t)ne);
|
||||||
|
|
||||||
NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element.
|
NodeElement_Cur->ID = ne->ID;// assign name to node and return to light element.
|
||||||
ParseHelper_Node_Exit();
|
ParseHelper_Node_Exit();
|
||||||
|
|
|
@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// Header files, Assimp.
|
// Header files, Assimp.
|
||||||
#include "StandardShapes.h"
|
#include "StandardShapes.h"
|
||||||
|
#include "StringUtils.h"
|
||||||
|
|
||||||
// Header files, stdlib.
|
// Header files, stdlib.
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -174,7 +175,7 @@ void X3DImporter::Postprocess_BuildLight(const CX3DImporter_NodeElement& pNodeEl
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw DeadlyImportError("Postprocess_BuildLight. Unknown type of light: " + std::to_string(pNodeElement.Type) + ".");
|
throw DeadlyImportError("Postprocess_BuildLight. Unknown type of light: " + to_string(pNodeElement.Type) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
pSceneLightList.push_back(new_light);
|
pSceneLightList.push_back(new_light);
|
||||||
|
@ -296,7 +297,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
||||||
MeshGeometry_AddTexCoord(**pMesh, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
MeshGeometry_AddTexCoord(**pMesh, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
||||||
else
|
else
|
||||||
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of ElevationGrid: " + std::to_string((*ch_it)->Type) + ".");
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of ElevationGrid: " + to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -333,7 +334,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
||||||
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
||||||
else
|
else
|
||||||
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedFaceSet: " + std::to_string((*ch_it)->Type) + ".");
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedFaceSet: " + to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -363,7 +364,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
|
||||||
{} // skip because already read when mesh created.
|
{} // skip because already read when mesh created.
|
||||||
else
|
else
|
||||||
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedLineSet: " + std::to_string((*ch_it)->Type) + ".");
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedLineSet: " + to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -401,7 +402,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
||||||
else
|
else
|
||||||
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedTriangleSet or IndexedTriangleFanSet, or \
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of IndexedTriangleSet or IndexedTriangleFanSet, or \
|
||||||
IndexedTriangleStripSet: " + std::to_string((*ch_it)->Type) + ".");
|
IndexedTriangleStripSet: " + to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -451,7 +452,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
|
||||||
{} // skip because already read when mesh created.
|
{} // skip because already read when mesh created.
|
||||||
else
|
else
|
||||||
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of PointSet: " + std::to_string((*ch_it)->Type) + ".");
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of PointSet: " + to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -480,7 +481,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Coordinate)
|
||||||
{} // skip because already read when mesh created.
|
{} // skip because already read when mesh created.
|
||||||
else
|
else
|
||||||
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of LineSet: " + std::to_string((*ch_it)->Type) + ".");
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of LineSet: " + to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -514,7 +515,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
||||||
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
||||||
else
|
else
|
||||||
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeFanSet: " + std::to_string((*ch_it)->Type) + ".");
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeFanSet: " + to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -557,7 +558,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
||||||
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
||||||
else
|
else
|
||||||
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeSet: " + std::to_string((*ch_it)->Type) + ".");
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TrianlgeSet: " + to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
|
@ -591,13 +592,13 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle
|
||||||
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_TextureCoordinate)
|
||||||
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
MeshGeometry_AddTexCoord(**pMesh, tnemesh.CoordIndex, tnemesh.TexCoordIndex, ((CX3DImporter_NodeElement_TextureCoordinate*)*ch_it)->Value);
|
||||||
else
|
else
|
||||||
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TriangleStripSet: " + std::to_string((*ch_it)->Type) + ".");
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown child of TriangleStripSet: " + to_string((*ch_it)->Type) + ".");
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++)
|
||||||
|
|
||||||
return;// mesh is build, nothing to do anymore.
|
return;// mesh is build, nothing to do anymore.
|
||||||
}// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_TriangleStripSet)
|
}// if(pNodeElement.Type == CX3DImporter_NodeElement::ENET_TriangleStripSet)
|
||||||
|
|
||||||
throw DeadlyImportError("Postprocess_BuildMesh. Unknown mesh type: " + std::to_string(pNodeElement.Type) + ".");
|
throw DeadlyImportError("Postprocess_BuildMesh. Unknown mesh type: " + to_string(pNodeElement.Type) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode, std::list<aiMesh*>& pSceneMeshList,
|
void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeElement, aiNode& pSceneNode, std::list<aiMesh*>& pSceneMeshList,
|
||||||
|
@ -659,7 +660,7 @@ void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeEle
|
||||||
}
|
}
|
||||||
else if(!PostprocessHelper_ElementIsMetadata((*it)->Type))// skip metadata
|
else if(!PostprocessHelper_ElementIsMetadata((*it)->Type))// skip metadata
|
||||||
{
|
{
|
||||||
throw DeadlyImportError("Postprocess_BuildNode. Unknown type: " + std::to_string((*it)->Type) + ".");
|
throw DeadlyImportError("Postprocess_BuildNode. Unknown type: " + to_string((*it)->Type) + ".");
|
||||||
}
|
}
|
||||||
}// for(std::list<CX3DImporter_NodeElement*>::const_iterator it = chit_begin; it != chit_end; it++)
|
}// for(std::list<CX3DImporter_NodeElement*>::const_iterator it = chit_begin; it != chit_end; it++)
|
||||||
|
|
||||||
|
|
|
@ -731,7 +731,7 @@ void XFileParser::ParseDataObjectMaterial( Material* pMaterial)
|
||||||
std::string matName;
|
std::string matName;
|
||||||
readHeadOfDataObject( &matName);
|
readHeadOfDataObject( &matName);
|
||||||
if( matName.empty())
|
if( matName.empty())
|
||||||
matName = std::string( "material") + std::to_string( mLineNumber );
|
matName = std::string( "material") + to_string( mLineNumber );
|
||||||
pMaterial->mName = matName;
|
pMaterial->mName = matName;
|
||||||
pMaterial->mIsReference = false;
|
pMaterial->mIsReference = false;
|
||||||
|
|
||||||
|
|
|
@ -292,14 +292,14 @@ inline void Buffer::Read(Value& obj, Asset& r)
|
||||||
this->mData.reset(data);
|
this->mData.reset(data);
|
||||||
|
|
||||||
if (statedLength > 0 && this->byteLength != statedLength) {
|
if (statedLength > 0 && this->byteLength != statedLength) {
|
||||||
throw DeadlyImportError("GLTF: buffer \"" + id + "\", expected " + std::to_string(statedLength) +
|
throw DeadlyImportError("GLTF: buffer \"" + id + "\", expected " + to_string(statedLength) +
|
||||||
" bytes, but found " + std::to_string(dataURI.dataLength));
|
" bytes, but found " + to_string(dataURI.dataLength));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // assume raw data
|
else { // assume raw data
|
||||||
if (statedLength != dataURI.dataLength) {
|
if (statedLength != dataURI.dataLength) {
|
||||||
throw DeadlyImportError("GLTF: buffer \"" + id + "\", expected " + std::to_string(statedLength) +
|
throw DeadlyImportError("GLTF: buffer \"" + id + "\", expected " + to_string(statedLength) +
|
||||||
" bytes, but found " + std::to_string(dataURI.dataLength));
|
" bytes, but found " + to_string(dataURI.dataLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
this->mData.reset(new uint8_t[dataURI.dataLength]);
|
this->mData.reset(new uint8_t[dataURI.dataLength]);
|
||||||
|
@ -991,7 +991,7 @@ Ref<Buffer> buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of float attribute: " + std::to_string(ifs.GetFloatAttributeType(idx)));
|
throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of float attribute: " + to_string(ifs.GetFloatAttributeType(idx)));
|
||||||
}
|
}
|
||||||
|
|
||||||
tval *= ifs.GetFloatAttributeDim(idx) * sizeof(o3dgc::Real);// After checking count of objects we can get size of array.
|
tval *= ifs.GetFloatAttributeDim(idx) * sizeof(o3dgc::Real);// After checking count of objects we can get size of array.
|
||||||
|
@ -1003,11 +1003,10 @@ Ref<Buffer> buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer);
|
||||||
{
|
{
|
||||||
// size = number_of_elements * components_per_element * size_of_component. See float attributes note.
|
// size = number_of_elements * components_per_element * size_of_component. See float attributes note.
|
||||||
size_t tval = ifs.GetNIntAttribute(idx);
|
size_t tval = ifs.GetNIntAttribute(idx);
|
||||||
|
switch( ifs.GetIntAttributeType( idx ) )
|
||||||
switch(ifs.GetIntAttributeType(idx))
|
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of int attribute: " + std::to_string(ifs.GetIntAttributeType(idx)));
|
throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of int attribute: " + to_string(ifs.GetIntAttributeType(idx)));
|
||||||
}
|
}
|
||||||
|
|
||||||
tval *= ifs.GetIntAttributeDim(idx) * sizeof(long);// See float attributes note.
|
tval *= ifs.GetIntAttributeDim(idx) * sizeof(long);// See float attributes note.
|
||||||
|
@ -1046,7 +1045,7 @@ Ref<Buffer> buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of float attribute: " + std::to_string(ifs.GetFloatAttributeType(idx)));
|
throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of float attribute: " + to_string(ifs.GetFloatAttributeType(idx)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1056,7 +1055,7 @@ Ref<Buffer> buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer);
|
||||||
{
|
{
|
||||||
// ifs.SetIntAttribute(idx, (long* const)(decoded_data + get_buf_offset(primitives[0].attributes.joint)));
|
// ifs.SetIntAttribute(idx, (long* const)(decoded_data + get_buf_offset(primitives[0].attributes.joint)));
|
||||||
default:
|
default:
|
||||||
throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of int attribute: " + std::to_string(ifs.GetIntAttributeType(idx)));
|
throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of int attribute: " + to_string(ifs.GetIntAttributeType(idx)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1621,6 +1620,4 @@ namespace Util {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // ns glTF
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace glTF {
|
||||||
inline Value& MakeValue(Value& val, const std::vector<float> & r, MemoryPoolAllocator<>& al) {
|
inline Value& MakeValue(Value& val, const std::vector<float> & r, MemoryPoolAllocator<>& al) {
|
||||||
val.SetArray();
|
val.SetArray();
|
||||||
val.Reserve(r.size(), al);
|
val.Reserve(r.size(), al);
|
||||||
for (int i = 0; i < r.size(); ++i) {
|
for (unsigned int i = 0; i < r.size(); ++i) {
|
||||||
val.PushBack(r[i], al);
|
val.PushBack(r[i], al);
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
|
|
|
@ -212,30 +212,29 @@ inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& bu
|
||||||
// calculate min and max values
|
// calculate min and max values
|
||||||
{
|
{
|
||||||
// Allocate and initialize with large values.
|
// Allocate and initialize with large values.
|
||||||
float float_MAX = 10000000000000;
|
float float_MAX = 10000000000000.0f;
|
||||||
for (int i = 0 ; i < numCompsOut ; i++) {
|
for (unsigned int i = 0 ; i < numCompsOut ; i++) {
|
||||||
acc->min.push_back( float_MAX);
|
acc->min.push_back( float_MAX);
|
||||||
acc->max.push_back(-float_MAX);
|
acc->max.push_back(-float_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search and set extreme values.
|
// Search and set extreme values.
|
||||||
float valueTmp;
|
float valueTmp;
|
||||||
for (int i = 0 ; i < count ; i++) {
|
for (unsigned int i = 0 ; i < count ; i++) {
|
||||||
for (int j = 0 ; j < numCompsOut ; j++) {
|
for (unsigned int j = 0 ; j < numCompsOut ; j++) {
|
||||||
|
if (numCompsOut == 1) {
|
||||||
|
valueTmp = static_cast<unsigned short*>(data)[i];
|
||||||
|
} else {
|
||||||
|
valueTmp = static_cast<aiVector3D*>(data)[i][j];
|
||||||
|
}
|
||||||
|
|
||||||
if (numCompsOut == 1) {
|
if (valueTmp < acc->min[j]) {
|
||||||
valueTmp = static_cast<unsigned short*>(data)[i];
|
acc->min[j] = valueTmp;
|
||||||
} else {
|
}
|
||||||
valueTmp = static_cast<aiVector3D*>(data)[i][j];
|
if (valueTmp > acc->max[j]) {
|
||||||
|
acc->max[j] = valueTmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valueTmp < acc->min[j]) {
|
|
||||||
acc->min[j] = valueTmp;
|
|
||||||
}
|
|
||||||
if (valueTmp > acc->max[j]) {
|
|
||||||
acc->max[j] = valueTmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +443,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aim, Ref<Mesh>& meshRef, Ref<Buffer
|
||||||
// aib->mName =====> skinRef->jointNames
|
// aib->mName =====> skinRef->jointNames
|
||||||
// Find the node with id = mName.
|
// Find the node with id = mName.
|
||||||
Ref<Node> nodeRef = mAsset.nodes.Get(aib->mName.C_Str());
|
Ref<Node> nodeRef = mAsset.nodes.Get(aib->mName.C_Str());
|
||||||
nodeRef->jointName = nodeRef->id; //"joint_" + std::to_string(idx_bone);
|
nodeRef->jointName = nodeRef->id;
|
||||||
|
|
||||||
unsigned int jointNamesIndex;
|
unsigned int jointNamesIndex;
|
||||||
bool addJointToJointNames = true;
|
bool addJointToJointNames = true;
|
||||||
|
@ -914,7 +913,7 @@ void glTFExporter::ExportAnimations()
|
||||||
|
|
||||||
// It appears that assimp stores this type of animation as multiple animations.
|
// It appears that assimp stores this type of animation as multiple animations.
|
||||||
// where each aiNodeAnim in mChannels animates a specific node.
|
// where each aiNodeAnim in mChannels animates a specific node.
|
||||||
std::string name = nameAnim + "_" + std::to_string(channelIndex);
|
std::string name = nameAnim + "_" + to_string(channelIndex);
|
||||||
name = mAsset->FindUniqueID(name, "animation");
|
name = mAsset->FindUniqueID(name, "animation");
|
||||||
Ref<Animation> animRef = mAsset->animations.Create(name);
|
Ref<Animation> animRef = mAsset->animations.Create(name);
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||||
|
|
||||||
#include "glTFImporter.h"
|
#include "glTFImporter.h"
|
||||||
|
|
||||||
#include "StringComparison.h"
|
#include "StringComparison.h"
|
||||||
|
#include "StringUtils.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
|
@ -285,7 +285,7 @@ void glTFImporter::ImportMeshes(glTF::Asset& r)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
throw DeadlyImportError("GLTF: Can not import mesh: unknown mesh extension (code: \"" + std::to_string(cur_ext->Type) +
|
throw DeadlyImportError("GLTF: Can not import mesh: unknown mesh extension (code: \"" + to_string(cur_ext->Type) +
|
||||||
"\"), only Open3DGC is supported.");
|
"\"), only Open3DGC is supported.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[Setup]
|
[Setup]
|
||||||
AppName=Open Asset Import Library - SDK
|
AppName=Open Asset Import Library - SDK
|
||||||
AppVerName=Open Asset Import Library - SDK (v2.0)
|
AppVerName=Open Asset Import Library - SDK (v3.3.1)
|
||||||
DefaultDirName={pf}\Assimp
|
DefaultDirName={pf}\Assimp
|
||||||
DefaultGroupName=Assimp
|
DefaultGroupName=Assimp
|
||||||
UninstallDisplayIcon={app}\bin\x86\assimp.exe
|
UninstallDisplayIcon={app}\bin\x86\assimp.exe
|
||||||
|
@ -12,9 +12,9 @@ SetupIconFile=..\..\tools\shared\assimp_tools_icon.ico
|
||||||
WizardImageFile=compiler:WizModernImage-IS.BMP
|
WizardImageFile=compiler:WizModernImage-IS.BMP
|
||||||
WizardSmallImageFile=compiler:WizModernSmallImage-IS.BMP
|
WizardSmallImageFile=compiler:WizModernSmallImage-IS.BMP
|
||||||
LicenseFile=License.rtf
|
LicenseFile=License.rtf
|
||||||
OutputBaseFileName=assimp-sdk-2.0-setup
|
OutputBaseFileName=assimp-sdk-3.3.1-setup
|
||||||
VersionInfoVersion=2.0.0.0
|
VersionInfoVersion=3.3.1.0
|
||||||
VersionInfoTextVersion=2.0
|
VersionInfoTextVersion=3.3.1
|
||||||
VersionInfoCompany=Assimp Development Team
|
VersionInfoCompany=Assimp Development Team
|
||||||
ArchitecturesInstallIn64BitMode=x64
|
ArchitecturesInstallIn64BitMode=x64
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ Name: "assimp_net"; Description: "C#/.NET Bindings"; Types: full
|
||||||
;Name: "vc9"; Description: "VC9 project files"; Types: full
|
;Name: "vc9"; Description: "VC9 project files"; Types: full
|
||||||
|
|
||||||
[Run]
|
[Run]
|
||||||
Filename: "{app}\stub\vcredist_x86.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2008 SP1 redistributable package (32 Bit)"; Check: not IsWin64
|
Filename: "{app}\stub\vcredist_x86.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2012 SP1 redistributable package (32 Bit)"; Check: not IsWin64
|
||||||
Filename: "{app}\stub\vcredist_x64.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2008 SP1 redistributable package (64 Bit)"; Check: IsWin64
|
Filename: "{app}\stub\vcredist_x64.exe"; Parameters: "/qb"; StatusMsg: "Installing VS2012 SP1 redistributable package (64 Bit)"; Check: IsWin64
|
||||||
|
|
||||||
[Files]
|
[Files]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue