Merge branch 'master' into kimkulling-issue_2212

pull/2219/head
Kim Kulling 2018-12-01 09:49:03 +01:00 committed by GitHub
commit dd21e4023e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 65251 additions and 735 deletions

View File

@ -1,5 +1,8 @@
# Install CMake
Asset-Importer-Lib supports a lot of different OSes and platforms. We are using cmake to generate the build environment for these via cmake. So you have to make sure that you have a working cmake-installation on your system. You can download it at https://cmake.org/
Asset-Importer-Lib can be build for a lot of different platforms. We are using cmake to generate the build environment for these via cmake. So you have to make sure that you have a working cmake-installation on your system. You can download it at https://cmake.org/ or for linux install it via
```
sudo apt-get install cmake
```
# Get the source
Make sure you have a working git-installation. Open a command prompt and clone the Asset-Importer-Lib via:
@ -11,44 +14,45 @@ git clone https://github.com/assimp/assimp.git
First you have to install Visual-Studio on your windows-system. You can get the Community-Version for free here: https://visualstudio.microsoft.com/de/downloads/
To generate the build environment for your IDE open a command prompt, navigate to your repo and type:
```
> cmake CMakeLists.txt
```
This will generate the project files.
This will generate the project files for the visual studio. All dependencies used to build Asset-IMporter-Lib shall be part of the repo. If you want to use you own zlib.installation this is possible as well. Check the options for it.
# Build instructions for Windows with UWP
See https://stackoverflow.com/questions/40803170/cmake-uwp-using-cmake-to-build-universal-windows-app
# Build instrcutions for Linux / Unix
Open a terminal and got to your repository. You can generate the projectfiles and build the library via:
Open a terminal and got to your repository. You can generate the makefiles and build the library via:
```
cmake CMakeLists.txt
make -j4
```
The option -j descripes the number of parallel processes for the build.
The option -j descripes the number of parallel processes for the build. In this case make will try to use 4 cores for the build.
If you want to use a IDE for linux you can try QTCreator for instance.
# CMake build options
The cmake-build-environment provides options to configure the build. The following options can be used:
- BUILD_SHARED_LIBS ( default ON ): Generation of shared libs ( dll for windows, so for Linux ). Set this to OFF to get a static lib.
- BUILD_FRAMEWORK ( default OFF, MacOnly): Build package as Mac OS X Framework bundle
- ASSIMP_DOUBLE_PRECISION( default OFF ): All data will be stored as double values.
- ASSIMP_OPT_BUILD_PACKAGES ( default OFF): Set to ON to generate CPack configuration files and packaging targets
- ASSIMP_ANDROID_JNIIOSYSTEM ( default OFF ): Android JNI IOSystem support is active
- ASSIMP_NO_EXPORT ( default OFF ): Disable Assimp's export functionality
- ASSIMP_BUILD_ZLIB ( default OFF ): Build your own zlib
- ASSIMP_BUILD_ASSIMP_TOOLS ( default ON ): If the supplementary tools for Assimp are built in addition to the library.
- ASSIMP_BUILD_SAMPLES ( default OFF ): If the official samples are built as well (needs Glut).
- ASSIMP_BUILD_TESTS ( default ON ): If the test suite for Assimp is built in addition to the library.
- ASSIMP_COVERALLS ( default OFF ): Enable this to measure test coverage.
- ASSIMP_WERROR( default OFF ): Treat warnings as errors.
- ASSIMP_ASAN ( default OFF ): Enable AddressSanitizer.
- ASSIMP_UBSAN ( default OFF ): Enable Undefined Behavior sanitizer.
- SYSTEM_IRRXML ( default OFF ): Use system installed Irrlicht/IrrXML library.
- BUILD_DOCS ( default OFF ): Build documentation using Doxygen.
- INJECT_DEBUG_POSTFIX( default ON ): Inject debug postfix in .a/.so lib names
- IGNORE_GIT_HASH ( default OFF ): Don't call git to get the hash.
- ASSIMP_INSTALL_PDB ( default ON ): Install MSVC debug files.
- **BUILD_SHARED_LIBS ( default ON )**: Generation of shared libs ( dll for windows, so for Linux ). Set this to OFF to get a static lib.
- **BUILD_FRAMEWORK ( default OFF, MacOnly)**: Build package as Mac OS X Framework bundle
- **ASSIMP_DOUBLE_PRECISION( default OFF )**: All data will be stored as double values.
- **ASSIMP_OPT_BUILD_PACKAGES ( default OFF)**: Set to ON to generate CPack configuration files and packaging targets
- **ASSIMP_ANDROID_JNIIOSYSTEM ( default OFF )**: Android JNI IOSystem support is active
- **ASSIMP_NO_EXPORT ( default OFF )**: Disable Assimp's export functionality
- **ASSIMP_BUILD_ZLIB ( default OFF )**: Build your own zlib
- **ASSIMP_BUILD_ASSIMP_TOOLS ( default ON )**: If the supplementary tools for Assimp are built in addition to the library.
- **ASSIMP_BUILD_SAMPLES ( default OFF )**: If the official samples are built as well (needs Glut).
- **ASSIMP_BUILD_TESTS ( default ON )**: If the test suite for Assimp is built in addition to the library.
- **ASSIMP_COVERALLS ( default OFF )**: Enable this to measure test coverage.
- **ASSIMP_WERROR( default OFF )**: Treat warnings as errors.
- **ASSIMP_ASAN ( default OFF )**: Enable AddressSanitizer.
- **ASSIMP_UBSAN ( default OFF )**: Enable Undefined Behavior sanitizer.
- **SYSTEM_IRRXML ( default OFF )**: Use system installed Irrlicht/IrrXML library.
- **BUILD_DOCS ( default OFF )**: Build documentation using Doxygen.
- **INJECT_DEBUG_POSTFIX( default ON )**: Inject debug postfix in .a/.so lib names
- **IGNORE_GIT_HASH ( default OFF )**: Don't call git to get the hash.
- **ASSIMP_INSTALL_PDB ( default ON )**: Install MSVC debug files.

View File

