Merge commit '89fbda0957ddc842d27a3a610c10bf2fe840a64f' into contrib
commit
cafa3d5811
|
@ -13,14 +13,14 @@ set(ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used f
|
||||||
|
|
||||||
option(ASSIMP_OPT_BUILD_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF)
|
option(ASSIMP_OPT_BUILD_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF)
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules" )
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules" )
|
||||||
set(LIBASSIMP_COMPONENT libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH})
|
set(LIBASSIMP_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH}" )
|
||||||
set(LIBASSIMP-DEV_COMPONENT libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH}-dev)
|
set(LIBASSIMP-DEV_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH}-dev" )
|
||||||
set(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPONENT} assimp-dev)
|
set(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPONENT} assimp-dev)
|
||||||
set(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names")
|
set(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names")
|
||||||
|
|
||||||
if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_IS_MINGW)
|
if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_IS_MINGW)
|
||||||
add_definitions(-fPIC) # this is a very important switch and some libraries seem now to have it....
|
add_definitions(-fPIC) # this is a very important switch and some libraries seem now to have it....
|
||||||
## hide all not-exported symbols
|
# hide all not-exported symbols
|
||||||
add_definitions( -fvisibility=hidden -Wall )
|
add_definitions( -fvisibility=hidden -Wall )
|
||||||
elseif(MSVC)
|
elseif(MSVC)
|
||||||
# enable multi-core compilation with MSVC
|
# enable multi-core compilation with MSVC
|
||||||
|
@ -37,9 +37,9 @@ INCLUDE (PrecompiledHeader)
|
||||||
# source tree. During an out-of-source build, however, do not litter this
|
# source tree. During an out-of-source build, however, do not litter this
|
||||||
# directory, since that is probably what the user wanted to avoid.
|
# directory, since that is probably what the user wanted to avoid.
|
||||||
IF ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
|
IF ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
|
||||||
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib )
|
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/lib" )
|
||||||
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib )
|
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/lib" )
|
||||||
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin )
|
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin" )
|
||||||
ENDIF ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
|
ENDIF ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
|
||||||
|
|
||||||
# Cache these to allow the user to override them manually.
|
# Cache these to allow the user to override them manually.
|
||||||
|
@ -50,7 +50,7 @@ SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE PATH
|
||||||
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE PATH
|
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE PATH
|
||||||
"Path the tool executables are installed to." )
|
"Path the tool executables are installed to." )
|
||||||
|
|
||||||
SET(ASSIMP_DEBUG_POSTFIX "D" CACHE STRING "Debug Postfitx for lib, samples and tools")
|
SET(ASSIMP_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfitx for lib, samples and tools")
|
||||||
|
|
||||||
# Allow the user to build a static library
|
# Allow the user to build a static library
|
||||||
SET ( ASSIMP_BUILD_STATIC_LIB OFF CACHE BOOL
|
SET ( ASSIMP_BUILD_STATIC_LIB OFF CACHE BOOL
|
||||||
|
@ -151,7 +151,6 @@ ENDIF ( ASSIMP_BUILD_COMPILER STREQUAL "")
|
||||||
|
|
||||||
MARK_AS_ADVANCED ( ASSIMP_BUILD_ARCHITECTURE ASSIMP_BUILD_COMPILER )
|
MARK_AS_ADVANCED ( ASSIMP_BUILD_ARCHITECTURE ASSIMP_BUILD_COMPILER )
|
||||||
|
|
||||||
|
|
||||||
ADD_SUBDIRECTORY( code/ )
|
ADD_SUBDIRECTORY( code/ )
|
||||||
SET ( ASSIMP_BUILD_ASSIMP_TOOLS ON CACHE BOOL
|
SET ( ASSIMP_BUILD_ASSIMP_TOOLS ON CACHE BOOL
|
||||||
"If the supplementary tools for Assimp are built in addition to the library."
|
"If the supplementary tools for Assimp are built in addition to the library."
|
||||||
|
@ -192,38 +191,38 @@ ENDIF(MSVC)
|
||||||
|
|
||||||
if(CMAKE_CPACK_COMMAND AND UNIX AND ASSIMP_OPT_BUILD_PACKAGES)
|
if(CMAKE_CPACK_COMMAND AND UNIX AND ASSIMP_OPT_BUILD_PACKAGES)
|
||||||
# Packing information
|
# Packing information
|
||||||
set(CPACK_PACKAGE_NAME assimp{ASSIMP_VERSION_MAJOR})
|
set(CPACK_PACKAGE_NAME "assimp{ASSIMP_VERSION_MAJOR}")
|
||||||
set(CPACK_PACKAGE_CONTACT "" CACHE STRING "Package maintainer and PGP signer.")
|
set(CPACK_PACKAGE_CONTACT "" CACHE STRING "Package maintainer and PGP signer.")
|
||||||
set(CPACK_PACKAGE_VENDOR "http://assimp.sourceforge.net/")
|
set(CPACK_PACKAGE_VENDOR "http://assimp.sourceforge.net/")
|
||||||
set(CPACK_PACKAGE_DISPLAY_NAME "Assimp ${ASSIMP_VERSION}")
|
set(CPACK_PACKAGE_DISPLAY_NAME "Assimp ${ASSIMP_VERSION}")
|
||||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY " - Open Asset Import Library ${ASSIMP_VERSION}")
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY " - Open Asset Import Library ${ASSIMP_VERSION}")
|
||||||
set(CPACK_PACKAGE_VERSION ${ASSIMP_VERSION}.${ASSIMP_PACKAGE_VERSION})
|
set(CPACK_PACKAGE_VERSION "${ASSIMP_VERSION}.${ASSIMP_PACKAGE_VERSION}" )
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR ${ASSIMP_VERSION_MAJOR})
|
set(CPACK_PACKAGE_VERSION_MAJOR "${ASSIMP_VERSION_MAJOR}")
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR ${ASSIMP_VERSION_MINOR})
|
set(CPACK_PACKAGE_VERSION_MINOR "${ASSIMP_VERSION_MINOR}")
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH ${ASSIMP_VERSION_PATCH})
|
set(CPACK_PACKAGE_VERSION_PATCH "${ASSIMP_VERSION_PATCH}")
|
||||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "assimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}")
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "assimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}")
|
||||||
#set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/description)
|
#set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/description")
|
||||||
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||||
|
|
||||||
string(TOUPPER ${LIBASSIMP_COMPONENT} LIBASSIMP_COMPONENT_UPPER)
|
string(TOUPPER ${LIBASSIMP_COMPONENT} "LIBASSIMP_COMPONENT_UPPER")
|
||||||
string(TOUPPER ${LIBASSIMP-DEV_COMPONENT} LIBASSIMP-DEV_COMPONENT_UPPER)
|
string(TOUPPER ${LIBASSIMP-DEV_COMPONENT} "LIBASSIMP-DEV_COMPONENT_UPPER")
|
||||||
|
|
||||||
set(CPACK_COMPONENT_ASSIMP-BIN_DISPLAY_NAME "tools")
|
set(CPACK_COMPONENT_ASSIMP-BIN_DISPLAY_NAME "tools")
|
||||||
set(CPACK_COMPONENT_ASSIMP-BIN_DEPENDS ${LIBASSIMP_COMPONENT})
|
set(CPACK_COMPONENT_ASSIMP-BIN_DEPENDS "${LIBASSIMP_COMPONENT}" )
|
||||||
set(CPACK_COMPONENT_${LIBASSIMP_COMPONENT_UPPER}_DISPLAY_NAME "libraries")
|
set(CPACK_COMPONENT_${LIBASSIMP_COMPONENT_UPPER}_DISPLAY_NAME "libraries")
|
||||||
set(CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT_UPPER}_DISPLAY_NAME "common headers and installs")
|
set(CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT_UPPER}_DISPLAY_NAME "common headers and installs")
|
||||||
set(CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT_UPPER}_DEPENDS ${LIBASSIMP_COMPONENT})
|
set(CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT_UPPER}_DEPENDS $ "{LIBASSIMP_COMPONENT}" )
|
||||||
set(CPACK_COMPONENT_ASSIMP-DEV_DISPLAY_NAME ${CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT}_DISPLAY_NAME})
|
set(CPACK_COMPONENT_ASSIMP-DEV_DISPLAY_NAME "${CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT}_DISPLAY_NAME}" )
|
||||||
set(CPACK_COMPONENT_ASSIMP-DEV_DEPENDS ${LIBASSIMP-DEV_COMPONENT})
|
set(CPACK_COMPONENT_ASSIMP-DEV_DEPENDS "${LIBASSIMP-DEV_COMPONENT}" )
|
||||||
set(CPACK_DEBIAN_BUILD_DEPENDS debhelper cmake libboost-dev libboost-thread-dev libboost-math-dev zlib1g-dev pkg-config)
|
set(CPACK_DEBIAN_BUILD_DEPENDS debhelper cmake libboost-dev libboost-thread-dev libboost-math-dev zlib1g-dev pkg-config)
|
||||||
|
|
||||||
# debian
|
# debian
|
||||||
set(CPACK_DEBIAN_PACKAGE_PRIORITY optional)
|
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||||
set(CPACK_DEBIAN_CMAKE_OPTIONS "-DBUILD_ASSIMP_SAMPLES:BOOL=${ASSIMP_BUILD_SAMPLES}")
|
set(CPACK_DEBIAN_CMAKE_OPTIONS "-DBUILD_ASSIMP_SAMPLES:BOOL=${ASSIMP_BUILD_SAMPLES}")
|
||||||
set(CPACK_DEBIAN_PACKAGE_SECTION libs)
|
set(CPACK_DEBIAN_PACKAGE_SECTION "libs" )
|
||||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_COMPONENTS_ALL})
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_COMPONENTS_ALL}")
|
||||||
set(CPACK_DEBIAN_PACKAGE_SUGGESTS)
|
set(CPACK_DEBIAN_PACKAGE_SUGGESTS)
|
||||||
set(CPACK_DEBIAN_PACKAGE_NAME assimp)
|
set(CPACK_DEBIAN_PACKAGE_NAME "assimp")
|
||||||
set(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES contrib/cppunit-1.12.1 contrib/cppunit_note.txt contrib/zlib workspaces test doc obj samples packaging)
|
set(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES contrib/cppunit-1.12.1 contrib/cppunit_note.txt contrib/zlib workspaces test doc obj samples packaging)
|
||||||
set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY svn export --force)
|
set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY svn export --force)
|
||||||
set(CPACK_DEBIAN_CHANGELOG)
|
set(CPACK_DEBIAN_CHANGELOG)
|
||||||
|
|
|
@ -57,17 +57,32 @@ def make_tuple(ai_obj, type = None):
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
# It is faster and more correct to have an init function for each assimp class
|
||||||
|
def _init_face(aiFace):
|
||||||
|
aiFace.indices = [aiFace.mIndices[i] for i in range(aiFace.mNumIndices)]
|
||||||
|
|
||||||
|
assimp_struct_inits = \
|
||||||
|
{ structs.Face : _init_face }
|
||||||
|
|
||||||
def call_init(obj, caller = None):
|
def call_init(obj, caller = None):
|
||||||
# init children
|
if helper.hasattr_silent(obj,'contents'): #pointer
|
||||||
if helper.hasattr_silent(obj, '_init'):
|
_init(obj.contents, obj, caller)
|
||||||
obj._init(parent = caller)
|
else:
|
||||||
|
_init(obj,parent=caller)
|
||||||
# pointers
|
|
||||||
elif helper.hasattr_silent(obj, 'contents'):
|
|
||||||
if helper.hasattr_silent(obj.contents, '_init'):
|
|
||||||
obj.contents._init(target = obj, parent = caller)
|
|
||||||
|
|
||||||
|
|
||||||
|
def _is_init_type(obj):
|
||||||
|
if helper.hasattr_silent(obj,'contents'): #pointer
|
||||||
|
return _is_init_type(obj[0])
|
||||||
|
# null-pointer case that arises when we reach a mesh attribute
|
||||||
|
# like mBitangents which use mNumVertices rather than mNumBitangents
|
||||||
|
# so it breaks the 'is iterable' check.
|
||||||
|
# Basically:
|
||||||
|
# FIXME!
|
||||||
|
elif not bool(obj):
|
||||||
|
return False
|
||||||
|
tname = obj.__class__.__name__
|
||||||
|
return not (tname[:2] == 'c_' or tname == 'Structure' \
|
||||||
|
or tname == 'POINTER') and not isinstance(obj,int)
|
||||||
|
|
||||||
def _init(self, target = None, parent = None):
|
def _init(self, target = None, parent = None):
|
||||||
"""
|
"""
|
||||||
|
@ -76,29 +91,35 @@ def _init(self, target = None, parent = None):
|
||||||
:param target: set the object which receive the added methods. Useful when manipulating
|
:param target: set the object which receive the added methods. Useful when manipulating
|
||||||
pointers, to skip the intermediate 'contents' deferencing.
|
pointers, to skip the intermediate 'contents' deferencing.
|
||||||
"""
|
"""
|
||||||
if helper.hasattr_silent(self, '_is_init'):
|
|
||||||
return self
|
|
||||||
self._is_init = True
|
|
||||||
|
|
||||||
if not target:
|
if not target:
|
||||||
target = self
|
target = self
|
||||||
|
|
||||||
for m in dir(self):
|
dirself = dir(self)
|
||||||
|
for m in dirself:
|
||||||
name = m[1:].lower()
|
|
||||||
|
|
||||||
if m.startswith("_"):
|
if m.startswith("_"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
obj = getattr(self, m)
|
|
||||||
|
|
||||||
if m.startswith('mNum'):
|
if m.startswith('mNum'):
|
||||||
if 'm' + m[4:] in dir(self):
|
if 'm' + m[4:] in dirself:
|
||||||
continue # will be processed later on
|
continue # will be processed later on
|
||||||
else:
|
else:
|
||||||
|
name = m[1:].lower()
|
||||||
|
|
||||||
|
obj = getattr(self, m)
|
||||||
setattr(target, name, obj)
|
setattr(target, name, obj)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if m == 'mName':
|
||||||
|
obj = self.mName
|
||||||
|
target.name = str(obj.data.decode("utf-8"))
|
||||||
|
target.__class__.__repr__ = lambda x: str(x.__class__) + "(" + x.name + ")"
|
||||||
|
target.__class__.__str__ = lambda x: x.name
|
||||||
|
continue
|
||||||
|
|
||||||
|
name = m[1:].lower()
|
||||||
|
|
||||||
|
obj = getattr(self, m)
|
||||||
|
|
||||||
# Create tuples
|
# Create tuples
|
||||||
if isinstance(obj, assimp_structs_as_tuple):
|
if isinstance(obj, assimp_structs_as_tuple):
|
||||||
|
@ -106,14 +127,6 @@ def _init(self, target = None, parent = None):
|
||||||
logger.debug(str(self) + ": Added array " + str(getattr(target, name)) + " as self." + name.lower())
|
logger.debug(str(self) + ": Added array " + str(getattr(target, name)) + " as self." + name.lower())
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
if isinstance(obj, structs.String):
|
|
||||||
setattr(target, 'name', obj.data.decode("utf-8"))
|
|
||||||
setattr(target.__class__, '__repr__', lambda x: str(x.__class__) + "(" + x.name + ")")
|
|
||||||
setattr(target.__class__, '__str__', lambda x: x.name)
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
if m.startswith('m'):
|
if m.startswith('m'):
|
||||||
|
|
||||||
if name == "parent":
|
if name == "parent":
|
||||||
|
@ -150,8 +163,15 @@ def _init(self, target = None, parent = None):
|
||||||
logger.debug(str(self) + ": Added list of " + str(obj) + " " + name + " as self." + name + " (type: " + str(type(obj)) + ")")
|
logger.debug(str(self) + ": Added list of " + str(obj) + " " + name + " as self." + name + " (type: " + str(type(obj)) + ")")
|
||||||
|
|
||||||
# initialize array elements
|
# initialize array elements
|
||||||
|
try:
|
||||||
|
init = assimp_struct_inits[type(obj[0])]
|
||||||
|
except KeyError:
|
||||||
|
if _is_init_type(obj[0]):
|
||||||
for e in getattr(target, name):
|
for e in getattr(target, name):
|
||||||
call_init(e, caller = target)
|
call_init(e, target)
|
||||||
|
else:
|
||||||
|
for e in getattr(target, name):
|
||||||
|
init(e)
|
||||||
|
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
@ -175,7 +195,8 @@ def _init(self, target = None, parent = None):
|
||||||
setattr(target, name, obj)
|
setattr(target, name, obj)
|
||||||
logger.debug("Added " + name + " as self." + name + " (type: " + str(type(obj)) + ")")
|
logger.debug("Added " + name + " as self." + name + " (type: " + str(type(obj)) + ")")
|
||||||
|
|
||||||
call_init(obj, caller = target)
|
if _is_init_type(obj):
|
||||||
|
call_init(obj, target)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,16 +210,6 @@ def _init(self, target = None, parent = None):
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
Python magic to add the _init() function to all C struct classes.
|
|
||||||
"""
|
|
||||||
for struct in dir(structs):
|
|
||||||
if not (struct.startswith('_') or struct.startswith('c_') or struct == "Structure" or struct == "POINTER") and not isinstance(getattr(structs, struct),int):
|
|
||||||
|
|
||||||
setattr(getattr(structs, struct), '_init', _init)
|
|
||||||
|
|
||||||
|
|
||||||
class AssimpLib(object):
|
class AssimpLib(object):
|
||||||
"""
|
"""
|
||||||
Assimp-Singleton
|
Assimp-Singleton
|
||||||
|
@ -281,7 +292,7 @@ def load(filename, processing=0):
|
||||||
#Uhhh, something went wrong!
|
#Uhhh, something went wrong!
|
||||||
raise AssimpError("could not import file: %s" % filename)
|
raise AssimpError("could not import file: %s" % filename)
|
||||||
|
|
||||||
scene = model.contents._init()
|
scene = _init(model.contents)
|
||||||
|
|
||||||
recur_pythonize(scene.rootnode, scene)
|
recur_pythonize(scene.rootnode, scene)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue