Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
4fb65cc9
T
three.js
项目概览
Ablesons
/
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,发现更多精彩内容 >>
提交
4fb65cc9
编写于
9月 04, 2012
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added handling of bump maps to Blender exporter.
上级
814634ff
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
32 addition
and
5 deletion
+32
-5
utils/exporters/blender/2.63/scripts/addons/io_mesh_threejs/export_threejs.py
...der/2.63/scripts/addons/io_mesh_threejs/export_threejs.py
+32
-5
未找到文件。
utils/exporters/blender/2.63/scripts/addons/io_mesh_threejs/export_threejs.py
浏览文件 @
4fb65cc9
...
...
@@ -1145,6 +1145,7 @@ def extract_materials(mesh, scene, option_colors, option_copy_textures, filepath
handle_texture
(
'light'
,
textures
,
material
,
filepath
,
option_copy_textures
)
handle_texture
(
'normal'
,
textures
,
material
,
filepath
,
option_copy_textures
)
handle_texture
(
'specular'
,
textures
,
material
,
filepath
,
option_copy_textures
)
handle_texture
(
'bump'
,
textures
,
material
,
filepath
,
option_copy_textures
)
material
[
"vertexColors"
]
=
m
.
THREE_useVertexColors
and
option_colors
...
...
@@ -1226,6 +1227,9 @@ def handle_texture(id, textures, material, filepath, option_copy_textures):
if
slot
.
use_map_normal
:
if
slot
.
normal_factor
!=
1.0
:
if
id
==
"bump"
:
material
[
'mapBumpScale'
]
=
slot
.
normal_factor
else
:
material
[
'mapNormalFactor'
]
=
slot
.
normal_factor
...
...
@@ -1820,7 +1824,10 @@ def extract_material_data(m, option_colors):
material
[
'mapLight'
]
=
""
material
[
'mapSpecular'
]
=
""
material
[
'mapNormal'
]
=
""
material
[
'mapBump'
]
=
""
material
[
'mapNormalFactor'
]
=
1.0
material
[
'mapBumpScale'
]
=
1.0
textures
=
guess_material_textures
(
m
)
...
...
@@ -1838,6 +1845,11 @@ def extract_material_data(m, option_colors):
if
textures
[
'normal'
][
'slot'
].
use_map_normal
:
material
[
'mapNormalFactor'
]
=
textures
[
'normal'
][
'slot'
].
normal_factor
if
textures
[
'bump'
]:
material
[
'mapBump'
]
=
textures
[
'bump'
][
'texture'
].
image
.
name
if
textures
[
'normal'
][
'slot'
].
use_map_normal
:
material
[
'mapBumpScale'
]
=
textures
[
'normal'
][
'slot'
].
normal_factor
material
[
'shading'
]
=
m
.
THREE_materialType
material
[
'blending'
]
=
m
.
THREE_blendingType
material
[
'depthWrite'
]
=
m
.
THREE_depthWrite
...
...
@@ -1851,7 +1863,8 @@ def guess_material_textures(material):
'diffuse'
:
None
,
'light'
:
None
,
'normal'
:
None
,
'specular'
:
None
'specular'
:
None
,
'bump'
:
None
}
# just take first textures of each, for the moment three.js materials can't handle more
...
...
@@ -1863,9 +1876,16 @@ def guess_material_textures(material):
texture
=
slot
.
texture
if
slot
.
use
and
texture
and
texture
.
type
==
'IMAGE'
:
# normal map in Blender UI: textures => image sampling => normal map
if
texture
.
use_normal_map
:
textures
[
'normal'
]
=
{
"texture"
:
texture
,
"slot"
:
slot
}
# bump map in Blender UI: textures => influence => geometry => normal
elif
slot
.
use_map_normal
:
textures
[
'bump'
]
=
{
"texture"
:
texture
,
"slot"
:
slot
}
elif
slot
.
use_map_specular
or
slot
.
use_map_hardness
:
textures
[
'specular'
]
=
{
"texture"
:
texture
,
"slot"
:
slot
}
...
...
@@ -1876,7 +1896,7 @@ def guess_material_textures(material):
else
:
textures
[
'light'
]
=
{
"texture"
:
texture
,
"slot"
:
slot
}
if
textures
[
'diffuse'
]
and
textures
[
'normal'
]
and
textures
[
'light'
]
and
textures
[
'specular'
]:
if
textures
[
'diffuse'
]
and
textures
[
'normal'
]
and
textures
[
'light'
]
and
textures
[
'specular'
]
and
textures
[
'bump'
]
:
break
return
textures
...
...
@@ -1889,10 +1909,10 @@ def generate_material_string(material):
shading
=
material
.
get
(
"shading"
,
"Lambert"
)
# normal mapped materials must use Phong
# normal
and bump
mapped materials must use Phong
# to get all required parameters for normal shader
if
material
[
'mapNormal'
]:
if
material
[
'mapNormal'
]
or
material
[
'mapBump'
]
:
shading
=
"Phong"
type_map
=
{
...
...
@@ -1914,7 +1934,9 @@ def generate_material_string(material):
lightMap
=
material
[
'mapLight'
]
specularMap
=
material
[
'mapSpecular'
]
normalMap
=
material
[
'mapNormal'
]
bumpMap
=
material
[
'mapBump'
]
normalMapFactor
=
material
[
'mapNormalFactor'
]
bumpMapScale
=
material
[
'mapBumpScale'
]
if
colorMap
:
parameters
+=
', "map": %s'
%
generate_string
(
colorMap
)
...
...
@@ -1924,10 +1946,15 @@ def generate_material_string(material):
parameters
+=
', "specularMap": %s'
%
generate_string
(
specularMap
)
if
normalMap
:
parameters
+=
', "normalMap": %s'
%
generate_string
(
normalMap
)
if
bumpMap
:
parameters
+=
', "bumpMap": %s'
%
generate_string
(
bumpMap
)
if
normalMapFactor
!=
1.0
:
parameters
+=
', "normalMapFactor": %g'
%
normalMapFactor
if
bumpMapScale
!=
1.0
:
parameters
+=
', "bumpMapScale": %g'
%
bumpMapScale
if
material
[
'vertexColors'
]:
parameters
+=
', "vertexColors": "vertex"'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录