Merge branch 'master' into fbx_blendshape_channelName
commit
f67c71d5c7
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -239,11 +238,13 @@ bool Structure :: ReadFieldPtr(TOUT<T> (&out)[N], const char* name,
|
||||||
try {
|
try {
|
||||||
f = &(*this)[name];
|
f = &(*this)[name];
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
// sanity check, should never happen if the genblenddna script is right
|
// sanity check, should never happen if the genblenddna script is right
|
||||||
if ((FieldFlag_Pointer|FieldFlag_Pointer) != (f->flags & (FieldFlag_Pointer|FieldFlag_Pointer))) {
|
if ((FieldFlag_Pointer|FieldFlag_Pointer) != (f->flags & (FieldFlag_Pointer|FieldFlag_Pointer))) {
|
||||||
throw Error((Formatter::format(),"Field `",name,"` of structure `",
|
throw Error((Formatter::format(),"Field `",name,"` of structure `",
|
||||||
this->name,"` ought to be a pointer AND an array"));
|
this->name,"` ought to be a pointer AND an array"));
|
||||||
}
|
}
|
||||||
|
#endif // _DEBUG
|
||||||
|
|
||||||
db.reader->IncPtr(f->offset);
|
db.reader->IncPtr(f->offset);
|
||||||
|
|
||||||
|
|
|
@ -5071,7 +5071,7 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
ptr += sprintf(ptr, "\r\n");
|
ptr += sprintf(ptr, "\r\n");
|
||||||
}
|
}
|
||||||
/* mathematical shapes face */
|
/* mathematical shapes face */
|
||||||
if (model->numshape && model->numshape && !(flags & M3D_EXP_NOFACE)) {
|
if (model->numshape !(flags & M3D_EXP_NOFACE)) {
|
||||||
for (j = 0; j < model->numshape; j++) {
|
for (j = 0; j < model->numshape; j++) {
|
||||||
sn = _m3d_safestr(model->shape[j].name, 0);
|
sn = _m3d_safestr(model->shape[j].name, 0);
|
||||||
if (!sn) {
|
if (!sn) {
|
||||||
|
|
|
@ -62,6 +62,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#define RAPIDJSON_HAS_STDSTRING 1
|
#define RAPIDJSON_HAS_STDSTRING 1
|
||||||
|
#define RAPIDJSON_NOMEMBERITERATORCLASS
|
||||||
#include <rapidjson/rapidjson.h>
|
#include <rapidjson/rapidjson.h>
|
||||||
#include <rapidjson/document.h>
|
#include <rapidjson/document.h>
|
||||||
#include <rapidjson/error/en.h>
|
#include <rapidjson/error/en.h>
|
||||||
|
|
|
@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define RAPIDJSON_HAS_STDSTRING 1
|
#define RAPIDJSON_HAS_STDSTRING 1
|
||||||
|
#define RAPIDJSON_NOMEMBERITERATORCLASS
|
||||||
#include <rapidjson/document.h>
|
#include <rapidjson/document.h>
|
||||||
#include <rapidjson/error/en.h>
|
#include <rapidjson/error/en.h>
|
||||||
#include <rapidjson/rapidjson.h>
|
#include <rapidjson/rapidjson.h>
|
||||||
|
|
|
@ -64,6 +64,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define RAPIDJSON_HAS_STDSTRING 1
|
#define RAPIDJSON_HAS_STDSTRING 1
|
||||||
|
#define RAPIDJSON_NOMEMBERITERATORCLASS
|
||||||
#include <rapidjson/document.h>
|
#include <rapidjson/document.h>
|
||||||
#include <rapidjson/error/en.h>
|
#include <rapidjson/error/en.h>
|
||||||
#include <rapidjson/rapidjson.h>
|
#include <rapidjson/rapidjson.h>
|
||||||
|
|
|
@ -416,6 +416,10 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
||||||
attr.color[c]->ExtractData(aim->mColors[c]);
|
attr.color[c]->ExtractData(aim->mColors[c]);
|
||||||
}
|
}
|
||||||
for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) {
|
for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) {
|
||||||
|
if (!attr.texcoord[tc]) {
|
||||||
|
throw DeadlyImportError("GLTF: Texture coordinate accessor not found or non-contiguous texture coordinate sets");
|
||||||
|
}
|
||||||
|
|
||||||
if (attr.texcoord[tc]->count != aim->mNumVertices) {
|
if (attr.texcoord[tc]->count != aim->mNumVertices) {
|
||||||
DefaultLogger::get()->warn("Texcoord stream size in mesh \"" + mesh.name +
|
DefaultLogger::get()->warn("Texcoord stream size in mesh \"" + mesh.name +
|
||||||
"\" does not match the vertex count");
|
"\" does not match the vertex count");
|
||||||
|
|
|
@ -42,17 +42,14 @@ substituted by assertions ...):
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
||||||
from pyassimp import *
|
from pyassimp import load
|
||||||
scene = load('hello.3ds')
|
with load('hello.3ds') as scene:
|
||||||
|
|
||||||
assert len(scene.meshes)
|
assert len(scene.meshes)
|
||||||
mesh = scene.meshes[0]
|
mesh = scene.meshes[0]
|
||||||
|
|
||||||
assert len(mesh.vertices)
|
assert len(mesh.vertices)
|
||||||
print(mesh.vertices[0])
|
print(mesh.vertices[0])
|
||||||
|
|
||||||
# don't forget this one, or you will leak!
|
|
||||||
release(scene)
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -61,13 +58,11 @@ scene:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
||||||
from pyassimp import *
|
from pyassimp import load
|
||||||
scene = load('hello.3ds')
|
with load('hello.3ds') as scene:
|
||||||
|
|
||||||
for c in scene.rootnode.children:
|
for c in scene.rootnode.children:
|
||||||
print(str(c))
|
print(str(c))
|
||||||
|
|
||||||
release(scene)
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -49,30 +49,27 @@ substituted by assertions ...):
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
|
|
||||||
from pyassimp import *
|
from pyassimp import load
|
||||||
scene = load('hello.3ds')
|
with load('hello.3ds') as scene:
|
||||||
|
|
||||||
assert len(scene.meshes)
|
assert len(scene.meshes)
|
||||||
mesh = scene.meshes[0]
|
mesh = scene.meshes[0]
|
||||||
|
|
||||||
assert len(mesh.vertices)
|
assert len(mesh.vertices)
|
||||||
print(mesh.vertices[0])
|
print(mesh.vertices[0])
|
||||||
|
|
||||||
# don't forget this one, or you will leak!
|
|
||||||
release(scene)
|
|
||||||
|
|
||||||
Another example to list the 'top nodes' in a scene:
|
Another example to list the 'top nodes' in a scene:
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
|
|
||||||
from pyassimp import *
|
from pyassimp import load
|
||||||
scene = load('hello.3ds')
|
with load('hello.3ds') as scene:
|
||||||
|
|
||||||
for c in scene.rootnode.children:
|
for c in scene.rootnode.children:
|
||||||
print(str(c))
|
print(str(c))
|
||||||
|
|
||||||
release(scene)
|
|
||||||
|
|
||||||
INSTALL
|
INSTALL
|
||||||
-------
|
-------
|
||||||
|
|
|
@ -14,10 +14,13 @@ if sys.version_info >= (3,0):
|
||||||
xrange = range
|
xrange = range
|
||||||
|
|
||||||
|
|
||||||
try: import numpy
|
try:
|
||||||
except ImportError: numpy = None
|
import numpy
|
||||||
|
except ImportError:
|
||||||
|
numpy = None
|
||||||
import logging
|
import logging
|
||||||
import ctypes
|
import ctypes
|
||||||
|
from contextlib import contextmanager
|
||||||
logger = logging.getLogger("pyassimp")
|
logger = logging.getLogger("pyassimp")
|
||||||
# attach default null handler to logger so it doesn't complain
|
# attach default null handler to logger so it doesn't complain
|
||||||
# even if you don't attach another handler to logger
|
# even if you don't attach another handler to logger
|
||||||
|
@ -272,6 +275,13 @@ def recur_pythonize(node, scene):
|
||||||
for c in node.children:
|
for c in node.children:
|
||||||
recur_pythonize(c, scene)
|
recur_pythonize(c, scene)
|
||||||
|
|
||||||
|
def release(scene):
|
||||||
|
'''
|
||||||
|
Release resources of a loaded scene.
|
||||||
|
'''
|
||||||
|
_assimp_lib.release(ctypes.pointer(scene))
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
def load(filename,
|
def load(filename,
|
||||||
file_type = None,
|
file_type = None,
|
||||||
processing = postprocess.aiProcess_Triangulate):
|
processing = postprocess.aiProcess_Triangulate):
|
||||||
|
@ -319,7 +329,10 @@ def load(filename,
|
||||||
raise AssimpError('Could not import file!')
|
raise AssimpError('Could not import file!')
|
||||||
scene = _init(model.contents)
|
scene = _init(model.contents)
|
||||||
recur_pythonize(scene.rootnode, scene)
|
recur_pythonize(scene.rootnode, scene)
|
||||||
return scene
|
try:
|
||||||
|
yield scene
|
||||||
|
finally:
|
||||||
|
release(scene)
|
||||||
|
|
||||||
def export(scene,
|
def export(scene,
|
||||||
filename,
|
filename,
|
||||||
|
@ -373,9 +386,6 @@ def export_blob(scene,
|
||||||
raise AssimpError('Could not export scene to blob!')
|
raise AssimpError('Could not export scene to blob!')
|
||||||
return exportBlobPtr
|
return exportBlobPtr
|
||||||
|
|
||||||
def release(scene):
|
|
||||||
_assimp_lib.release(ctypes.pointer(scene))
|
|
||||||
|
|
||||||
def _finalize_texture(tex, target):
|
def _finalize_texture(tex, target):
|
||||||
setattr(target, "achformathint", tex.achFormatHint)
|
setattr(target, "achformathint", tex.achFormatHint)
|
||||||
if numpy:
|
if numpy:
|
||||||
|
|
Loading…
Reference in New Issue