update assimp lib

This commit is contained in:
marauder2k7 2024-12-09 20:22:47 +00:00
parent 03a348deb7
commit d3f8fee74e
1725 changed files with 196314 additions and 62009 deletions

View file

@ -0,0 +1,17 @@
ISC License
Copyright 2024, pyassimp contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

View file

@ -76,7 +76,7 @@ $ python setup.py install
```
PyAssimp requires a assimp dynamic library (`DLL` on windows,
`.so` on linux, `.dynlib` on macOS) in order to work. The default search directories are:
`.so` on linux, `.dylib` on macOS) in order to work. The default search directories are:
- the current directory
- on linux additionally: `/usr/lib`, `/usr/local/lib`,
`/usr/lib/x86_64-linux-gnu`

View file

@ -81,7 +81,7 @@ Install ``pyassimp`` by running:
$ python setup.py install
PyAssimp requires a assimp dynamic library (``DLL`` on windows, ``.so``
on linux, ``.dynlib`` on macOS) in order to work. The default search
on linux, ``.dylib`` on macOS) in order to work. The default search
directories are:
- the current directory

View file

@ -115,6 +115,10 @@ def _init(self, target = None, parent = None):
if m.startswith("_"):
continue
# We should not be accessing `mPrivate` according to structs.Scene.
if m == 'mPrivate':
continue
if m.startswith('mNum'):
if 'm' + m[4:] in dirself:
continue # will be processed later on
@ -211,7 +215,7 @@ def _init(self, target = None, parent = None):
else: # starts with 'm' but not iterable
setattr(target, m, obj)
setattr(target, name, obj)
logger.debug("Added " + name + " as self." + name + " (type: " + str(type(obj)) + ")")
if _is_init_type(obj):
@ -307,6 +311,7 @@ def load(filename,
Scene object with model data
'''
from ctypes import c_char_p
if hasattr(filename, 'read'):
# This is the case where a file object has been passed to load.
# It is calling the following function:
@ -320,7 +325,7 @@ def load(filename,
model = _assimp_lib.load_mem(data,
len(data),
processing,
file_type)
c_char_p(file_type.encode(sys.getfilesystemencoding())))
else:
# a filename string has been passed
model = _assimp_lib.load(filename.encode(sys.getfilesystemencoding()), processing)
@ -386,6 +391,19 @@ def export_blob(scene,
raise AssimpError('Could not export scene to blob!')
return exportBlobPtr
def available_formats():
"""
Return a list of file format extensions supported to import.
Returns
---------
A list of upper-case file extensions, e.g. [3DS, OBJ]
"""
from ctypes import byref
extension_list = structs.String()
_assimp_lib.dll.aiGetExtensionList(byref(extension_list))
return [e[2:].upper() for e in str(extension_list.data, sys.getfilesystemencoding()).split(";")]
def _finalize_texture(tex, target):
setattr(target, "achformathint", tex.achFormatHint)
if numpy:

View file

@ -1,41 +0,0 @@
FORMATS = ["CSM",
"LWS",
"B3D",
"COB",
"PLY",
"IFC",
"OFF",
"SMD",
"IRRMESH",
"3D",
"DAE",
"MDL",
"HMP",
"TER",
"WRL",
"XML",
"NFF",
"AC",
"OBJ",
"3DS",
"STL",
"IRR",
"Q3O",
"Q3D",
"MS3D",
"Q3S",
"ZGL",
"MD2",
"X",
"BLEND",
"XGL",
"MD5MESH",
"MAX",
"LXO",
"DXF",
"BVH",
"LWO",
"NDO"]
def available_formats():
return FORMATS

View file

@ -5,13 +5,17 @@ Some fancy helper functions.
"""
import os
import platform
import ctypes
import operator
from distutils.sysconfig import get_python_lib
import re
import sys
have_distutils = sys.version_info[0] < 3 and sys.version_info[1] < 12
if have_distutils:
from distutils.sysconfig import get_python_lib
try: import numpy
except ImportError: numpy = None
@ -32,10 +36,14 @@ if os.name=='posix':
if 'LD_LIBRARY_PATH' in os.environ:
additional_dirs.extend([item for item in os.environ['LD_LIBRARY_PATH'].split(':') if item])
if platform.system() == 'Darwin':
if 'DYLD_LIBRARY_PATH' in os.environ:
additional_dirs.extend([item for item in os.environ['DYLD_LIBRARY_PATH'].split(':') if item])
# check if running from anaconda.
anaconda_keywords = ("conda", "continuum")
if any(k in sys.version.lower() for k in anaconda_keywords):
if have_distutils and any(k in sys.version.lower() for k in anaconda_keywords):
cur_path = get_python_lib()
pattern = re.compile('.*\/lib\/')
conda_lib = pattern.match(cur_path).group()

View file

@ -270,7 +270,7 @@ aiProcess_SortByPType = 0x8000
# point primitives to separate meshes.
# <li>
# <li>Set the <tt>AI_CONFIG_PP_SBP_REMOVE<tt> option to
# @code aiPrimitiveType_POINTS | aiPrimitiveType_LINES
# @code aiPrimitiveType_POINT | aiPrimitiveType_LINE
# @endcode to cause SortByPType to reject point
# and line meshes from the scene.
# <li>

View file

@ -1,6 +1,6 @@
#-*- coding: utf-8 -*-
from ctypes import POINTER, c_void_p, c_uint, c_char, c_float, Structure, c_double, c_ubyte, c_size_t, c_uint32
from ctypes import POINTER, c_void_p, c_uint, c_char, c_float, Structure, c_double, c_ubyte, c_size_t, c_uint32, c_int
class Vector2D(Structure):
@ -70,7 +70,7 @@ class String(Structure):
See 'types.h' for details.
"""
MAXLEN = 1024
AI_MAXLEN = 1024
_fields_ = [
# Binary length of the string excluding the terminal 0. This is NOT the
@ -78,8 +78,8 @@ class String(Structure):
# the number of bytes from the beginning of the string to its end.
("length", c_uint32),
# String buffer. Size limit is MAXLEN
("data", c_char*MAXLEN),
# String buffer. Size limit is AI_MAXLEN
("data", c_char*AI_MAXLEN),
]
class MaterialPropertyString(Structure):
@ -90,7 +90,7 @@ class MaterialPropertyString(Structure):
material property (see MaterialSystem.cpp aiMaterial::AddProperty() for details).
"""
MAXLEN = 1024
AI_MAXLEN = 1024
_fields_ = [
# Binary length of the string excluding the terminal 0. This is NOT the
@ -98,8 +98,8 @@ class MaterialPropertyString(Structure):
# the number of bytes from the beginning of the string to its end.
("length", c_uint32),
# String buffer. Size limit is MAXLEN
("data", c_char*MAXLEN),
# String buffer. Size limit is AI_MAXLEN
("data", c_char*AI_MAXLEN),
]
class MemoryInfo(Structure):
@ -748,18 +748,29 @@ class Mesh(Structure):
# - Vertex animations refer to meshes by their names.
("mName", String),
# The number of attachment meshes. Note! Currently only works with Collada loader.
# The number of attachment meshes.
# Currently known to work with loaders:
# - Collada
# - gltf
("mNumAnimMeshes", c_uint),
# Attachment meshes for this mesh, for vertex-based animation.
# Attachment meshes carry replacement data for some of the
# mesh'es vertex components (usually positions, normals).
# Note! Currently only works with Collada loader.
# Currently known to work with loaders:
# - Collada
# - gltf
("mAnimMeshes", POINTER(POINTER(AnimMesh))),
# Method of morphing when animeshes are specified.
("mMethod", c_uint),
# The bounding box.
("mAABB", 2 * Vector3D),
# Vertex UV stream names. Pointer to array of size AI_MAX_NUMBER_OF_TEXTURECOORDS
("mTextureCoordsNames", POINTER(POINTER(String)))
]
class Camera(Structure):
@ -999,6 +1010,54 @@ class Animation(Structure):
]
class SkeletonBone(Structure):
"""
See 'mesh.h' for details
"""
_fields_ = [
# The parent bone index, is -1 one if this bone represents the root bone.
("mParent", c_int),
# The number of weights
("mNumnWeights", c_uint),
# The mesh index, which will get influenced by the weight
("mMeshId", POINTER(Mesh)),
# The influence weights of this bone, by vertex index.
("mWeights", POINTER(VertexWeight)),
# Matrix that transforms from bone space to mesh space in bind pose.
#
# This matrix describes the position of the mesh
# in the local space of this bone when the skeleton was bound.
# Thus it can be used directly to determine a desired vertex position,
# given the world-space transform of the bone when animated,
# and the position of the vertex in mesh space.
#
# It is sometimes called an inverse-bind matrix,
# or inverse bind pose matrix
("mOffsetMatrix", Matrix4x4),
# Matrix that transforms the locale bone in bind pose.
("mLocalMatrix", Matrix4x4)
]
class Skeleton(Structure):
"""
See 'mesh.h' for details
"""
_fields_ = [
# Name
("mName", String),
# Number of bones
("mNumBones", c_uint),
# Bones
("mBones", POINTER(POINTER(SkeletonBone)))
]
class ExportDataBlob(Structure):
"""
See 'cexport.h' for details.
@ -1120,6 +1179,15 @@ class Scene(Structure):
# can be used to store format-specific metadata as well.
("mMetadata", POINTER(Metadata)),
# The name of the scene itself
("mName", String),
# Number of skeletons
("mNumSkeletons", c_uint),
# Skeletons
("mSkeletons", POINTER(POINTER(Skeleton))),
# Internal data, do not touch
("mPrivate", POINTER(c_char)),
]

View file

@ -466,8 +466,8 @@ class PyAssimp3DViewer:
try:
self.set_shaders_v130()
self.prepare_shaders()
except RuntimeError, message:
sys.stderr.write("%s\n" % message)
except RuntimeError as e:
sys.stderr.write("%s\n" % e.message)
sys.stdout.write("Could not compile shaders in version 1.30, trying version 1.20\n")
if not shader_compilation_succeeded:

View file

@ -8,7 +8,7 @@ def readme():
return f.read()
setup(name='pyassimp',
version='4.1.4',
version='5.2.5',
license='ISC',
description='Python bindings for the Open Asset Import Library (ASSIMP)',
long_description=readme(),