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

@ -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)),
]