Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36c08a0a7d | ||
|
|
52f3cd0afb | ||
|
|
c5ba04cabf | ||
|
|
427eaad642 | ||
|
|
04f0075b63 | ||
|
|
fb1c9ab86d | ||
|
|
9245469fb8 | ||
|
|
22d026ac40 | ||
|
|
f6925db3d8 | ||
|
|
d5d9e59949 | ||
|
|
eea8099b05 | ||
|
|
a5e179edf5 | ||
|
|
f8b79acb36 |
@@ -4,6 +4,8 @@ before_install:
|
||||
env:
|
||||
- TRAVIS_NO_EXPORT=YES
|
||||
- TRAVIS_NO_EXPORT=NO
|
||||
- TRAVIS_STATIC_BUILD=ON
|
||||
- TRAVIS_STATIC_BUILD=OFF
|
||||
|
||||
language: cpp
|
||||
|
||||
@@ -11,7 +13,7 @@ compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
||||
script: cmake -G "Unix Makefiles" -DASSIMP_ENABLE_BOOST_WORKAROUND=YES -DASSIMP_NO_EXPORT=$TRAVIS_NO_EXPORT && make
|
||||
script: cmake -G "Unix Makefiles" -DASSIMP_ENABLE_BOOST_WORKAROUND=YES -DASSIMP_NO_EXPORT=$TRAVIS_NO_EXPORT -STATIC_BUILD=$TRAVIS_STATIC_BUILD && make
|
||||
|
||||
|
||||
|
||||
|
||||
25
cmake-modules/Findassimp.cmake
Normal file
25
cmake-modules/Findassimp.cmake
Normal file
@@ -0,0 +1,25 @@
|
||||
FIND_PATH(
|
||||
assimp_INCLUDE_DIRS
|
||||
NAMES postprocess.h scene.h version.h config.h cimport.h
|
||||
PATHS /usr/local/include/
|
||||
)
|
||||
|
||||
FIND_LIBRARY(
|
||||
assimp_LIBRARIES
|
||||
NAMES assimp
|
||||
PATHS /usr/local/lib/
|
||||
)
|
||||
|
||||
IF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
|
||||
SET(assimp_FOUND TRUE)
|
||||
ENDIF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
|
||||
|
||||
IF (assimp_FOUND)
|
||||
IF (NOT assimp_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found asset importer library: ${assimp_LIBRARIES}")
|
||||
ENDIF (NOT assimp_FIND_QUIETLY)
|
||||
ELSE (assimp_FOUND)
|
||||
IF (assimp_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find asset importer library")
|
||||
ENDIF (assimp_FIND_REQUIRED)
|
||||
ENDIF (assimp_FOUND)
|
||||
@@ -4,6 +4,7 @@
|
||||
# 3) Add libassimp using the file lists (eliminates duplication of file names between
|
||||
# source groups and library command)
|
||||
#
|
||||
cmake_minimum_required( VERSION 2.6 )
|
||||
SET( HEADER_PATH ../include/assimp )
|
||||
|
||||
SET( COMPILER_HEADERS
|
||||
|
||||
@@ -95,7 +95,7 @@ Exporter::ExportFormatEntry gExporters[] =
|
||||
Exporter::ExportFormatEntry( "stl", "Stereolithography", "stl" , &ExportSceneSTL,
|
||||
aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices
|
||||
),
|
||||
Exporter::ExportFormatEntry( "stlb", "Stereolithography(binary)", "stlb" , &ExportSceneSTLBinary,
|
||||
Exporter::ExportFormatEntry( "stlb", "Stereolithography (binary)", "stl" , &ExportSceneSTLBinary,
|
||||
aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices
|
||||
),
|
||||
#endif
|
||||
|
||||
@@ -111,7 +111,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
|
||||
|
||||
// Read root node
|
||||
NextNode(reader.get());
|
||||
if (!CurrentNodeNameEquals(reader, "mesh")) {
|
||||
if (!CurrentNodeNameEquals(reader.get(), "mesh")) {
|
||||
throw DeadlyImportError("Root node is not <mesh> but <" + string(reader->getNodeName()) + "> in " + pFile);
|
||||
}
|
||||
|
||||
@@ -127,20 +127,20 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
|
||||
// This can be used to share geometry between submeshes
|
||||
|
||||
NextNode(reader.get());
|
||||
if (CurrentNodeNameEquals(reader, nnSharedGeometry))
|
||||
if (CurrentNodeNameEquals(reader.get(), nnSharedGeometry))
|
||||
{
|
||||
DefaultLogger::get()->debug("Reading shared geometry");
|
||||
unsigned int NumVertices = GetAttribute<unsigned int>(reader.get(), "vertexcount");
|
||||
|
||||
NextNode(reader.get());
|
||||
while(CurrentNodeNameEquals(reader, nnVertexBuffer)) {
|
||||
while(CurrentNodeNameEquals(reader.get(), nnVertexBuffer)) {
|
||||
ReadVertexBuffer(m_SharedGeometry, reader.get(), NumVertices);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------- Sub Meshes --------------------
|
||||
|
||||
if (!CurrentNodeNameEquals(reader, nnSubMeshes)) {
|
||||
if (!CurrentNodeNameEquals(reader.get(), nnSubMeshes)) {
|
||||
throw DeadlyImportError("Could not find <submeshes> node inside root <mesh> node");
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
|
||||
vector<aiMaterial*> materials;
|
||||
|
||||
NextNode(reader.get());
|
||||
while(CurrentNodeNameEquals(reader, nnSubMesh))
|
||||
while(CurrentNodeNameEquals(reader.get(), nnSubMesh))
|
||||
{
|
||||
SubMesh* submesh = new SubMesh();
|
||||
ReadSubMesh(subMeshes.size(), *submesh, reader.get());
|
||||
@@ -178,10 +178,10 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
|
||||
|
||||
// Skip submesh names.
|
||||
/// @todo Should these be read to scene etc. metadata?
|
||||
if (CurrentNodeNameEquals(reader, nnSubMeshNames))
|
||||
if (CurrentNodeNameEquals(reader.get(), nnSubMeshNames))
|
||||
{
|
||||
NextNode(reader.get());
|
||||
while(CurrentNodeNameEquals(reader, nnSubMesh)) {
|
||||
while(CurrentNodeNameEquals(reader.get(), nnSubMesh)) {
|
||||
NextNode(reader.get());
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
|
||||
vector<Bone> Bones;
|
||||
vector<Animation> Animations;
|
||||
|
||||
if (CurrentNodeNameEquals(reader, nnSkeletonLink))
|
||||
if (CurrentNodeNameEquals(reader.get(), nnSkeletonLink))
|
||||
{
|
||||
string skeletonFile = GetAttribute<string>(reader.get(), "name");
|
||||
if (!skeletonFile.empty())
|
||||
@@ -210,7 +210,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
|
||||
}
|
||||
|
||||
// Now there might be <boneassignments> for the shared geometry
|
||||
if (CurrentNodeNameEquals(reader, "boneassignments")) {
|
||||
if (CurrentNodeNameEquals(reader.get(), "boneassignments")) {
|
||||
ReadBoneWeights(m_SharedGeometry, reader.get());
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
|
||||
{
|
||||
DefaultLogger::get()->debug("RemoveRedundantMatsProcess begin");
|
||||
|
||||
unsigned int iCnt = 0, unreferenced = 0;
|
||||
unsigned int redundantRemoved = 0, unreferencedRemoved = 0;
|
||||
if (pScene->mNumMaterials)
|
||||
{
|
||||
// Find out which materials are referenced by meshes
|
||||
@@ -125,9 +125,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: reimplement this algorithm to work in-place
|
||||
|
||||
unsigned int* aiMappingTable = new unsigned int[pScene->mNumMaterials];
|
||||
unsigned int iNewNum = 0;
|
||||
|
||||
@@ -139,37 +137,42 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
|
||||
aiHashes = new uint32_t[pScene->mNumMaterials];
|
||||
for (unsigned int i = 0; i < pScene->mNumMaterials;++i)
|
||||
{
|
||||
// if the material is not referenced ... remove it
|
||||
if (!abReferenced[i]) {
|
||||
++unreferenced;
|
||||
// No mesh is referencing this material, remove it.
|
||||
if (!abReferenced[i]) {
|
||||
++unreferencedRemoved;
|
||||
delete pScene->mMaterials[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check all previously mapped materials for a matching hash.
|
||||
// On a match we can delete this material and just make it ref to the same index.
|
||||
uint32_t me = aiHashes[i] = ComputeMaterialHash(pScene->mMaterials[i]);
|
||||
for (unsigned int a = 0; a < i;++a)
|
||||
{
|
||||
if (abReferenced[a] && me == aiHashes[a]) {
|
||||
++iCnt;
|
||||
++redundantRemoved;
|
||||
me = 0;
|
||||
aiMappingTable[i] = aiMappingTable[a];
|
||||
delete pScene->mMaterials[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
// This is a new material that is referenced, add to the map.
|
||||
if (me) {
|
||||
aiMappingTable[i] = iNewNum++;
|
||||
}
|
||||
}
|
||||
if (iCnt) {
|
||||
// build an output material list
|
||||
// If the new material count differs from the original,
|
||||
// we need to rebuild the material list and remap mesh material indexes.
|
||||
if (iNewNum != pScene->mNumMaterials) {
|
||||
aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];
|
||||
::memset(ppcMaterials,0,sizeof(void*)*iNewNum);
|
||||
for (unsigned int p = 0; p < pScene->mNumMaterials;++p)
|
||||
{
|
||||
// if the material is not referenced ... remove it
|
||||
if (!abReferenced[p])
|
||||
if (!abReferenced[p]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// generate new names for all modified materials
|
||||
const unsigned int idx = aiMappingTable[p];
|
||||
@@ -179,10 +182,11 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
|
||||
sz.length = ::sprintf(sz.data,"JoinedMaterial_#%i",p);
|
||||
((aiMaterial*)ppcMaterials[idx])->AddProperty(&sz,AI_MATKEY_NAME);
|
||||
}
|
||||
else ppcMaterials[idx] = pScene->mMaterials[p];
|
||||
else
|
||||
ppcMaterials[idx] = pScene->mMaterials[p];
|
||||
}
|
||||
// update all material indices
|
||||
for (unsigned int p = 0; p < pScene->mNumMeshes;++p) {
|
||||
for (unsigned int p = 0; p < pScene->mNumMeshes;++p) {
|
||||
aiMesh* mesh = pScene->mMeshes[p];
|
||||
mesh->mMaterialIndex = aiMappingTable[mesh->mMaterialIndex];
|
||||
}
|
||||
@@ -195,12 +199,15 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
|
||||
delete[] aiHashes;
|
||||
delete[] aiMappingTable;
|
||||
}
|
||||
if (!iCnt)DefaultLogger::get()->debug("RemoveRedundantMatsProcess finished ");
|
||||
if (redundantRemoved == 0 && unreferencedRemoved == 0)
|
||||
{
|
||||
DefaultLogger::get()->debug("RemoveRedundantMatsProcess finished ");
|
||||
}
|
||||
else
|
||||
{
|
||||
char szBuffer[128]; // should be sufficiently large
|
||||
::sprintf(szBuffer,"RemoveRedundantMatsProcess finished. %i redundant and %i unused materials",
|
||||
iCnt,unreferenced);
|
||||
::sprintf(szBuffer,"RemoveRedundantMatsProcess finished. Removed %i redundant and %i unused materials.",
|
||||
redundantRemoved,unreferencedRemoved);
|
||||
DefaultLogger::get()->info(szBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +136,9 @@ XFileParser::XFileParser( const std::vector<char>& pBuffer)
|
||||
ThrowException( boost::str( boost::format( "Unknown float size %1% specified in xfile header.")
|
||||
% mBinaryFloatSize));
|
||||
|
||||
// The x format specifies size in bits, but we work in bytes
|
||||
mBinaryFloatSize /= 8;
|
||||
|
||||
P += 16;
|
||||
|
||||
// If this is a compressed X file, apply the inflate algorithm to it
|
||||
|
||||
@@ -144,7 +144,7 @@ protected:
|
||||
protected:
|
||||
unsigned int mMajorVersion, mMinorVersion; ///< version numbers
|
||||
bool mIsBinaryFormat; ///< true if the file is in binary, false if it's in text form
|
||||
unsigned int mBinaryFloatSize; ///< float size, either 32 or 64 bits
|
||||
unsigned int mBinaryFloatSize; ///< float size in bytes, either 4 or 8
|
||||
// counter for number arrays in binary format
|
||||
unsigned int mBinaryNumCount;
|
||||
|
||||
|
||||
@@ -211,10 +211,10 @@ struct aiExportDataBlob
|
||||
extension that should be used when writing
|
||||
the data to disc.
|
||||
*/
|
||||
aiString name;
|
||||
C_STRUCT aiString name;
|
||||
|
||||
/** Pointer to the next blob in the chain or NULL if there is none. */
|
||||
aiExportDataBlob * next;
|
||||
C_STRUCT aiExportDataBlob * next;
|
||||
|
||||
#ifdef __cplusplus
|
||||
/// Default constructor
|
||||
@@ -247,7 +247,7 @@ ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const C_STRUCT
|
||||
* returned by aiExportScene().
|
||||
* @param pData the data blob returned by #aiExportSceneToBlob
|
||||
*/
|
||||
ASSIMP_API C_STRUCT void aiReleaseExportBlob( const C_STRUCT aiExportDataBlob* pData );
|
||||
ASSIMP_API void aiReleaseExportBlob( const C_STRUCT aiExportDataBlob* pData );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ struct aiString
|
||||
/** Standard return type for some library functions.
|
||||
* Rarely used, and if, mostly in the C API.
|
||||
*/
|
||||
enum aiReturn
|
||||
typedef enum aiReturn
|
||||
{
|
||||
/** Indicates that a function was successful */
|
||||
aiReturn_SUCCESS = 0x0,
|
||||
@@ -388,7 +388,7 @@ enum aiReturn
|
||||
* Force 32-bit size enum
|
||||
*/
|
||||
_AI_ENFORCE_ENUM_SIZE = 0x7fffffff
|
||||
}; // !enum aiReturn
|
||||
} aiReturn; // !enum aiReturn
|
||||
|
||||
// just for backwards compatibility, don't use these constants anymore
|
||||
#define AI_SUCCESS aiReturn_SUCCESS
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
cmake_minimum_required( VERSION 2.6 )
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${Assimp_SOURCE_DIR}/include
|
||||
${Assimp_SOURCE_DIR}/code
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/version.h>
|
||||
#include <assimp/config.h>
|
||||
#include <assimp/cimport.h>
|
||||
#include <assimp/cimport.h>
|
||||
#include <assimp/cexport.h>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
cmake_minimum_required( VERSION 2.6 )
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${Assimp_SOURCE_DIR}/include
|
||||
${Assimp_SOURCE_DIR}/code
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
FIND_PACKAGE(DirectX REQUIRED)
|
||||
cmake_minimum_required( VERSION 2.6 )
|
||||
|
||||
FIND_PACKAGE(DirectX REQUIRED)
|
||||
|
||||
INCLUDE_DIRECTORIES (
|
||||
${Assimp_SOURCE_DIR}/include
|
||||
|
||||
Reference in New Issue
Block a user