Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2014-03-12 23:22:51 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-03-12 23:22:51 +0400
commit3879603620c4241bec612665dd97ab4b598559c6 (patch)
treee639cf6d345b602fa02b4d2977bb9bd56efa222b /io_scene_fbx/parse_fbx.py
parenta7da6cfa5b2190e7a41c73e33396969d04f48c2f (diff)
Initial commit of new FBX 7.4 binary exporter
What to expect: * Static export of empties, meshes, cameras and lamps, as well as materials and (image!) textures should work OK. There are a few advanced topics still TODO regarding meshes and mat/tex, though. * Custom properties from objects/meshes/lamps/cameras/armatures/bones/materials/textures are exported too (only simple ones, ints/floats/strings). * Armature export: this needs testing by people having *native* FBX aplications, linking between bones and meshes seems to work, but I have doubts about bones orientations. * Animation: still a complete TODO. Note that old FBX ASCII 6.1 exporter is still available (top dropdown in exporter's UI). Many thanks to Campbell, which did the ground work of decyphering FBX binary format and wrote basic code to read/write it.
Diffstat (limited to 'io_scene_fbx/parse_fbx.py')
-rw-r--r--io_scene_fbx/parse_fbx.py35
1 files changed, 8 insertions, 27 deletions
diff --git a/io_scene_fbx/parse_fbx.py b/io_scene_fbx/parse_fbx.py
index f634e52e..87f8624f 100644
--- a/io_scene_fbx/parse_fbx.py
+++ b/io_scene_fbx/parse_fbx.py
@@ -32,6 +32,8 @@ from struct import unpack
import array
import zlib
+from . import data_types
+
# at the end of each nested block, there is a NUL record to indicate
# that the sub-scope exists (i.e. to distinguish between P: and P : {})
# this NUL record is 13 bytes long.
@@ -87,12 +89,12 @@ read_data_dict = {
b'L'[0]: lambda read: unpack(b'<q', read(8))[0], # 64 bit int
b'R'[0]: lambda read: read(read_uint(read)), # binary data
b'S'[0]: lambda read: read(read_uint(read)), # string data
- b'f'[0]: lambda read: unpack_array(read, 'f', 4, False), # array (float)
- b'i'[0]: lambda read: unpack_array(read, 'i', 4, True), # array (int)
- b'd'[0]: lambda read: unpack_array(read, 'd', 8, False), # array (double)
- b'l'[0]: lambda read: unpack_array(read, 'q', 8, True), # array (long)
- b'b'[0]: lambda read: unpack_array(read, 'b', 1, False), # array (bool)
- b'c'[0]: lambda read: unpack_array(read, 'B', 1, False), # array (ubyte)
+ b'f'[0]: lambda read: unpack_array(read, data_types.ARRAY_FLOAT32, 4, False), # array (float)
+ b'i'[0]: lambda read: unpack_array(read, data_types.ARRAY_INT32, 4, True), # array (int)
+ b'd'[0]: lambda read: unpack_array(read, data_types.ARRAY_FLOAT64, 8, False), # array (double)
+ b'l'[0]: lambda read: unpack_array(read, data_types.ARRAY_INT64, 8, True), # array (long)
+ b'b'[0]: lambda read: unpack_array(read, data_types.ARRAY_BOOL, 1, False), # array (bool)
+ b'c'[0]: lambda read: unpack_array(read, data_types.ARRAY_BYTE, 1, False), # array (ubyte)
}
@@ -166,24 +168,3 @@ def parse(fn, use_namedtuple=True):
args = (b'', [], bytearray(0), root_elems)
return FBXElem(*args) if use_namedtuple else args, fbx_version
-
-# Inline module, only for external use
-# pyfbx.data_types
-data_types = type(array)("data_types")
-data_types.__dict__.update(
-dict(
-INT16 = b'Y'[0],
-BOOL = b'C'[0],
-INT32 = b'I'[0],
-FLOAT32 = b'F'[0],
-FLOAT64 = b'D'[0],
-INT64 = b'L'[0],
-BYTES = b'R'[0],
-STRING = b'S'[0],
-FLOAT32_ARRAY = b'f'[0],
-INT32_ARRAY = b'i'[0],
-FLOAT64_ARRAY = b'd'[0],
-INT64_ARRAY = b'l'[0],
-BOOL_ARRAY = b'b'[0],
-BYTE_ARRAY = b'c'[0],
-))