Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
a650e83e
Commit
a650e83e
authored
6 years ago
by
Kalle-Samuli Riihikoski
Browse files
Options
Downloads
Patches
Plain Diff
blender 2.8 update
parent
2a0d3baf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
io_coat3D/__init__.py
+18
-8
18 additions, 8 deletions
io_coat3D/__init__.py
io_coat3D/coat.py
+197
-236
197 additions, 236 deletions
io_coat3D/coat.py
io_coat3D/tex.py
+135
-4
135 additions, 4 deletions
io_coat3D/tex.py
with
350 additions
and
248 deletions
io_coat3D/__init__.py
+
18
−
8
View file @
a650e83e
...
...
@@ -20,7 +20,7 @@ bl_info = {
"
name
"
:
"
3D-Coat Applink
"
,
"
author
"
:
"
Kalle-Samuli Riihikoski (haikalle)
"
,
"
version
"
:
(
3
,
5
,
22
),
"
blender
"
:
(
2
,
59
,
0
),
"
blender
"
:
(
2
,
8
,
0
),
"
location
"
:
"
Scene > 3D-Coat Applink
"
,
"
description
"
:
"
Transfer data between 3D-Coat/Blender
"
,
"
warning
"
:
""
,
...
...
@@ -59,9 +59,24 @@ def register():
objpath
=
StringProperty
(
name
=
"
Object_Path
"
)
applink_address
=
StringProperty
(
name
=
"
Object_Applink_address
"
)
applink_name
=
StringProperty
(
name
=
"
Object_Applink_
name
"
name
=
"
Applink object
name
"
)
applink_group
=
StringProperty
(
name
=
"
Applink group
"
)
applink_skip
=
StringProperty
(
name
=
"
Object_Applink_Update
"
,
default
=
"
False
"
)
applink_firsttime
=
BoolProperty
(
name
=
"
FirstTime
"
,
description
=
"
FirstTime
"
,
default
=
True
)
coatpath
=
StringProperty
(
name
=
"
Coat_Path
"
)
...
...
@@ -216,12 +231,7 @@ def register():
)
# copy location
cursor
=
FloatVectorProperty
(
name
=
"
Cursor
"
,
description
=
"
Location
"
,
subtype
=
"
XYZ
"
,
default
=
(
0.0
,
0.0
,
0.0
)
)
loca
=
FloatVectorProperty
(
name
=
"
location
"
,
description
=
"
Location
"
,
...
...
This diff is collapsed.
Click to expand it.
io_coat3D/coat.py
+
197
−
236
View file @
a650e83e
This diff is collapsed.
Click to expand it.
io_coat3D/tex.py
+
135
−
4
View file @
a650e83e
...
...
@@ -19,8 +19,9 @@
import
bpy
import
os
import
re
def
find_index
(
objekti
):
luku
=
0
for
tex
in
objekti
.
active_material
.
texture_slots
:
if
(
not
(
hasattr
(
tex
,
'
texture
'
))):
...
...
@@ -28,10 +29,140 @@ def find_index(objekti):
luku
=
luku
+
1
return
luku
def
gettex
(
mat_list
,
objekti
,
scene
,
export
):
def
readtexturefolder
(
objekti
,
is_new
):
#read textures from texture file
coat3D
=
bpy
.
context
.
scene
.
coat3D
obj_coat
=
objekti
.
coat3D
texcoat
=
{}
texcoat
[
'
color
'
]
=
[]
texcoat
[
'
metalness
'
]
=
[]
texcoat
[
'
rough
'
]
=
[]
texcoat
[
'
nmap
'
]
=
[]
texcoat
[
'
disp
'
]
=
[]
if
(
is_new
==
True
):
files_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
objekti
.
coat3D
.
applink_address
))
else
:
files_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
objekti
.
coat3D
.
applink_address
))
files_dir
=
files_dir
.
replace
(
'
3DC2Blender
'
+
os
.
sep
+
'
Objects
'
,
'
3DC2Blender
'
+
os
.
sep
+
'
Textures
'
)
files
=
os
.
listdir
(
files_dir
)
materiaali_muutos
=
objekti
.
active_material
.
name
uusin_mat
=
materiaali_muutos
.
replace
(
'
Material.
'
,
'
Material_
'
)
for
i
in
files
:
if
(
i
.
startswith
(
obj_coat
.
applink_name
+
'
_
'
+
uusin_mat
)):
koko_osoite
=
files_dir
+
os
.
sep
+
i
listed
=
re
.
split
(
r
'
[_.]
'
,
i
)
tex_name
=
listed
[
-
2
]
texcoat
[
tex_name
].
append
(
koko_osoite
)
createnodes
(
objekti
,
texcoat
)
def
checkmaterial
(
mat_list
,
objekti
):
#check how many materials object has
mat_list
=
[]
for
obj_mate
in
objekti
.
material_slots
:
if
(
obj_mate
.
material
.
use_nodes
==
False
):
obj_mate
.
material
.
use_nodes
=
True
def
createnodes
(
objekti
,
texcoat
):
#luo nodes palikat ja linkittaa tekstuurit niihin
bring_color
=
True
#naiden tarkoitus on tsekata onko tarvetta luoda uusi node vai riittaako paivitys
bring_metalness
=
True
bring_roughness
=
True
bring_normal
=
True
bring_disp
=
True
act_material
=
objekti
.
active_material
if
(
objekti
.
active_material
.
use_nodes
==
False
):
objekti
.
active_material
.
use_nodes
=
True
#ensimmaiseksi kaydaan kaikki image nodet lapi ja tarkistetaan onko nimi 3DC alkunen jos on niin reload
for
node
in
act_material
.
node_tree
.
nodes
:
if
(
node
.
type
==
'
TEX_IMAGE
'
):
if
(
node
.
name
==
'
3DC_color
'
):
bring_color
=
False
node
.
image
.
reload
()
elif
(
node
.
name
==
'
3DC_metalness
'
):
bring_metalness
=
False
node
.
image
.
reload
()
elif
(
node
.
name
==
'
3DC_roughness
'
):
bring_roughness
=
False
node
.
image
.
reload
()
elif
(
node
.
name
==
'
3DC_normal
'
):
bring_normal
=
False
node
.
image
.
reload
()
#seuraavaksi lahdemme rakentamaan node tree. Lahdetaan Material Outputista rakentaa
main_mat
=
act_material
.
node_tree
.
nodes
[
'
Material Output
'
]
if
(
main_mat
.
inputs
[
'
Surface
'
].
is_linked
==
True
):
glue_mat
=
main_mat
.
inputs
[
'
Surface
'
].
links
[
0
].
from_node
#Color
if
(
bring_color
==
True
and
glue_mat
.
inputs
.
find
(
'
Base Color
'
)
!=
-
1
and
texcoat
[
'
color
'
]
!=
[]):
node
=
act_material
.
node_tree
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
node
.
location
=
-
400
,
400
node
.
name
=
'
3DC_color
'
if
(
texcoat
[
'
color
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
color
'
][
0
])
input_color
=
glue_mat
.
inputs
.
find
(
'
Base Color
'
)
act_material
.
node_tree
.
links
.
new
(
node
.
outputs
[
0
],
glue_mat
.
inputs
[
input_color
])
#Metalness
if
(
bring_metalness
==
True
and
glue_mat
.
inputs
.
find
(
'
Metallic
'
)
!=
-
1
and
texcoat
[
'
metalness
'
]
!=
[]):
node
=
act_material
.
node_tree
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
node
.
location
=
-
600
,
200
node
.
name
=
'
3DC_metalness
'
if
(
texcoat
[
'
metalness
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
metalness
'
][
0
])
node
.
color_space
=
'
NONE
'
input_color
=
glue_mat
.
inputs
.
find
(
'
Metallic
'
)
act_material
.
node_tree
.
links
.
new
(
node
.
outputs
[
0
],
glue_mat
.
inputs
[
input_color
])
#Roughness
if
(
bring_roughness
==
True
and
glue_mat
.
inputs
.
find
(
'
Roughness
'
)
!=
-
1
and
texcoat
[
'
rough
'
]
!=
[]):
node
=
act_material
.
node_tree
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
node
.
location
=
-
550
,
0
node
.
name
=
'
3DC_roughness
'
if
(
texcoat
[
'
rough
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
rough
'
][
0
])
node
.
color_space
=
'
NONE
'
input_color
=
glue_mat
.
inputs
.
find
(
'
Roughness
'
)
act_material
.
node_tree
.
links
.
new
(
node
.
outputs
[
0
],
glue_mat
.
inputs
[
input_color
])
#Normal map
if
(
bring_normal
==
True
and
glue_mat
.
inputs
.
find
(
'
Normal
'
)
!=
-
1
and
texcoat
[
'
nmap
'
]
!=
[]):
node
=
act_material
.
node_tree
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
normal_node
=
act_material
.
node_tree
.
nodes
.
new
(
'
ShaderNodeNormalMap
'
)
node
.
location
=
-
600
,
-
270
normal_node
.
location
=
-
300
,
-
170
node
.
name
=
'
3DC_normal
'
if
(
texcoat
[
'
nmap
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
nmap
'
][
0
])
node
.
color_space
=
'
NONE
'
input_color
=
glue_mat
.
inputs
.
find
(
'
Normal
'
)
act_material
.
node_tree
.
links
.
new
(
node
.
outputs
[
0
],
normal_node
.
inputs
[
1
])
act_material
.
node_tree
.
links
.
new
(
normal_node
.
outputs
[
0
],
glue_mat
.
inputs
[
input_color
])
bpy
.
ops
.
object
.
editmode_toggle
()
#HACKKI joka saa tekstuurit nakymaan heti
bpy
.
ops
.
object
.
editmode_toggle
()
def
matlab
(
mat_list
,
objekti
,
scene
,
is_new
):
#checkmaterial(mat_list, objekti)
readtexturefolder
(
objekti
,
is_new
)
"""
print(
'
tassa tietoo
'
)
print(mat_list,objekti,scene,export)
coat3D = bpy.context.scene.coat3D
coa = objekti.coat3D
print(coat3D,coa)
if(bpy.context.scene.render.engine ==
'
VRAY_RENDER
'
or bpy.context.scene.render.engine ==
'
VRAY_RENDER_PREVIEW
'
):
vray = True
...
...
@@ -47,7 +178,7 @@ def gettex(mat_list, objekti, scene,export):
bring_spec = 1
bring_normal = 1
bring_disp = 1
texcoat = {}
texcoat[
'
color
'
] = []
texcoat[
'
specular
'
] = []
...
...
@@ -331,5 +462,5 @@ def gettex(mat_list, objekti, scene,export):
if(objekti.data.uv_textures.active):
objekti.modifiers[
'
Displace
'
].texture_coords =
'
UV
'
objekti.modifiers[
'
Displace
'
].uv_layer = objekti.data.uv_textures.active.name
"""
return
(
'
FINISHED
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment