Merge branch 'master' into GLTF2_recursive_references_fix
commit
c0dc26de8e
|
@ -11,7 +11,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- name: configure
|
- name: configure
|
||||||
run: cmake CMakeLists.txt
|
run: cmake CMakeLists.txt
|
||||||
- name: build
|
- name: build
|
||||||
|
@ -23,7 +23,7 @@ jobs:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- name: configure
|
- name: configure
|
||||||
run: cmake CMakeLists.txt
|
run: cmake CMakeLists.txt
|
||||||
- name: build
|
- name: build
|
||||||
|
@ -35,7 +35,7 @@ jobs:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- name: configure
|
- name: configure
|
||||||
run: cmake CMakeLists.txt
|
run: cmake CMakeLists.txt
|
||||||
- name: build
|
- name: build
|
||||||
|
|
|
@ -7,6 +7,14 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||||
|
|
||||||
set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
|
set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
|
||||||
|
|
||||||
|
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
|
||||||
|
|
||||||
|
if ("${LIB64}" STREQUAL "TRUE")
|
||||||
|
set(LIBSUFFIX 64)
|
||||||
|
else()
|
||||||
|
set(LIBSUFFIX "")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
if(MSVC_TOOLSET_VERSION)
|
if(MSVC_TOOLSET_VERSION)
|
||||||
set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
||||||
|
@ -75,23 +83,20 @@ else()
|
||||||
endif()
|
endif()
|
||||||
set_target_properties(assimp::assimp PROPERTIES
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
IMPORTED_SONAME_DEBUG "${sharedLibraryName}"
|
IMPORTED_SONAME_DEBUG "${sharedLibraryName}"
|
||||||
IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}"
|
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${sharedLibraryName}"
|
||||||
)
|
)
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" )
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${sharedLibraryName}" )
|
||||||
else()
|
else()
|
||||||
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
||||||
set_target_properties(assimp::assimp PROPERTIES
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}"
|
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${staticLibraryName}"
|
||||||
)
|
)
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}" )
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${staticLibraryName}" )
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Commands beyond this point should not need to know the version.
|
# Commands beyond this point should not need to know the version.
|
||||||
set(CMAKE_IMPORT_FILE_VERSION)
|
set(CMAKE_IMPORT_FILE_VERSION)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,14 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||||
|
|
||||||
set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
|
set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
|
||||||
|
|
||||||
|
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
|
||||||
|
|
||||||
|
if ("${LIB64}" STREQUAL "TRUE")
|
||||||
|
set(LIBSUFFIX 64)
|
||||||
|
else()
|
||||||
|
set(LIBSUFFIX "")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
if(MSVC_TOOLSET_VERSION)
|
if(MSVC_TOOLSET_VERSION)
|
||||||
set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
set(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
||||||
|
@ -75,17 +83,17 @@ else()
|
||||||
endif()
|
endif()
|
||||||
set_target_properties(assimp::assimp PROPERTIES
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
IMPORTED_SONAME_RELEASE "${sharedLibraryName}"
|
IMPORTED_SONAME_RELEASE "${sharedLibraryName}"
|
||||||
IMPORTED_LOCATION_RELEASE "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}"
|
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${sharedLibraryName}"
|
||||||
)
|
)
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" )
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${sharedLibraryName}" )
|
||||||
else()
|
else()
|
||||||
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@")
|
||||||
set_target_properties(assimp::assimp PROPERTIES
|
set_target_properties(assimp::assimp PROPERTIES
|
||||||
IMPORTED_LOCATION_RELEASE "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}"
|
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${staticLibraryName}"
|
||||||
)
|
)
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp )
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}" )
|
list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib${LIBSUFFIX}/${staticLibraryName}" )
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -43,7 +41,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/** @file Implementation of the 3ds importer class */
|
/** @file Implementation of the 3ds importer class */
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
||||||
|
|
||||||
// internal headers
|
// internal headers
|
||||||
|
|
|
@ -441,12 +441,33 @@ struct Material {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
Material(const Material &other) = default;
|
Material(const Material &other) :
|
||||||
Material &operator=(const Material &other) = default;
|
mName(other.mName),
|
||||||
|
mDiffuse(other.mDiffuse),
|
||||||
|
mSpecularExponent(other.mSpecularExponent),
|
||||||
|
mShininessStrength(other.mShininessStrength),
|
||||||
|
mSpecular(other.mSpecular),
|
||||||
|
mAmbient(other.mAmbient),
|
||||||
|
mShading(other.mShading),
|
||||||
|
mTransparency(other.mTransparency),
|
||||||
|
sTexDiffuse(other.sTexDiffuse),
|
||||||
|
sTexOpacity(other.sTexOpacity),
|
||||||
|
sTexSpecular(other.sTexSpecular),
|
||||||
|
sTexReflective(other.sTexReflective),
|
||||||
|
sTexBump(other.sTexBump),
|
||||||
|
sTexEmissive(other.sTexEmissive),
|
||||||
|
sTexShininess(other.sTexShininess),
|
||||||
|
mBumpHeight(other.mBumpHeight),
|
||||||
|
mEmissive(other.mEmissive),
|
||||||
|
sTexAmbient(other.sTexAmbient),
|
||||||
|
mTwoSided(other.mTwoSided) {
|
||||||
|
// empty
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
||||||
Material(Material &&other) AI_NO_EXCEPT
|
Material(Material &&other) AI_NO_EXCEPT :
|
||||||
: mName(std::move(other.mName)),
|
mName(std::move(other.mName)),
|
||||||
mDiffuse(std::move(other.mDiffuse)),
|
mDiffuse(std::move(other.mDiffuse)),
|
||||||
mSpecularExponent(std::move(other.mSpecularExponent)),
|
mSpecularExponent(std::move(other.mSpecularExponent)),
|
||||||
mShininessStrength(std::move(other.mShininessStrength)),
|
mShininessStrength(std::move(other.mShininessStrength)),
|
||||||
|
@ -465,6 +486,7 @@ struct Material {
|
||||||
mEmissive(std::move(other.mEmissive)),
|
mEmissive(std::move(other.mEmissive)),
|
||||||
sTexAmbient(std::move(other.sTexAmbient)),
|
sTexAmbient(std::move(other.sTexAmbient)),
|
||||||
mTwoSided(std::move(other.mTwoSided)) {
|
mTwoSided(std::move(other.mTwoSided)) {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
Material &operator=(Material &&other) AI_NO_EXCEPT {
|
Material &operator=(Material &&other) AI_NO_EXCEPT {
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -72,7 +70,6 @@ static const aiImporterDesc desc = {
|
||||||
"3ds prj"
|
"3ds prj"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Begins a new parsing block
|
// Begins a new parsing block
|
||||||
// - Reads the current chunk and validates it
|
// - Reads the current chunk and validates it
|
||||||
|
@ -141,15 +138,13 @@ bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandle
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Loader registry entry
|
// Loader registry entry
|
||||||
const aiImporterDesc* Discreet3DSImporter::GetInfo () const
|
const aiImporterDesc* Discreet3DSImporter::GetInfo () const {
|
||||||
{
|
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Setup configuration properties
|
// Setup configuration properties
|
||||||
void Discreet3DSImporter::SetupProperties(const Importer* /*pImp*/)
|
void Discreet3DSImporter::SetupProperties(const Importer* /*pImp*/) {
|
||||||
{
|
|
||||||
// nothing to be done for the moment
|
// nothing to be done for the moment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +195,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||||
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(mesh);
|
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace all occurences of the default material with a
|
// Replace all occurrences of the default material with a
|
||||||
// valid material. Generate it if no material containing
|
// valid material. Generate it if no material containing
|
||||||
// DEFAULT in its name has been found in the file
|
// DEFAULT in its name has been found in the file
|
||||||
ReplaceDefaultMaterial();
|
ReplaceDefaultMaterial();
|
||||||
|
@ -227,8 +222,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Applies a master-scaling factor to the imported scene
|
// Applies a master-scaling factor to the imported scene
|
||||||
void Discreet3DSImporter::ApplyMasterScale(aiScene* pScene)
|
void Discreet3DSImporter::ApplyMasterScale(aiScene* pScene) {
|
||||||
{
|
|
||||||
// There are some 3DS files with a zero scaling factor
|
// There are some 3DS files with a zero scaling factor
|
||||||
if (!mMasterScale)mMasterScale = 1.0f;
|
if (!mMasterScale)mMasterScale = 1.0f;
|
||||||
else mMasterScale = 1.0f / mMasterScale;
|
else mMasterScale = 1.0f / mMasterScale;
|
||||||
|
@ -1084,7 +1078,7 @@ void Discreet3DSImporter::ParseMeshChunk()
|
||||||
mMesh.mFaceMaterials.resize(mMesh.mFaces.size(),0xcdcdcdcd);
|
mMesh.mFaceMaterials.resize(mMesh.mFaces.size(),0xcdcdcdcd);
|
||||||
|
|
||||||
// Larger 3DS files could have multiple FACE chunks here
|
// Larger 3DS files could have multiple FACE chunks here
|
||||||
chunkSize = stream->GetRemainingSizeToLimit();
|
chunkSize = (int)stream->GetRemainingSizeToLimit();
|
||||||
if ( chunkSize > (int) sizeof(Discreet3DS::Chunk ) )
|
if ( chunkSize > (int) sizeof(Discreet3DS::Chunk ) )
|
||||||
ParseFaceChunk();
|
ParseFaceChunk();
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,15 +65,11 @@ using namespace D3DS;
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** Importer class for 3D Studio r3 and r4 3DS files
|
/** Importer class for 3D Studio r3 and r4 3DS files
|
||||||
*/
|
*/
|
||||||
class Discreet3DSImporter : public BaseImporter
|
class Discreet3DSImporter : public BaseImporter {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Discreet3DSImporter();
|
Discreet3DSImporter();
|
||||||
~Discreet3DSImporter();
|
~Discreet3DSImporter();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
* See BaseImporter::CanRead() for details.
|
* See BaseImporter::CanRead() for details.
|
||||||
|
|
|
@ -9,6 +9,9 @@ For details, see http://sourceforge.net/projects/libb64
|
||||||
|
|
||||||
const int CHARS_PER_LINE = 72;
|
const int CHARS_PER_LINE = 72;
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4244)
|
||||||
|
|
||||||
void base64_init_encodestate(base64_encodestate* state_in)
|
void base64_init_encodestate(base64_encodestate* state_in)
|
||||||
{
|
{
|
||||||
state_in->step = step_A;
|
state_in->step = step_A;
|
||||||
|
@ -107,3 +110,4 @@ int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
|
||||||
return (int)(codechar - code_out);
|
return (int)(codechar - code_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
|
@ -206,7 +206,7 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
|
||||||
inflateInit2(&zstream, 16+MAX_WBITS);
|
inflateInit2(&zstream, 16+MAX_WBITS);
|
||||||
|
|
||||||
zstream.next_in = reinterpret_cast<Bytef*>( reader->GetPtr() );
|
zstream.next_in = reinterpret_cast<Bytef*>( reader->GetPtr() );
|
||||||
zstream.avail_in = reader->GetRemainingSize();
|
zstream.avail_in = (uInt) reader->GetRemainingSize();
|
||||||
|
|
||||||
size_t total = 0l;
|
size_t total = 0l;
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ void CSMImporter::InternReadFile( const std::string& pFile,
|
||||||
*ot++ = *buffer++;
|
*ot++ = *buffer++;
|
||||||
|
|
||||||
*ot = '\0';
|
*ot = '\0';
|
||||||
nda->mNodeName.length = (ai_uint32)(ot-nda->mNodeName.data);
|
nda->mNodeName.length = static_cast<ai_uint32>(ot-nda->mNodeName.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
anim->mNumChannels = static_cast<unsigned int>(anims_temp.size());
|
anim->mNumChannels = static_cast<unsigned int>(anims_temp.size());
|
||||||
|
|
|
@ -83,32 +83,61 @@ namespace Assimp {
|
||||||
void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out);
|
void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out);
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Exporter worker function prototypes. Should not be necessary to #ifndef them, it's just a prototype
|
// Exporter worker function prototypes. Do not use const, because some exporter need to convert
|
||||||
// do not use const, because some exporter need to convert the scene temporary
|
// the scene temporary
|
||||||
|
#ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER
|
||||||
void ExportSceneCollada(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneCollada(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_X_EXPORTER
|
||||||
void ExportSceneXFile(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneXFile(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_STEP_EXPORTER
|
||||||
void ExportSceneStep(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneStep(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER
|
||||||
void ExportSceneObj(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneObj(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneObjNoMtl(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneObjNoMtl(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_STL_EXPORTER
|
||||||
void ExportSceneSTL(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneSTL(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneSTLBinary(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneSTLBinary(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_PLY_EXPORTER
|
||||||
void ExportScenePly(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportScenePly(const char*,IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportScenePlyBinary(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportScenePlyBinary(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_3DS_EXPORTER
|
||||||
void ExportScene3DS(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportScene3DS(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER
|
||||||
void ExportSceneGLTF(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneGLTF(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneGLB(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneGLB(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneGLTF2(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneGLTF2(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneGLB2(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneGLB2(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
||||||
void ExportSceneAssbin(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneAssbin(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER
|
||||||
void ExportSceneAssxml(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneAssxml(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_X3D_EXPORTER
|
||||||
void ExportSceneX3D(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneX3D(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_FBX_EXPORTER
|
||||||
void ExportSceneFBX(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneFBX(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneFBXA(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneFBXA(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_3MF_EXPORTER
|
||||||
void ExportScene3MF( const char*, IOSystem*, const aiScene*, const ExportProperties* );
|
void ExportScene3MF( const char*, IOSystem*, const aiScene*, const ExportProperties* );
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_M3D_EXPORTER
|
||||||
void ExportSceneM3D(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneM3D(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
void ExportSceneM3DA(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
void ExportSceneM3DA(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||||
|
#endif
|
||||||
|
#ifndef ASSIMP_BUILD_NO_ASSJSON_EXPORTER
|
||||||
void ExportAssimp2Json(const char* , IOSystem*, const aiScene* , const Assimp::ExportProperties*);
|
void ExportAssimp2Json(const char* , IOSystem*, const aiScene* , const Assimp::ExportProperties*);
|
||||||
|
#endif
|
||||||
|
|
||||||
static void setupExporterArray(std::vector<Exporter::ExportFormatEntry> &exporters) {
|
static void setupExporterArray(std::vector<Exporter::ExportFormatEntry> &exporters) {
|
||||||
#ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER
|
#ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER
|
||||||
|
|
|
@ -1483,6 +1483,7 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
delete root;
|
delete root;
|
||||||
|
delete reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_IRR_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_IRR_IMPORTER
|
||||||
|
|
|
@ -312,7 +312,9 @@ void ExportSceneM3DA(
|
||||||
M3DExporter::M3DExporter(const aiScene *pScene, const ExportProperties *pProperties) :
|
M3DExporter::M3DExporter(const aiScene *pScene, const ExportProperties *pProperties) :
|
||||||
mScene(pScene),
|
mScene(pScene),
|
||||||
mProperties(pProperties),
|
mProperties(pProperties),
|
||||||
outfile() {}
|
outfile() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void M3DExporter::doExport(
|
void M3DExporter::doExport(
|
||||||
|
@ -352,6 +354,9 @@ void M3DExporter::doExport(
|
||||||
// explicitly release file pointer,
|
// explicitly release file pointer,
|
||||||
// so we don't have to rely on class destruction.
|
// so we don't have to rely on class destruction.
|
||||||
outfile.reset();
|
outfile.reset();
|
||||||
|
|
||||||
|
M3D_FREE(m3d->name);
|
||||||
|
m3d->name = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -121,8 +121,9 @@ M3DWrapper::~M3DWrapper() {
|
||||||
|
|
||||||
void M3DWrapper::reset() {
|
void M3DWrapper::reset() {
|
||||||
ClearSave();
|
ClearSave();
|
||||||
if (m3d_)
|
if (m3d_) {
|
||||||
m3d_free(m3d_);
|
m3d_free(m3d_);
|
||||||
|
}
|
||||||
m3d_ = nullptr;
|
m3d_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5440,13 +5440,13 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
out += 2;
|
out += 2;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
*((float *)out) = vrtx[i].data.x;
|
memcpy(out, &vrtx[i].data.x, sizeof(float));
|
||||||
out += 4;
|
out += 4;
|
||||||
*((float *)out) = vrtx[i].data.y;
|
memcpy(out, &vrtx[i].data.y, sizeof(float));
|
||||||
out += 4;
|
out += 4;
|
||||||
*((float *)out) = vrtx[i].data.z;
|
memcpy(out, &vrtx[i].data.z, sizeof(float));
|
||||||
out += 4;
|
out += 4;
|
||||||
*((float *)out) = vrtx[i].data.w;
|
memcpy(out, &vrtx[i].data.w, sizeof(float));
|
||||||
out += 4;
|
out += 4;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
|
@ -5474,9 +5474,11 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
}
|
}
|
||||||
out = _m3d_addidx(out, sk_s, vrtx[i].data.skinid);
|
out = _m3d_addidx(out, sk_s, vrtx[i].data.skinid);
|
||||||
}
|
}
|
||||||
*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
||||||
|
memcpy(length, &v, sizeof(uint32_t));
|
||||||
|
//*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
||||||
out = NULL;
|
out = NULL;
|
||||||
len += *length;
|
len += v;
|
||||||
}
|
}
|
||||||
/* bones chunk */
|
/* bones chunk */
|
||||||
if (model->numbone && model->bone && !(flags & M3D_EXP_NOBONE)) {
|
if (model->numbone && model->bone && !(flags & M3D_EXP_NOBONE)) {
|
||||||
|
@ -5660,8 +5662,9 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
out = _m3d_addidx(out, vi_s, vrtxidx[face[i].data.normal[j]]);
|
out = _m3d_addidx(out, vi_s, vrtxidx[face[i].data.normal[j]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
||||||
len += *length;
|
memcpy(length, &v, sizeof(uint32_t));
|
||||||
|
len += v;
|
||||||
out = NULL;
|
out = NULL;
|
||||||
}
|
}
|
||||||
/* mathematical shapes face */
|
/* mathematical shapes face */
|
||||||
|
@ -5721,8 +5724,9 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
||||||
len += *length;
|
memcpy( length, &v, sizeof(uint32_t));
|
||||||
|
len += v;
|
||||||
out = NULL;
|
out = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5765,8 +5769,9 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, model->label[l].text));
|
out = _m3d_addidx(out, si_s, _m3d_stridx(str, numstr, model->label[l].text));
|
||||||
}
|
}
|
||||||
if (length) {
|
if (length) {
|
||||||
*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
||||||
len += *length;
|
memcpy( length, &v, sizeof(uint32_t));
|
||||||
|
len += v;
|
||||||
}
|
}
|
||||||
out = NULL;
|
out = NULL;
|
||||||
sn = sl = NULL;
|
sn = sl = NULL;
|
||||||
|
@ -5796,8 +5801,9 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
out = _m3d_addidx(out, vi_s, vrtxidx[a->frame[i].transform[k].ori]);
|
out = _m3d_addidx(out, vi_s, vrtxidx[a->frame[i].transform[k].ori]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*length = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
uint32_t v = (uint32_t)((uintptr_t)out - (uintptr_t)((uint8_t *)h + len));
|
||||||
len += *length;
|
memcpy( length, &v, sizeof(uint32_t));
|
||||||
|
len += v;
|
||||||
out = NULL;
|
out = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -503,7 +503,7 @@ aiReturn aiMaterial::AddBinaryProperty (const void* pInput,
|
||||||
pcNew->mData = new char[pSizeInBytes];
|
pcNew->mData = new char[pSizeInBytes];
|
||||||
memcpy (pcNew->mData,pInput,pSizeInBytes);
|
memcpy (pcNew->mData,pInput,pSizeInBytes);
|
||||||
|
|
||||||
pcNew->mKey.length = (ai_uint32)::strlen(pKey);
|
pcNew->mKey.length = static_cast<ai_uint32>( ::strlen(pKey) );
|
||||||
ai_assert ( MAXLEN > pcNew->mKey.length);
|
ai_assert ( MAXLEN > pcNew->mKey.length);
|
||||||
strcpy( pcNew->mKey.data, pKey );
|
strcpy( pcNew->mKey.data, pKey );
|
||||||
|
|
||||||
|
|
|
@ -617,7 +617,7 @@ bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model
|
||||||
// We'll leave it up to the user to figure out which extension the file has.
|
// We'll leave it up to the user to figure out which extension the file has.
|
||||||
aiString name;
|
aiString name;
|
||||||
strncpy( name.data, pTexture->strName, sizeof name.data );
|
strncpy( name.data, pTexture->strName, sizeof name.data );
|
||||||
name.length = (ai_uint32)strlen( name.data );
|
name.length = static_cast<ai_uint32>(strlen( name.data ));
|
||||||
pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
|
pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -616,7 +616,7 @@ void SMDImporter::CreateOutputMaterials() {
|
||||||
if (aszTextures[iMat].length())
|
if (aszTextures[iMat].length())
|
||||||
{
|
{
|
||||||
::strncpy(szName.data, aszTextures[iMat].c_str(),MAXLEN-1);
|
::strncpy(szName.data, aszTextures[iMat].c_str(),MAXLEN-1);
|
||||||
szName.length = (ai_uint32)aszTextures[iMat].length();
|
szName.length = static_cast<ai_uint32>( aszTextures[iMat].length() );
|
||||||
pcMat->AddProperty(&szName,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
pcMat->AddProperty(&szName,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -43,17 +41,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/** @file Implementation of the Terragen importer class */
|
/** @file Implementation of the Terragen importer class */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_TERRAGEN_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_TERRAGEN_IMPORTER
|
||||||
|
|
||||||
#include "TerragenLoader.h"
|
#include "TerragenLoader.h"
|
||||||
#include <assimp/StreamReader.h>
|
#include <assimp/StreamReader.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/importerdesc.h>
|
||||||
#include <assimp/IOSystem.hpp>
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/importerdesc.h>
|
#include <assimp/IOSystem.hpp>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -72,19 +68,16 @@ static const aiImporterDesc desc = {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
TerragenImporter::TerragenImporter()
|
TerragenImporter::TerragenImporter() :
|
||||||
: configComputeUVs (false)
|
configComputeUVs(false) {}
|
||||||
{}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor, private as well
|
// Destructor, private as well
|
||||||
TerragenImporter::~TerragenImporter()
|
TerragenImporter::~TerragenImporter() {}
|
||||||
{}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool TerragenImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
bool TerragenImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const {
|
||||||
{
|
|
||||||
// check file extension
|
// check file extension
|
||||||
std::string extension = GetExtension(pFile);
|
std::string extension = GetExtension(pFile);
|
||||||
|
|
||||||
|
@ -105,15 +98,13 @@ bool TerragenImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler,
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Build a string of all file extensions supported
|
// Build a string of all file extensions supported
|
||||||
const aiImporterDesc* TerragenImporter::GetInfo () const
|
const aiImporterDesc *TerragenImporter::GetInfo() const {
|
||||||
{
|
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Setup import properties
|
// Setup import properties
|
||||||
void TerragenImporter::SetupProperties(const Importer* pImp)
|
void TerragenImporter::SetupProperties(const Importer *pImp) {
|
||||||
{
|
|
||||||
// AI_CONFIG_IMPORT_TER_MAKE_UVS
|
// AI_CONFIG_IMPORT_TER_MAKE_UVS
|
||||||
configComputeUVs = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_TER_MAKE_UVS, 0));
|
configComputeUVs = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_TER_MAKE_UVS, 0));
|
||||||
}
|
}
|
||||||
|
@ -121,8 +112,7 @@ void TerragenImporter::SetupProperties(const Importer* pImp)
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void TerragenImporter::InternReadFile(const std::string &pFile,
|
void TerragenImporter::InternReadFile(const std::string &pFile,
|
||||||
aiScene* pScene, IOSystem* pIOHandler)
|
aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
{
|
|
||||||
IOStream *file = pIOHandler->Open(pFile, "rb");
|
IOStream *file = pIOHandler->Open(pFile, "rb");
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
|
@ -151,8 +141,7 @@ void TerragenImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// Now read all chunks until we're finished or an EOF marker is encountered
|
// Now read all chunks until we're finished or an EOF marker is encountered
|
||||||
reader.IncPtr(16);
|
reader.IncPtr(16);
|
||||||
while (reader.GetRemainingSize() >= 4)
|
while (reader.GetRemainingSize() >= 4) {
|
||||||
{
|
|
||||||
const char *head = (const char *)reader.GetPtr();
|
const char *head = (const char *)reader.GetPtr();
|
||||||
reader.IncPtr(4);
|
reader.IncPtr(4);
|
||||||
|
|
||||||
|
@ -161,42 +150,35 @@ void TerragenImporter::InternReadFile( const std::string& pFile,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Number of x-data points
|
// Number of x-data points
|
||||||
if (!::strncmp(head,AI_TERR_CHUNK_XPTS,4))
|
if (!::strncmp(head, AI_TERR_CHUNK_XPTS, 4)) {
|
||||||
{
|
|
||||||
x = (uint16_t)reader.GetI2();
|
x = (uint16_t)reader.GetI2();
|
||||||
}
|
}
|
||||||
// Number of y-data points
|
// Number of y-data points
|
||||||
else if (!::strncmp(head,AI_TERR_CHUNK_YPTS,4))
|
else if (!::strncmp(head, AI_TERR_CHUNK_YPTS, 4)) {
|
||||||
{
|
|
||||||
y = (uint16_t)reader.GetI2();
|
y = (uint16_t)reader.GetI2();
|
||||||
}
|
}
|
||||||
// Squared terrains width-1.
|
// Squared terrains width-1.
|
||||||
else if (!::strncmp(head,AI_TERR_CHUNK_SIZE,4))
|
else if (!::strncmp(head, AI_TERR_CHUNK_SIZE, 4)) {
|
||||||
{
|
|
||||||
x = y = (uint16_t)reader.GetI2() + 1;
|
x = y = (uint16_t)reader.GetI2() + 1;
|
||||||
}
|
}
|
||||||
// terrain scaling
|
// terrain scaling
|
||||||
else if (!::strncmp(head,AI_TERR_CHUNK_SCAL,4))
|
else if (!::strncmp(head, AI_TERR_CHUNK_SCAL, 4)) {
|
||||||
{
|
|
||||||
root->mTransformation.a1 = reader.GetF4();
|
root->mTransformation.a1 = reader.GetF4();
|
||||||
root->mTransformation.b2 = reader.GetF4();
|
root->mTransformation.b2 = reader.GetF4();
|
||||||
root->mTransformation.c3 = reader.GetF4();
|
root->mTransformation.c3 = reader.GetF4();
|
||||||
}
|
}
|
||||||
// mapping == 1: earth radius
|
// mapping == 1: earth radius
|
||||||
else if (!::strncmp(head,AI_TERR_CHUNK_CRAD,4))
|
else if (!::strncmp(head, AI_TERR_CHUNK_CRAD, 4)) {
|
||||||
{
|
|
||||||
reader.GetF4();
|
reader.GetF4();
|
||||||
}
|
}
|
||||||
// mapping mode
|
// mapping mode
|
||||||
else if (!::strncmp(head,AI_TERR_CHUNK_CRVM,4))
|
else if (!::strncmp(head, AI_TERR_CHUNK_CRVM, 4)) {
|
||||||
{
|
|
||||||
mode = reader.GetI1();
|
mode = reader.GetI1();
|
||||||
if (0 != mode)
|
if (0 != mode)
|
||||||
ASSIMP_LOG_ERROR("TER: Unsupported mapping mode, a flat terrain is returned");
|
ASSIMP_LOG_ERROR("TER: Unsupported mapping mode, a flat terrain is returned");
|
||||||
}
|
}
|
||||||
// actual terrain data
|
// actual terrain data
|
||||||
else if (!::strncmp(head,AI_TERR_CHUNK_ALTW,4))
|
else if (!::strncmp(head, AI_TERR_CHUNK_ALTW, 4)) {
|
||||||
{
|
|
||||||
float hscale = (float)reader.GetI2() / 65536;
|
float hscale = (float)reader.GetI2() / 65536;
|
||||||
float bheight = (float)reader.GetI2();
|
float bheight = (float)reader.GetI2();
|
||||||
|
|
||||||
|
@ -247,8 +229,10 @@ void TerragenImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// make indices
|
// make indices
|
||||||
f->mIndices = new unsigned int[f->mNumIndices = 4];
|
f->mIndices = new unsigned int[f->mNumIndices = 4];
|
||||||
for (unsigned int i = 0; i < 4;++i)
|
for (unsigned int i = 0; i < 4; ++i) {
|
||||||
f->mIndices[i] = t++;
|
f->mIndices[i] = t;
|
||||||
|
t++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -69,21 +68,17 @@ namespace Assimp {
|
||||||
* The loader is basing on the information found here:
|
* The loader is basing on the information found here:
|
||||||
* http://www.planetside.co.uk/terragen/dev/tgterrain.html#chunks
|
* http://www.planetside.co.uk/terragen/dev/tgterrain.html#chunks
|
||||||
*/
|
*/
|
||||||
class TerragenImporter : public BaseImporter
|
class TerragenImporter : public BaseImporter {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
TerragenImporter();
|
TerragenImporter();
|
||||||
~TerragenImporter();
|
~TerragenImporter();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
||||||
bool checkSig) const;
|
bool checkSig) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
const aiImporterDesc *GetInfo() const;
|
const aiImporterDesc *GetInfo() const;
|
||||||
|
|
||||||
|
@ -95,7 +90,6 @@ protected:
|
||||||
void SetupProperties(const Importer *pImp);
|
void SetupProperties(const Importer *pImp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool configComputeUVs;
|
bool configComputeUVs;
|
||||||
|
|
||||||
}; //! class TerragenImporter
|
}; //! class TerragenImporter
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -48,26 +46,112 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* http://local.wasp.uwa.edu.au/~pbourke/dataformats/unreal/
|
* http://local.wasp.uwa.edu.au/~pbourke/dataformats/unreal/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_3D_IMPORTER
|
||||||
|
|
||||||
#include "Unreal/UnrealLoader.h"
|
#include "Unreal/UnrealLoader.h"
|
||||||
#include "PostProcessing/ConvertToLHProcess.h"
|
#include "PostProcessing/ConvertToLHProcess.h"
|
||||||
|
|
||||||
#include <assimp/StreamReader.h>
|
|
||||||
#include <assimp/ParsingUtils.h>
|
#include <assimp/ParsingUtils.h>
|
||||||
|
#include <assimp/StreamReader.h>
|
||||||
#include <assimp/fast_atof.h>
|
#include <assimp/fast_atof.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/importerdesc.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/Importer.hpp>
|
||||||
#include <assimp/importerdesc.h>
|
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
namespace Unreal {
|
||||||
|
|
||||||
|
/*
|
||||||
|
0 = Normal one-sided
|
||||||
|
1 = Normal two-sided
|
||||||
|
2 = Translucent two-sided
|
||||||
|
3 = Masked two-sided
|
||||||
|
4 = Modulation blended two-sided
|
||||||
|
8 = Placeholder triangle for weapon positioning (invisible)
|
||||||
|
*/
|
||||||
|
enum MeshFlags {
|
||||||
|
MF_NORMAL_OS = 0,
|
||||||
|
MF_NORMAL_TS = 1,
|
||||||
|
MF_NORMAL_TRANS_TS = 2,
|
||||||
|
MF_NORMAL_MASKED_TS = 3,
|
||||||
|
MF_NORMAL_MOD_TS = 4,
|
||||||
|
MF_WEAPON_PLACEHOLDER = 8
|
||||||
|
};
|
||||||
|
|
||||||
|
// a single triangle
|
||||||
|
struct Triangle {
|
||||||
|
uint16_t mVertex[3]; // Vertex indices
|
||||||
|
char mType; // James' Mesh Type
|
||||||
|
char mColor; // Color for flat and Gourand Shaded
|
||||||
|
unsigned char mTex[3][2]; // Texture UV coordinates
|
||||||
|
unsigned char mTextureNum; // Source texture offset
|
||||||
|
char mFlags; // Unreal Mesh Flags (unused)
|
||||||
|
unsigned int matIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
// temporary representation for a material
|
||||||
|
struct TempMat {
|
||||||
|
TempMat() :
|
||||||
|
type(MF_NORMAL_OS), tex(), numFaces(0) {}
|
||||||
|
|
||||||
|
explicit TempMat(const Triangle &in) :
|
||||||
|
type((Unreal::MeshFlags)in.mType), tex(in.mTextureNum), numFaces(0) {}
|
||||||
|
|
||||||
|
// type of mesh
|
||||||
|
Unreal::MeshFlags type;
|
||||||
|
|
||||||
|
// index of texture
|
||||||
|
unsigned int tex;
|
||||||
|
|
||||||
|
// number of faces using us
|
||||||
|
unsigned int numFaces;
|
||||||
|
|
||||||
|
// for std::find
|
||||||
|
bool operator==(const TempMat &o) {
|
||||||
|
return (tex == o.tex && type == o.type);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Vertex {
|
||||||
|
int32_t X : 11;
|
||||||
|
int32_t Y : 11;
|
||||||
|
int32_t Z : 10;
|
||||||
|
};
|
||||||
|
|
||||||
|
// UNREAL vertex compression
|
||||||
|
inline void CompressVertex(const aiVector3D &v, uint32_t &out) {
|
||||||
|
union {
|
||||||
|
Vertex n;
|
||||||
|
int32_t t;
|
||||||
|
};
|
||||||
|
t = 0;
|
||||||
|
n.X = (int32_t)v.x;
|
||||||
|
n.Y = (int32_t)v.y;
|
||||||
|
n.Z = (int32_t)v.z;
|
||||||
|
::memcpy(&out, &t, sizeof(int32_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
// UNREAL vertex decompression
|
||||||
|
inline void DecompressVertex(aiVector3D &v, int32_t in) {
|
||||||
|
union {
|
||||||
|
Vertex n;
|
||||||
|
int32_t i;
|
||||||
|
};
|
||||||
|
i = in;
|
||||||
|
|
||||||
|
v.x = (float)n.X;
|
||||||
|
v.y = (float)n.Y;
|
||||||
|
v.z = (float)n.Z;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace Unreal
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static const aiImporterDesc desc = {
|
||||||
"Unreal Mesh Importer",
|
"Unreal Mesh Importer",
|
||||||
"",
|
"",
|
||||||
|
@ -81,54 +165,46 @@ static const aiImporterDesc desc = {
|
||||||
"3d uc"
|
"3d uc"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
UnrealImporter::UnrealImporter()
|
UnrealImporter::UnrealImporter() :
|
||||||
: configFrameID (0)
|
mConfigFrameID(0), mConfigHandleFlags(true) {}
|
||||||
, configHandleFlags (true)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor, private as well
|
// Destructor, private as well
|
||||||
UnrealImporter::~UnrealImporter()
|
UnrealImporter::~UnrealImporter() {}
|
||||||
{}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool UnrealImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const
|
bool UnrealImporter::CanRead(const std::string &pFile, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
|
||||||
{
|
|
||||||
return SimpleExtensionCheck(pFile, "3d", "uc");
|
return SimpleExtensionCheck(pFile, "3d", "uc");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Build a string of all file extensions supported
|
// Build a string of all file extensions supported
|
||||||
const aiImporterDesc* UnrealImporter::GetInfo () const
|
const aiImporterDesc *UnrealImporter::GetInfo() const {
|
||||||
{
|
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Setup configuration properties for the loader
|
// Setup configuration properties for the loader
|
||||||
void UnrealImporter::SetupProperties(const Importer* pImp)
|
void UnrealImporter::SetupProperties(const Importer *pImp) {
|
||||||
{
|
|
||||||
// The
|
// The
|
||||||
// AI_CONFIG_IMPORT_UNREAL_KEYFRAME option overrides the
|
// AI_CONFIG_IMPORT_UNREAL_KEYFRAME option overrides the
|
||||||
// AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option.
|
// AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option.
|
||||||
configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_UNREAL_KEYFRAME,-1);
|
mConfigFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_UNREAL_KEYFRAME, -1);
|
||||||
if(static_cast<unsigned int>(-1) == configFrameID) {
|
if (static_cast<unsigned int>(-1) == mConfigFrameID) {
|
||||||
configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0);
|
mConfigFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AI_CONFIG_IMPORT_UNREAL_HANDLE_FLAGS, default is true
|
// AI_CONFIG_IMPORT_UNREAL_HANDLE_FLAGS, default is true
|
||||||
configHandleFlags = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_UNREAL_HANDLE_FLAGS,1));
|
mConfigHandleFlags = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_UNREAL_HANDLE_FLAGS, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void UnrealImporter::InternReadFile(const std::string &pFile,
|
void UnrealImporter::InternReadFile(const std::string &pFile,
|
||||||
aiScene* pScene, IOSystem* pIOHandler)
|
aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
{
|
|
||||||
// For any of the 3 files being passed get the three correct paths
|
// For any of the 3 files being passed get the three correct paths
|
||||||
// First of all, determine file extension
|
// First of all, determine file extension
|
||||||
std::string::size_type pos = pFile.find_last_of('.');
|
std::string::size_type pos = pFile.find_last_of('.');
|
||||||
|
@ -143,8 +219,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
throw DeadlyImportError("UNREAL: Unexpected naming scheme");
|
throw DeadlyImportError("UNREAL: Unexpected naming scheme");
|
||||||
}
|
}
|
||||||
extension = pFile.substr(0, pos);
|
extension = pFile.substr(0, pos);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
extension = pFile.substr(0, pos);
|
extension = pFile.substr(0, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +261,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
tri.mType = d_reader.GetI1();
|
tri.mType = d_reader.GetI1();
|
||||||
|
|
||||||
// handle mesh flagss?
|
// handle mesh flagss?
|
||||||
if (configHandleFlags)
|
if (mConfigHandleFlags)
|
||||||
tri.mType = Unreal::MF_NORMAL_OS;
|
tri.mType = Unreal::MF_NORMAL_OS;
|
||||||
else {
|
else {
|
||||||
// ignore MOD and MASKED for the moment, treat them as two-sided
|
// ignore MOD and MASKED for the moment, treat them as two-sided
|
||||||
|
@ -211,7 +286,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// read number of frames
|
// read number of frames
|
||||||
const uint32_t numFrames = a_reader.GetI2();
|
const uint32_t numFrames = a_reader.GetI2();
|
||||||
if (configFrameID >= numFrames) {
|
if (mConfigFrameID >= numFrames) {
|
||||||
throw DeadlyImportError("UNREAL: The requested frame does not exist");
|
throw DeadlyImportError("UNREAL: The requested frame does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +295,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
throw DeadlyImportError("UNREAL: Unexpected aniv file length");
|
throw DeadlyImportError("UNREAL: Unexpected aniv file length");
|
||||||
|
|
||||||
// skip to our frame
|
// skip to our frame
|
||||||
a_reader.IncPtr(configFrameID *numVert*4);
|
a_reader.IncPtr(mConfigFrameID * numVert * 4);
|
||||||
|
|
||||||
// collect vertices
|
// collect vertices
|
||||||
std::vector<aiVector3D> vertices(numVert);
|
std::vector<aiVector3D> vertices(numVert);
|
||||||
|
@ -261,12 +336,13 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
for (; !IsLineEnd(*data); ++data) {
|
for (; !IsLineEnd(*data); ++data) {
|
||||||
if (!::ASSIMP_strincmp(data, "NAME=", 5)) {
|
if (!::ASSIMP_strincmp(data, "NAME=", 5)) {
|
||||||
const char *d = data += 5;
|
const char *d = data += 5;
|
||||||
for (;!IsSpaceOrNewLine(*data);++data);
|
for (; !IsSpaceOrNewLine(*data); ++data)
|
||||||
|
;
|
||||||
me.first = std::string(d, (size_t)(data - d));
|
me.first = std::string(d, (size_t)(data - d));
|
||||||
}
|
} else if (!::ASSIMP_strincmp(data, "FILE=", 5)) {
|
||||||
else if (!::ASSIMP_strincmp(data,"FILE=",5)) {
|
|
||||||
const char *d = data += 5;
|
const char *d = data += 5;
|
||||||
for (;!IsSpaceOrNewLine(*data);++data);
|
for (; !IsSpaceOrNewLine(*data); ++data)
|
||||||
|
;
|
||||||
me.second = std::string(d, (size_t)(data - d));
|
me.second = std::string(d, (size_t)(data - d));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,11 +364,11 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
if (!::ASSIMP_strincmp(data, "NUM=", 4)) {
|
if (!::ASSIMP_strincmp(data, "NUM=", 4)) {
|
||||||
data += 4;
|
data += 4;
|
||||||
me.first = strtoul10(data, &data);
|
me.first = strtoul10(data, &data);
|
||||||
}
|
} else if (!::ASSIMP_strincmp(data, "TEXTURE=", 8)) {
|
||||||
else if (!::ASSIMP_strincmp(data,"TEXTURE=",8)) {
|
|
||||||
data += 8;
|
data += 8;
|
||||||
const char *d = data;
|
const char *d = data;
|
||||||
for (;!IsSpaceOrNewLine(*data);++data);
|
for (; !IsSpaceOrNewLine(*data); ++data)
|
||||||
|
;
|
||||||
me.second = std::string(d, (size_t)(data - d));
|
me.second = std::string(d, (size_t)(data - d));
|
||||||
|
|
||||||
// try to find matching path names, doesn't care if we don't find them
|
// try to find matching path names, doesn't care if we don't find them
|
||||||
|
@ -305,17 +381,14 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (TokenMatchI(data, "SCALE", 5)) {
|
||||||
else if (TokenMatchI(data,"SCALE",5)) {
|
|
||||||
|
|
||||||
for (; !IsLineEnd(*data); ++data) {
|
for (; !IsLineEnd(*data); ++data) {
|
||||||
if (data[0] == 'X' && data[1] == '=') {
|
if (data[0] == 'X' && data[1] == '=') {
|
||||||
data = fast_atoreal_move<float>(data + 2, (float &)nd->mTransformation.a1);
|
data = fast_atoreal_move<float>(data + 2, (float &)nd->mTransformation.a1);
|
||||||
}
|
} else if (data[0] == 'Y' && data[1] == '=') {
|
||||||
else if (data[0] == 'Y' && data[1] == '=') {
|
|
||||||
data = fast_atoreal_move<float>(data + 2, (float &)nd->mTransformation.b2);
|
data = fast_atoreal_move<float>(data + 2, (float &)nd->mTransformation.b2);
|
||||||
}
|
} else if (data[0] == 'Z' && data[1] == '=') {
|
||||||
else if (data[0] == 'Z' && data[1] == '=') {
|
|
||||||
data = fast_atoreal_move<float>(data + 2, (float &)nd->mTransformation.c3);
|
data = fast_atoreal_move<float>(data + 2, (float &)nd->mTransformation.c3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,8 +396,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ASSIMP_LOG_ERROR("Unable to open .uc file");
|
ASSIMP_LOG_ERROR("Unable to open .uc file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,8 +414,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
materials.push_back(mat);
|
materials.push_back(mat);
|
||||||
|
|
||||||
++pScene->mNumMeshes;
|
++pScene->mNumMeshes;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
tri.matIndex = static_cast<unsigned int>(nt - materials.begin());
|
tri.matIndex = static_cast<unsigned int>(nt - materials.begin());
|
||||||
++nt->numFaces;
|
++nt->numFaces;
|
||||||
}
|
}
|
||||||
|
@ -385,16 +456,16 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
const int twosided = 1;
|
const int twosided = 1;
|
||||||
mat->AddProperty(&twosided, 1, AI_MATKEY_TWOSIDED);
|
mat->AddProperty(&twosided, 1, AI_MATKEY_TWOSIDED);
|
||||||
::strcat(s.data, "ts_");
|
::strcat(s.data, "ts_");
|
||||||
}
|
} else
|
||||||
else ::strcat(s.data,"os_");
|
::strcat(s.data, "os_");
|
||||||
|
|
||||||
// make TRANS faces 90% opaque that RemRedundantMaterials won't catch us
|
// make TRANS faces 90% opaque that RemRedundantMaterials won't catch us
|
||||||
if (materials[i].type == Unreal::MF_NORMAL_TRANS_TS) {
|
if (materials[i].type == Unreal::MF_NORMAL_TRANS_TS) {
|
||||||
const float opac = 0.9f;
|
const float opac = 0.9f;
|
||||||
mat->AddProperty(&opac, 1, AI_MATKEY_OPACITY);
|
mat->AddProperty(&opac, 1, AI_MATKEY_OPACITY);
|
||||||
::strcat(s.data, "tran_");
|
::strcat(s.data, "tran_");
|
||||||
}
|
} else
|
||||||
else ::strcat(s.data,"opaq_");
|
::strcat(s.data, "opaq_");
|
||||||
|
|
||||||
// a special name for the weapon attachment point
|
// a special name for the weapon attachment point
|
||||||
if (materials[i].type == Unreal::MF_WEAPON_PLACEHOLDER) {
|
if (materials[i].type == Unreal::MF_WEAPON_PLACEHOLDER) {
|
||||||
|
@ -404,7 +475,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// set color and name
|
// set color and name
|
||||||
mat->AddProperty(&color, 1, AI_MATKEY_COLOR_DIFFUSE);
|
mat->AddProperty(&color, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||||
s.length = (ai_uint32)::strlen(s.data);
|
s.length = static_cast<ai_uint32>(::strlen(s.data));
|
||||||
mat->AddProperty(&s, AI_MATKEY_NAME);
|
mat->AddProperty(&s, AI_MATKEY_NAME);
|
||||||
|
|
||||||
// set texture, if any
|
// set texture, if any
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -47,118 +46,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define INCLUDED_AI_3D_LOADER_H
|
#define INCLUDED_AI_3D_LOADER_H
|
||||||
|
|
||||||
#include <assimp/BaseImporter.h>
|
#include <assimp/BaseImporter.h>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace Unreal {
|
|
||||||
|
|
||||||
/*
|
|
||||||
0 = Normal one-sided
|
|
||||||
1 = Normal two-sided
|
|
||||||
2 = Translucent two-sided
|
|
||||||
3 = Masked two-sided
|
|
||||||
4 = Modulation blended two-sided
|
|
||||||
8 = Placeholder triangle for weapon positioning (invisible)
|
|
||||||
*/
|
|
||||||
enum MeshFlags {
|
|
||||||
MF_NORMAL_OS = 0,
|
|
||||||
MF_NORMAL_TS = 1,
|
|
||||||
MF_NORMAL_TRANS_TS = 2,
|
|
||||||
MF_NORMAL_MASKED_TS = 3,
|
|
||||||
MF_NORMAL_MOD_TS = 4,
|
|
||||||
MF_WEAPON_PLACEHOLDER = 8
|
|
||||||
};
|
|
||||||
|
|
||||||
// a single triangle
|
|
||||||
struct Triangle {
|
|
||||||
uint16_t mVertex[3]; // Vertex indices
|
|
||||||
char mType; // James' Mesh Type
|
|
||||||
char mColor; // Color for flat and Gourand Shaded
|
|
||||||
unsigned char mTex[3][2]; // Texture UV coordinates
|
|
||||||
unsigned char mTextureNum; // Source texture offset
|
|
||||||
char mFlags; // Unreal Mesh Flags (unused)
|
|
||||||
|
|
||||||
unsigned int matIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
// temporary representation for a material
|
|
||||||
struct TempMat {
|
|
||||||
TempMat()
|
|
||||||
: type()
|
|
||||||
, tex()
|
|
||||||
, numFaces (0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
explicit TempMat(const Triangle& in)
|
|
||||||
: type ((Unreal::MeshFlags)in.mType)
|
|
||||||
, tex (in.mTextureNum)
|
|
||||||
, numFaces (0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// type of mesh
|
|
||||||
Unreal::MeshFlags type;
|
|
||||||
|
|
||||||
// index of texture
|
|
||||||
unsigned int tex;
|
|
||||||
|
|
||||||
// number of faces using us
|
|
||||||
unsigned int numFaces;
|
|
||||||
|
|
||||||
// for std::find
|
|
||||||
bool operator == (const TempMat& o ) {
|
|
||||||
return (tex == o.tex && type == o.type);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Vertex
|
|
||||||
{
|
|
||||||
int32_t X : 11;
|
|
||||||
int32_t Y : 11;
|
|
||||||
int32_t Z : 10;
|
|
||||||
};
|
|
||||||
|
|
||||||
// UNREAL vertex compression
|
|
||||||
inline void CompressVertex(const aiVector3D& v, uint32_t& out)
|
|
||||||
{
|
|
||||||
union {
|
|
||||||
Vertex n;
|
|
||||||
int32_t t;
|
|
||||||
};
|
|
||||||
n.X = (int32_t)v.x;
|
|
||||||
n.Y = (int32_t)v.y;
|
|
||||||
n.Z = (int32_t)v.z;
|
|
||||||
::memcpy( &out, &t, sizeof(int32_t));
|
|
||||||
//out = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
// UNREAL vertex decompression
|
|
||||||
inline void DecompressVertex(aiVector3D& v, int32_t in)
|
|
||||||
{
|
|
||||||
union {
|
|
||||||
Vertex n;
|
|
||||||
int32_t i;
|
|
||||||
};
|
|
||||||
i = in;
|
|
||||||
|
|
||||||
v.x = (float)n.X;
|
|
||||||
v.y = (float)n.Y;
|
|
||||||
v.z = (float)n.Z;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Unreal
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** @brief Importer class to load UNREAL files (*.3d)
|
/** @brief Importer class to load UNREAL files (*.3d)
|
||||||
*/
|
*/
|
||||||
class UnrealImporter : public BaseImporter
|
class UnrealImporter : public BaseImporter {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
UnrealImporter();
|
UnrealImporter();
|
||||||
~UnrealImporter();
|
~UnrealImporter();
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Returns whether we can handle the format of the given file
|
/** @brief Returns whether we can handle the format of the given file
|
||||||
*
|
*
|
||||||
|
@ -168,7 +66,6 @@ public:
|
||||||
bool checkSig) const;
|
bool checkSig) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Called by Importer::GetExtensionList()
|
/** @brief Called by Importer::GetExtensionList()
|
||||||
*
|
*
|
||||||
|
@ -176,7 +73,6 @@ protected:
|
||||||
*/
|
*/
|
||||||
const aiImporterDesc *GetInfo() const;
|
const aiImporterDesc *GetInfo() const;
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Setup properties for the importer
|
/** @brief Setup properties for the importer
|
||||||
*
|
*
|
||||||
|
@ -184,7 +80,6 @@ protected:
|
||||||
*/
|
*/
|
||||||
void SetupProperties(const Importer *pImp);
|
void SetupProperties(const Importer *pImp);
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** @brief Imports the given file into the given scene structure.
|
/** @brief Imports the given file into the given scene structure.
|
||||||
*
|
*
|
||||||
|
@ -194,14 +89,14 @@ protected:
|
||||||
IOSystem *pIOHandler);
|
IOSystem *pIOHandler);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! frame to be loaded
|
//! frame to be loaded
|
||||||
uint32_t configFrameID;
|
uint32_t mConfigFrameID;
|
||||||
|
|
||||||
//! process surface flags
|
//! process surface flags
|
||||||
bool configHandleFlags;
|
bool mConfigHandleFlags;
|
||||||
|
|
||||||
}; // !class UnrealImporter
|
}; // !class UnrealImporter
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
#endif // AI_UNREALIMPORTER_H_INC
|
#endif // AI_UNREALIMPORTER_H_INC
|
||||||
|
|
|
@ -176,7 +176,7 @@ void XGLImporter::InternReadFile( const std::string& pFile,
|
||||||
raw_reader->IncPtr(2);
|
raw_reader->IncPtr(2);
|
||||||
|
|
||||||
zstream.next_in = reinterpret_cast<Bytef*>( raw_reader->GetPtr() );
|
zstream.next_in = reinterpret_cast<Bytef*>( raw_reader->GetPtr() );
|
||||||
zstream.avail_in = raw_reader->GetRemainingSize();
|
zstream.avail_in = (uInt) raw_reader->GetRemainingSize();
|
||||||
|
|
||||||
size_t total = 0l;
|
size_t total = 0l;
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,7 @@ struct Accessor : public Object {
|
||||||
inline uint8_t *GetPointer();
|
inline uint8_t *GetPointer();
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool ExtractData(T *&outData);
|
void ExtractData(T *&outData);
|
||||||
|
|
||||||
void WriteData(size_t count, const void *src_buffer, size_t src_stride);
|
void WriteData(size_t count, const void *src_buffer, size_t src_stride);
|
||||||
|
|
||||||
|
|
|
@ -621,9 +621,12 @@ inline void CopyData(size_t count,
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool Accessor::ExtractData(T *&outData) {
|
void Accessor::ExtractData(T *&outData)
|
||||||
|
{
|
||||||
uint8_t* data = GetPointer();
|
uint8_t* data = GetPointer();
|
||||||
if (!data) return false;
|
if (!data) {
|
||||||
|
throw DeadlyImportError("GLTF: data is NULL");
|
||||||
|
}
|
||||||
|
|
||||||
const size_t elemSize = GetElementSize();
|
const size_t elemSize = GetElementSize();
|
||||||
const size_t totalSize = elemSize * count;
|
const size_t totalSize = elemSize * count;
|
||||||
|
@ -643,8 +646,6 @@ bool Accessor::ExtractData(T *&outData) {
|
||||||
memcpy(outData + i, data + i * stride, elemSize);
|
memcpy(outData + i, data + i * stride, elemSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Accessor::WriteData(size_t _count, const void *src_buffer, size_t src_stride) {
|
inline void Accessor::WriteData(size_t _count, const void *src_buffer, size_t src_stride) {
|
||||||
|
|
|
@ -15,7 +15,11 @@ if ( MSVC )
|
||||||
endif ( MSVC )
|
endif ( MSVC )
|
||||||
|
|
||||||
IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
|
IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
|
||||||
|
IF(APPLE)
|
||||||
|
add_library(IrrXML STATIC ${IrrXML_SRCS})
|
||||||
|
ELSE()
|
||||||
add_library(IrrXML ${IrrXML_SRCS})
|
add_library(IrrXML ${IrrXML_SRCS})
|
||||||
|
ENDIF()
|
||||||
ELSE()
|
ELSE()
|
||||||
add_library(IrrXML STATIC ${IrrXML_SRCS})
|
add_library(IrrXML STATIC ${IrrXML_SRCS})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
|
@ -8,16 +8,7 @@
|
||||||
#include "irrXML.h"
|
#include "irrXML.h"
|
||||||
#include "irrString.h"
|
#include "irrString.h"
|
||||||
#include "irrArray.h"
|
#include "irrArray.h"
|
||||||
|
#include "fast_atof.h"
|
||||||
#include <cassert>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <cctype>
|
|
||||||
#include <cstdint>
|
|
||||||
//using namespace Assimp;
|
|
||||||
|
|
||||||
// For locale independent number conversion
|
|
||||||
#include <sstream>
|
|
||||||
#include <locale>
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define IRR_DEBUGPRINT(x) printf((x));
|
#define IRR_DEBUGPRINT(x) printf((x));
|
||||||
|
@ -37,14 +28,23 @@ template<class char_type, class superclass>
|
||||||
class CXMLReaderImpl : public IIrrXMLReader<char_type, superclass>
|
class CXMLReaderImpl : public IIrrXMLReader<char_type, superclass>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CXMLReaderImpl(IFileReadCallBack* callback, bool deleteCallBack = true)
|
CXMLReaderImpl(IFileReadCallBack* callback, bool deleteCallBack = true)
|
||||||
: TextData(0), P(0), TextBegin(0), TextSize(0), CurrentNodeType(EXN_NONE),
|
: TextData(0)
|
||||||
SourceFormat(ETF_ASCII), TargetFormat(ETF_ASCII)
|
, P(0)
|
||||||
{
|
, TextBegin(0)
|
||||||
if (!callback)
|
, TextSize(0)
|
||||||
|
, CurrentNodeType(EXN_NONE)
|
||||||
|
, SourceFormat(ETF_ASCII)
|
||||||
|
, TargetFormat(ETF_ASCII)
|
||||||
|
, NodeName ()
|
||||||
|
, EmptyString()
|
||||||
|
, IsEmptyElement(false)
|
||||||
|
, SpecialCharacters()
|
||||||
|
, Attributes() {
|
||||||
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
storeTargetFormat();
|
storeTargetFormat();
|
||||||
|
|
||||||
|
@ -168,8 +168,7 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
core::stringc c = attr->Value.c_str();
|
core::stringc c = attr->Value.c_str();
|
||||||
return static_cast<float>(atof(c.c_str()));
|
return core::fast_atof(c.c_str());
|
||||||
//return fast_atof(c.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,11 +180,7 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
core::stringc c = attrvalue;
|
core::stringc c = attrvalue;
|
||||||
std::istringstream sstr(c.c_str());
|
return core::fast_atof(c.c_str());
|
||||||
sstr.imbue(std::locale("C")); // Locale free number convert
|
|
||||||
float fNum;
|
|
||||||
sstr >> fNum;
|
|
||||||
return fNum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -228,7 +223,7 @@ private:
|
||||||
{
|
{
|
||||||
char_type* start = P;
|
char_type* start = P;
|
||||||
|
|
||||||
// move forward until '<' found
|
// more forward until '<' found
|
||||||
while(*P != L'<' && *P)
|
while(*P != L'<' && *P)
|
||||||
++P;
|
++P;
|
||||||
|
|
||||||
|
@ -438,10 +433,6 @@ private:
|
||||||
while(*P != L'>')
|
while(*P != L'>')
|
||||||
++P;
|
++P;
|
||||||
|
|
||||||
// remove trailing whitespace, if any
|
|
||||||
while( std::isspace( P[-1]))
|
|
||||||
--P;
|
|
||||||
|
|
||||||
NodeName = core::string<char_type>(pBeginClose, (int)(P - pBeginClose));
|
NodeName = core::string<char_type>(pBeginClose, (int)(P - pBeginClose));
|
||||||
++P;
|
++P;
|
||||||
}
|
}
|
||||||
|
@ -676,12 +667,8 @@ private:
|
||||||
|
|
||||||
TextData = new char_type[sizeWithoutHeader];
|
TextData = new char_type[sizeWithoutHeader];
|
||||||
|
|
||||||
// MSVC debugger complains here about loss of data ...
|
|
||||||
size_t numShift = sizeof( char_type) * 8;
|
|
||||||
assert(numShift < 64);
|
|
||||||
const src_char_type cc = (src_char_type)(((uint64_t(1u) << numShift) - 1));
|
|
||||||
for (int i=0; i<sizeWithoutHeader; ++i)
|
for (int i=0; i<sizeWithoutHeader; ++i)
|
||||||
TextData[i] = char_type( source[i] & cc);
|
TextData[i] = (char_type)source[i];
|
||||||
|
|
||||||
TextBegin = TextData;
|
TextBegin = TextData;
|
||||||
TextSize = sizeWithoutHeader;
|
TextSize = sizeWithoutHeader;
|
||||||
|
|
|
@ -0,0 +1,139 @@
|
||||||
|
// Copyright (C) 2002-2005 Nikolaus Gebhardt
|
||||||
|
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
||||||
|
// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h
|
||||||
|
|
||||||
|
#ifndef __FAST_A_TO_F_H_INCLUDED__
|
||||||
|
#define __FAST_A_TO_F_H_INCLUDED__
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
namespace irr
|
||||||
|
{
|
||||||
|
namespace core
|
||||||
|
{
|
||||||
|
|
||||||
|
const float fast_atof_table[] = {
|
||||||
|
0.f,
|
||||||
|
0.1f,
|
||||||
|
0.01f,
|
||||||
|
0.001f,
|
||||||
|
0.0001f,
|
||||||
|
0.00001f,
|
||||||
|
0.000001f,
|
||||||
|
0.0000001f,
|
||||||
|
0.00000001f,
|
||||||
|
0.000000001f,
|
||||||
|
0.0000000001f,
|
||||||
|
0.00000000001f,
|
||||||
|
0.000000000001f,
|
||||||
|
0.0000000000001f,
|
||||||
|
0.00000000000001f,
|
||||||
|
0.000000000000001f
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Provides a fast function for converting a string into a float,
|
||||||
|
//! about 6 times faster than atof in win32.
|
||||||
|
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
|
||||||
|
inline char* fast_atof_move(char* c, float& out)
|
||||||
|
{
|
||||||
|
bool inv = false;
|
||||||
|
char *t;
|
||||||
|
float f;
|
||||||
|
|
||||||
|
if (*c=='-')
|
||||||
|
{
|
||||||
|
c++;
|
||||||
|
inv = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
f = (float)strtol(c, &t, 10);
|
||||||
|
|
||||||
|
c = t;
|
||||||
|
|
||||||
|
if (*c == '.')
|
||||||
|
{
|
||||||
|
c++;
|
||||||
|
|
||||||
|
float pl = (float)strtol(c, &t, 10);
|
||||||
|
pl *= fast_atof_table[t-c];
|
||||||
|
|
||||||
|
f += pl;
|
||||||
|
|
||||||
|
c = t;
|
||||||
|
|
||||||
|
if (*c == 'e')
|
||||||
|
{
|
||||||
|
++c;
|
||||||
|
float exp = (float)strtol(c, &t, 10);
|
||||||
|
f *= (float)pow(10.0f, exp);
|
||||||
|
c = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inv)
|
||||||
|
f *= -1.0f;
|
||||||
|
|
||||||
|
out = f;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Provides a fast function for converting a string into a float,
|
||||||
|
//! about 6 times faster than atof in win32.
|
||||||
|
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
|
||||||
|
inline const char* fast_atof_move_const(const char* c, float& out)
|
||||||
|
{
|
||||||
|
bool inv = false;
|
||||||
|
char *t;
|
||||||
|
float f;
|
||||||
|
|
||||||
|
if (*c=='-')
|
||||||
|
{
|
||||||
|
c++;
|
||||||
|
inv = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
f = (float)strtol(c, &t, 10);
|
||||||
|
|
||||||
|
c = t;
|
||||||
|
|
||||||
|
if (*c == '.')
|
||||||
|
{
|
||||||
|
c++;
|
||||||
|
|
||||||
|
float pl = (float)strtol(c, &t, 10);
|
||||||
|
pl *= fast_atof_table[t-c];
|
||||||
|
|
||||||
|
f += pl;
|
||||||
|
|
||||||
|
c = t;
|
||||||
|
|
||||||
|
if (*c == 'e')
|
||||||
|
{
|
||||||
|
++c;
|
||||||
|
f32 exp = (f32)strtol(c, &t, 10);
|
||||||
|
f *= (f32)powf(10.0f, exp);
|
||||||
|
c = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inv)
|
||||||
|
f *= -1.0f;
|
||||||
|
|
||||||
|
out = f;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline float fast_atof(const char* c)
|
||||||
|
{
|
||||||
|
float ret;
|
||||||
|
fast_atof_move_const(c, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace core
|
||||||
|
}// end namespace irr
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -21,6 +21,7 @@ class array
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
array()
|
array()
|
||||||
: data(0), allocated(0), used(0),
|
: data(0), allocated(0), used(0),
|
||||||
free_when_destroyed(true), is_sorted(true)
|
free_when_destroyed(true), is_sorted(true)
|
||||||
|
|
|
@ -79,13 +79,8 @@ typedef unsigned short wchar_t;
|
||||||
#endif // microsoft compiler
|
#endif // microsoft compiler
|
||||||
|
|
||||||
//! define a break macro for debugging only in Win32 mode.
|
//! define a break macro for debugging only in Win32 mode.
|
||||||
// WORKAROUND (assimp): remove __asm
|
#if !defined(_WIN64) && defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG)
|
||||||
#if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG)
|
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3}
|
||||||
#if defined(_M_IX86)
|
|
||||||
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) /*if (_CONDITION_) {_asm int 3}*/
|
|
||||||
#else
|
|
||||||
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
|
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
|
||||||
#endif
|
#endif
|
||||||
|
@ -96,10 +91,8 @@ When you call unmanaged code that returns a bool type value of false from manage
|
||||||
the return value may appear as true. See
|
the return value may appear as true. See
|
||||||
http://support.microsoft.com/default.aspx?kbid=823071 for details.
|
http://support.microsoft.com/default.aspx?kbid=823071 for details.
|
||||||
Compiler version defines: VC6.0 : 1200, VC7.0 : 1300, VC7.1 : 1310, VC8.0 : 1400*/
|
Compiler version defines: VC6.0 : 1200, VC7.0 : 1300, VC7.1 : 1310, VC8.0 : 1400*/
|
||||||
|
#if !defined(_WIN64) && defined(WIN32) && defined(_MSC_VER) && (_MSC_VER > 1299) && (_MSC_VER < 1400)
|
||||||
// WORKAROUND (assimp): remove __asm
|
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX __asm mov eax,100
|
||||||
#if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER > 1299) && (_MSC_VER < 1400)
|
|
||||||
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX /*__asm mov eax,100*/
|
|
||||||
#else
|
#else
|
||||||
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX
|
#define _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX
|
||||||
#endif // _IRR_MANAGED_MARSHALLING_BUGFIX
|
#endif // _IRR_MANAGED_MARSHALLING_BUGFIX
|
||||||
|
|
|
@ -2,14 +2,10 @@
|
||||||
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
||||||
// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
|
// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
|
||||||
|
|
||||||
// Need to include Assimp, too. We're using Assimp's version of fast_atof
|
|
||||||
// so we need stdint.h. But no PCH.
|
|
||||||
|
|
||||||
|
|
||||||
#include "irrXML.h"
|
#include "irrXML.h"
|
||||||
#include "irrString.h"
|
#include "irrString.h"
|
||||||
#include "irrArray.h"
|
#include "irrArray.h"
|
||||||
//#include <assimp/fast_atof.h>
|
#include "fast_atof.h"
|
||||||
#include "CXMLReaderImpl.h"
|
#include "CXMLReaderImpl.h"
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
|
@ -18,7 +14,7 @@ namespace io
|
||||||
{
|
{
|
||||||
|
|
||||||
//! Implementation of the file read callback for ordinary files
|
//! Implementation of the file read callback for ordinary files
|
||||||
class IRRXML_API CFileReadCallBack : public IFileReadCallBack
|
class CFileReadCallBack : public IFileReadCallBack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,6 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
# define IRRXML_API __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
# define IRRXML_API __attribute__ ((visibility("default")))
|
|
||||||
#endif // _WIN32
|
|
||||||
|
|
||||||
/** \mainpage irrXML 1.2 API documentation
|
/** \mainpage irrXML 1.2 API documentation
|
||||||
<div align="center"><img src="logobig.png" ></div>
|
<div align="center"><img src="logobig.png" ></div>
|
||||||
|
|
||||||
|
@ -178,7 +172,7 @@ namespace io
|
||||||
ETF_UTF32_BE,
|
ETF_UTF32_BE,
|
||||||
|
|
||||||
//! UTF-32 format, little endian
|
//! UTF-32 format, little endian
|
||||||
ETF_UTF32_LE
|
ETF_UTF32_LE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,7 +209,7 @@ namespace io
|
||||||
two methods to read your data and give a pointer to an instance of
|
two methods to read your data and give a pointer to an instance of
|
||||||
your implementation when calling createIrrXMLReader(),
|
your implementation when calling createIrrXMLReader(),
|
||||||
createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */
|
createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */
|
||||||
class IRRXML_API IFileReadCallBack
|
class IFileReadCallBack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -415,7 +409,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReader* createIrrXMLReader(const char* filename);
|
IrrXMLReader* createIrrXMLReader(const char* filename);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
||||||
/** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can
|
/** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can
|
||||||
|
@ -427,7 +421,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReader* createIrrXMLReader(FILE* file);
|
IrrXMLReader* createIrrXMLReader(FILE* file);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
||||||
/** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can
|
/** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can
|
||||||
|
@ -440,7 +434,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback);
|
IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-16 xml parser.
|
//! Creates an instance of an UFT-16 xml parser.
|
||||||
/** This means that
|
/** This means that
|
||||||
|
@ -452,7 +446,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename);
|
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-16 xml parser.
|
//! Creates an instance of an UFT-16 xml parser.
|
||||||
/** This means that all character data will be returned in UTF-16. The file to read can
|
/** This means that all character data will be returned in UTF-16. The file to read can
|
||||||
|
@ -464,7 +458,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file);
|
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-16 xml parser.
|
//! Creates an instance of an UFT-16 xml parser.
|
||||||
/** This means that all character data will be returned in UTF-16. The file to read can
|
/** This means that all character data will be returned in UTF-16. The file to read can
|
||||||
|
@ -477,7 +471,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback);
|
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback);
|
||||||
|
|
||||||
|
|
||||||
//! Creates an instance of an UFT-32 xml parser.
|
//! Creates an instance of an UFT-32 xml parser.
|
||||||
|
@ -489,7 +483,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename);
|
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-32 xml parser.
|
//! Creates an instance of an UFT-32 xml parser.
|
||||||
/** This means that all character data will be returned in UTF-32. The file to read can
|
/** This means that all character data will be returned in UTF-32. The file to read can
|
||||||
|
@ -501,7 +495,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file);
|
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file);
|
||||||
|
|
||||||
//! Creates an instance of an UFT-32 xml parser.
|
//! Creates an instance of an UFT-32 xml parser.
|
||||||
/** This means that
|
/** This means that
|
||||||
|
@ -515,7 +509,7 @@ namespace io
|
||||||
\return Returns a pointer to the created xml parser. This pointer should be
|
\return Returns a pointer to the created xml parser. This pointer should be
|
||||||
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
deleted using 'delete' after no longer needed. Returns 0 if an error occured
|
||||||
and the file could not be opened. */
|
and the file could not be opened. */
|
||||||
IRRXML_API IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback);
|
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback);
|
||||||
|
|
||||||
|
|
||||||
/*! \file irrxml.h
|
/*! \file irrxml.h
|
||||||
|
|
|
@ -55,36 +55,51 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace Math {
|
namespace Math {
|
||||||
|
|
||||||
// TODO: use binary GCD for unsigned integers ....
|
/// @brief Will return the greatest common divisor.
|
||||||
|
/// @param a [in] Value a.
|
||||||
|
/// @param b [in] Value b.
|
||||||
|
/// @return The greatest common divisor.
|
||||||
template <typename IntegerType>
|
template <typename IntegerType>
|
||||||
inline
|
inline IntegerType gcd( IntegerType a, IntegerType b ) {
|
||||||
IntegerType gcd( IntegerType a, IntegerType b ) {
|
|
||||||
const IntegerType zero = (IntegerType)0;
|
const IntegerType zero = (IntegerType)0;
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
if ( a == zero )
|
if ( a == zero ) {
|
||||||
return b;
|
return b;
|
||||||
|
}
|
||||||
b %= a;
|
b %= a;
|
||||||
|
|
||||||
if ( b == zero )
|
if ( b == zero ) {
|
||||||
return a;
|
return a;
|
||||||
|
}
|
||||||
a %= b;
|
a %= b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Will return the greatest common divisor.
|
||||||
|
/// @param a [in] Value a.
|
||||||
|
/// @param b [in] Value b.
|
||||||
|
/// @return The greatest common divisor.
|
||||||
template < typename IntegerType >
|
template < typename IntegerType >
|
||||||
inline
|
inline IntegerType lcm( IntegerType a, IntegerType b ) {
|
||||||
IntegerType lcm( IntegerType a, IntegerType b ) {
|
|
||||||
const IntegerType t = gcd (a,b);
|
const IntegerType t = gcd (a,b);
|
||||||
if (!t)
|
if (!t) {
|
||||||
return t;
|
return t;
|
||||||
|
}
|
||||||
return a / t * b;
|
return a / t * b;
|
||||||
}
|
}
|
||||||
|
/// @brief Will return the smallest epsilon-value for the requested type.
|
||||||
|
/// @return The numercical limit epsilon depending on its type.
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline T getEpsilon() {
|
||||||
T getEpsilon() {
|
|
||||||
return std::numeric_limits<T>::epsilon();
|
return std::numeric_limits<T>::epsilon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Will return the constant PI for the requested type.
|
||||||
|
/// @return Pi
|
||||||
|
template<class T>
|
||||||
|
inline T PI() {
|
||||||
|
return static_cast<T>(3.14159265358979323846);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // namespace Math
|
||||||
|
} // namespace Assimp
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -52,10 +50,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#pragma GCC system_header
|
#pragma GCC system_header
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assimp/IOStream.hpp>
|
|
||||||
#include <assimp/Defines.h>
|
|
||||||
#include <assimp/ByteSwapper.h>
|
#include <assimp/ByteSwapper.h>
|
||||||
|
#include <assimp/Defines.h>
|
||||||
#include <assimp/Exceptional.h>
|
#include <assimp/Exceptional.h>
|
||||||
|
#include <assimp/IOStream.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -74,10 +72,8 @@ namespace Assimp {
|
||||||
template <bool SwapEndianess = false, bool RuntimeSwitch = false>
|
template <bool SwapEndianess = false, bool RuntimeSwitch = false>
|
||||||
class StreamReader {
|
class StreamReader {
|
||||||
public:
|
public:
|
||||||
// FIXME: use these data types throughout the whole library,
|
using diff = size_t;
|
||||||
// then change them to 64 bit values :-)
|
using pos = size_t;
|
||||||
using diff = int;
|
|
||||||
using pos = unsigned int;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Construction from a given stream with a well-defined endianness.
|
/** Construction from a given stream with a well-defined endianness.
|
||||||
|
@ -91,39 +87,44 @@ public:
|
||||||
* stream is in little endian byte order. Otherwise the
|
* stream is in little endian byte order. Otherwise the
|
||||||
* endianness information is contained in the @c SwapEndianess
|
* endianness information is contained in the @c SwapEndianess
|
||||||
* template parameter and this parameter is meaningless. */
|
* template parameter and this parameter is meaningless. */
|
||||||
StreamReader(std::shared_ptr<IOStream> stream, bool le = false)
|
StreamReader(std::shared_ptr<IOStream> stream, bool le = false) :
|
||||||
: stream(stream)
|
mStream(stream),
|
||||||
, le(le)
|
mBuffer(nullptr),
|
||||||
{
|
mCurrent(nullptr),
|
||||||
|
mEnd(nullptr),
|
||||||
|
mLimit(nullptr),
|
||||||
|
mLe(le) {
|
||||||
ai_assert(stream);
|
ai_assert(stream);
|
||||||
InternBegin();
|
InternBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
StreamReader(IOStream* stream, bool le = false)
|
StreamReader(IOStream *stream, bool le = false) :
|
||||||
: stream(std::shared_ptr<IOStream>(stream))
|
mStream(std::shared_ptr<IOStream>(stream)),
|
||||||
, le(le)
|
mBuffer(nullptr),
|
||||||
{
|
mCurrent(nullptr),
|
||||||
ai_assert(stream);
|
mEnd(nullptr),
|
||||||
|
mLimit(nullptr),
|
||||||
|
mLe(le) {
|
||||||
|
ai_assert(nullptr != stream);
|
||||||
InternBegin();
|
InternBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
~StreamReader() {
|
~StreamReader() {
|
||||||
delete[] buffer;
|
delete[] mBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecated, use overloaded operator>> instead
|
// deprecated, use overloaded operator>> instead
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Read a float from the stream */
|
/// Read a float from the stream.
|
||||||
float GetF4()
|
float GetF4() {
|
||||||
{
|
|
||||||
return Get<float>();
|
return Get<float>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Read a double from the stream */
|
/// Read a double from the stream.
|
||||||
double GetF8() {
|
double GetF8() {
|
||||||
return Get<double>();
|
return Get<double>();
|
||||||
}
|
}
|
||||||
|
@ -159,42 +160,42 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Read a unsigned 8 bit integer from the stream */
|
/// Read a unsigned 8 bit integer from the stream
|
||||||
uint8_t GetU1() {
|
uint8_t GetU1() {
|
||||||
return Get<uint8_t>();
|
return Get<uint8_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Read an unsigned 32 bit integer from the stream */
|
/// Read an unsigned 32 bit integer from the stream
|
||||||
uint32_t GetU4() {
|
uint32_t GetU4() {
|
||||||
return Get<uint32_t>();
|
return Get<uint32_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Read a unsigned 64 bit integer from the stream */
|
/// Read a unsigned 64 bit integer from the stream
|
||||||
uint64_t GetU8() {
|
uint64_t GetU8() {
|
||||||
return Get<uint64_t>();
|
return Get<uint64_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Get the remaining stream size (to the end of the stream) */
|
/// Get the remaining stream size (to the end of the stream)
|
||||||
unsigned int GetRemainingSize() const {
|
size_t GetRemainingSize() const {
|
||||||
return (unsigned int)(end - current);
|
return (unsigned int)(mEnd - mCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Get the remaining stream size (to the current read limit). The
|
/** Get the remaining stream size (to the current read limit). The
|
||||||
* return value is the remaining size of the stream if no custom
|
* return value is the remaining size of the stream if no custom
|
||||||
* read limit has been set. */
|
* read limit has been set. */
|
||||||
unsigned int GetRemainingSizeToLimit() const {
|
size_t GetRemainingSizeToLimit() const {
|
||||||
return (unsigned int)(limit - current);
|
return (unsigned int)(mLimit - mCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Increase the file pointer (relative seeking) */
|
/** Increase the file pointer (relative seeking) */
|
||||||
void IncPtr(intptr_t plus) {
|
void IncPtr(intptr_t plus) {
|
||||||
current += plus;
|
mCurrent += plus;
|
||||||
if (current > limit) {
|
if (mCurrent > mLimit) {
|
||||||
throw DeadlyImportError("End of file or read limit was reached");
|
throw DeadlyImportError("End of file or read limit was reached");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +203,7 @@ public:
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Get the current file pointer */
|
/** Get the current file pointer */
|
||||||
int8_t *GetPtr() const {
|
int8_t *GetPtr() const {
|
||||||
return current;
|
return mCurrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
@ -212,8 +213,8 @@ public:
|
||||||
* @param p The new pointer, which is validated against the size
|
* @param p The new pointer, which is validated against the size
|
||||||
* limit and buffer boundaries. */
|
* limit and buffer boundaries. */
|
||||||
void SetPtr(int8_t *p) {
|
void SetPtr(int8_t *p) {
|
||||||
current = p;
|
mCurrent = p;
|
||||||
if (current > limit || current < buffer) {
|
if (mCurrent > mLimit || mCurrent < mBuffer) {
|
||||||
throw DeadlyImportError("End of file or read limit was reached");
|
throw DeadlyImportError("End of file or read limit was reached");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,14 +230,13 @@ public:
|
||||||
::memcpy(out, ur, bytes);
|
::memcpy(out, ur, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
/// @brief Get the current offset from the beginning of the file
|
||||||
/** Get the current offset from the beginning of the file */
|
|
||||||
int GetCurrentPos() const {
|
int GetCurrentPos() const {
|
||||||
return (unsigned int)(current - buffer);
|
return (unsigned int)(mCurrent - mBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCurrentPos(size_t pos) {
|
void SetCurrentPos(size_t pos) {
|
||||||
SetPtr(buffer + pos);
|
SetPtr(mBuffer + pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
@ -249,12 +249,12 @@ public:
|
||||||
unsigned int SetReadLimit(unsigned int _limit) {
|
unsigned int SetReadLimit(unsigned int _limit) {
|
||||||
unsigned int prev = GetReadLimit();
|
unsigned int prev = GetReadLimit();
|
||||||
if (UINT_MAX == _limit) {
|
if (UINT_MAX == _limit) {
|
||||||
limit = end;
|
mLimit = mEnd;
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
limit = buffer + _limit;
|
mLimit = mBuffer + _limit;
|
||||||
if (limit > end) {
|
if (mLimit > mEnd) {
|
||||||
throw DeadlyImportError("StreamReader: Invalid read limit");
|
throw DeadlyImportError("StreamReader: Invalid read limit");
|
||||||
}
|
}
|
||||||
return prev;
|
return prev;
|
||||||
|
@ -264,14 +264,14 @@ public:
|
||||||
/** Get the current read limit in bytes. Reading over this limit
|
/** Get the current read limit in bytes. Reading over this limit
|
||||||
* accidentally raises an exception. */
|
* accidentally raises an exception. */
|
||||||
unsigned int GetReadLimit() const {
|
unsigned int GetReadLimit() const {
|
||||||
return (unsigned int)(limit - buffer);
|
return (unsigned int)(mLimit - mBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
/** Skip to the read limit in bytes. Reading over this limit
|
/** Skip to the read limit in bytes. Reading over this limit
|
||||||
* accidentally raises an exception. */
|
* accidentally raises an exception. */
|
||||||
void SkipToReadLimit() {
|
void SkipToReadLimit() {
|
||||||
current = limit;
|
mCurrent = mLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
@ -286,14 +286,14 @@ public:
|
||||||
/** Generic read method. ByteSwap::Swap(T*) *must* be defined */
|
/** Generic read method. ByteSwap::Swap(T*) *must* be defined */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T Get() {
|
T Get() {
|
||||||
if ( current + sizeof(T) > limit) {
|
if (mCurrent + sizeof(T) > mLimit) {
|
||||||
throw DeadlyImportError("End of file or stream limit was reached");
|
throw DeadlyImportError("End of file or stream limit was reached");
|
||||||
}
|
}
|
||||||
|
|
||||||
T f;
|
T f;
|
||||||
::memcpy (&f, current, sizeof(T));
|
::memcpy(&f, mCurrent, sizeof(T));
|
||||||
Intern::Getter<SwapEndianess,T,RuntimeSwitch>() (&f,le);
|
Intern::Getter<SwapEndianess, T, RuntimeSwitch>()(&f, mLe);
|
||||||
current += sizeof(T);
|
mCurrent += sizeof(T);
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
@ -301,31 +301,29 @@ public:
|
||||||
private:
|
private:
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
void InternBegin() {
|
void InternBegin() {
|
||||||
if (!stream) {
|
if (nullptr == mStream) {
|
||||||
// in case someone wonders: StreamReader is frequently invoked with
|
|
||||||
// no prior validation whether the input stream is valid. Since
|
|
||||||
// no one bothers changing the error message, this message here
|
|
||||||
// is passed down to the caller and 'unable to open file'
|
|
||||||
// simply describes best what happened.
|
|
||||||
throw DeadlyImportError("StreamReader: Unable to open file");
|
throw DeadlyImportError("StreamReader: Unable to open file");
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t s = stream->FileSize() - stream->Tell();
|
const size_t filesize = mStream->FileSize() - mStream->Tell();
|
||||||
if (!s) {
|
if (0 == filesize) {
|
||||||
throw DeadlyImportError("StreamReader: File is empty or EOF is already reached");
|
throw DeadlyImportError("StreamReader: File is empty or EOF is already reached");
|
||||||
}
|
}
|
||||||
|
|
||||||
current = buffer = new int8_t[s];
|
mCurrent = mBuffer = new int8_t[filesize];
|
||||||
const size_t read = stream->Read(current,1,s);
|
const size_t read = mStream->Read(mCurrent, 1, filesize);
|
||||||
// (read < s) can only happen if the stream was opened in text mode, in which case FileSize() is not reliable
|
// (read < s) can only happen if the stream was opened in text mode, in which case FileSize() is not reliable
|
||||||
ai_assert(read <= s);
|
ai_assert(read <= filesize);
|
||||||
end = limit = &buffer[read-1] + 1;
|
mEnd = mLimit = &mBuffer[read - 1] + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<IOStream> stream;
|
std::shared_ptr<IOStream> mStream;
|
||||||
int8_t *buffer, *current, *end, *limit;
|
int8_t *mBuffer;
|
||||||
bool le;
|
int8_t *mCurrent;
|
||||||
|
int8_t *mEnd;
|
||||||
|
int8_t *mLimit;
|
||||||
|
bool mLe;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
SET(SAMPLE_PROJECT_NAME assimp_simpleogl)
|
||||||
|
|
||||||
FIND_PACKAGE(OpenGL)
|
FIND_PACKAGE(OpenGL)
|
||||||
FIND_PACKAGE(GLUT)
|
FIND_PACKAGE(GLUT)
|
||||||
IF ( MSVC )
|
IF ( MSVC )
|
||||||
|
@ -16,6 +18,10 @@ IF ( NOT GLUT_FOUND )
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
# Used for usage and error messages in the program.
|
||||||
|
ADD_COMPILE_DEFINITIONS(ASSIMP_VERSION="${ASSIMP_VERSION}")
|
||||||
|
ADD_COMPILE_DEFINITIONS(PROJECT_NAME="${SAMPLE_PROJECT_NAME}")
|
||||||
|
|
||||||
if ( MSVC )
|
if ( MSVC )
|
||||||
ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
|
ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
|
||||||
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
|
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
|
||||||
|
@ -34,17 +40,17 @@ LINK_DIRECTORIES(
|
||||||
${Assimp_BINARY_DIR}/lib
|
${Assimp_BINARY_DIR}/lib
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE( assimp_simpleogl
|
ADD_EXECUTABLE( ${SAMPLE_PROJECT_NAME}
|
||||||
Sample_SimpleOpenGL.c
|
Sample_SimpleOpenGL.c
|
||||||
)
|
)
|
||||||
|
|
||||||
SET_PROPERTY(TARGET assimp_simpleogl PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
|
SET_PROPERTY(TARGET ${SAMPLE_PROJECT_NAME} PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES( assimp_simpleogl assimp ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${M_LIB} )
|
TARGET_LINK_LIBRARIES( ${SAMPLE_PROJECT_NAME} assimp ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${M_LIB} )
|
||||||
SET_TARGET_PROPERTIES( assimp_simpleogl PROPERTIES
|
SET_TARGET_PROPERTIES( ${SAMPLE_PROJECT_NAME} PROPERTIES
|
||||||
OUTPUT_NAME assimp_simpleogl
|
OUTPUT_NAME ${SAMPLE_PROJECT_NAME}
|
||||||
)
|
)
|
||||||
|
|
||||||
INSTALL( TARGETS assimp_simpleogl
|
INSTALL( TARGETS ${SAMPLE_PROJECT_NAME}
|
||||||
DESTINATION "${ASSIMP_BIN_INSTALL_DIR}" COMPONENT assimp-dev
|
DESTINATION "${ASSIMP_BIN_INSTALL_DIR}" COMPONENT assimp-dev
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <glut.h>
|
#include <freeglut.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/glut.h>
|
#include <GL/freeglut.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* assimp include files. These three are usually needed. */
|
/* assimp include files. These three are usually needed. */
|
||||||
|
@ -25,6 +25,39 @@
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
|
|
||||||
|
#define COMMAND_USAGE "--usage"
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------- */
|
||||||
|
inline static void print_run_command(const char* command_name) {
|
||||||
|
printf("Run '%s %s' for more information.\n",
|
||||||
|
PROJECT_NAME, command_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------- */
|
||||||
|
inline static void print_error(const char* msg) {
|
||||||
|
printf("ERROR: %s\n", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define NEW_LINE "\n"
|
||||||
|
#define DOUBLE_NEW_LINE NEW_LINE NEW_LINE
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------- */
|
||||||
|
inline static void print_usage() {
|
||||||
|
static const char* usage_format =
|
||||||
|
"Usage: "
|
||||||
|
PROJECT_NAME
|
||||||
|
" <file>" DOUBLE_NEW_LINE
|
||||||
|
"where:" DOUBLE_NEW_LINE
|
||||||
|
" %-10s %s" DOUBLE_NEW_LINE
|
||||||
|
"options:" DOUBLE_NEW_LINE
|
||||||
|
" %-10s %s" DOUBLE_NEW_LINE;
|
||||||
|
printf(usage_format,
|
||||||
|
// where
|
||||||
|
"file", "The input model file to load.",
|
||||||
|
// options
|
||||||
|
COMMAND_USAGE, "Display usage.");
|
||||||
|
}
|
||||||
|
|
||||||
/* the global Assimp scene object */
|
/* the global Assimp scene object */
|
||||||
const C_STRUCT aiScene* scene = NULL;
|
const C_STRUCT aiScene* scene = NULL;
|
||||||
GLuint scene_list = 0;
|
GLuint scene_list = 0;
|
||||||
|
@ -245,7 +278,7 @@ void do_motion (void)
|
||||||
static int frames = 0;
|
static int frames = 0;
|
||||||
|
|
||||||
int time = glutGet(GLUT_ELAPSED_TIME);
|
int time = glutGet(GLUT_ELAPSED_TIME);
|
||||||
angle += (time-prev_time)*0.01f;
|
angle += static_cast<float>((time-prev_time)*0.01);
|
||||||
prev_time = time;
|
prev_time = time;
|
||||||
|
|
||||||
frames += 1;
|
frames += 1;
|
||||||
|
@ -324,12 +357,42 @@ int loadasset (const char* path)
|
||||||
/* ---------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------- */
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
const char* model_file = NULL;
|
||||||
C_STRUCT aiLogStream stream;
|
C_STRUCT aiLogStream stream;
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
print_error("No input model file specifed.");
|
||||||
|
print_run_command(COMMAND_USAGE);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find and execute available commands entered by the user.
|
||||||
|
for (int i = 1; i < argc; ++i) {
|
||||||
|
if (!strncmp(argv[i], COMMAND_USAGE, strlen(COMMAND_USAGE))) {
|
||||||
|
print_usage();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check and validate the specified model file extension.
|
||||||
|
model_file = argv[1];
|
||||||
|
const char* extension = strchr(model_file, '.');
|
||||||
|
if (!extension) {
|
||||||
|
print_error("Please provide a file with a valid extension.");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AI_FALSE == aiIsExtensionSupported(extension)) {
|
||||||
|
print_error("The specified model file extension is currently "
|
||||||
|
"unsupported in Assimp " ASSIMP_VERSION ".");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
glutInitWindowSize(900,600);
|
glutInitWindowSize(900,600);
|
||||||
glutInitWindowPosition(100,100);
|
glutInitWindowPosition(100,100);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
|
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
|
||||||
|
|
||||||
glutCreateWindow("Assimp - Very simple OpenGL sample");
|
glutCreateWindow("Assimp - Very simple OpenGL sample");
|
||||||
glutDisplayFunc(display);
|
glutDisplayFunc(display);
|
||||||
|
@ -346,14 +409,11 @@ int main(int argc, char **argv)
|
||||||
stream = aiGetPredefinedLogStream(aiDefaultLogStream_FILE,"assimp_log.txt");
|
stream = aiGetPredefinedLogStream(aiDefaultLogStream_FILE,"assimp_log.txt");
|
||||||
aiAttachLogStream(&stream);
|
aiAttachLogStream(&stream);
|
||||||
|
|
||||||
/* the model name can be specified on the command line. If none
|
// Load the model file.
|
||||||
is specified, we try to locate one of the more expressive test
|
if(0 != loadasset(model_file)) {
|
||||||
models from the repository (/models-nonbsd may be missing in
|
print_error("Failed to load model. Please ensure that the specified file exists.");
|
||||||
some distributions so we need a fallback from /models!). */
|
aiDetachAllLogStreams();
|
||||||
if( 0 != loadasset( argc >= 2 ? argv[1] : "../../test/models-nonbsd/X/dwarf.x")) {
|
return EXIT_FAILURE;
|
||||||
if( argc != 1 || (0 != loadasset( "../../../../test/models-nonbsd/X/dwarf.x") && 0 != loadasset( "../../test/models/X/Testwuson.X"))) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glClearColor(0.1f,0.1f,0.1f,1.f);
|
glClearColor(0.1f,0.1f,0.1f,1.f);
|
||||||
|
@ -384,5 +444,5 @@ int main(int argc, char **argv)
|
||||||
again. This will definitely release the last resources allocated
|
again. This will definitely release the last resources allocated
|
||||||
by Assimp.*/
|
by Assimp.*/
|
||||||
aiDetachAllLogStreams();
|
aiDetachAllLogStreams();
|
||||||
return 0;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,14 @@ SET( COMMON
|
||||||
unit/utIssues.cpp
|
unit/utIssues.cpp
|
||||||
unit/utAnim.cpp
|
unit/utAnim.cpp
|
||||||
unit/AssimpAPITest.cpp
|
unit/AssimpAPITest.cpp
|
||||||
|
unit/AssimpAPITest_aiMatrix3x3.cpp
|
||||||
|
unit/AssimpAPITest_aiMatrix4x4.cpp
|
||||||
|
unit/AssimpAPITest_aiQuaternion.cpp
|
||||||
|
unit/AssimpAPITest_aiVector2D.cpp
|
||||||
|
unit/AssimpAPITest_aiVector3D.cpp
|
||||||
|
unit/MathTest.cpp
|
||||||
|
unit/MathTest.h
|
||||||
|
unit/RandomNumberGeneration.h
|
||||||
unit/utBatchLoader.cpp
|
unit/utBatchLoader.cpp
|
||||||
unit/utDefaultIOStream.cpp
|
unit/utDefaultIOStream.cpp
|
||||||
unit/utFastAtof.cpp
|
unit/utFastAtof.cpp
|
||||||
|
@ -76,10 +84,12 @@ SET( COMMON
|
||||||
unit/utProfiler.cpp
|
unit/utProfiler.cpp
|
||||||
unit/utSharedPPData.cpp
|
unit/utSharedPPData.cpp
|
||||||
unit/utStringUtils.cpp
|
unit/utStringUtils.cpp
|
||||||
|
unit/Common/uiScene.cpp
|
||||||
unit/Common/utLineSplitter.cpp
|
unit/Common/utLineSplitter.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( IMPORTERS
|
SET( IMPORTERS
|
||||||
|
unit/ImportExport/Assxml/utAssxmlImportExport.cpp
|
||||||
unit/utLWSImportExport.cpp
|
unit/utLWSImportExport.cpp
|
||||||
unit/utLWOImportExport.cpp
|
unit/utLWOImportExport.cpp
|
||||||
unit/utSMDImportExport.cpp
|
unit/utSMDImportExport.cpp
|
||||||
|
@ -136,6 +146,9 @@ SET( IMPORTERS
|
||||||
unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp
|
unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp
|
||||||
unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp
|
unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp
|
||||||
unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp
|
unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp
|
||||||
|
#unit/ImportExport/IRR/utIrrImportExport.cpp
|
||||||
|
unit/ImportExport/RAW/utRAWImportExport.cpp
|
||||||
|
unit/ImportExport/Terragen/utTerragenImportExport.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( MATERIAL
|
SET( MATERIAL
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,151 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include "MathTest.h"
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class AssimpAPITest_aiMatrix3x3 : public AssimpMathTest {
|
||||||
|
protected:
|
||||||
|
virtual void SetUp() {
|
||||||
|
result_c = result_cpp = aiMatrix3x3();
|
||||||
|
}
|
||||||
|
|
||||||
|
aiMatrix3x3 result_c, result_cpp;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiIdentityMatrix3Test) {
|
||||||
|
// Force a non-identity matrix.
|
||||||
|
result_c = aiMatrix3x3(0,0,0,0,0,0,0,0,0);
|
||||||
|
aiIdentityMatrix3(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromMatrix4Test) {
|
||||||
|
const auto m = random_mat4();
|
||||||
|
result_cpp = aiMatrix3x3(m);
|
||||||
|
aiMatrix3FromMatrix4(&result_c, &m);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromQuaternionTest) {
|
||||||
|
const auto q = random_quat();
|
||||||
|
result_cpp = q.GetMatrix();
|
||||||
|
aiMatrix3FromQuaternion(&result_c, &q);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3AreEqualTest) {
|
||||||
|
result_c = result_cpp = random_mat3();
|
||||||
|
EXPECT_EQ(result_cpp == result_c,
|
||||||
|
(bool)aiMatrix3AreEqual(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3AreEqualEpsilonTest) {
|
||||||
|
result_c = result_cpp = random_mat3();
|
||||||
|
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
|
||||||
|
(bool)aiMatrix3AreEqualEpsilon(&result_cpp, &result_c, Epsilon));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMultiplyMatrix3Test) {
|
||||||
|
const auto m = random_mat3();
|
||||||
|
result_c = result_cpp = random_mat3();
|
||||||
|
result_cpp *= m;
|
||||||
|
aiMultiplyMatrix3(&result_c, &m);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiTransposeMatrix3Test) {
|
||||||
|
result_c = result_cpp = random_mat3();
|
||||||
|
result_cpp.Transpose();
|
||||||
|
aiTransposeMatrix3(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3InverseTest) {
|
||||||
|
// Use a predetermined matrix to prevent arbitrary
|
||||||
|
// cases where it could have a null determinant.
|
||||||
|
result_c = result_cpp = aiMatrix3x3(
|
||||||
|
5, 2, 7,
|
||||||
|
4, 6, 9,
|
||||||
|
1, 8, 3);
|
||||||
|
result_cpp.Inverse();
|
||||||
|
aiMatrix3Inverse(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3DeterminantTest) {
|
||||||
|
result_c = result_cpp = random_mat3();
|
||||||
|
EXPECT_EQ(result_cpp.Determinant(),
|
||||||
|
aiMatrix3Determinant(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3RotationZTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
aiMatrix3x3::RotationZ(angle, result_cpp);
|
||||||
|
aiMatrix3RotationZ(&result_c, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromRotationAroundAxisTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
const auto axis = random_unit_vec3();
|
||||||
|
aiMatrix3x3::Rotation(angle, axis, result_cpp);
|
||||||
|
aiMatrix3FromRotationAroundAxis(&result_c, &axis, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3TranslationTest) {
|
||||||
|
const auto axis = random_vec2();
|
||||||
|
aiMatrix3x3::Translation(axis, result_cpp);
|
||||||
|
aiMatrix3Translation(&result_c, &axis);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromToTest) {
|
||||||
|
// Use predetermined vectors to prevent running into division by zero.
|
||||||
|
const auto from = aiVector3D(1,2,1).Normalize(), to = aiVector3D(-1,1,1).Normalize();
|
||||||
|
aiMatrix3x3::FromToMatrix(from, to, result_cpp);
|
||||||
|
aiMatrix3FromTo(&result_c, &from, &to);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
|
@ -0,0 +1,259 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include "MathTest.h"
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class AssimpAPITest_aiMatrix4x4 : public AssimpMathTest {
|
||||||
|
protected:
|
||||||
|
virtual void SetUp() {
|
||||||
|
result_c = result_cpp = aiMatrix4x4();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Generates a predetermined transformation matrix to use
|
||||||
|
for the aiDecompose functions to prevent running into
|
||||||
|
division by zero. */
|
||||||
|
aiMatrix4x4 get_predetermined_transformation_matrix_for_decomposition() const {
|
||||||
|
aiMatrix4x4 t, r;
|
||||||
|
aiMatrix4x4::Translation(aiVector3D(14,-25,-8), t);
|
||||||
|
aiMatrix4x4::Rotation(Math::PI<float>() / 4.0f, aiVector3D(1).Normalize(), r);
|
||||||
|
return t * r;
|
||||||
|
}
|
||||||
|
|
||||||
|
aiMatrix4x4 result_c, result_cpp;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiIdentityMatrix4Test) {
|
||||||
|
// Force a non-identity matrix.
|
||||||
|
result_c = aiMatrix4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
|
||||||
|
aiIdentityMatrix4(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromMatrix3Test) {
|
||||||
|
aiMatrix3x3 m = random_mat3();
|
||||||
|
result_cpp = aiMatrix4x4(m);
|
||||||
|
aiMatrix4FromMatrix3(&result_c, &m);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromScalingQuaternionPositionTest) {
|
||||||
|
const aiVector3D s = random_vec3();
|
||||||
|
const aiQuaternion q = random_quat();
|
||||||
|
const aiVector3D t = random_vec3();
|
||||||
|
result_cpp = aiMatrix4x4(s, q, t);
|
||||||
|
aiMatrix4FromScalingQuaternionPosition(&result_c, &s, &q, &t);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4AddTest) {
|
||||||
|
const aiMatrix4x4 temp = random_mat4();
|
||||||
|
result_c = result_cpp = random_mat4();
|
||||||
|
result_cpp = result_cpp + temp;
|
||||||
|
aiMatrix4Add(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4AreEqualTest) {
|
||||||
|
result_c = result_cpp = random_mat4();
|
||||||
|
EXPECT_EQ(result_cpp == result_c,
|
||||||
|
(bool)aiMatrix4AreEqual(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4AreEqualEpsilonTest) {
|
||||||
|
result_c = result_cpp = random_mat4();
|
||||||
|
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
|
||||||
|
(bool)aiMatrix4AreEqualEpsilon(&result_cpp, &result_c, Epsilon));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMultiplyMatrix4Test) {
|
||||||
|
const auto m = random_mat4();
|
||||||
|
result_c = result_cpp = random_mat4();
|
||||||
|
result_cpp *= m;
|
||||||
|
aiMultiplyMatrix4(&result_c, &m);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiTransposeMatrix4Test) {
|
||||||
|
result_c = result_cpp = random_mat4();
|
||||||
|
result_cpp.Transpose();
|
||||||
|
aiTransposeMatrix4(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4InverseTest) {
|
||||||
|
// Use a predetermined matrix to prevent arbitrary
|
||||||
|
// cases where it could have a null determinant.
|
||||||
|
result_c = result_cpp = aiMatrix4x4(
|
||||||
|
6, 10, 15, 3,
|
||||||
|
14, 2, 12, 8,
|
||||||
|
9, 13, 5, 16,
|
||||||
|
4, 7, 11, 1);
|
||||||
|
result_cpp.Inverse();
|
||||||
|
aiMatrix4Inverse(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DeterminantTest) {
|
||||||
|
result_c = result_cpp = random_mat4();
|
||||||
|
EXPECT_EQ(result_cpp.Determinant(),
|
||||||
|
aiMatrix4Determinant(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4IsIdentityTest) {
|
||||||
|
EXPECT_EQ(result_cpp.IsIdentity(),
|
||||||
|
(bool)aiMatrix4IsIdentity(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiDecomposeMatrixTest) {
|
||||||
|
aiVector3D scaling_c, scaling_cpp,
|
||||||
|
position_c, position_cpp;
|
||||||
|
aiQuaternion rotation_c, rotation_cpp;
|
||||||
|
|
||||||
|
result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition();
|
||||||
|
result_cpp.Decompose(scaling_cpp, rotation_cpp, position_cpp);
|
||||||
|
aiDecomposeMatrix(&result_c, &scaling_c, &rotation_c, &position_c);
|
||||||
|
EXPECT_EQ(scaling_cpp, scaling_c);
|
||||||
|
EXPECT_EQ(position_cpp, position_c);
|
||||||
|
EXPECT_EQ(rotation_cpp, rotation_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DecomposeIntoScalingEulerAnglesPositionTest) {
|
||||||
|
aiVector3D scaling_c, scaling_cpp,
|
||||||
|
rotation_c, rotation_cpp,
|
||||||
|
position_c, position_cpp;
|
||||||
|
|
||||||
|
result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition();
|
||||||
|
result_cpp.Decompose(scaling_cpp, rotation_cpp, position_cpp);
|
||||||
|
aiMatrix4DecomposeIntoScalingEulerAnglesPosition(&result_c, &scaling_c, &rotation_c, &position_c);
|
||||||
|
EXPECT_EQ(scaling_cpp, scaling_c);
|
||||||
|
EXPECT_EQ(position_cpp, position_c);
|
||||||
|
EXPECT_EQ(rotation_cpp, rotation_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DecomposeIntoScalingAxisAnglePositionTest) {
|
||||||
|
aiVector3D scaling_c, scaling_cpp,
|
||||||
|
axis_c, axis_cpp,
|
||||||
|
position_c, position_cpp;
|
||||||
|
float angle_c, angle_cpp;
|
||||||
|
|
||||||
|
result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition();
|
||||||
|
result_cpp.Decompose(scaling_cpp, axis_cpp, angle_cpp, position_cpp);
|
||||||
|
aiMatrix4DecomposeIntoScalingAxisAnglePosition(&result_c, &scaling_c, &axis_c, &angle_c, &position_c);
|
||||||
|
EXPECT_EQ(scaling_cpp, scaling_c);
|
||||||
|
EXPECT_EQ(axis_cpp, axis_c);
|
||||||
|
EXPECT_EQ(angle_cpp, angle_c);
|
||||||
|
EXPECT_EQ(position_cpp, position_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DecomposeNoScalingTest) {
|
||||||
|
aiVector3D position_c, position_cpp;
|
||||||
|
aiQuaternion rotation_c, rotation_cpp;
|
||||||
|
|
||||||
|
result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition();
|
||||||
|
result_cpp.DecomposeNoScaling(rotation_cpp, position_cpp);
|
||||||
|
aiMatrix4DecomposeNoScaling(&result_c, &rotation_c, &position_c);
|
||||||
|
EXPECT_EQ(position_cpp, position_c);
|
||||||
|
EXPECT_EQ(rotation_cpp, rotation_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromEulerAnglesTest) {
|
||||||
|
const float x(RandPI.next()),
|
||||||
|
y(RandPI.next()),
|
||||||
|
z(RandPI.next());
|
||||||
|
result_cpp.FromEulerAnglesXYZ(x, y, z);
|
||||||
|
aiMatrix4FromEulerAngles(&result_c, x, y, z);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4RotationXTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
aiMatrix4x4::RotationX(angle, result_cpp);
|
||||||
|
aiMatrix4RotationX(&result_c, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4RotationYTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
aiMatrix4x4::RotationY(angle, result_cpp);
|
||||||
|
aiMatrix4RotationY(&result_c, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4RotationZTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
aiMatrix4x4::RotationZ(angle, result_cpp);
|
||||||
|
aiMatrix4RotationZ(&result_c, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromRotationAroundAxisTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
const auto axis = random_unit_vec3();
|
||||||
|
aiMatrix4x4::Rotation(angle, axis, result_cpp);
|
||||||
|
aiMatrix4FromRotationAroundAxis(&result_c, &axis, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4TranslationTest) {
|
||||||
|
const auto axis = random_vec3();
|
||||||
|
aiMatrix4x4::Translation(axis, result_cpp);
|
||||||
|
aiMatrix4Translation(&result_c, &axis);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4ScalingTest) {
|
||||||
|
const auto scaling = random_vec3();
|
||||||
|
aiMatrix4x4::Scaling(scaling, result_cpp);
|
||||||
|
aiMatrix4Scaling(&result_c, &scaling);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromToTest) {
|
||||||
|
// Use predetermined vectors to prevent running into division by zero.
|
||||||
|
const auto from = aiVector3D(1,2,1).Normalize(), to = aiVector3D(-1,1,1).Normalize();
|
||||||
|
aiMatrix4x4::FromToMatrix(from, to, result_cpp);
|
||||||
|
aiMatrix4FromTo(&result_c, &from, &to);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include "MathTest.h"
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class AssimpAPITest_aiQuaternion : public AssimpMathTest {
|
||||||
|
protected:
|
||||||
|
virtual void SetUp() {
|
||||||
|
result_c = result_cpp = aiQuaternion();
|
||||||
|
}
|
||||||
|
|
||||||
|
aiQuaternion result_c, result_cpp;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiCreateQuaternionFromMatrixTest) {
|
||||||
|
// Use a predetermined transformation matrix
|
||||||
|
// to prevent running into division by zero.
|
||||||
|
aiMatrix3x3 m, r;
|
||||||
|
aiMatrix3x3::Translation(aiVector2D(14,-25), m);
|
||||||
|
aiMatrix3x3::RotationZ(Math::PI<float>() / 4.0f, r);
|
||||||
|
m = m * r;
|
||||||
|
|
||||||
|
result_cpp = aiQuaternion(m);
|
||||||
|
aiCreateQuaternionFromMatrix(&result_c, &m);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionFromEulerAnglesTest) {
|
||||||
|
const float x(RandPI.next()),
|
||||||
|
y(RandPI.next()),
|
||||||
|
z(RandPI.next());
|
||||||
|
result_cpp = aiQuaternion(x, y, z);
|
||||||
|
aiQuaternionFromEulerAngles(&result_c, x, y, z);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionFromAxisAngleTest) {
|
||||||
|
const float angle(RandPI.next());
|
||||||
|
const aiVector3D axis(random_unit_vec3());
|
||||||
|
result_cpp = aiQuaternion(axis, angle);
|
||||||
|
aiQuaternionFromAxisAngle(&result_c, &axis, angle);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionFromNormalizedQuaternionTest) {
|
||||||
|
const auto qvec3 = random_unit_vec3();
|
||||||
|
result_cpp = aiQuaternion(qvec3);
|
||||||
|
aiQuaternionFromNormalizedQuaternion(&result_c, &qvec3);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionAreEqualTest) {
|
||||||
|
result_c = result_cpp = random_quat();
|
||||||
|
EXPECT_EQ(result_cpp == result_c,
|
||||||
|
(bool)aiQuaternionAreEqual(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionAreEqualEpsilonTest) {
|
||||||
|
result_c = result_cpp = random_quat();
|
||||||
|
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
|
||||||
|
(bool)aiQuaternionAreEqualEpsilon(&result_cpp, &result_c, Epsilon));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionNormalizeTest) {
|
||||||
|
result_c = result_cpp = random_quat();
|
||||||
|
aiQuaternionNormalize(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp.Normalize(), result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionConjugateTest) {
|
||||||
|
result_c = result_cpp = random_quat();
|
||||||
|
aiQuaternionConjugate(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp.Conjugate(), result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionMultiplyTest) {
|
||||||
|
const aiQuaternion temp = random_quat();
|
||||||
|
result_c = result_cpp = random_quat();
|
||||||
|
result_cpp = result_cpp * temp;
|
||||||
|
aiQuaternionMultiply(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionInterpolateTest) {
|
||||||
|
// Use predetermined quaternions to prevent division by zero
|
||||||
|
// during slerp calculations.
|
||||||
|
const float INTERPOLATION(0.5f);
|
||||||
|
const auto q1 = aiQuaternion(aiVector3D(-1,1,1).Normalize(), Math::PI<float>() / 4.0f);
|
||||||
|
const auto q2 = aiQuaternion(aiVector3D(1,2,1).Normalize(), Math::PI<float>() / 2.0f);
|
||||||
|
aiQuaternion::Interpolate(result_cpp, q1, q2, INTERPOLATION);
|
||||||
|
aiQuaternionInterpolate(&result_c, &q1, &q2, INTERPOLATION);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
|
@ -0,0 +1,140 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include "MathTest.h"
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class AssimpAPITest_aiVector2D : public AssimpMathTest {
|
||||||
|
protected:
|
||||||
|
virtual void SetUp() {
|
||||||
|
result_c = result_cpp = aiVector2D();
|
||||||
|
temp = random_vec2(); // Generates a random 2D vector != null vector.
|
||||||
|
}
|
||||||
|
|
||||||
|
aiVector2D result_c, result_cpp, temp;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2AreEqualTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
EXPECT_EQ(result_cpp == result_c,
|
||||||
|
(bool)aiVector2AreEqual(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2AreEqualEpsilonTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
|
||||||
|
(bool)aiVector2AreEqualEpsilon(&result_cpp, &result_c, Epsilon));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2AddTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
result_cpp += temp;
|
||||||
|
aiVector2Add(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2SubtractTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
result_cpp -= temp;
|
||||||
|
aiVector2Subtract(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2ScaleTest) {
|
||||||
|
const float FACTOR = RandNonZero.next();
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
result_cpp *= FACTOR;
|
||||||
|
aiVector2Scale(&result_c, FACTOR);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2SymMulTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
result_cpp = result_cpp.SymMul(temp);
|
||||||
|
aiVector2SymMul(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2DivideByScalarTest) {
|
||||||
|
const float DIVISOR = RandNonZero.next();
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
result_cpp /= DIVISOR;
|
||||||
|
aiVector2DivideByScalar(&result_c, DIVISOR);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2DivideByVectorTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
result_cpp = result_cpp / temp;
|
||||||
|
aiVector2DivideByVector(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2LengthTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
EXPECT_EQ(result_cpp.Length(), aiVector2Length(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2SquareLengthTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
EXPECT_EQ(result_cpp.SquareLength(), aiVector2SquareLength(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2NegateTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
aiVector2Negate(&result_c);
|
||||||
|
EXPECT_EQ(-result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2DotProductTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
EXPECT_EQ(result_cpp * result_c,
|
||||||
|
aiVector2DotProduct(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector2D, aiVector2NormalizeTest) {
|
||||||
|
result_c = result_cpp = random_vec2();
|
||||||
|
aiVector2Normalize(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp.Normalize(), result_c);
|
||||||
|
}
|
|
@ -0,0 +1,185 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include "MathTest.h"
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class AssimpAPITest_aiVector3D : public AssimpMathTest {
|
||||||
|
protected:
|
||||||
|
virtual void SetUp() {
|
||||||
|
result_c = result_cpp = aiVector3D();
|
||||||
|
temp = random_vec3(); // Generates a random 3D vector != null vector.
|
||||||
|
}
|
||||||
|
|
||||||
|
aiVector3D result_c, result_cpp, temp;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3AreEqualTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
EXPECT_EQ(result_cpp == result_c,
|
||||||
|
(bool)aiVector3AreEqual(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3AreEqualEpsilonTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
|
||||||
|
(bool)aiVector3AreEqualEpsilon(&result_cpp, &result_c, Epsilon));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3LessThanTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
EXPECT_EQ(result_cpp < temp,
|
||||||
|
(bool)aiVector3LessThan(&result_c, &temp));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3AddTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp += temp;
|
||||||
|
aiVector3Add(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3SubtractTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp -= temp;
|
||||||
|
aiVector3Subtract(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3ScaleTest) {
|
||||||
|
const float FACTOR = RandNonZero.next();
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp *= FACTOR;
|
||||||
|
aiVector3Scale(&result_c, FACTOR);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3SymMulTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp = result_cpp.SymMul(temp);
|
||||||
|
aiVector3SymMul(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3DivideByScalarTest) {
|
||||||
|
const float DIVISOR = RandNonZero.next();
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp /= DIVISOR;
|
||||||
|
aiVector3DivideByScalar(&result_c, DIVISOR);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3DivideByVectorTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp = result_cpp / temp;
|
||||||
|
aiVector3DivideByVector(&result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3LengthTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
EXPECT_EQ(result_cpp.Length(), aiVector3Length(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3SquareLengthTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
EXPECT_EQ(result_cpp.SquareLength(), aiVector3SquareLength(&result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3NegateTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
aiVector3Negate(&result_c);
|
||||||
|
EXPECT_EQ(-result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3DotProductTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
EXPECT_EQ(result_cpp * result_c,
|
||||||
|
aiVector3DotProduct(&result_cpp, &result_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3CrossProductTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
result_cpp = result_cpp ^ temp;
|
||||||
|
aiVector3CrossProduct(&result_c, &result_c, &temp);
|
||||||
|
EXPECT_EQ(result_cpp, result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3NormalizeTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
aiVector3Normalize(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp.Normalize(), result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3NormalizeSafeTest) {
|
||||||
|
result_c = result_cpp = random_vec3();
|
||||||
|
aiVector3NormalizeSafe(&result_c);
|
||||||
|
EXPECT_EQ(result_cpp.NormalizeSafe(), result_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiVector3RotateByQuaternionTest) {
|
||||||
|
aiVector3D v_c, v_cpp;
|
||||||
|
v_c = v_cpp = random_vec3();
|
||||||
|
const auto q = random_quat();
|
||||||
|
aiVector3RotateByQuaternion(&v_c, &q);
|
||||||
|
EXPECT_EQ(q.Rotate(v_cpp), v_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiTransformVecByMatrix3Test) {
|
||||||
|
const auto m = random_mat3();
|
||||||
|
aiVector3D v_c, v_cpp;
|
||||||
|
v_c = v_cpp = random_vec3();
|
||||||
|
v_cpp *= m;
|
||||||
|
aiTransformVecByMatrix3(&v_c, &m);
|
||||||
|
EXPECT_EQ(v_cpp, v_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AssimpAPITest_aiVector3D, aiTransformVecByMatrix4Test) {
|
||||||
|
const auto m = random_mat4();
|
||||||
|
aiVector3D v_c, v_cpp;
|
||||||
|
v_c = v_cpp = random_vec3();
|
||||||
|
v_cpp *= m;
|
||||||
|
aiTransformVecByMatrix4(&v_c, &m);
|
||||||
|
EXPECT_EQ(v_cpp, v_c);
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utScene : public ::testing::Test {
|
||||||
|
protected:
|
||||||
|
aiScene *scene;
|
||||||
|
|
||||||
|
void SetUp() override {
|
||||||
|
scene = new aiScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() override {
|
||||||
|
delete scene;
|
||||||
|
scene = nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(utScene, findNodeTest) {
|
||||||
|
scene->mRootNode = new aiNode();
|
||||||
|
scene->mRootNode->mName.Set("test");
|
||||||
|
aiNode *child = new aiNode;
|
||||||
|
child->mName.Set("child");
|
||||||
|
scene->mRootNode->addChildren(1, &child);
|
||||||
|
aiNode *found = scene->mRootNode->FindNode("child");
|
||||||
|
EXPECT_EQ(child, found);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(utScene, sceneHasContentTest) {
|
||||||
|
EXPECT_FALSE(scene->HasAnimations());
|
||||||
|
EXPECT_FALSE(scene->HasMaterials());
|
||||||
|
EXPECT_FALSE(scene->HasMeshes());
|
||||||
|
EXPECT_FALSE(scene->HasCameras());
|
||||||
|
EXPECT_FALSE(scene->HasLights());
|
||||||
|
EXPECT_FALSE(scene->HasTextures());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(utScene, getShortFilenameTest) {
|
||||||
|
std::string long_filename1 = "foo_bar/name";
|
||||||
|
const char *name1 = scene->GetShortFilename(long_filename1.c_str());
|
||||||
|
EXPECT_NE(nullptr, name1);
|
||||||
|
|
||||||
|
std::string long_filename2 = "foo_bar\\name";
|
||||||
|
const char *name2 = scene->GetShortFilename(long_filename2.c_str());
|
||||||
|
EXPECT_NE(nullptr, name2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(utScene, getEmbeddedTextureTest) {
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2019, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "SceneDiffer.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utAssxmlImportExport : public AbstractImportExportBase {
|
||||||
|
public:
|
||||||
|
bool importerTest() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
bool exporterTest() override {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure);
|
||||||
|
EXPECT_NE(scene, nullptr );
|
||||||
|
|
||||||
|
::Assimp::Exporter exporter;
|
||||||
|
return AI_SUCCESS == exporter.Export(scene, "assxml", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_out.assxml");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
||||||
|
TEST_F(utAssxmlImportExport, exportAssxmlTest) {
|
||||||
|
EXPECT_TRUE(exporterTest());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utIrrImportExport : public AbstractImportExportBase {
|
||||||
|
public:
|
||||||
|
virtual bool importerTest() {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/IRR/box.irr", aiProcess_ValidateDataStructure);
|
||||||
|
return nullptr != scene;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(utIrrImportExport, importSimpleIrrTest) {
|
||||||
|
EXPECT_TRUE(importerTest());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(utIrrImportExport, importSGIrrTest) {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/IRR/dawfInCellar_SameHierarchy.irr", aiProcess_ValidateDataStructure);
|
||||||
|
EXPECT_NE( nullptr,scene);
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utRAWImportExport : public AbstractImportExportBase {
|
||||||
|
public:
|
||||||
|
virtual bool importerTest() {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/RAW/Wuson.raw", aiProcess_ValidateDataStructure);
|
||||||
|
#ifndef ASSIMP_BUILD_NO_RAW_IMPORTER
|
||||||
|
return nullptr != scene;
|
||||||
|
#else
|
||||||
|
return nullptr == scene;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(utRAWImportExport, importSimpleRAWTest) {
|
||||||
|
EXPECT_TRUE(importerTest());
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "AbstractImportExportBase.h"
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
|
class utTerragenImportExport : public AbstractImportExportBase {
|
||||||
|
public:
|
||||||
|
virtual bool importerTest() {
|
||||||
|
/*Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/TER/RealisticTerrain.ter", aiProcess_ValidateDataStructure);
|
||||||
|
return nullptr != scene;*/
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(utTerragenImportExport, importX3DFromFileTest) {
|
||||||
|
EXPECT_TRUE(importerTest());
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "MathTest.h"
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
// Initialize epsilon value.
|
||||||
|
const float AssimpMathTest::Epsilon = Math::getEpsilon<float>();
|
||||||
|
|
||||||
|
// Initialize with an interval of [1,100].
|
||||||
|
RandomUniformFloatGenerator AssimpMathTest::RandNonZero(1.0f, 100.0f);
|
||||||
|
|
||||||
|
// Initialize with an interval of [-PI,PI] inclusively.
|
||||||
|
RandomUniformFloatGenerator AssimpMathTest::RandPI(-Math::PI<float>(), Math::PI<float>());
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ASSIMP_MATH_TEST_H
|
||||||
|
#define ASSIMP_MATH_TEST_H
|
||||||
|
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
#include <assimp/types.h>
|
||||||
|
#include "RandomNumberGeneration.h"
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
/** Custom test class providing several math related utilities. */
|
||||||
|
class AssimpMathTest : public ::testing::Test {
|
||||||
|
public:
|
||||||
|
/** Return a random non-null 2D vector. */
|
||||||
|
inline static aiVector2D random_vec2() {
|
||||||
|
return aiVector2D(RandNonZero.next(), RandNonZero.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a random non-null 3D vector. */
|
||||||
|
inline static aiVector3D random_vec3() {
|
||||||
|
return aiVector3D(RandNonZero.next(), RandNonZero.next(),RandNonZero.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a random unit 3D vector. */
|
||||||
|
inline static aiVector3D random_unit_vec3() {
|
||||||
|
return random_vec3().NormalizeSafe();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a quaternion with random orientation and
|
||||||
|
* rotation angle around axis. */
|
||||||
|
inline static aiQuaternion random_quat() {
|
||||||
|
return aiQuaternion(random_unit_vec3(), RandPI.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a random non-null 3x3 matrix. */
|
||||||
|
inline static aiMatrix3x3 random_mat3() {
|
||||||
|
return aiMatrix3x3(
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(),
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(),
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a random non-null 4x4 matrix. */
|
||||||
|
inline static aiMatrix4x4 random_mat4() {
|
||||||
|
return aiMatrix4x4(
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(), RandNonZero.next(),
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(), RandNonZero.next(),
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(), RandNonZero.next(),
|
||||||
|
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(), RandNonZero.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Epsilon value to use in tests. */
|
||||||
|
static const float Epsilon;
|
||||||
|
|
||||||
|
/** Random number generators. */
|
||||||
|
static RandomUniformFloatGenerator RandNonZero, RandPI;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // ASSIMP_MATH_TEST_H
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ASSIMP_RANDOM_NUMBER_GENERATION_H
|
||||||
|
#define ASSIMP_RANDOM_NUMBER_GENERATION_H
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
/** Helper class to use for generating pseudo-random
|
||||||
|
* real numbers, with a uniform distribution. */
|
||||||
|
template<typename T>
|
||||||
|
class RandomUniformRealGenerator {
|
||||||
|
public:
|
||||||
|
RandomUniformRealGenerator() :
|
||||||
|
dist_(),
|
||||||
|
rd_(),
|
||||||
|
re_(rd_()) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
RandomUniformRealGenerator(T min, T max) :
|
||||||
|
dist_(min, max),
|
||||||
|
rd_(),
|
||||||
|
re_(rd_()) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
inline T next() {
|
||||||
|
return dist_(re_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::uniform_real_distribution<T> dist_;
|
||||||
|
std::random_device rd_;
|
||||||
|
std::default_random_engine re_;
|
||||||
|
};
|
||||||
|
|
||||||
|
using RandomUniformFloatGenerator = RandomUniformRealGenerator<float>;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // ASSIMP_RANDOM_NUMBER_GENERATION_H
|
|
@ -43,6 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
|
@ -50,7 +52,7 @@ using namespace Assimp;
|
||||||
|
|
||||||
class utM3DImportExport : public AbstractImportExportBase {
|
class utM3DImportExport : public AbstractImportExportBase {
|
||||||
public:
|
public:
|
||||||
virtual bool importerTest() {
|
bool importerTest() override {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals.m3d", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals.m3d", aiProcess_ValidateDataStructure);
|
||||||
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||||
|
@ -59,8 +61,24 @@ public:
|
||||||
return nullptr == scene;
|
return nullptr == scene;
|
||||||
#endif // ASSIMP_BUILD_NO_M3D_IMPORTER
|
#endif // ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
bool exporterTest() override {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals.m3d", aiProcess_ValidateDataStructure);
|
||||||
|
Exporter exporter;
|
||||||
|
aiReturn ret = exporter.Export(scene, "m3d", ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals_out.m3d");
|
||||||
|
return ret == AI_SUCCESS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(utM3DImportExport, importM3DFromFileTest) {
|
TEST_F(utM3DImportExport, importM3DFromFileTest) {
|
||||||
EXPECT_TRUE(importerTest());
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
TEST_F(utM3DImportExport, exportM3DFromFileTest) {
|
||||||
|
EXPECT_TRUE(exporterTest());
|
||||||
|
}
|
||||||
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
|
|
|
@ -402,13 +402,12 @@ int CMaterialManager::FindValidPath(aiString* p_szString)
|
||||||
}
|
}
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
// copy the result string back to the aiString
|
// copy the result string back to the aiStr
|
||||||
const size_t iLen = strlen(szTemp);
|
const size_t len = strlen(szTemp);
|
||||||
size_t iLen2 = iLen+1;
|
size_t len2 = len+1;
|
||||||
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
|
len2 = len2 > MAXLEN ? MAXLEN : len2;
|
||||||
memcpy(p_szString->data,szTemp,iLen2);
|
memcpy(p_szString->data, szTemp, len2);
|
||||||
p_szString->length = static_cast<ai_uint32>(iLen);
|
p_szString->length = static_cast<ai_uint32>(len);
|
||||||
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1490,4 +1489,5 @@ int CMaterialManager::EndMaterial (AssetHelper::MeshHelper* pcMesh)
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}; // end namespace AssimpView
|
|
||||||
|
} // end namespace AssimpView
|
||||||
|
|
Loading…
Reference in New Issue