@ -170,7 +170,7 @@ IF(NOT IGNORE_GIT_HASH)
# Get the latest abbreviated commit hash of the working branch
EXECUTE_PROCESS(
COMMAND git log -1 --format=%h --no-show-signature
COMMAND git rev-parse --short=8 HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE

View File

@ -161,19 +161,21 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
aiScene* pScene, IOSystem* pIOHandler)
{
StreamReaderLE stream(pIOHandler->Open(pFile,"rb"));
this->stream = &stream;
// We should have at least one chunk
if (stream.GetRemainingSize() < 16) {
throw DeadlyImportError("3DS file is either empty or corrupt: " + pFile);
}
this->stream = &stream;
// Allocate our temporary 3DS representation
mScene = new D3DS::Scene();
D3DS::Scene _scene;
mScene = &_scene;
// Initialize members
D3DS::Node _rootNode("UNNAMED");
mLastNodeIndex = -1;
mCurrentNode = new D3DS::Node("UNNAMED");
mCurrentNode = &_rootNode;
mRootNode = mCurrentNode;
mRootNode->mHierarchyPos = -1;
mRootNode->mHierarchyIndex = -1;
@ -193,7 +195,6 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
// file.
for (auto &mesh : mScene->mMeshes) {
if (mesh.mFaces.size() > 0 && mesh.mPositions.size() == 0) {
delete mScene;
throw DeadlyImportError("3DS file contains faces but no vertices: " + pFile);
}
CheckIndices(mesh);
@ -201,7 +202,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(mesh);
}
// Replace all occurrences of the default material with a
// Replace all occurences of the default material with a
// valid material. Generate it if no material containing
// DEFAULT in its name has been found in the file
ReplaceDefaultMaterial();
@ -218,10 +219,8 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
// Now apply the master scaling factor to the scene
ApplyMasterScale(pScene);
// Delete our internal scene representation and the root
// node, so the whole hierarchy will follow
delete mRootNode;
delete mScene;
// Our internal scene representation and the root
// node will be automatically deleted, so the whole hierarchy will follow
AI_DEBUG_INVALIDATE_PTR(mRootNode);
AI_DEBUG_INVALIDATE_PTR(mScene);

View File

@ -89,7 +89,7 @@ size_t Write<unsigned int>(IOStream * stream, const unsigned int& w) {
const uint32_t t = (uint32_t)w;
if (w > t) {
// this shouldn't happen, integers in Assimp data structures never exceed 2^32
throw new DeadlyExportError("loss of data due to 64 -> 32 bit integer conversion");
throw DeadlyExportError("loss of data due to 64 -> 32 bit integer conversion");
}
stream->Write(&t,4,1);
@ -805,10 +805,16 @@ public:
WriteBinaryScene( &uncompressedStream, pScene );
uLongf uncompressedSize = static_cast<uLongf>(uncompressedStream.Tell());
uLongf compressedSize = (uLongf)(uncompressedStream.Tell() * 1.001 + 12.);
uLongf compressedSize = (uLongf)compressBound(uncompressedSize);
uint8_t* compressedBuffer = new uint8_t[ compressedSize ];
compress2( compressedBuffer, &compressedSize, (const Bytef*)uncompressedStream.GetBufferPointer(), uncompressedSize, 9 );
int res = compress2( compressedBuffer, &compressedSize, (const Bytef*)uncompressedStream.GetBufferPointer(), uncompressedSize, 9 );
if(res != Z_OK)
{
delete [] compressedBuffer;
pIOSystem->Close(out);
throw DeadlyExportError("Compression failed.");
}
out->Write( &uncompressedSize, sizeof(uint32_t), 1 );
out->Write( compressedBuffer, sizeof(char), compressedSize );

View File

@ -57,6 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/anim.h>
#include <assimp/scene.h>
#include <assimp/importerdesc.h>
#include <memory>
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
# include <zlib.h>
@ -103,7 +104,9 @@ bool AssbinImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bo
template <typename T>
T Read(IOStream * stream) {
T t;
stream->Read( &t, sizeof(T), 1 );
size_t res = stream->Read( &t, sizeof(T), 1 );
if(res != 1)
throw DeadlyImportError("Unexpected EOF");
return t;
}
@ -144,7 +147,8 @@ template <>
aiString Read<aiString>(IOStream * stream) {
aiString s;
stream->Read(&s.length,4,1);
stream->Read(s.data,s.length,1);
if(s.length)
stream->Read(s.data,s.length,1);
s.data[s.length] = 0;
return s;
}
@ -207,46 +211,48 @@ void ReadBounds( IOStream * stream, T* /*p*/, unsigned int n ) {
}
// -----------------------------------------------------------------------------------
void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* parent ) {
uint32_t chunkID = Read<uint32_t>(stream);
(void)(chunkID);
ai_assert(chunkID == ASSBIN_CHUNK_AINODE);
void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** onode, aiNode* parent ) {
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AINODE)
throw DeadlyImportError("Magic chunk identifiers are wrong!");
/*uint32_t size =*/ Read<uint32_t>(stream);
*node = new aiNode();
std::unique_ptr<aiNode> node(new aiNode());
(*node)->mName = Read<aiString>(stream);
(*node)->mTransformation = Read<aiMatrix4x4>(stream);
(*node)->mNumChildren = Read<unsigned int>(stream);
(*node)->mNumMeshes = Read<unsigned int>(stream);
node->mName = Read<aiString>(stream);
node->mTransformation = Read<aiMatrix4x4>(stream);
unsigned numChildren = Read<unsigned int>(stream);
unsigned numMeshes = Read<unsigned int>(stream);
unsigned int nb_metadata = Read<unsigned int>(stream);
if(parent) {
(*node)->mParent = parent;
node->mParent = parent;
}
if ((*node)->mNumMeshes) {
(*node)->mMeshes = new unsigned int[(*node)->mNumMeshes];
for (unsigned int i = 0; i < (*node)->mNumMeshes; ++i) {
(*node)->mMeshes[i] = Read<unsigned int>(stream);
if (numMeshes)
{
node->mMeshes = new unsigned int[numMeshes];
for (unsigned int i = 0; i < numMeshes; ++i) {
node->mMeshes[i] = Read<unsigned int>(stream);
node->mNumMeshes++;
}
}
if ((*node)->mNumChildren) {
(*node)->mChildren = new aiNode*[(*node)->mNumChildren];
for (unsigned int i = 0; i < (*node)->mNumChildren; ++i) {
ReadBinaryNode( stream, &(*node)->mChildren[i], *node );
if (numChildren) {
node->mChildren = new aiNode*[numChildren];
for (unsigned int i = 0; i < numChildren; ++i) {
ReadBinaryNode( stream, &node->mChildren[i], node.get() );
node->mNumChildren++;
}
}
if ( nb_metadata > 0 ) {
(*node)->mMetaData = aiMetadata::Alloc(nb_metadata);
node->mMetaData = aiMetadata::Alloc(nb_metadata);
for (unsigned int i = 0; i < nb_metadata; ++i) {
(*node)->mMetaData->mKeys[i] = Read<aiString>(stream);
(*node)->mMetaData->mValues[i].mType = (aiMetadataType) Read<uint16_t>(stream);
void* data( nullptr );
node->mMetaData->mKeys[i] = Read<aiString>(stream);
node->mMetaData->mValues[i].mType = (aiMetadataType) Read<uint16_t>(stream);
void* data = nullptr;
switch ((*node)->mMetaData->mValues[i].mType) {
switch (node->mMetaData->mValues[i].mType) {
case AI_BOOL:
data = new bool(Read<bool>(stream));
break;
@ -275,16 +281,16 @@ void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* p
break;
}
(*node)->mMetaData->mValues[i].mData = data;
node->mMetaData->mValues[i].mData = data;
}
}
*onode = node.release();
}
// -----------------------------------------------------------------------------------
void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b ) {
uint32_t chunkID = Read<uint32_t>(stream);
(void)(chunkID);
ai_assert(chunkID == ASSBIN_CHUNK_AIBONE);
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AIBONE)
throw DeadlyImportError("Magic chunk identifiers are wrong!");
/*uint32_t size =*/ Read<uint32_t>(stream);
b->mName = Read<aiString>(stream);
@ -306,12 +312,10 @@ void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b ) {
static bool fitsIntoUI16(unsigned int mNumVertices) {
return ( mNumVertices < (1u<<16) );
}
// -----------------------------------------------------------------------------------
void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) {
uint32_t chunkID = Read<uint32_t>(stream);
(void)(chunkID);
ai_assert(chunkID == ASSBIN_CHUNK_AIMESH);
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AIMESH)
throw DeadlyImportError("Magic chunk identifiers are wrong!");
/*uint32_t size =*/ Read<uint32_t>(stream);
mesh->mPrimitiveTypes = Read<unsigned int>(stream);
@ -423,9 +427,8 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) {
// -----------------------------------------------------------------------------------
void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialProperty* prop) {
uint32_t chunkID = Read<uint32_t>(stream);
(void)(chunkID);
ai_assert(chunkID == ASSBIN_CHUNK_AIMATERIALPROPERTY);
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AIMATERIALPROPERTY)
throw DeadlyImportError("Magic chunk identifiers are wrong!");
/*uint32_t size =*/ Read<uint32_t>(stream);
prop->mKey = Read<aiString>(stream);
@ -440,9 +443,8 @@ void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialPro
// -----------------------------------------------------------------------------------
void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat) {
uint32_t chunkID = Read<uint32_t>(stream);
(void)(chunkID);
ai_assert(chunkID == ASSBIN_CHUNK_AIMATERIAL);
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AIMATERIAL)
throw DeadlyImportError("Magic chunk identifiers are wrong!");
/*uint32_t size =*/ Read<uint32_t>(stream);
mat->mNumAllocated = mat->mNumProperties = Read<unsigned int>(stream);
@ -462,9 +464,8 @@ void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat) {
// -----------------------------------------------------------------------------------
void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd) {
uint32_t chunkID = Read<uint32_t>(stream);
(void)(chunkID);
ai_assert(chunkID == ASSBIN_CHUNK_AINODEANIM);
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AINODEANIM)
throw DeadlyImportError("Magic chunk identifiers are wrong!");
/*uint32_t size =*/ Read<uint32_t>(stream);
nd->mNodeName = Read<aiString>(stream);
@ -508,9 +509,8 @@ void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd) {
// -----------------------------------------------------------------------------------
void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim ) {
uint32_t chunkID = Read<uint32_t>(stream);
(void)(chunkID);
ai_assert(chunkID == ASSBIN_CHUNK_AIANIMATION);
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AIANIMATION)
throw DeadlyImportError("Magic chunk identifiers are wrong!");
/*uint32_t size =*/ Read<uint32_t>(stream);
anim->mName = Read<aiString> (stream);
@ -529,9 +529,8 @@ void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim ) {
// -----------------------------------------------------------------------------------
void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) {
uint32_t chunkID = Read<uint32_t>(stream);
(void)(chunkID);
ai_assert(chunkID == ASSBIN_CHUNK_AITEXTURE);
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AITEXTURE)
throw DeadlyImportError("Magic chunk identifiers are wrong!");
/*uint32_t size =*/ Read<uint32_t>(stream);
tex->mWidth = Read<unsigned int>(stream);
@ -551,9 +550,8 @@ void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) {
// -----------------------------------------------------------------------------------
void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l ) {
uint32_t chunkID = Read<uint32_t>(stream);
(void)(chunkID);
ai_assert(chunkID == ASSBIN_CHUNK_AILIGHT);
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AILIGHT)
throw DeadlyImportError("Magic chunk identifiers are wrong!");
/*uint32_t size =*/ Read<uint32_t>(stream);
l->mName = Read<aiString>(stream);
@ -577,9 +575,8 @@ void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l ) {
// -----------------------------------------------------------------------------------
void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam ) {
uint32_t chunkID = Read<uint32_t>(stream);
(void)(chunkID);
ai_assert(chunkID == ASSBIN_CHUNK_AICAMERA);
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AICAMERA)
throw DeadlyImportError("Magic chunk identifiers are wrong!");
/*uint32_t size =*/ Read<uint32_t>(stream);
cam->mName = Read<aiString>(stream);
@ -594,9 +591,8 @@ void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam ) {
// -----------------------------------------------------------------------------------
void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
uint32_t chunkID = Read<uint32_t>(stream);
(void)(chunkID);
ai_assert(chunkID == ASSBIN_CHUNK_AISCENE);
if(Read<uint32_t>(stream) != ASSBIN_CHUNK_AISCENE)
throw DeadlyImportError("Magic chunk identifiers are wrong!");
/*uint32_t size =*/ Read<uint32_t>(stream);
scene->mFlags = Read<unsigned int>(stream);
@ -614,6 +610,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
// Read all meshes
if (scene->mNumMeshes) {
scene->mMeshes = new aiMesh*[scene->mNumMeshes];
memset(scene->mMeshes, 0, scene->mNumMeshes*sizeof(aiMesh*));
for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
scene->mMeshes[i] = new aiMesh();
ReadBinaryMesh( stream,scene->mMeshes[i]);
@ -623,6 +620,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
// Read materials
if (scene->mNumMaterials) {
scene->mMaterials = new aiMaterial*[scene->mNumMaterials];
memset(scene->mMaterials, 0, scene->mNumMaterials*sizeof(aiMaterial*));
for (unsigned int i = 0; i< scene->mNumMaterials; ++i) {
scene->mMaterials[i] = new aiMaterial();
ReadBinaryMaterial(stream,scene->mMaterials[i]);
@ -632,6 +630,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
// Read all animations
if (scene->mNumAnimations) {
scene->mAnimations = new aiAnimation*[scene->mNumAnimations];
memset(scene->mAnimations, 0, scene->mNumAnimations*sizeof(aiAnimation*));
for (unsigned int i = 0; i < scene->mNumAnimations;++i) {
scene->mAnimations[i] = new aiAnimation();
ReadBinaryAnim(stream,scene->mAnimations[i]);
@ -641,6 +640,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
// Read all textures
if (scene->mNumTextures) {
scene->mTextures = new aiTexture*[scene->mNumTextures];
memset(scene->mTextures, 0, scene->mNumTextures*sizeof(aiTexture*));
for (unsigned int i = 0; i < scene->mNumTextures;++i) {
scene->mTextures[i] = new aiTexture();
ReadBinaryTexture(stream,scene->mTextures[i]);
@ -650,6 +650,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
// Read lights
if (scene->mNumLights) {
scene->mLights = new aiLight*[scene->mNumLights];
memset(scene->mLights, 0, scene->mNumLights*sizeof(aiLight*));
for (unsigned int i = 0; i < scene->mNumLights;++i) {
scene->mLights[i] = new aiLight();
ReadBinaryLight(stream,scene->mLights[i]);
@ -659,6 +660,7 @@ void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) {
// Read cameras
if (scene->mNumCameras) {
scene->mCameras = new aiCamera*[scene->mNumCameras];
memset(scene->mCameras, 0, scene->mNumCameras*sizeof(aiCamera*));
for (unsigned int i = 0; i < scene->mNumCameras;++i) {
scene->mCameras[i] = new aiCamera();
ReadBinaryCamera(stream,scene->mCameras[i]);
@ -675,7 +677,7 @@ void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
}
// signature
stream->Seek( 44, aiOrigin_CUR );
stream->Seek( 44, aiOrigin_CUR );
unsigned int versionMajor = Read<unsigned int>(stream);
unsigned int versionMinor = Read<unsigned int>(stream);
@ -701,11 +703,19 @@ void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
uLongf compressedSize = static_cast<uLongf>(stream->FileSize() - stream->Tell());
unsigned char * compressedData = new unsigned char[ compressedSize ];
stream->Read( compressedData, 1, compressedSize );
size_t len = stream->Read( compressedData, 1, compressedSize );
ai_assert(len == compressedSize);
unsigned char * uncompressedData = new unsigned char[ uncompressedSize ];
uncompress( uncompressedData, &uncompressedSize, compressedData, compressedSize );
int res = uncompress( uncompressedData, &uncompressedSize, compressedData, len );
if(res != Z_OK)
{
delete [] uncompressedData;
delete [] compressedData;
pIOHandler->Close(stream);
throw DeadlyImportError("Zlib decompression failed.");
}
MemoryIOStream io( uncompressedData, uncompressedSize );

View File

@ -191,6 +191,14 @@ SET( Common_SRCS
)
SOURCE_GROUP(Common FILES ${Common_SRCS})
SET( STEPParser_SRCS
Importer/STEPParser/STEPFileReader.h
Importer/STEPParser/STEPFileReader.cpp
Importer/STEPParser/STEPFileEncoding.cpp
Importer/STEPParser/STEPFileEncoding.h
)
SOURCE_GROUP(STEPParser FILES ${STEPParser_SRCS})
IF ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER )
SET( C4D_SRCS
C4DImporter.cpp
@ -487,11 +495,8 @@ ADD_ASSIMP_IMPORTER( IFC
Importer/IFC/IFCCurve.cpp
Importer/IFC/IFCBoolean.cpp
Importer/IFC/IFCOpenings.cpp
Importer/IFC/STEPFileReader.h
Importer/IFC/STEPFileReader.cpp
Importer/IFC/STEPFileEncoding.cpp
Importer/IFC/STEPFileEncoding.h
)
if (ASSIMP_BUILD_IFC_IMPORTER)
if (MSVC)
set_source_files_properties(Importer/IFC/IFCReaderGen1_2x3.cpp Importer/IFC/IFCReaderGen2_2x3.cpp PROPERTIES COMPILE_FLAGS "/bigobj")
@ -885,6 +890,7 @@ SET( assimp_src
${Exporter_SRCS}
${PostProcessing_SRCS}
${MaterialSystem_SRCS}
${STEPParser_SRCS}
${Step_SRCS}
# Model Support

View File

@ -419,8 +419,6 @@ private:
} //namespace D3MF
static const std::string Extension = "3mf";
static const aiImporterDesc desc = {
"3mf Importer",
"",
@ -431,7 +429,7 @@ static const aiImporterDesc desc = {
0,
0,
0,
Extension.c_str()
"3mf"
};
D3MFImporter::D3MFImporter()
@ -445,7 +443,7 @@ D3MFImporter::~D3MFImporter() {
bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bool checkSig) const {
const std::string extension( GetExtension( filename ) );
if(extension == Extension ) {
if(extension == desc.mFileExtensions ) {
return true;
} else if ( !extension.length() || checkSig ) {
if ( nullptr == pIOHandler ) {

View File

@ -55,28 +55,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultLogger.hpp>
namespace Assimp {
namespace DXF {
namespace DXF {
// read pairs of lines, parse group code and value and provide utilities
// to convert the data to the target data type.
class LineReader
{
// do NOT skip empty lines. In DXF files, they count as valid data.
class LineReader {
public:
LineReader(StreamReaderLE& reader)
// do NOT skip empty lines. In DXF files, they count as valid data.
: splitter(reader,false,true)
, groupcode( 0 )
, value()
, end()
{
: splitter(reader,false,true)
, groupcode( 0 )
, value()
, end() {
// empty
}
public:
// -----------------------------------------
bool Is(int gc, const char* what) const {
return groupcode == gc && !strcmp(what,value.c_str());
@ -102,8 +95,6 @@ public:
return !((bool)*this);
}
public:
// -----------------------------------------
unsigned int ValueAsUnsignedInt() const {
return strtoul10(value.c_str());
@ -119,8 +110,6 @@ public:
return fast_atof(value.c_str());
}
public:
// -----------------------------------------
/** pseudo-iterator increment to advance to the next (groupcode/value) pair */
LineReader& operator++() {
@ -175,14 +164,12 @@ private:
int end;
};
// represents a POLYLINE or a LWPOLYLINE. or even a 3DFACE The data is converted as needed.
struct PolyLine
{
struct PolyLine {
PolyLine()
: flags()
{}
: flags() {
// empty
}
std::vector<aiVector3D> positions;
std::vector<aiColor4D> colors;
@ -194,14 +181,15 @@ struct PolyLine
std::string desc;
};
// reference to a BLOCK. Specifies its own coordinate system.
struct InsertBlock
{
struct InsertBlock {
InsertBlock()
: scale(1.f,1.f,1.f)
, angle()
{}
: pos()
, scale(1.f,1.f,1.f)
, angle()
, name() {
// empty
}
aiVector3D pos;
aiVector3D scale;
@ -228,9 +216,7 @@ struct FileData
std::vector<Block> blocks;
};
}
} // Namespace Assimp
}}
#endif

View File

@ -63,16 +63,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
// AutoCAD Binary DXF<CR><LF><SUB><NULL>
#define AI_DXF_BINARY_IDENT ("AutoCAD Binary DXF\r\n\x1a\0")
#define AI_DXF_BINARY_IDENT_LEN (24)
const std::string AI_DXF_BINARY_IDENT = std::string("AutoCAD Binary DXF\r\n\x1a\0");
const size_t AI_DXF_BINARY_IDENT_LEN = 24u;
// default vertex color that all uncolored vertices will receive
#define AI_DXF_DEFAULT_COLOR aiColor4D(0.6f,0.6f,0.6f,0.6f)
const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f));
// color indices for DXF - 16 are supported, the table is
// taken directly from the DXF spec.
static aiColor4D g_aclrDxfIndexColors[] =
{
static aiColor4D g_aclrDxfIndexColors[] = {
aiColor4D (0.6f, 0.6f, 0.6f, 1.0f),
aiColor4D (1.0f, 0.0f, 0.0f, 1.0f), // red
aiColor4D (0.0f, 1.0f, 0.0f, 1.0f), // green
@ -93,6 +92,10 @@ static aiColor4D g_aclrDxfIndexColors[] =
#define AI_DXF_NUM_INDEX_COLORS (sizeof(g_aclrDxfIndexColors)/sizeof(g_aclrDxfIndexColors[0]))
#define AI_DXF_ENTITIES_MAGIC_BLOCK "$ASSIMP_ENTITIES_MAGIC"
static const int GroupCode_Name = 2;
static const int GroupCode_XComp = 10;
static const int GroupCode_YComp = 20;
static const int GroupCode_ZComp = 30;
static const aiImporterDesc desc = {
"Drawing Interchange Format (DXF) Importer",
@ -110,24 +113,27 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
DXFImporter::DXFImporter()
{}
: BaseImporter() {
// empty
}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
DXFImporter::~DXFImporter()
{}
DXFImporter::~DXFImporter() {
// empty
}
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool DXFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig ) const {
const std::string& extension = GetExtension( pFile );
if ( extension == "dxf" ) {
bool DXFImporter::CanRead( const std::string& filename, IOSystem* pIOHandler, bool checkSig ) const {
const std::string& extension = GetExtension( filename );
if ( extension == desc.mFileExtensions ) {
return true;
}
if ( extension.empty() || checkSig ) {
static const char *pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" };
return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 4, 32 );
const char *pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" };
return BaseImporter::SearchFileHeaderForToken(pIOHandler, filename, pTokens, 4, 32 );
}
return false;
@ -135,29 +141,25 @@ bool DXFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
// ------------------------------------------------------------------------------------------------
// Get a list of all supported file extensions
const aiImporterDesc* DXFImporter::GetInfo () const
{
const aiImporterDesc* DXFImporter::GetInfo () const {
return &desc;
}
// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
void DXFImporter::InternReadFile( const std::string& pFile,
aiScene* pScene,
IOSystem* pIOHandler)
{
std::shared_ptr<IOStream> file = std::shared_ptr<IOStream>( pIOHandler->Open( pFile) );
void DXFImporter::InternReadFile( const std::string& filename, aiScene* pScene, IOSystem* pIOHandler) {
std::shared_ptr<IOStream> file = std::shared_ptr<IOStream>( pIOHandler->Open( filename) );
// Check whether we can read the file
if( file.get() == NULL) {
throw DeadlyImportError( "Failed to open DXF file " + pFile + "");
if( file.get() == nullptr ) {
throw DeadlyImportError( "Failed to open DXF file " + filename + "");
}
// check whether this is a binaray DXF file - we can't read binary DXF files :-(
// Check whether this is a binary DXF file - we can't read binary DXF files :-(
char buff[AI_DXF_BINARY_IDENT_LEN+1] = {0};
file->Read(buff,AI_DXF_BINARY_IDENT_LEN,1);
if (!strncmp(AI_DXF_BINARY_IDENT,buff,AI_DXF_BINARY_IDENT_LEN)) {
if (0 == strncmp(AI_DXF_BINARY_IDENT.c_str(),buff,AI_DXF_BINARY_IDENT_LEN)) {
throw DeadlyImportError("DXF: Binary files are not supported at the moment");
}
@ -226,13 +228,11 @@ void DXFImporter::InternReadFile( const std::string& pFile,
}
// ------------------------------------------------------------------------------------------------
void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output)
{
void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output) {
// the process of resolving all the INSERT statements can grow the
// poly-count excessively, so log the original number.
// XXX Option to import blocks as separate nodes?
if (!DefaultLogger::isNullLogger()) {
unsigned int vcount = 0, icount = 0;
for (const DXF::Block& bl : output.blocks) {
for (std::shared_ptr<const DXF::PolyLine> pl : bl.lines) {
@ -293,7 +293,7 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output)
}
}
if (!pScene->mNumMeshes) {
if ( 0 == pScene->mNumMeshes) {
throw DeadlyImportError("DXF: this file contains no 3d data");
}
@ -366,8 +366,7 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output)
// ------------------------------------------------------------------------------------------------
void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& blocks_by_name)
{
void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& blocks_by_name) {
for (const DXF::InsertBlock& insert : bl.insertions) {
// first check if the referenced blocks exists ...
@ -407,8 +406,7 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc
}
// ------------------------------------------------------------------------------------------------
void DXFImporter::GenerateMaterials(aiScene* pScene, DXF::FileData& /*output*/)
{
void DXFImporter::GenerateMaterials(aiScene* pScene, DXF::FileData& /*output*/) {
// generate an almost-white default material. Reason:
// the default vertex color is GREY, so we are
// already at Assimp's usual default color.
@ -433,8 +431,7 @@ void DXFImporter::GenerateMaterials(aiScene* pScene, DXF::FileData& /*output*/)
}
// ------------------------------------------------------------------------------------------------
void DXFImporter::GenerateHierarchy(aiScene* pScene, DXF::FileData& /*output*/)
{
void DXFImporter::GenerateHierarchy(aiScene* pScene, DXF::FileData& /*output*/) {
// generate the output scene graph, which is just the root node with a single child for each layer.
pScene->mRootNode = new aiNode();
pScene->mRootNode->mName.Set("<DXF_ROOT>");
@ -488,17 +485,17 @@ void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output) {
while( !reader.End() && !reader.Is(0,"ENDBLK")) {
switch(reader.GroupCode()) {
case 2:
case GroupCode_Name:
block.name = reader.Value();
break;
case 10:
case GroupCode_XComp:
block.base.x = reader.ValueAsFloat();
break;
case 20:
case GroupCode_YComp:
block.base.y = reader.ValueAsFloat();
break;
case 30:
case GroupCode_ZComp:
block.base.z = reader.ValueAsFloat();
break;
}
@ -525,9 +522,8 @@ void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output) {
}
// ------------------------------------------------------------------------------------------------
void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output)
{
// push a new block onto the stack.
void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output) {
// Push a new block onto the stack.
output.blocks.push_back( DXF::Block() );
DXF::Block& block = output.blocks.back();
@ -557,27 +553,25 @@ void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output)
" inserted blocks in ENTITIES" );
}
void DXFImporter::ParseInsertion(DXF::LineReader& reader, DXF::FileData& output)
{
void DXFImporter::ParseInsertion(DXF::LineReader& reader, DXF::FileData& output) {
output.blocks.back().insertions.push_back( DXF::InsertBlock() );
DXF::InsertBlock& bl = output.blocks.back().insertions.back();
while( !reader.End() && !reader.Is(0)) {
switch(reader.GroupCode())
{
switch(reader.GroupCode()) {
// name of referenced block
case 2:
case GroupCode_Name:
bl.name = reader.Value();
break;
// translation
case 10:
case GroupCode_XComp:
bl.pos.x = reader.ValueAsFloat();
break;
case 20:
case GroupCode_YComp:
bl.pos.y = reader.ValueAsFloat();
break;
case 30:
case GroupCode_ZComp:
bl.pos.z = reader.ValueAsFloat();
break;
@ -704,8 +698,7 @@ void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output)
#define DXF_VERTEX_FLAG_HAS_POSITIONS 0x40
// ------------------------------------------------------------------------------------------------
void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& line)
{
void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& line) {
unsigned int cnti = 0, flags = 0;
unsigned int indices[4];
@ -718,8 +711,7 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li
break;
}
switch (reader.GroupCode())
{
switch (reader.GroupCode()) {
case 8:
// layer to which the vertex belongs to - assume that
// this is always the layer the top-level poly-line
@ -734,9 +726,17 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li
break;
// VERTEX COORDINATES
case 10: out.x = reader.ValueAsFloat();break;
case 20: out.y = reader.ValueAsFloat();break;
case 30: out.z = reader.ValueAsFloat();break;
case GroupCode_XComp:
out.x = reader.ValueAsFloat();
break;
case GroupCode_YComp:
out.y = reader.ValueAsFloat();
break;
case GroupCode_ZComp:
out.z = reader.ValueAsFloat();
break;
// POLYFACE vertex indices
case 71:
@ -770,6 +770,10 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li
if (indices[i] == 0) {
ASSIMP_LOG_WARN("DXF: invalid vertex index, indices are one-based.");
--line.counts.back();
// Workaround to fix issue 2229
if (line.counts.back() == 0) {
line.counts.pop_back();
}
continue;
}
line.indices.push_back(indices[i]-1);
@ -808,62 +812,74 @@ void DXFImporter::Parse3DFace(DXF::LineReader& reader, DXF::FileData& output)
break;
// x position of the first corner
case 10: vip[0].x = reader.ValueAsFloat();
case 10:
vip[0].x = reader.ValueAsFloat();
b[2] = true;
break;
// y position of the first corner
case 20: vip[0].y = reader.ValueAsFloat();
case 20:
vip[0].y = reader.ValueAsFloat();
b[2] = true;
break;
// z position of the first corner
case 30: vip[0].z = reader.ValueAsFloat();
case 30:
vip[0].z = reader.ValueAsFloat();
b[2] = true;
break;
// x position of the second corner
case 11: vip[1].x = reader.ValueAsFloat();
case 11:
vip[1].x = reader.ValueAsFloat();
b[3] = true;
break;
// y position of the second corner
case 21: vip[1].y = reader.ValueAsFloat();
case 21:
vip[1].y = reader.ValueAsFloat();
b[3] = true;
break;
// z position of the second corner
case 31: vip[1].z = reader.ValueAsFloat();
case 31:
vip[1].z = reader.ValueAsFloat();
b[3] = true;
break;
// x position of the third corner
case 12: vip[2].x = reader.ValueAsFloat();
case 12:
vip[2].x = reader.ValueAsFloat();
b[0] = true;
break;
// y position of the third corner
case 22: vip[2].y = reader.ValueAsFloat();
case 22:
vip[2].y = reader.ValueAsFloat();
b[0] = true;
break;
// z position of the third corner
case 32: vip[2].z = reader.ValueAsFloat();
case 32:
vip[2].z = reader.ValueAsFloat();
b[0] = true;
break;
// x position of the fourth corner
case 13: vip[3].x = reader.ValueAsFloat();
case 13:
vip[3].x = reader.ValueAsFloat();
b[1] = true;
break;
// y position of the fourth corner
case 23: vip[3].y = reader.ValueAsFloat();
case 23:
vip[3].y = reader.ValueAsFloat();
b[1] = true;
break;
// z position of the fourth corner
case 33: vip[3].z = reader.ValueAsFloat();
case 33:
vip[3].z = reader.ValueAsFloat();
b[1] = true;
break;

View File

@ -50,32 +50,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <map>
namespace Assimp {
namespace DXF {
class LineReader;
struct FileData;
struct PolyLine;
struct Block;
struct InsertBlock;
typedef std::map<std::string, const DXF::Block*> BlockMap;
}
// Forward declarations
namespace DXF {
class LineReader;
struct FileData;
struct PolyLine;
struct Block;
struct InsertBlock;
typedef std::map<std::string, const DXF::Block*> BlockMap;
}
// ---------------------------------------------------------------------------
/** DXF importer implementation.
*
*/
class DXFImporter : public BaseImporter
{
/**
* @brief DXF importer implementation.
*/
class DXFImporter : public BaseImporter {
public:
DXFImporter();
~DXFImporter();
public:
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
* See BaseImporter::CanRead() for details. */
@ -83,7 +78,6 @@ public:
bool checkSig) const;
protected:
// -------------------------------------------------------------------
/** Return importer meta information.
* See #BaseImporter::GetInfo for the details*/

View File

@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
#include "IFCLoader.h"
#include "STEPFileReader.h"
#include "../STEPParser/STEPFileReader.h"
#include "IFCUtil.h"

View File

@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_STEPFILE_IMPORTER
#include "StepFileImporter.h"
#include "../../Importer/IFC/STEPFileReader.h"
#include "../../Importer/STEPParser/STEPFileReader.h"
#include <assimp/importerdesc.h>
#include <assimp/DefaultIOSystem.h>

View File

@ -413,8 +413,9 @@ void MDLImporter::InternReadFile_Quake1() {
#if 1
// FIXME: the cast is wrong and cause a warning on clang 5.0
// disable thi code for now, fix it later
// disable this code for now, fix it later
ai_assert(false && "Bad pointer cast");
pcFirstFrame = nullptr; // Workaround: msvc++ C4703 error
#else
BE_NCONST MDL::GroupFrame* pcFrames2 = (BE_NCONST MDL::GroupFrame*)pcFrames;
pcFirstFrame = (BE_NCONST MDL::SimpleFrame*)(&pcFrames2->time + pcFrames->type);

View File

@ -181,8 +181,7 @@ void MS3DImporter :: CollectChildJoints(const std::vector<TempJoint>& joints,
ch->mParent = nd;
ch->mTransformation = aiMatrix4x4::Translation(joints[i].position,aiMatrix4x4()=aiMatrix4x4())*
// XXX actually, I don't *know* why we need the inverse here. Probably column vs. row order?
aiMatrix4x4().FromEulerAnglesXYZ(joints[i].rotation).Transpose();
aiMatrix4x4().FromEulerAnglesXYZ(joints[i].rotation);
const aiMatrix4x4 abs = absTrafo*ch->mTransformation;
for(unsigned int a = 0; a < mScene->mNumMeshes; ++a) {
@ -639,11 +638,8 @@ void MS3DImporter::InternReadFile( const std::string& pFile,
aiQuatKey& q = nd->mRotationKeys[nd->mNumRotationKeys++];
q.mTime = (*rot).time*animfps;
// XXX it seems our matrix&quaternion code has faults in its conversion routines --
// aiQuaternion(x,y,z) seems to besomething different as quat(matrix.fromeuler(x,y,z)).
q.mValue = aiQuaternion(aiMatrix3x3(aiMatrix4x4().FromEulerAnglesXYZ((*rot).value)*
aiMatrix4x4().FromEulerAnglesXYZ((*it).rotation)).Transpose());
q.mValue = aiQuaternion(aiMatrix3x3(aiMatrix4x4().FromEulerAnglesXYZ((*it).rotation)*
aiMatrix4x4().FromEulerAnglesXYZ((*rot).value)));
}
}

File diff suppressed because it is too large Load Diff

View File

@ -219,6 +219,7 @@ protected:
/** Parse the SMD file and create the output scene
*/
void ParseFile();
void ReadSmd(const std::string &pFile, IOSystem* pIOHandler);
// -------------------------------------------------------------------
/** Parse the triangles section of the SMD file
@ -289,13 +290,6 @@ protected:
*/
unsigned int GetTextureIndex(const std::string& filename);
// -------------------------------------------------------------------
/** Computes absolute bone transformations
* All output transformations are in worldspace.
*/
void ComputeAbsoluteBoneTransformations();
// -------------------------------------------------------------------
/** Parse a line in the skeleton section
*/
@ -344,7 +338,9 @@ protected:
*/
void CreateOutputMeshes();
void CreateOutputNodes();
void CreateOutputAnimations();
void CreateOutputAnimations(const std::string &pFile, IOSystem* pIOHandler);
void CreateOutputAnimation(int index, const std::string &name);
void GetAnimationFileList(const std::string &pFile, IOSystem* pIOHandler, std::vector<std::tuple<std::string, std::string>>& outList);
void CreateOutputMaterials();
@ -413,6 +409,8 @@ private:
*/
unsigned int iLineNumber;
bool bLoadAnimationList = true;
bool noSkeletonMesh = false;
};
} // end of namespace Assimp

View File

@ -142,7 +142,7 @@ namespace STEP {
struct TypeError : DeadlyImportError {
enum {
ENTITY_NOT_SPECIFIED = 0xffffffffffffffffLL,
ENTITY_NOT_SPECIFIED_32 = -1u
ENTITY_NOT_SPECIFIED_32 = 0x00000000ffffffff
};
TypeError (const std::string& s,uint64_t entity = ENTITY_NOT_SPECIFIED, uint64_t line = SyntaxError::LINE_NOT_SPECIFIED);

View File

@ -1357,6 +1357,13 @@ inline void Asset::Load(const std::string& pFile, bool isBinary)
}
}
// Force reading of skins since they're not always directly referenced
if (Value* skinsArray = FindArray(doc, "skins")) {
for (unsigned int i = 0; i < skinsArray->Size(); ++i) {
skins.Retrieve(i);
}
}
if (Value* animsArray = FindArray(doc, "animations")) {
for (unsigned int i = 0; i < animsArray->Size(); ++i) {
animations.Retrieve(i);

View File

@ -59,32 +59,10 @@ bool isSeparator( T in ) {
return false;
}
static const unsigned char chartype_table[ 256 ] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0-15
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 32-47
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, // 48-63
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 64-79
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80-95
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 96-111
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 112-127
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // > 127
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
template<class T>
inline
bool isNumeric( const T in ) {
return ( chartype_table[ static_cast<size_t>( in ) ] == 1 );
return ( in >= '0' && in <= '9' );
}
template<class T>

View File

@ -1486,9 +1486,8 @@ Just copy'n'paste the template from Appendix A and adapt it for your needs.
with DefaultLogger::get()->[error, warn, debug, info].
</li>
<li>
Make sure that your loader compiles against all build configurations on all supported platforms. This includes <i>-noboost</i>! To avoid problems,
see the boost section on this page for a list of all 'allowed' boost classes (again, this grew historically when we had to accept that boost
is not THAT widely spread that one could rely on it being available everywhere).
Make sure that your loader compiles against all build configurations on all supported platforms. You can use our CI-build to check several platforms
like Windows and Linux ( 32 bit and 64 bit ).
</li>
<li>
Provide some _free_ test models in <tt>&lt;root&gt;/test/models/&lt;FormatName&gt;/</tt> and credit their authors.
@ -1567,22 +1566,6 @@ NewMaterial->AddProperty(&aiString(MaterialName.c_str()), AI_MATKEY_NAME);//Mate
NewMaterial->AddProperty(&aiString(Texturename.c_str()), AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0));//again, Texturename is a std::string
@endcode
@section boost Boost
The boost whitelist:
<ul>
<li><i>boost.scoped_ptr</i></li>
<li><i>boost.scoped_array</i></li>
<li><i>boost.format</i> </li>
<li><i>boost.random</i> </li>
<li><i>boost.common_factor</i> </li>
<li><i>boost.foreach</i> </li>
<li><i>boost.tuple</i></li>
</ul>
(if you happen to need something else, i.e. boost::thread, make this an optional feature.
<tt>assimp_BUILD_BOOST_WORKAROUND</tt> is defined for <i>-noboost</i> builds)
@section appa Appendix A - Template for BaseImporter's abstract methods
@code

View File

@ -80,7 +80,9 @@ public:
// -------------------------------------------------------------------
// Read from stream
size_t Read(void* pvBuffer, size_t pSize, size_t pCount) {
const size_t cnt = std::min(pCount,(length-pos)/pSize),ofs = pSize*cnt;
ai_assert(pvBuffer);
ai_assert(pSize);
const size_t cnt = std::min(pCount,(length-pos)/pSize), ofs = pSize*cnt;
memcpy(pvBuffer,buffer+pos,ofs);
pos += ofs;

View File

@ -63,8 +63,7 @@ public:
aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a)
: r(_r), g(_g), b(_b), a(_a) {}
explicit aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {}
aiColor4t (const aiColor4t& o)
: r(o.r), g(o.g), b(o.b), a(o.a) {}
aiColor4t (const aiColor4t& o) = default;
public:
// combined operators

View File

@ -673,6 +673,12 @@ enum aiComponent
#define AI_CONFIG_IMPORT_SMD_KEYFRAME "IMPORT_SMD_KEYFRAME"
#define AI_CONFIG_IMPORT_UNREAL_KEYFRAME "IMPORT_UNREAL_KEYFRAME"
// ---------------------------------------------------------------------------
/** Smd load multiple animations
*
* Property type: bool. Default value: true.
*/
#define AI_CONFIG_IMPORT_SMD_LOAD_ANIMATION_LIST "IMPORT_SMD_LOAD_ANIMATION_LIST"
// ---------------------------------------------------------------------------
/** @brief Configures the AC loader to collect all surfaces which have the

View File

@ -527,27 +527,25 @@ inline aiMatrix4x4t<TReal>& aiMatrix4x4t<TReal>::FromEulerAnglesXYZ(TReal x, TRe
{
aiMatrix4x4t<TReal>& _this = *this;
TReal cr = std::cos( x );
TReal sr = std::sin( x );
TReal cp = std::cos( y );
TReal sp = std::sin( y );
TReal cy = std::cos( z );
TReal sy = std::sin( z );
TReal cx = std::cos(x);
TReal sx = std::sin(x);
TReal cy = std::cos(y);
TReal sy = std::sin(y);
TReal cz = std::cos(z);
TReal sz = std::sin(z);
_this.a1 = cp*cy ;
_this.a2 = cp*sy;
_this.a3 = -sp ;
// mz*my*mx
_this.a1 = cz * cy;
_this.a2 = cz * sy * sx - sz * cx;
_this.a3 = sz * sx + cz * sy * cx;
TReal srsp = sr*sp;
TReal crsp = cr*sp;
_this.b1 = sz * cy;
_this.b2 = cz * cx + sz * sy * sx;
_this.b3 = sz * sy * cx - cz * sx;
_this.b1 = srsp*cy-cr*sy ;
_this.b2 = srsp*sy+cr*cy ;
_this.b3 = sr*cp ;
_this.c1 = crsp*cy+sr*sy ;
_this.c2 = crsp*sy-sr*cy ;
_this.c3 = cr*cp ;
_this.c1 = -sy;
_this.c2 = cy * sx;
_this.c3 = cy * cx;
return *this;
}

View File

@ -66,8 +66,8 @@ public:
aiVector2t () : x(), y() {}
aiVector2t (TReal _x, TReal _y) : x(_x), y(_y) {}
explicit aiVector2t (TReal _xyz) : x(_xyz), y(_xyz) {}
aiVector2t (const aiVector2t& o) : x(o.x), y(o.y) {}
aiVector2t (const aiVector2t& o) = default;
void Set( TReal pX, TReal pY);
TReal SquareLength() const ;
TReal Length() const ;

View File

@ -69,7 +69,7 @@ public:
aiVector3t() AI_NO_EXCEPT : x(), y(), z() {}
aiVector3t(TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {}
explicit aiVector3t (TReal _xyz ) : x(_xyz), y(_xyz), z(_xyz) {}
aiVector3t( const aiVector3t& o ) : x(o.x), y(o.y), z(o.z) {}
aiVector3t( const aiVector3t& o ) = default;
public:

File diff suppressed because it is too large Load Diff

View File

@ -69,3 +69,8 @@ TEST_F( utDXFImporterExporter, importerWithoutExtensionTest ) {
EXPECT_NE( nullptr, scene );
}
TEST_F(utDXFImporterExporter, issue2229) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/DXF/issue_2229.dxf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}

View File

@ -82,15 +82,18 @@ void CompressBinaryDump(const char* file, unsigned int head_size)
uint8_t* data = new uint8_t[size];
fread(data,1,size,p);
uLongf out_size = (uLongf)((size-head_size) * 1.001 + 12.);
uint32_t uncompressed_size = size-head_size;
uLongf out_size = (uLongf)compressBound(uncompressed_size);
uint8_t* out = new uint8_t[out_size];
compress2(out,&out_size,data+head_size,size-head_size,9);
int res = compress2(out,&out_size,data+head_size,uncompressed_size,9);
if(res != Z_OK)
fprintf(stderr, "compress2: error\n");
fclose(p);
p = fopen(file,"w");
fwrite(data,head_size,1,p);
fwrite(&out_size,4,1,p); // write size of uncompressed data
fwrite(&uncompressed_size,4,1,p); // write size of uncompressed data
fwrite(out,out_size,1,p);
fclose(p);