Merge branch 'master' into issue_1728
commit
2e7e16b52b
|
@ -75,10 +75,9 @@ using namespace Util;
|
||||||
|
|
||||||
|
|
||||||
Converter::Converter( aiScene* out, const Document& doc )
|
Converter::Converter( aiScene* out, const Document& doc )
|
||||||
: defaultMaterialIndex()
|
: defaultMaterialIndex()
|
||||||
, out( out )
|
, out( out )
|
||||||
, doc( doc )
|
, doc( doc ) {
|
||||||
{
|
|
||||||
// animations need to be converted first since this will
|
// animations need to be converted first since this will
|
||||||
// populate the node_anim_chain_bits map, which is needed
|
// populate the node_anim_chain_bits map, which is needed
|
||||||
// to determine which nodes need to be generated.
|
// to determine which nodes need to be generated.
|
||||||
|
@ -116,8 +115,7 @@ Converter::Converter( aiScene* out, const Document& doc )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Converter::~Converter()
|
Converter::~Converter() {
|
||||||
{
|
|
||||||
std::for_each( meshes.begin(), meshes.end(), Util::delete_fun<aiMesh>() );
|
std::for_each( meshes.begin(), meshes.end(), Util::delete_fun<aiMesh>() );
|
||||||
std::for_each( materials.begin(), materials.end(), Util::delete_fun<aiMaterial>() );
|
std::for_each( materials.begin(), materials.end(), Util::delete_fun<aiMaterial>() );
|
||||||
std::for_each( animations.begin(), animations.end(), Util::delete_fun<aiAnimation>() );
|
std::for_each( animations.begin(), animations.end(), Util::delete_fun<aiAnimation>() );
|
||||||
|
@ -126,8 +124,7 @@ Converter::~Converter()
|
||||||
std::for_each( textures.begin(), textures.end(), Util::delete_fun<aiTexture>() );
|
std::for_each( textures.begin(), textures.end(), Util::delete_fun<aiTexture>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Converter::ConvertRootNode()
|
void Converter::ConvertRootNode() {
|
||||||
{
|
|
||||||
out->mRootNode = new aiNode();
|
out->mRootNode = new aiNode();
|
||||||
out->mRootNode->mName.Set( "RootNode" );
|
out->mRootNode->mName.Set( "RootNode" );
|
||||||
|
|
||||||
|
@ -354,10 +351,12 @@ void Converter::ConvertCamera( const Model& model, const Camera& cam )
|
||||||
out_camera->mName.Set( FixNodeName( model.Name() ) );
|
out_camera->mName.Set( FixNodeName( model.Name() ) );
|
||||||
|
|
||||||
out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight();
|
out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight();
|
||||||
|
|
||||||
//cameras are defined along positive x direction
|
//cameras are defined along positive x direction
|
||||||
out_camera->mPosition = aiVector3D(0.0f);
|
out_camera->mPosition = cam.Position();
|
||||||
out_camera->mLookAt = aiVector3D(1.0f, 0.0f, 0.0f);
|
out_camera->mLookAt = ( cam.InterestPosition() - out_camera->mPosition ).Normalize();
|
||||||
out_camera->mUp = aiVector3D(0.0f, 1.0f, 0.0f);
|
out_camera->mUp = cam.UpVector();
|
||||||
|
|
||||||
out_camera->mHorizontalFOV = AI_DEG_TO_RAD( cam.FieldOfView() );
|
out_camera->mHorizontalFOV = AI_DEG_TO_RAD( cam.FieldOfView() );
|
||||||
out_camera->mClipPlaneNear = cam.NearPlane();
|
out_camera->mClipPlaneNear = cam.NearPlane();
|
||||||
out_camera->mClipPlaneFar = cam.FarPlane();
|
out_camera->mClipPlaneFar = cam.FarPlane();
|
||||||
|
|
|
@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
|
||||||
|
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||||
# include <zlib.h>
|
# include <zlib.h>
|
||||||
#else
|
#else
|
||||||
|
@ -67,7 +66,6 @@ using namespace Assimp::FBX;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// signal parse error, this is always unrecoverable. Throws DeadlyImportError.
|
// signal parse error, this is always unrecoverable. Throws DeadlyImportError.
|
||||||
AI_WONT_RETURN void ParseError(const std::string& message, const Token& token) AI_WONT_RETURN_SUFFIX;
|
AI_WONT_RETURN void ParseError(const std::string& message, const Token& token) AI_WONT_RETURN_SUFFIX;
|
||||||
|
@ -213,7 +211,6 @@ Scope::~Scope()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Parser::Parser (const TokenList& tokens, bool is_binary)
|
Parser::Parser (const TokenList& tokens, bool is_binary)
|
||||||
: tokens(tokens)
|
: tokens(tokens)
|
||||||
|
@ -537,18 +534,18 @@ void ReadBinaryDataArray(char type, uint32_t count, const char*& data, const cha
|
||||||
uint32_t stride = 0;
|
uint32_t stride = 0;
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case 'f':
|
case 'f':
|
||||||
case 'i':
|
case 'i':
|
||||||
stride = 4;
|
stride = 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'l':
|
case 'l':
|
||||||
stride = 8;
|
stride = 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ai_assert(false);
|
ai_assert(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint32_t full_length = stride * count;
|
const uint32_t full_length = stride * count;
|
||||||
|
|
|
@ -108,7 +108,7 @@ Property* ReadTypedProperty(const Element& element)
|
||||||
ParseTokenAsFloat(*tok[6]))
|
ParseTokenAsFloat(*tok[6]))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView")) {
|
else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) {
|
||||||
return new TypedProperty<float>(ParseTokenAsFloat(*tok[4]));
|
return new TypedProperty<float>(ParseTokenAsFloat(*tok[4]));
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -138,7 +138,6 @@ PropertyTable::PropertyTable()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
PropertyTable::PropertyTable(const Element& element, std::shared_ptr<const PropertyTable> templateProps)
|
PropertyTable::PropertyTable(const Element& element, std::shared_ptr<const PropertyTable> templateProps)
|
||||||
: templateProps(templateProps)
|
: templateProps(templateProps)
|
||||||
|
@ -229,8 +228,6 @@ DirectPropertyMap PropertyTable::GetUnparsedProperties() const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} //! FBX
|
} //! FBX
|
||||||
} //! Assimp
|
} //! Assimp
|
||||||
|
|
||||||
|
|
|
@ -76,13 +76,11 @@ Token::Token(const char* sbegin, const char* send, TokenType type, unsigned int
|
||||||
ai_assert(static_cast<size_t>(send-sbegin) > 0);
|
ai_assert(static_cast<size_t>(send-sbegin) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Token::~Token()
|
Token::~Token()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -340,9 +340,9 @@ void FlipQuakeHeader(BE_NCONST MDL::Header* pcHeader)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Read a Quake 1 file
|
// Read a Quake 1 file
|
||||||
void MDLImporter::InternReadFile_Quake1( )
|
void MDLImporter::InternReadFile_Quake1() {
|
||||||
{
|
|
||||||
ai_assert(NULL != pScene);
|
ai_assert(NULL != pScene);
|
||||||
|
|
||||||
BE_NCONST MDL::Header *pcHeader = (BE_NCONST MDL::Header*)this->mBuffer;
|
BE_NCONST MDL::Header *pcHeader = (BE_NCONST MDL::Header*)this->mBuffer;
|
||||||
|
|
||||||
#ifdef AI_BUILD_BIG_ENDIAN
|
#ifdef AI_BUILD_BIG_ENDIAN
|
||||||
|
@ -355,9 +355,11 @@ void MDLImporter::InternReadFile_Quake1( )
|
||||||
const unsigned char* szCurrent = (const unsigned char*)(pcHeader+1);
|
const unsigned char* szCurrent = (const unsigned char*)(pcHeader+1);
|
||||||
|
|
||||||
// need to read all textures
|
// need to read all textures
|
||||||
for (unsigned int i = 0; i < (unsigned int)pcHeader->num_skins;++i)
|
for ( unsigned int i = 0; i < (unsigned int)pcHeader->num_skins; ++i) {
|
||||||
{
|
union {
|
||||||
union{BE_NCONST MDL::Skin* pcSkin;BE_NCONST MDL::GroupSkin* pcGroupSkin;};
|
BE_NCONST MDL::Skin* pcSkin;
|
||||||
|
BE_NCONST MDL::GroupSkin* pcGroupSkin;
|
||||||
|
};
|
||||||
if (szCurrent + sizeof(MDL::Skin) > this->mBuffer + this->iFileSize) {
|
if (szCurrent + sizeof(MDL::Skin) > this->mBuffer + this->iFileSize) {
|
||||||
throw DeadlyImportError("[Quake 1 MDL] Unexpected EOF");
|
throw DeadlyImportError("[Quake 1 MDL] Unexpected EOF");
|
||||||
}
|
}
|
||||||
|
@ -365,17 +367,15 @@ void MDLImporter::InternReadFile_Quake1( )
|
||||||
|
|
||||||
AI_SWAP4( pcSkin->group );
|
AI_SWAP4( pcSkin->group );
|
||||||
|
|
||||||
// Quake 1 groupskins
|
// Quake 1 group-skins
|
||||||
if (1 == pcSkin->group)
|
if (1 == pcSkin->group) {
|
||||||
{
|
|
||||||
AI_SWAP4( pcGroupSkin->nb );
|
AI_SWAP4( pcGroupSkin->nb );
|
||||||
|
|
||||||
// need to skip multiple images
|
// need to skip multiple images
|
||||||
const unsigned int iNumImages = (unsigned int)pcGroupSkin->nb;
|
const unsigned int iNumImages = (unsigned int)pcGroupSkin->nb;
|
||||||
szCurrent += sizeof(uint32_t) * 2;
|
szCurrent += sizeof(uint32_t) * 2;
|
||||||
|
|
||||||
if (0 != iNumImages)
|
if (0 != iNumImages) {
|
||||||
{
|
|
||||||
if (!i) {
|
if (!i) {
|
||||||
// however, create only one output image (the first)
|
// however, create only one output image (the first)
|
||||||
this->CreateTextureARGB8_3DGS_MDL3(szCurrent + iNumImages * sizeof(float));
|
this->CreateTextureARGB8_3DGS_MDL3(szCurrent + iNumImages * sizeof(float));
|
||||||
|
@ -384,10 +384,7 @@ void MDLImporter::InternReadFile_Quake1( )
|
||||||
szCurrent += pcHeader->skinheight * pcHeader->skinwidth +
|
szCurrent += pcHeader->skinheight * pcHeader->skinwidth +
|
||||||
sizeof(float) * iNumImages;
|
sizeof(float) * iNumImages;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
// 3DGS has a few files that are using other 3DGS like texture formats here
|
|
||||||
else
|
|
||||||
{
|
|
||||||
szCurrent += sizeof(uint32_t);
|
szCurrent += sizeof(uint32_t);
|
||||||
unsigned int iSkip = i ? UINT_MAX : 0;
|
unsigned int iSkip = i ? UINT_MAX : 0;
|
||||||
CreateTexture_3DGS_MDL4(szCurrent,pcSkin->group,&iSkip);
|
CreateTexture_3DGS_MDL4(szCurrent,pcSkin->group,&iSkip);
|
||||||
|
@ -407,17 +404,14 @@ void MDLImporter::InternReadFile_Quake1( )
|
||||||
BE_NCONST MDL::Frame* pcFrames = (BE_NCONST MDL::Frame*)szCurrent;
|
BE_NCONST MDL::Frame* pcFrames = (BE_NCONST MDL::Frame*)szCurrent;
|
||||||
BE_NCONST MDL::SimpleFrame* pcFirstFrame;
|
BE_NCONST MDL::SimpleFrame* pcFirstFrame;
|
||||||
|
|
||||||
if (0 == pcFrames->type)
|
if (0 == pcFrames->type) {
|
||||||
{
|
|
||||||
// get address of single frame
|
// get address of single frame
|
||||||
pcFirstFrame = &pcFrames->frame;
|
pcFirstFrame = &pcFrames->frame;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// get the first frame in the group
|
// get the first frame in the group
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// FIXME: the cast is wrong and causea a warning on clang 5.0
|
// FIXME: the cast is wrong and cause a warning on clang 5.0
|
||||||
// disable thi code for now, fix it later
|
// disable thi code for now, fix it later
|
||||||
ai_assert(false && "Bad pointer cast");
|
ai_assert(false && "Bad pointer cast");
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -70,7 +70,7 @@ class ASSIMP_API IOStream
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
/** Constructor protected, use IOSystem::Open() to create an instance. */
|
/** Constructor protected, use IOSystem::Open() to create an instance. */
|
||||||
IOStream(void);
|
IOStream();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -124,17 +124,18 @@ public:
|
||||||
}; //! class IOStream
|
}; //! class IOStream
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
inline IOStream::IOStream()
|
inline
|
||||||
{
|
IOStream::IOStream() {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
inline IOStream::~IOStream()
|
inline
|
||||||
{
|
IOStream::~IOStream() {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
} //!namespace Assimp
|
} //!namespace Assimp
|
||||||
|
|
||||||
#endif //!!AI_IOSTREAM_H_INC
|
#endif //!!AI_IOSTREAM_H_INC
|
||||||
|
|
Loading…
Reference in New Issue