pull/1431/head
Kim Kulling 2017-09-12 19:07:21 +02:00
commit b5f770e456
38 changed files with 1725 additions and 206 deletions

7
.gitattributes vendored
View File

@ -13,3 +13,10 @@ CHANGES text eol=lf
CREDITS text eol=lf
LICENSE text eol=lf
Readme.md text eol=lf
# make sure that repo-specific settings (.gitignore, CI-setup,...)
# are excluded from the source-package generated via 'git archive'
.git* export-ignore
/.travis* export-ignore
/.coveralls* export-ignore
appveyor.yml export-ignore

View File

@ -28,14 +28,16 @@ env:
- secure: "lZ7pHQvl5dpZWzBQAaIMf0wqrvtcZ4wiZKeIZjf83TEsflW8+z0uTpIuN30ZV6Glth/Sq1OhLnTP5+N57fZU/1ebA5twHdvP4bS5CIUUg71/CXQZNl36xeaqvxsG/xRrdpKOsPdjAOsQ9KPTQulsX43XDLS7CasMiLvYOpqKcPc="
- PV=r8e PLATF=linux-x86_64 NDK_HOME=${TRAVIS_BUILD_DIR}/android-ndk-${PV} PATH=${PATH}:${NDK_HOME}
matrix:
- LINUX=1 TRAVIS_NO_EXPORT=YES ENABLE_COVERALLS=ON
- LINUX=1 TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF
- LINUX=1 SHARED_BUILD=ON ENABLE_COVERALLS=OFF
- LINUX=1 SHARED_BUILD=OFF ENABLE_COVERALLS=OFF
compiler:
- gcc
- clang
- os: linux LINUX=1 TRAVIS_NO_EXPORT=YES ENABLE_COVERALLS=ON
compiler: gcc
- os: linux LINUX=1 TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF
compiler: clang
- os: linux LINUX=1 SHARED_BUILD=ON TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF
compiler: gcc
- os: linux LINUX=1 SHARED_BUILD=ON TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF
compiler: clang
- os: osx
osx_image: xcode8.2
install:
- if [ $ANDROID ]; then wget -c http://dl.google.com/android/ndk/android-ndk-${PV}-${PLATF}.tar.bz2 && tar xf android-ndk-${PV}-${PLATF}.tar.bz2 ; fi

View File

