Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
02a08075
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
02a08075
编写于
3月 04, 2015
作者:
R
rkusa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Blender: export hierarchy
上级
e60612aa
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
62 addition
and
55 deletion
+62
-55
utils/exporters/blender/addons/io_three/__init__.py
utils/exporters/blender/addons/io_three/__init__.py
+13
-0
utils/exporters/blender/addons/io_three/constants.py
utils/exporters/blender/addons/io_three/constants.py
+3
-0
utils/exporters/blender/addons/io_three/exporter/api/object.py
.../exporters/blender/addons/io_three/exporter/api/object.py
+25
-42
utils/exporters/blender/addons/io_three/exporter/object.py
utils/exporters/blender/addons/io_three/exporter/object.py
+12
-12
utils/exporters/blender/addons/io_three/exporter/scene.py
utils/exporters/blender/addons/io_three/exporter/scene.py
+9
-1
未找到文件。
utils/exporters/blender/addons/io_three/__init__.py
浏览文件 @
02a08075
...
...
@@ -303,6 +303,7 @@ def save_settings_export(properties):
constants
.
EMBED_ANIMATION
:
properties
.
option_embed_animation
,
constants
.
LIGHTS
:
properties
.
option_lights
,
constants
.
CAMERAS
:
properties
.
option_cameras
,
constants
.
HIERARCHY
:
properties
.
option_hierarchy
,
constants
.
MORPH_TARGETS
:
properties
.
option_animation_morph
,
constants
.
ANIMATION
:
properties
.
option_animation_skeletal
,
...
...
@@ -447,6 +448,10 @@ def restore_settings_export(properties):
properties
.
option_cameras
=
settings
.
get
(
constants
.
CAMERAS
,
constants
.
EXPORT_OPTIONS
[
constants
.
CAMERAS
])
properties
.
option_hierarchy
=
settings
.
get
(
constants
.
HIERARCHY
,
constants
.
EXPORT_OPTIONS
[
constants
.
HIERARCHY
])
## }
## Animation {
...
...
@@ -638,6 +643,11 @@ class ExportThree(bpy.types.Operator, ExportHelper):
description
=
"Export default scene cameras"
,
default
=
False
)
option_hierarchy
=
BoolProperty
(
name
=
"Hierarchy"
,
description
=
"Export object hierarchy"
,
default
=
False
)
option_animation_morph
=
BoolProperty
(
name
=
"Morph animation"
,
description
=
"Export animation (morphs)"
,
...
...
@@ -811,6 +821,9 @@ class ExportThree(bpy.types.Operator, ExportHelper):
row
.
prop
(
self
.
properties
,
'option_cameras'
)
## }
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
'option_hierarchy'
)
layout
.
separator
()
## Settings {
...
...
utils/exporters/blender/addons/io_three/constants.py
浏览文件 @
02a08075
...
...
@@ -60,6 +60,7 @@ SKIN_WEIGHTS = 'skinWeights'
LOGGING
=
'logging'
CAMERAS
=
'cameras'
LIGHTS
=
'lights'
HIERARCHY
=
'hierarchy'
FACE_MATERIALS
=
'faceMaterials'
SKINNING
=
'skinning'
COPY_TEXTURES
=
'copyTextures'
...
...
@@ -110,6 +111,7 @@ EXPORT_OPTIONS = {
MORPH_TARGETS
:
False
,
CAMERAS
:
False
,
LIGHTS
:
False
,
HIERARCHY
:
False
,
COPY_TEXTURES
:
True
,
TEXTURE_FOLDER
:
''
,
LOGGING
:
DEBUG
,
...
...
@@ -160,6 +162,7 @@ POINT_LIGHT = 'PointLight'
SPOT_LIGHT
=
'SpotLight'
HEMISPHERE_LIGHT
=
'HemisphereLight'
MESH
=
'Mesh'
EMPTY
=
'Empty'
SPRITE
=
'Sprite'
DEFAULT_METADATA
=
{
...
...
utils/exporters/blender/addons/io_three/exporter/api/object.py
浏览文件 @
02a08075
...
...
@@ -2,6 +2,7 @@ import math
import
mathutils
import
bpy
from
bpy
import
data
,
context
,
types
from
bpy_extras.io_utils
import
axis_conversion
from
..
import
constants
,
logger
,
utilities
,
exceptions
from
.constants
import
(
MESH
,
...
...
@@ -225,14 +226,8 @@ def position(obj, options):
"""
logger
.
debug
(
'object.position(%s)'
,
obj
)
vector
=
_decompose_matrix
(
obj
)[
0
]
vector
=
(
vector
.
x
,
vector
.
y
,
vector
.
z
)
round_off
,
round_val
=
utilities
.
rounding
(
options
)
if
round_off
:
vector
=
utilities
.
round_off
(
vector
,
round_val
)
return
vector
vector
=
matrix
(
obj
,
options
).
to_translation
()
return
(
vector
.
x
,
vector
.
y
,
vector
.
z
)
@
_object
...
...
@@ -250,23 +245,35 @@ def receive_shadow(obj):
return
False
AXIS_CONVERSION
=
axis_conversion
(
to_forward
=
'Z'
,
to_up
=
'Y'
).
to_4x4
()
@
_object
def
rotation
(
obj
,
options
):
def
matrix
(
obj
,
options
):
"""
:param obj:
:param options:
"""
logger
.
debug
(
'object.rotation(%s)'
,
obj
)
vector
=
_decompose_matrix
(
obj
)[
1
].
to_euler
(
ZYX
)
vector
=
(
vector
.
x
,
vector
.
y
,
vector
.
z
)
logger
.
debug
(
'object.matrix(%s)'
,
obj
)
if
options
.
get
(
constants
.
HIERARCHY
,
False
)
and
obj
.
parent
:
parent_inverted
=
obj
.
parent
.
matrix_world
.
inverted
(
mathutils
.
Matrix
())
return
parent_inverted
*
obj
.
matrix_world
else
:
return
AXIS_CONVERSION
*
obj
.
matrix_world
round_off
,
round_val
=
utilities
.
rounding
(
options
)
if
round_off
:
vector
=
utilities
.
round_off
(
vector
,
round_val
)
@
_object
def
rotation
(
obj
,
options
):
"""
:param obj:
:param options:
return
vector
"""
logger
.
debug
(
'object.rotation(%s)'
,
obj
)
vector
=
matrix
(
obj
,
options
).
to_euler
(
ZYX
)
return
(
vector
.
x
,
vector
.
y
,
vector
.
z
)
@
_object
...
...
@@ -278,14 +285,8 @@ def scale(obj, options):
"""
logger
.
debug
(
'object.scale(%s)'
,
obj
)
vector
=
_decompose_matrix
(
obj
)[
2
]
vector
=
(
vector
.
x
,
vector
.
y
,
vector
.
z
)
round_off
,
round_val
=
utilities
.
rounding
(
options
)
if
round_off
:
vector
=
utilities
.
round_off
(
vector
,
round_val
)
return
vector
vector
=
matrix
(
obj
,
options
).
to_scale
()
return
(
vector
.
x
,
vector
.
y
,
vector
.
z
)
@
_object
...
...
@@ -477,24 +478,6 @@ def extracted_meshes():
return
[
key
for
key
in
_MESH_MAP
.
keys
()]
def
_decompose_matrix
(
obj
,
local
=
False
):
"""
:param obj:
:param local: (Default value = False)
"""
rotate_x_pi2
=
mathutils
.
Quaternion
((
1.0
,
0.0
,
0.0
),
math
.
radians
(
-
90.0
))
rotate_x_pi2
=
rotate_x_pi2
.
to_matrix
().
to_4x4
()
if
local
:
matrix
=
rotate_x_pi2
*
obj
.
matrix_local
else
:
matrix
=
rotate_x_pi2
*
obj
.
matrix_world
return
matrix
.
decompose
()
def
_on_visible_layer
(
obj
,
visible_layers
):
"""
...
...
utils/exporters/blender/addons/io_three/exporter/object.py
浏览文件 @
02a08075
...
...
@@ -68,14 +68,13 @@ class Object(base_classes.BaseNode):
logger
.
debug
(
"Object()._node_setup()"
)
self
[
constants
.
NAME
]
=
api
.
object
.
name
(
self
.
node
)
self
[
constants
.
POSITION
]
=
api
.
object
.
position
(
self
.
node
,
self
.
options
)
transform
=
api
.
object
.
matrix
(
self
.
node
,
self
.
options
)
matrix
=
[]
for
col
in
range
(
0
,
4
):
for
row
in
range
(
0
,
4
):
matrix
.
append
(
transform
[
row
][
col
])
self
[
constants
.
ROTATION
]
=
api
.
object
.
rotation
(
self
.
node
,
self
.
options
)
self
[
constants
.
SCALE
]
=
api
.
object
.
scale
(
self
.
node
,
self
.
options
)
self
[
constants
.
MATRIX
]
=
matrix
self
[
constants
.
VISIBLE
]
=
api
.
object
.
visible
(
self
.
node
)
...
...
@@ -120,11 +119,12 @@ class Object(base_classes.BaseNode):
elif
self
[
constants
.
TYPE
]
in
lights
:
self
.
_init_light
()
#for child in api.object.children(self.node, self.scene.valid_types):
# if not self.get(constants.CHILDREN):
# self[constants.CHILDREN] = [Object(child, parent=self)]
# else:
# self[constants.CHILDREN].append(Object(child, parent=self))
if
self
.
options
.
get
(
constants
.
HIERARCHY
,
False
):
for
child
in
api
.
object
.
children
(
self
.
node
,
self
.
scene
.
valid_types
):
if
not
self
.
get
(
constants
.
CHILDREN
):
self
[
constants
.
CHILDREN
]
=
[
Object
(
child
,
parent
=
self
)]
else
:
self
[
constants
.
CHILDREN
].
append
(
Object
(
child
,
parent
=
self
))
def
_root_setup
(
self
):
"""Applies to a root/scene object"""
...
...
utils/exporters/blender/addons/io_three/exporter/scene.py
浏览文件 @
02a08075
...
...
@@ -39,6 +39,9 @@ class Scene(base_classes.BaseScene):
"""
valid_types
=
[
api
.
constants
.
MESH
]
if
self
.
options
.
get
(
constants
.
HIERARCHY
,
False
):
valid_types
.
append
(
api
.
constants
.
EMPTY
)
if
self
.
options
.
get
(
constants
.
CAMERAS
):
logger
.
info
(
"Adding cameras to valid object types"
)
valid_types
.
append
(
api
.
constants
.
CAMERA
)
...
...
@@ -207,7 +210,12 @@ class Scene(base_classes.BaseScene):
self
[
constants
.
UUID
]
=
utilities
.
id_from_name
(
scene_name
)
objects
=
[]
for
node
in
api
.
object
.
nodes
(
self
.
valid_types
,
self
.
options
):
if
self
.
options
.
get
(
constants
.
HIERARCHY
,
False
):
nodes
=
api
.
object
.
assemblies
(
self
.
valid_types
,
self
.
options
)
else
:
nodes
=
api
.
object
.
nodes
(
self
.
valid_types
,
self
.
options
)
for
node
in
nodes
:
logger
.
info
(
"Parsing object %s"
,
node
)
obj
=
object_
.
Object
(
node
,
parent
=
self
[
constants
.
OBJECT
])
objects
.
append
(
obj
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录