@ -148,6 +148,12 @@ find_package(OpenMP)
if (OPENMP_FOUND)
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
IF(MSVC)
IF(MSVC_VERSION GREATER 1910)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:twoPhase-")
ENDIF()
ENDIF()
endif()
CONFIGURE_FILE(

View File

@ -8,7 +8,6 @@ A library to import and export various 3d-model-formats including scene-post-pro
<img alt="Coverity Scan Build Status"
src="https://scan.coverity.com/projects/5607/badge.svg"/>
</a>
<span class="badge-patreon"><a href="https://www.patreon.com/assimp" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
[![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master)
[![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
<br>
@ -19,6 +18,11 @@ Additionally, assimp features various __mesh post processing tools__: normals an
This is the development repo containing the latest features and bugfixes. For productive use though, we recommend one of the stable releases available from [Github Assimp Releases](https://github.com/assimp/assimp/releases).
Monthly donations via Patreon:
<br>[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/assimp)
<br>
One-off donations via PayPal:
<br>[![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4)
@ -114,6 +118,8 @@ Take a look into the `INSTALL` file. Our build system is CMake, if you used CMak
* [.NET](port/AssimpNET/Readme.md)
* [Pascal](port/AssimpPascal/Readme.md)
* [Javascript (Alpha)](https://github.com/makc/assimp2json)
* [Unity 3d Plugin] (https://www.assetstore.unity3d.com/en/#!/content/91777)
* [JVM](https://github.com/kotlin-graphics/assimp) Full jvm port (currently supported obj, ply, stl, ~collada)
### Other tools ###
[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities.

View File

@ -56,18 +56,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
static const unsigned int NotSet = 0xcdcdcdcd;
// ------------------------------------------------------------------------------------------------
// Setup final material indices, generae a default material if necessary
void Discreet3DSImporter::ReplaceDefaultMaterial()
{
// Try to find an existing material that matches the
// typical default material setting:
// - no textures
// - diffuse color (in grey!)
// NOTE: This is here to workaround the fact that some
// exporters are writing a default material, too.
unsigned int idx = 0xcdcdcdcd;
unsigned int idx( NotSet );
for (unsigned int i = 0; i < mScene->mMaterials.size();++i)
{
std::string s = mScene->mMaterials[i].mName;
@ -93,7 +94,9 @@ void Discreet3DSImporter::ReplaceDefaultMaterial()
}
idx = i;
}
if (0xcdcdcdcd == idx)idx = (unsigned int)mScene->mMaterials.size();
if ( NotSet == idx ) {
idx = ( unsigned int )mScene->mMaterials.size();
}
// now iterate through all meshes and through all faces and
// find all faces that are using the default material

View File

@ -325,7 +325,7 @@ inline size_t WriteArray(IOStream * stream, const T* in, unsigned int size)
{
AssbinChunkWriter chunk( container, ASSBIN_CHUNK_AINODE );
size_t nb_metadata = (node->mMetaData != NULL ? node->mMetaData->mNumProperties : 0);
unsigned int nb_metadata = (node->mMetaData != NULL ? node->mMetaData->mNumProperties : 0);
Write<aiString>(&chunk,node->mName);
Write<aiMatrix4x4>(&chunk,node->mTransformation);

View File

@ -866,8 +866,8 @@ void ColladaExporter::WriteController( size_t pIndex)
std::vector<ai_real> bind_poses;
bind_poses.reserve(mesh->mNumBones * 16);
for( size_t i = 0; i < mesh->mNumBones; ++i)
for( size_t j = 0; j < 4; ++j)
for(unsigned int i = 0; i < mesh->mNumBones; ++i)
for( unsigned int j = 0; j < 4; ++j)
bind_poses.insert(bind_poses.end(), mesh->mBones[i]->mOffsetMatrix[j], mesh->mBones[i]->mOffsetMatrix[j] + 4);
WriteFloatArray( idstr + "-skin-bind_poses", FloatType_Mat4x4, (const ai_real*) bind_poses.data(), bind_poses.size() / 16);
@ -924,11 +924,11 @@ void ColladaExporter::WriteController( size_t pIndex)
ai_uint weight_index = 0;
std::vector<ai_int> joint_weight_indices(2 * joint_weight_indices_length, (ai_int)-1);
for( size_t i = 0; i < mesh->mNumBones; ++i)
for( size_t j = 0; j < mesh->mBones[i]->mNumWeights; ++j)
for( unsigned int i = 0; i < mesh->mNumBones; ++i)
for( unsigned j = 0; j < mesh->mBones[i]->mNumWeights; ++j)
{
unsigned int vId = mesh->mBones[i]->mWeights[j].mVertexId;
for( size_t k = 0; k < num_influences[vId]; ++k)
for( ai_uint k = 0; k < num_influences[vId]; ++k)
{
if (joint_weight_indices[2 * (accum_influences[vId] + k)] == -1)
{

View File

@ -728,7 +728,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada::
? aiMorphingMethod_MORPH_RELATIVE
: aiMorphingMethod_MORPH_NORMALIZED;
dstMesh->mAnimMeshes = new aiAnimMesh*[animMeshes.size()];
dstMesh->mNumAnimMeshes = animMeshes.size();
dstMesh->mNumAnimMeshes = static_cast<unsigned int>(animMeshes.size());
for (unsigned int i = 0; i < animMeshes.size(); i++)
dstMesh->mAnimMeshes[i] = animMeshes.at(i);
}
@ -1377,9 +1377,9 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
{
aiNodeAnim* dstAnim = new aiNodeAnim;
dstAnim->mNodeName = nodeName;
dstAnim->mNumPositionKeys = resultTrafos.size();
dstAnim->mNumRotationKeys= resultTrafos.size();
dstAnim->mNumScalingKeys = resultTrafos.size();
dstAnim->mNumPositionKeys = static_cast<unsigned int>(resultTrafos.size());
dstAnim->mNumRotationKeys = static_cast<unsigned int>(resultTrafos.size());
dstAnim->mNumScalingKeys = static_cast<unsigned int>(resultTrafos.size());
dstAnim->mPositionKeys = new aiVectorKey[resultTrafos.size()];
dstAnim->mRotationKeys = new aiQuatKey[resultTrafos.size()];
dstAnim->mScalingKeys = new aiVectorKey[resultTrafos.size()];
@ -1445,11 +1445,11 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
++morphAnimChannelIndex;
}
morphAnim->mNumKeys = morphTimeValues.size();
morphAnim->mNumKeys = static_cast<unsigned int>(morphTimeValues.size());
morphAnim->mKeys = new aiMeshMorphKey[morphAnim->mNumKeys];
for (unsigned int key = 0; key < morphAnim->mNumKeys; key++)
{
morphAnim->mKeys[key].mNumValuesAndWeights = morphChannels.size();
morphAnim->mKeys[key].mNumValuesAndWeights = static_cast<unsigned int>(morphChannels.size());
morphAnim->mKeys[key].mValues = new unsigned int [morphChannels.size()];
morphAnim->mKeys[key].mWeights = new double [morphChannels.size()];
@ -1470,13 +1470,13 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
{
aiAnimation* anim = new aiAnimation;
anim->mName.Set( pName);
anim->mNumChannels = anims.size();
anim->mNumChannels = static_cast<unsigned int>(anims.size());
if (anim->mNumChannels > 0)
{
anim->mChannels = new aiNodeAnim*[anims.size()];
std::copy( anims.begin(), anims.end(), anim->mChannels);
}
anim->mNumMorphMeshChannels = morphAnims.size();
anim->mNumMorphMeshChannels = static_cast<unsigned int>(morphAnims.size());
if (anim->mNumMorphMeshChannels > 0)
{
anim->mMorphMeshChannels = new aiMeshMorphAnim*[anim->mNumMorphMeshChannels];

View File

@ -2231,7 +2231,7 @@ void ColladaParser::ReadIndexData( Mesh* pMesh)
}
#ifdef ASSIMP_BUILD_DEBUG
if (primType != Prim_TriFans && primType != Prim_TriStrips &&
if (primType != Prim_TriFans && primType != Prim_TriStrips && primType != Prim_LineStrip &&
primType != Prim_Lines) { // this is ONLY to workaround a bug in SketchUp 15.3.331 where it writes the wrong 'count' when it writes out the 'lines'.
ai_assert(actualPrimitives == numPrimitives);
}
@ -2400,6 +2400,10 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pP
size_t numberOfVertices = indices.size() / numOffsets;
numPrimitives = numberOfVertices - 2;
}
if (pPrimType == Prim_LineStrip) {
size_t numberOfVertices = indices.size() / numOffsets;
numPrimitives = numberOfVertices - 1;
}
pMesh->mFaceSize.reserve( numPrimitives);
pMesh->mFacePosIndices.reserve( indices.size() / numOffsets);
@ -2416,6 +2420,11 @@ size_t ColladaParser::ReadPrimitives( Mesh* pMesh, std::vector<InputChannel>& pP
for (size_t currentVertex = 0; currentVertex < numPoints; currentVertex++)
CopyVertex(currentVertex, numOffsets, numPoints, perVertexOffset, pMesh, pPerIndexChannels, currentPrimitive, indices);
break;
case Prim_LineStrip:
numPoints = 2;
for (size_t currentVertex = 0; currentVertex < numPoints; currentVertex++)
CopyVertex(currentVertex, numOffsets, 1, perVertexOffset, pMesh, pPerIndexChannels, currentPrimitive, indices);
break;
case Prim_Triangles:
numPoints = 3;
for (size_t currentVertex = 0; currentVertex < numPoints; currentVertex++)

View File

@ -95,14 +95,10 @@ public:
XmlSerializer(XmlReader* xmlReader)
: xmlReader(xmlReader)
{
// empty
}
void ImportXml(aiScene* scene)
{
scene->mFlags |= AI_SCENE_FLAGS_NON_VERBOSE_FORMAT;
void ImportXml(aiScene* scene) {
scene->mRootNode = new aiNode();
std::vector<aiNode*> children;

View File

@ -56,47 +56,46 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
namespace FBX {
enum Flag
{
e_unknown_0 = 1 << 0,
e_unknown_1 = 1 << 1,
e_unknown_2 = 1 << 2,
e_unknown_3 = 1 << 3,
e_unknown_4 = 1 << 4,
e_unknown_5 = 1 << 5,
e_unknown_6 = 1 << 6,
e_unknown_7 = 1 << 7,
e_unknown_8 = 1 << 8,
e_unknown_9 = 1 << 9,
e_unknown_10 = 1 << 10,
e_unknown_11 = 1 << 11,
e_unknown_12 = 1 << 12,
e_unknown_13 = 1 << 13,
e_unknown_14 = 1 << 14,
e_unknown_15 = 1 << 15,
e_unknown_16 = 1 << 16,
e_unknown_17 = 1 << 17,
e_unknown_18 = 1 << 18,
e_unknown_19 = 1 << 19,
e_unknown_20 = 1 << 20,
e_unknown_21 = 1 << 21,
e_unknown_22 = 1 << 22,
e_unknown_23 = 1 << 23,
e_flag_field_size_64_bit = 1 << 24, // Not sure what is
e_unknown_25 = 1 << 25,
e_unknown_26 = 1 << 26,
e_unknown_27 = 1 << 27,
e_unknown_28 = 1 << 28,
e_unknown_29 = 1 << 29,
e_unknown_30 = 1 << 30,
e_unknown_31 = 1 << 31
};
bool check_flag(uint32_t flags, Flag to_check)
{
return (flags & to_check) != 0;
}
//enum Flag
//{
// e_unknown_0 = 1 << 0,
// e_unknown_1 = 1 << 1,
// e_unknown_2 = 1 << 2,
// e_unknown_3 = 1 << 3,
// e_unknown_4 = 1 << 4,
// e_unknown_5 = 1 << 5,
// e_unknown_6 = 1 << 6,
// e_unknown_7 = 1 << 7,
// e_unknown_8 = 1 << 8,
// e_unknown_9 = 1 << 9,
// e_unknown_10 = 1 << 10,
// e_unknown_11 = 1 << 11,
// e_unknown_12 = 1 << 12,
// e_unknown_13 = 1 << 13,
// e_unknown_14 = 1 << 14,
// e_unknown_15 = 1 << 15,
// e_unknown_16 = 1 << 16,
// e_unknown_17 = 1 << 17,
// e_unknown_18 = 1 << 18,
// e_unknown_19 = 1 << 19,
// e_unknown_20 = 1 << 20,
// e_unknown_21 = 1 << 21,
// e_unknown_22 = 1 << 22,
// e_unknown_23 = 1 << 23,
// e_flag_field_size_64_bit = 1 << 24, // Not sure what is
// e_unknown_25 = 1 << 25,
// e_unknown_26 = 1 << 26,
// e_unknown_27 = 1 << 27,
// e_unknown_28 = 1 << 28,
// e_unknown_29 = 1 << 29,
// e_unknown_30 = 1 << 30,
// e_unknown_31 = 1 << 31
//};
//
//bool check_flag(uint32_t flags, Flag to_check)
//{
// return (flags & to_check) != 0;
//}
// ------------------------------------------------------------------------------------------------
Token::Token(const char* sbegin, const char* send, TokenType type, unsigned int offset)
:
@ -341,10 +340,10 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input,
// ------------------------------------------------------------------------------------------------
bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor, const char* end, uint32_t const flags)
bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor, const char* end, bool const is64bits)
{
// the first word contains the offset at which this block ends
const uint64_t end_offset = /*check_flag(flags, e_flag_field_size_64_bit) ? ReadDoubleWord(input, cursor, end) : */ReadWord(input, cursor, end);
const uint64_t end_offset = is64bits ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end);
// we may get 0 if reading reached the end of the file -
// fbx files have a mysterious extra footer which I don't know
@ -362,10 +361,10 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
}
// the second data word contains the number of properties in the scope
const uint64_t prop_count = /*check_flag(flags, e_flag_field_size_64_bit) ? ReadDoubleWord(input, cursor, end) : */ReadWord(input, cursor, end);
const uint64_t prop_count = is64bits ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end);
// the third data word contains the length of the property list
const uint64_t prop_length = /*check_flag(flags, e_flag_field_size_64_bit) ? ReadDoubleWord(input, cursor, end) :*/ ReadWord(input, cursor, end);
const uint64_t prop_length = is64bits ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end);
// now comes the name of the scope/key
const char* sbeg, *send;
@ -392,7 +391,7 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
// at the end of each nested block, there is a NUL record to indicate
// that the sub-scope exists (i.e. to distinguish between P: and P : {})
// this NUL record is 13 bytes long on 32 bit version and 25 bytes long on 64 bit.
const size_t sentinel_block_length = /*check_flag(flags, e_flag_field_size_64_bit) ? (sizeof(uint64_t) * 3 + 1) : */(sizeof(uint32_t) * 3 + 1);
const size_t sentinel_block_length = is64bits ? (sizeof(uint64_t)* 3 + 1) : (sizeof(uint32_t)* 3 + 1);
if (Offset(input, cursor) < end_offset) {
if (end_offset - Offset(input, cursor) < sentinel_block_length) {
@ -403,7 +402,7 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
// XXX this is vulnerable to stack overflowing ..
while(Offset(input, cursor) < end_offset - sentinel_block_length) {
ReadScope(output_tokens, input, cursor, input + end_offset - sentinel_block_length, flags);
ReadScope(output_tokens, input, cursor, input + end_offset - sentinel_block_length, is64bits);
}
output_tokens.push_back(new_Token(cursor, cursor + 1, TokenType_CLOSE_BRACKET, Offset(input, cursor) ));
@ -426,6 +425,7 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
}
// ------------------------------------------------------------------------------------------------
// TODO: Test FBX Binary files newer than the 7500 version to check if the 64 bits address behaviour is consistent
void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int length)
{
ai_assert(input);
@ -438,19 +438,17 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int le
TokenizeError("magic bytes not found",0);
}
//uint32_t offset = 0x15;
const char* cursor = input + 0x15;
const uint32_t flags = ReadWord(input, cursor, input + length);
const uint8_t padding_0 = ReadByte(input, cursor, input + length); // unused
(void) padding_0;
const uint8_t padding_1 = ReadByte(input, cursor, input + length); // unused
(void) padding_1;
const char* cursor = input + 18;
const uint8_t unknown_1 = ReadByte(input, cursor, input + length);
const uint8_t unknown_2 = ReadByte(input, cursor, input + length);
const uint8_t unknown_3 = ReadByte(input, cursor, input + length);
const uint8_t unknown_4 = ReadByte(input, cursor, input + length);
const uint8_t unknown_5 = ReadByte(input, cursor, input + length);
const uint32_t version = ReadWord(input, cursor, input + length);
const bool is64bits = version >= 7500;
while (cursor < input + length)
{
if(!ReadScope(output_tokens, input, cursor, input + length, flags)) {
if (!ReadScope(output_tokens, input, cursor, input + length, is64bits)) {
break;
}
}

View File

@ -2367,8 +2367,13 @@ void Converter::ConvertAnimationStack( const AnimationStack& st )
int64_t start_time = st.LocalStart();
int64_t stop_time = st.LocalStop();
double start_timeF = CONVERT_FBX_TIME( start_time );
double stop_timeF = CONVERT_FBX_TIME( stop_time );
bool has_local_startstop = start_time != 0 || stop_time != 0;
if ( !has_local_startstop ) {
// no time range given, so accept every keyframe and use the actual min/max time
// the numbers are INT64_MIN/MAX, the 20000 is for safety because GenerateNodeAnimations uses an epsilon of 10000
start_time = -9223372036854775807ll + 20000;
stop_time = 9223372036854775807ll - 20000;
}
try {
for( const NodeMap::value_type& kv : node_map ) {
@ -2400,27 +2405,23 @@ void Converter::ConvertAnimationStack( const AnimationStack& st )
return;
}
//adjust relative timing for animation
{
double start_fps = start_timeF * anim_fps;
double start_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(start_time) * anim_fps) : min_time;
double stop_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(stop_time) * anim_fps) : max_time;
for ( unsigned int c = 0; c < anim->mNumChannels; c++ )
{
aiNodeAnim* channel = anim->mChannels[ c ];
for ( uint32_t i = 0; i < channel->mNumPositionKeys; i++ )
channel->mPositionKeys[ i ].mTime -= start_fps;
for ( uint32_t i = 0; i < channel->mNumRotationKeys; i++ )
channel->mRotationKeys[ i ].mTime -= start_fps;
for ( uint32_t i = 0; i < channel->mNumScalingKeys; i++ )
channel->mScalingKeys[ i ].mTime -= start_fps;
}
max_time -= min_time;
// adjust relative timing for animation
for ( unsigned int c = 0; c < anim->mNumChannels; c++ ) {
aiNodeAnim* channel = anim->mChannels[ c ];
for ( uint32_t i = 0; i < channel->mNumPositionKeys; i++ )
channel->mPositionKeys[ i ].mTime -= start_time_fps;
for ( uint32_t i = 0; i < channel->mNumRotationKeys; i++ )
channel->mRotationKeys[ i ].mTime -= start_time_fps;
for ( uint32_t i = 0; i < channel->mNumScalingKeys; i++ )
channel->mScalingKeys[ i ].mTime -= start_time_fps;
}
// for some mysterious reason, mDuration is simply the maximum key -- the
// validator always assumes animations to start at zero.
anim->mDuration = ( stop_timeF - start_timeF ) * anim_fps;
anim->mDuration = stop_time_fps - start_time_fps;
anim->mTicksPerSecond = anim_fps;
}

View File

@ -128,7 +128,7 @@ void ProcessParametrizedProfile(const IfcParameterizedProfileDef& def, TempMesh&
meshout.verts.push_back( IfcVector3( std::cos(angle)*radius, std::sin(angle)*radius, 0.f ));
}
meshout.vertcnt.push_back(segments);
meshout.vertcnt.push_back(static_cast<unsigned int>(segments));
}
else if( const IfcIShapeProfileDef* const ishape = def.ToPtr<IfcIShapeProfileDef>()) {
// construct simplified IBeam shape

View File

@ -164,7 +164,7 @@ struct Header {
//! Could be the total size of the file (and not a float)
float size;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
@ -223,7 +223,7 @@ struct Header_MDL7 {
//! Size of the Frame_MDL7 data structure used in the file
uint16_t frame_stc_size;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
@ -242,7 +242,7 @@ struct Bone_MDL7 {
//! Optional name of the bone
char name[1 /* DUMMY SIZE */];
} /* PACK_STRUCT */;
} PACK_STRUCT;
#if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS)
# define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS (16 + 20)
@ -290,7 +290,7 @@ struct Group_MDL7 {
//! Number of frames
int32_t numframes;
} /* PACK_STRUCT */;
} PACK_STRUCT;
#define AI_MDL7_SKINTYPE_MIPFLAG 0x08
#define AI_MDL7_SKINTYPE_MATERIAL 0x10
@ -312,7 +312,7 @@ struct Deformer_MDL7 {
int32_t group_index;
int32_t elements;
int32_t deformerdata_size;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
@ -324,7 +324,7 @@ struct DeformerElement_MDL7 {
int32_t element_index;
char element_name[AI_MDL7_MAX_BONENAMESIZE];
int32_t weights;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct DeformerWeight_MDL7
@ -334,7 +334,7 @@ struct DeformerWeight_MDL7 {
//! for deformer_typ==0 (==bones) index == vertex index
int32_t index;
float weight;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// don't know why this was in the original headers ...
typedef int32_t MD7_MATERIAL_ASCDEFSIZE;
@ -345,7 +345,7 @@ typedef int32_t MD7_MATERIAL_ASCDEFSIZE;
*/
struct ColorValue_MDL7 {
float r,g,b,a;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct Material_MDL7
@ -366,7 +366,7 @@ struct Material_MDL7 {
//! Phong power
float Power;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct Skin
@ -388,7 +388,7 @@ struct Skin {
//! Texture data
uint8_t *data;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
@ -399,7 +399,7 @@ struct Skin {
struct Skin_MDL5 {
int32_t size, width, height;
uint8_t *data;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// maximum length of texture file name
#if (!defined AI_MDL7_MAX_TEXNAMESIZE)
@ -416,7 +416,7 @@ struct Skin_MDL7 {
int32_t width;
int32_t height;
char texture_name[AI_MDL7_MAX_TEXNAMESIZE];
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct RGB565
@ -426,7 +426,7 @@ struct RGB565 {
uint16_t r : 5;
uint16_t g : 6;
uint16_t b : 5;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct ARGB4
@ -455,7 +455,7 @@ struct GroupSkin {
//! Data of each image
uint8_t **data;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct TexCoord
@ -470,7 +470,7 @@ struct TexCoord {
//! Texture coordinate in the ty direction
int32_t t;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct TexCoord_MDL3
@ -482,7 +482,7 @@ struct TexCoord_MDL3 {
//! position, vertically in range 0..skinheight-1
int16_t v;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct TexCoord_MDL7
@ -494,7 +494,7 @@ struct TexCoord_MDL7 {
//! position, vertically in range 0..1
float v;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct SkinSet_MDL7
@ -510,7 +510,7 @@ struct SkinSet_MDL7
//! Material index
int32_t material; // size 4
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct Triangle
@ -523,7 +523,7 @@ struct Triangle
//! Vertex indices
int32_t vertex[3];
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct Triangle_MDL3
@ -536,7 +536,7 @@ struct Triangle_MDL3
//! Index of 3 skin vertices in range 0..numskinverts
uint16_t index_uv[3];
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct Triangle_MDL7
@ -549,7 +549,7 @@ struct Triangle_MDL7
//! Two skinsets. The second will be used for multi-texturing
SkinSet_MDL7 skinsets[2];
} /* PACK_STRUCT */;
} PACK_STRUCT;
#if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV)
# define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV (6+sizeof(SkinSet_MDL7)-sizeof(uint32_t))
@ -577,7 +577,7 @@ struct Vertex
{
uint8_t v[3];
uint8_t normalIndex;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
@ -603,7 +603,7 @@ struct Vertex_MDL7
uint8_t norm162index;
float norm[3];
};
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct BoneTransform_MDL7
@ -620,7 +620,7 @@ struct BoneTransform_MDL7
//! I HATE 3DGS AND THE SILLY DEVELOPER WHO DESIGNED
//! THIS STUPID FILE FORMAT!
int8_t _unused_[2];
} /* PACK_STRUCT */;
} PACK_STRUCT;
#define AI_MDL7_MAX_FRAMENAMESIZE 16
@ -654,7 +654,7 @@ struct SimpleFrame
//! Vertex list of the frame
Vertex *verts;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct Frame
@ -667,7 +667,7 @@ struct Frame
//! Frame data
SimpleFrame frame;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
@ -684,7 +684,7 @@ struct SimpleFrame_MDLn_SP
//! Vertex list of the frame
Vertex_MDL4 *verts;
} /* PACK_STRUCT */;
} PACK_STRUCT;
// -------------------------------------------------------------------------------------
/** \struct GroupFrame
@ -706,7 +706,7 @@ struct GroupFrame
//! List of single frames
SimpleFrame *frames;
} /* PACK_STRUCT */;
} PACK_STRUCT;
#include "./../include/assimp/Compiler/poppack1.h"

View File

@ -278,7 +278,7 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel,
bone_vertex_map[vsBDEF2_ptr->bone_index1].push_back(
aiVertexWeight(index, vsBDEF2_ptr->bone_weight));
bone_vertex_map[vsBDEF2_ptr->bone_index2].push_back(
aiVertexWeight(index, 1.0 - vsBDEF2_ptr->bone_weight));
aiVertexWeight(index, 1.0f - vsBDEF2_ptr->bone_weight));
break;
case pmx::PmxVertexSkinningType::BDEF4:
bone_vertex_map[vsBDEF4_ptr->bone_index1].push_back(
@ -295,7 +295,7 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel,
bone_vertex_map[vsSDEF_ptr->bone_index1].push_back(
aiVertexWeight(index, vsSDEF_ptr->bone_weight));
bone_vertex_map[vsSDEF_ptr->bone_index2].push_back(
aiVertexWeight(index, 1.0 - vsSDEF_ptr->bone_weight));
aiVertexWeight(index, 1.0f - vsSDEF_ptr->bone_weight));
break;
case pmx::PmxVertexSkinningType::QDEF:
const auto vsQDEF_ptr =
@ -325,7 +325,7 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel,
aiMatrix4x4::Translation(-pos, pBone->mOffsetMatrix);
auto it = bone_vertex_map.find(ii);
if (it != bone_vertex_map.end()) {
pBone->mNumWeights = it->second.size();
pBone->mNumWeights = static_cast<unsigned int>(it->second.size());
pBone->mWeights = it->second.data();
it->second.swap(*(new vector<aiVertexWeight>));
}

View File

@ -304,7 +304,7 @@ void ObjFileMtlImporter::createMaterial()
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
m_pModel->m_pCurrentMaterial->MaterialName.Set( name );
if (m_pModel->m_pCurrentMesh) {
m_pModel->m_pCurrentMesh->m_uiMaterialIndex = m_pModel->m_MaterialLib.size() - 1;
m_pModel->m_pCurrentMesh->m_uiMaterialIndex = static_cast<unsigned int>(m_pModel->m_MaterialLib.size() - 1);
}
m_pModel->m_MaterialLib.push_back( name );
m_pModel->m_MaterialMap[ name ] = m_pModel->m_pCurrentMaterial;

View File

@ -555,10 +555,15 @@ void ObjFileParser::getMaterialDesc() {
// Search for material
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find(strName);
if (it == m_pModel->m_MaterialMap.end()) {
// Not found, use default material
m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial;
DefaultLogger::get()->error("OBJ: failed to locate material " + strName + ", skipping");
strName = m_pModel->m_pDefaultMaterial->MaterialName.C_Str();
// Not found, so we don't know anything about the material except for its name.
// This may be the case if the material library is missing. We don't want to lose all
// materials if that happens, so create a new named material instead of discarding it
// completely.
DefaultLogger::get()->error("OBJ: failed to locate material " + strName + ", creating new material");
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
m_pModel->m_pCurrentMaterial->MaterialName.Set(strName);
m_pModel->m_MaterialLib.push_back(strName);
m_pModel->m_MaterialMap[strName] = m_pModel->m_pCurrentMaterial;
} else {
// Found, using detected material
m_pModel->m_pCurrentMaterial = (*it).second;

View File

@ -538,7 +538,7 @@ void PLYImporter::LoadFace(const PLY::Element* pcElement, const PLY::ElementInst
ai_assert(NULL != instElement);
if (mGeneratedMesh == NULL)
throw DeadlyImportError("Invalid .ply file: Vertices shoud be declared before faces");
throw DeadlyImportError("Invalid .ply file: Vertices should be declared before faces");
bool bOne = false;

View File

@ -618,7 +618,7 @@ bool PLY::DOM::ParseInstanceBinary(IOStreamBuffer<char> &streamBuffer, DOM* p_pc
}
streamBuffer.getNextBlock(buffer);
unsigned int bufferSize = buffer.size();
unsigned int bufferSize = static_cast<unsigned int>(buffer.size());
const char* pCur = (char*)&buffer[0];
if (!p_pcOut->ParseElementInstanceListsBinary(streamBuffer, buffer, pCur, bufferSize, loader, p_bBE))
{
@ -1025,7 +1025,7 @@ bool PLY::PropertyInstance::ParseValueBinary(IOStreamBuffer<char> &streamBuffer,
buffer = std::vector<char>(buffer.end() - bufferSize, buffer.end());
buffer.insert(buffer.end(), nbuffer.begin(), nbuffer.end());
nbuffer.clear();
bufferSize = buffer.size();
bufferSize = static_cast<unsigned int>(buffer.size());
pCur = (char*)&buffer[0];
}
else

View File

@ -160,6 +160,11 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
unsigned int& num_ref = num_refs[pcNode->mMeshes[i]];
ai_assert(0 != num_ref);
--num_ref;
// Save the name of the last mesh
if (num_ref==0)
{
pcMeshOut->mName = pcMesh->mName;
}
if (identity) {
// copy positions without modifying them
@ -626,9 +631,10 @@ void PretransformVertices::Execute( aiScene* pScene)
// now delete all nodes in the scene and build a new
// flat node graph with a root node and some level 1 children
aiNode* newRoot = new aiNode();
newRoot->mName = pScene->mRootNode->mName;
delete pScene->mRootNode;
pScene->mRootNode = new aiNode();
pScene->mRootNode->mName.Set("<dummy_root>");
if (1 == pScene->mNumMeshes && !pScene->mNumLights && !pScene->mNumCameras)
{
@ -646,7 +652,7 @@ void PretransformVertices::Execute( aiScene* pScene)
{
aiNode* pcNode = *nodes = new aiNode();
pcNode->mParent = pScene->mRootNode;
pcNode->mName.length = ::ai_snprintf(pcNode->mName.data,MAXLEN,"mesh_%u",i);
pcNode->mName = pScene->mMeshes[i]->mName;
// setup mesh indices
pcNode->mNumMeshes = 1;

View File

@ -39,14 +39,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
#ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
#include "Q3BSPZipArchive.h"
#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <assimp/ai_assert.h>
namespace Assimp {
@ -137,7 +133,6 @@ zlib_filefunc_def IOSystem2Unzip::get(IOSystem* pIOHandler) {
return mapping;
}
// ------------------------------------------------------------------------------------------------
ZipFile::ZipFile(size_t size) : m_Size(size) {
ai_assert(m_Size != 0);

View File

@ -44,7 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <contrib/unzip/unzip.h>
#include <assimp/IOStream.hpp>
#include <assimp/IOSystem.hpp>
#include <string>
#include <vector>
#include <map>
#include <cassert>

View File

@ -58,6 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "time.h"
#include <assimp/DefaultLogger.hpp>
#include <assimp/scene.h>
#include <assimp/mesh.h>
#include <stdio.h>
#include "ScenePrivate.h"
@ -757,7 +758,7 @@ void SceneCombiner::MergeBones(aiMesh* out,std::vector<aiMesh*>::const_iterator
// ------------------------------------------------------------------------------------------------
// Merge a list of meshes
void SceneCombiner::MergeMeshes(aiMesh** _out,unsigned int /*flags*/,
void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/,
std::vector<aiMesh*>::const_iterator begin,
std::vector<aiMesh*>::const_iterator end)
{
@ -772,8 +773,14 @@ void SceneCombiner::MergeMeshes(aiMesh** _out,unsigned int /*flags*/,
aiMesh* out = *_out = new aiMesh();
out->mMaterialIndex = (*begin)->mMaterialIndex;
std::string name;
// Find out how much output storage we'll need
for (std::vector<aiMesh*>::const_iterator it = begin; it != end;++it) {
for (std::vector<aiMesh*>::const_iterator it = begin; it != end; ++it) {
const char *meshName( (*it)->mName.C_Str() );
name += std::string( meshName );
if ( it != end - 1 ) {
name += ".";
}
out->mNumVertices += (*it)->mNumVertices;
out->mNumFaces += (*it)->mNumFaces;
out->mNumBones += (*it)->mNumBones;
@ -781,6 +788,7 @@ void SceneCombiner::MergeMeshes(aiMesh** _out,unsigned int /*flags*/,
// combine primitive type flags
out->mPrimitiveTypes |= (*it)->mPrimitiveTypes;
}
out->mName.Set( name.c_str() );
if (out->mNumVertices) {
aiVector3D* pv2;
@ -789,7 +797,7 @@ void SceneCombiner::MergeMeshes(aiMesh** _out,unsigned int /*flags*/,
if ((**begin).HasPositions()) {
pv2 = out->mVertices = new aiVector3D[out->mNumVertices];
for (std::vector<aiMesh*>::const_iterator it = begin; it != end;++it) {
for (std::vector<aiMesh*>::const_iterator it = begin; it != end; ++it) {
if ((*it)->mVertices) {
::memcpy(pv2,(*it)->mVertices,(*it)->mNumVertices*sizeof(aiVector3D));
}
@ -809,7 +817,7 @@ void SceneCombiner::MergeMeshes(aiMesh** _out,unsigned int /*flags*/,
pv2 += (*it)->mNumVertices;
}
}
// copy tangents and bitangents
// copy tangents and bi-tangents
if ((**begin).HasTangentsAndBitangents()) {
pv2 = out->mTangents = new aiVector3D[out->mNumVertices];

View File

@ -95,8 +95,8 @@ struct WordIterator: public std::iterator<std::input_iterator_tag, const char*>
end_ = other.end_;
return *this;
}
bool operator==(WordIterator &other) const { return start_ == other.start_; }
bool operator!=(WordIterator &other) const { return start_ != other.start_; }
bool operator==(const WordIterator &other) const { return start_ == other.start_; }
bool operator!=(const WordIterator &other) const { return start_ != other.start_; }
WordIterator &operator++() {
start_ += strcspn(start_, whitespace);
start_ += strspn(start_, whitespace);
@ -558,7 +558,7 @@ void X3DImporter::XML_ReadNode_GetAttrVal_AsArrF(const int pAttrIdx, std::vector
WordIterator wordItBegin(val, val + strlen(val));
WordIterator wordItEnd;
std::transform(wordItBegin, wordItEnd, std::back_inserter(pValue), [](const char *match) { return atof(match); });
std::transform(wordItBegin, wordItEnd, std::back_inserter(pValue), [](const char *match) { return static_cast<float>(atof(match)); });
}
}

View File

@ -242,7 +242,7 @@ Ref<T> LazyDict<T>::Create(const char* id)
}
T* inst = new T();
inst->id = id;
inst->index = mObjs.size();
inst->index = static_cast<int>(mObjs.size());
return Add(inst);
}

View File

@ -886,7 +886,7 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
timeData[i] = nodeChannel->mPositionKeys[frameIndex].mTime / ticksPerSecond;
}
Ref<Accessor> timeAccessor = ExportData(mAsset, animId, buffer, numKeyframes, &timeData[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
Ref<Accessor> timeAccessor = ExportData(mAsset, animId, buffer, static_cast<unsigned int>(numKeyframes), &timeData[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
if (timeAccessor) animRef->Parameters.TIME = timeAccessor;
}
@ -899,7 +899,7 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
translationData[i] = nodeChannel->mPositionKeys[frameIndex].mValue;
}
Ref<Accessor> tranAccessor = ExportData(mAsset, animId, buffer, numKeyframes, translationData, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
Ref<Accessor> tranAccessor = ExportData(mAsset, animId, buffer, static_cast<unsigned int>(numKeyframes), translationData, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
if ( tranAccessor ) {
animRef->Parameters.translation = tranAccessor;
}
@ -915,7 +915,7 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
scaleData[i] = nodeChannel->mScalingKeys[frameIndex].mValue;
}
Ref<Accessor> scaleAccessor = ExportData(mAsset, animId, buffer, numKeyframes, scaleData, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
Ref<Accessor> scaleAccessor = ExportData(mAsset, animId, buffer, static_cast<unsigned int>(numKeyframes), scaleData, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
if ( scaleAccessor ) {
animRef->Parameters.scale = scaleAccessor;
}
@ -934,7 +934,7 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
rotationData[i][3] = nodeChannel->mRotationKeys[frameIndex].mValue.w;
}
Ref<Accessor> rotAccessor = ExportData(mAsset, animId, buffer, numKeyframes, rotationData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
Ref<Accessor> rotAccessor = ExportData(mAsset, animId, buffer, static_cast<unsigned int>(numKeyframes), rotationData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
if ( rotAccessor ) {
animRef->Parameters.rotation = rotAccessor;
}
@ -989,7 +989,7 @@ void glTF2Exporter::ExportAnimations()
Animation::AnimChannel tmpAnimChannel;
Animation::AnimSampler tmpAnimSampler;
tmpAnimChannel.sampler = animRef->Samplers.size();
tmpAnimChannel.sampler = static_cast<int>(animRef->Samplers.size());
tmpAnimChannel.target.path = channelType;
tmpAnimSampler.output = channelType;
tmpAnimSampler.id = name + "_" + channelType;

View File

@ -875,7 +875,7 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
timeData[i] = nodeChannel->mPositionKeys[frameIndex].mTime / ticksPerSecond;
}
Ref<Accessor> timeAccessor = ExportData(mAsset, animId, buffer, numKeyframes, &timeData[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
Ref<Accessor> timeAccessor = ExportData(mAsset, animId, buffer, static_cast<unsigned int>(numKeyframes), &timeData[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
if (timeAccessor) animRef->Parameters.TIME = timeAccessor;
}
@ -888,7 +888,7 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
translationData[i] = nodeChannel->mPositionKeys[frameIndex].mValue;
}
Ref<Accessor> tranAccessor = ExportData(mAsset, animId, buffer, numKeyframes, translationData, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
Ref<Accessor> tranAccessor = ExportData(mAsset, animId, buffer, static_cast<unsigned int>(numKeyframes), translationData, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
if ( tranAccessor ) {
animRef->Parameters.translation = tranAccessor;
}
@ -904,7 +904,7 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
scaleData[i] = nodeChannel->mScalingKeys[frameIndex].mValue;
}
Ref<Accessor> scaleAccessor = ExportData(mAsset, animId, buffer, numKeyframes, scaleData, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
Ref<Accessor> scaleAccessor = ExportData(mAsset, animId, buffer, static_cast<unsigned int>(numKeyframes), scaleData, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
if ( scaleAccessor ) {
animRef->Parameters.scale = scaleAccessor;
}
@ -923,7 +923,7 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
rotationData[i][3] = nodeChannel->mRotationKeys[frameIndex].mValue.w;
}
Ref<Accessor> rotAccessor = ExportData(mAsset, animId, buffer, numKeyframes, rotationData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
Ref<Accessor> rotAccessor = ExportData(mAsset, animId, buffer, static_cast<unsigned int>(numKeyframes), rotationData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
if ( rotAccessor ) {
animRef->Parameters.rotation = rotAccessor;
}

View File

@ -11,3 +11,7 @@ set( IrrXML_SRCS
add_library(IrrXML STATIC ${IrrXML_SRCS})
set(IRRXML_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "IrrXML_Include" )
set(IRRXML_LIBRARY "IrrXML" CACHE INTERNAL "IrrXML" )
install(TARGETS IrrXML
ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
COMPONENT ${LIBASSIMP_COMPONENT})

View File

@ -217,10 +217,9 @@ public:
static void MergeScenes(aiScene** dest,std::vector<aiScene*>& src,
unsigned int flags = 0);
// -------------------------------------------------------------------
/** Merges two or more scenes and attaches all sceenes to a specific
* position in the node graph of the masteer scene.
/** Merges two or more scenes and attaches all scenes to a specific
* position in the node graph of the master scene.
*
* @param dest Receives a pointer to the destination scene. If the
* pointer doesn't point to NULL when the function is called, the
@ -236,7 +235,6 @@ public:
std::vector<AttachmentInfo>& src,
unsigned int flags = 0);
// -------------------------------------------------------------------
/** Merges two or more meshes
*
@ -255,7 +253,6 @@ public:
std::vector<aiMesh*>::const_iterator begin,
std::vector<aiMesh*>::const_iterator end);
// -------------------------------------------------------------------
/** Merges two or more bones
*

View File

@ -9,6 +9,10 @@ import ctypes
from ctypes import POINTER
import operator
from distutils.sysconfig import get_python_lib
import re
import sys
try: import numpy
except: numpy = None
@ -26,7 +30,15 @@ if os.name=='posix':
additional_dirs.append('/usr/lib/x86_64-linux-gnu')
additional_dirs.append('/usr/local/lib/')
# note - this won't catch libassimp.so.N.n, but
# check if running from anaconda.
if "conda" or "continuum" in sys.version.lower():
cur_path = get_python_lib()
pattern = re.compile('.*\/lib\/')
conda_lib = pattern.match(cur_path).group()
logger.info("Adding Anaconda lib path:"+ conda_lib)
additional_dirs.append(conda_lib)
# note - this won't catch libassimp.so.N.n, but
# currently there's always a symlink called
# libassimp.so in /usr/local/lib.
ext_whitelist.append('.so')
@ -39,7 +51,7 @@ elif os.name=='nt':
for dir_candidate in path_dirs:
if 'assimp' in dir_candidate.lower():
additional_dirs.append(dir_candidate)
#print(additional_dirs)
def vec2tuple(x):
""" Converts a VECTOR3D to a Tuple """
@ -61,10 +73,10 @@ def transform(vector3, matrix4x4):
m2[0]*x + m2[1]*y + m2[2]*z + m2[3],
m3[0]*x + m3[1]*y + m3[2]*z + m3[3]
]
def _inv(matrix4x4):
m0,m1,m2,m3 = matrix4x4
det = m0[3]*m1[2]*m2[1]*m3[0] - m0[2]*m1[3]*m2[1]*m3[0] - \
m0[3]*m1[1]*m2[2]*m3[0] + m0[1]*m1[3]*m2[2]*m3[0] + \
m0[2]*m1[1]*m2[3]*m3[0] - m0[1]*m1[2]*m2[3]*m3[0] - \
@ -77,7 +89,7 @@ def _inv(matrix4x4):
m0[2]*m1[1]*m2[0]*m3[3] + m0[1]*m1[2]*m2[0]*m3[3] + \
m0[2]*m1[0]*m2[1]*m3[3] - m0[0]*m1[2]*m2[1]*m3[3] - \
m0[1]*m1[0]*m2[2]*m3[3] + m0[0]*m1[1]*m2[2]*m3[3]
return[[( m1[2]*m2[3]*m3[1] - m1[3]*m2[2]*m3[1] + m1[3]*m2[1]*m3[2] - m1[1]*m2[3]*m3[2] - m1[2]*m2[1]*m3[3] + m1[1]*m2[2]*m3[3]) /det,
( m0[3]*m2[2]*m3[1] - m0[2]*m2[3]*m3[1] - m0[3]*m2[1]*m3[2] + m0[1]*m2[3]*m3[2] + m0[2]*m2[1]*m3[3] - m0[1]*m2[2]*m3[3]) /det,
( m0[2]*m1[3]*m3[1] - m0[3]*m1[2]*m3[1] + m0[3]*m1[1]*m3[2] - m0[1]*m1[3]*m3[2] - m0[2]*m1[1]*m3[3] + m0[1]*m1[2]*m3[3]) /det,
@ -94,7 +106,7 @@ def _inv(matrix4x4):
( m0[1]*m2[2]*m3[0] - m0[2]*m2[1]*m3[0] + m0[2]*m2[0]*m3[1] - m0[0]*m2[2]*m3[1] - m0[1]*m2[0]*m3[2] + m0[0]*m2[1]*m3[2]) /det,
( m0[2]*m1[1]*m3[0] - m0[1]*m1[2]*m3[0] - m0[2]*m1[0]*m3[1] + m0[0]*m1[2]*m3[1] + m0[1]*m1[0]*m3[2] - m0[0]*m1[1]*m3[2]) /det,
( m0[1]*m1[2]*m2[0] - m0[2]*m1[1]*m2[0] + m0[2]*m1[0]*m2[1] - m0[0]*m1[2]*m2[1] - m0[1]*m1[0]*m2[2] + m0[0]*m1[1]*m2[2]) /det]]
def get_bounding_box(scene):
bb_min = [1e10, 1e10, 1e10] # x,y,z
bb_max = [-1e10, -1e10, -1e10] # x,y,z
@ -129,7 +141,7 @@ def get_bounding_box_for_node(node, bb_min, bb_max, transformation):
t3[0]*T0[2] + t3[1]*T1[2] + t3[2]*T2[2] + t3[3]*T3[2],
t3[0]*T0[3] + t3[1]*T1[3] + t3[2]*T2[3] + t3[3]*T3[3]
] ]
for mesh in node.meshes:
for v in mesh.vertices:
v = transform(v, transformation)
@ -149,25 +161,25 @@ def get_bounding_box_for_node(node, bb_min, bb_max, transformation):
def try_load_functions(library_path, dll):
'''
Try to bind to aiImportFile and aiReleaseImport
Arguments
---------
library_path: path to current lib
dll: ctypes handle to library
Returns
---------
If unsuccessful:
None
If successful:
Tuple containing (library_path,
Tuple containing (library_path,
load from filename function,
load from memory function,
export to filename function,
release function,
release function,
ctypes handle to assimp library)
'''
try:
load = dll.aiImportFile
release = dll.aiReleaseImport
@ -176,7 +188,7 @@ def try_load_functions(library_path, dll):
except AttributeError:
#OK, this is a library, but it doesn't have the functions we need
return None
# library found!
from .structs import Scene
load.restype = POINTER(Scene)
@ -185,13 +197,13 @@ def try_load_functions(library_path, dll):
def search_library():
'''
Loads the assimp library.
Loads the assimp library.
Throws exception AssimpError if no library_path is found
Returns: tuple, (load from filename function,
Returns: tuple, (load from filename function,
load from memory function,
export to filename function,
release function,
release function,
dll)
'''
#this path
@ -201,7 +213,7 @@ def search_library():
try:
ctypes.windll.kernel32.SetErrorMode(0x8007)
except AttributeError:
pass
pass
candidates = []
# test every file
@ -209,7 +221,7 @@ def search_library():
if os.path.isdir(curfolder):
for filename in os.listdir(curfolder):
# our minimum requirement for candidates is that
# they should contain 'assimp' somewhere in
# they should contain 'assimp' somewhere in
# their name
if filename.lower().find('assimp')==-1 or\
os.path.splitext(filename)[-1].lower() not in ext_whitelist:
@ -248,10 +260,10 @@ def hasattr_silent(object, name):
"""
Calls hasttr() with the given parameters and preserves the legacy (pre-Python 3.2)
functionality of silently catching exceptions.
Returns the result of hasatter() or False if an exception was raised.
"""
try:
return hasattr(object, name)
except:

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,9 @@ setup(name='pyassimp',
description='Python bindings for the Open Asset Import Library (ASSIMP)',
url='https://github.com/assimp/assimp',
packages=['pyassimp'],
data_files=[('share/pyassimp', ['README.md']),
('share/examples/pyassimp', ['scripts/' + f for f in os.listdir('scripts/')])], requires=['numpy']
data_files=[
('share/pyassimp', ['README.md']),
('share/examples/pyassimp', ['scripts/' + f for f in os.listdir('scripts/')])
],
requires=['numpy']
)

View File

@ -116,6 +116,7 @@ SET( TEST_SRCS
unit/utRemoveRedundantMaterials.cpp
unit/utRemoveVCProcess.cpp
unit/utScenePreprocessor.cpp
unit/utSceneCombiner.cpp
unit/utSharedPPData.cpp
unit/utStringUtils.cpp
unit/utSMDImportExport.cpp
@ -130,6 +131,7 @@ SET( TEST_SRCS
unit/utVector3.cpp
unit/utXImporterExporter.cpp
unit/utD3MFImportExport.cpp
unit/utQ3DImportExport.cpp
unit/utProfiler.cpp
)

View File

@ -43,13 +43,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
class utD3MFImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3MF/box.3mf", 0);
return nullptr != scene;
EXPECT_EQ( 1u, scene->mNumMeshes );
aiMesh *mesh = scene->mMeshes[ 0 ];
EXPECT_NE( nullptr, mesh );
EXPECT_EQ( 12u, mesh->mNumFaces );
EXPECT_EQ( 8u, mesh->mNumVertices );
return ( nullptr != scene );
}
};

View File

@ -54,8 +54,6 @@ public:
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OpenGEX/Example.ogex", 0 );
return nullptr != scene;
return true;
}
};

View File

@ -0,0 +1,61 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2017, 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 "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
using namespace Assimp;
class utQ3DImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/Q3D/earth.q3o", 0 );
return nullptr != scene;
}
};
TEST_F(utQ3DImportExport, importTest) {
EXPECT_TRUE( importerTest() );
}

View File

@ -0,0 +1,70 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2017, 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/SceneCombiner.h>
#include <assimp/mesh.h>
using namespace ::Assimp;
class utSceneCombiner : public ::testing::Test {
// empty
};
TEST_F( utSceneCombiner, MergeMeshes_ValidNames_Test ) {
std::vector<aiMesh*> merge_list;
aiMesh *mesh1 = new aiMesh;
mesh1->mName.Set( "mesh_1" );
merge_list.push_back( mesh1 );
aiMesh *mesh2 = new aiMesh;
mesh2->mName.Set( "mesh_2" );
merge_list.push_back( mesh2 );
aiMesh *mesh3 = new aiMesh;
mesh3->mName.Set( "mesh_3" );
merge_list.push_back( mesh3 );
aiMesh *out( nullptr );
SceneCombiner::MergeMeshes( &out, 0, merge_list.begin(), merge_list.end() );
std::string outName = out->mName.C_Str();
EXPECT_EQ( "mesh_1.mesh_2.mesh_3", outName );
}

View File

@ -6,7 +6,11 @@
#include "glview.hpp"
// Header files, OpenGL.
#include <GL/glu.h>
#if defined(__APPLE__)
# include <OpenGL/glu.h>
#else
# include <GL/glu.h>
#endif
// Header files, DevIL.
#include <il.h>