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
77774b1f
Commit
77774b1f
authored
13 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
formatting edits only
parent
e1c5b902
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
io_mesh_uv_layout/export_uv_eps.py
+5
-3
5 additions, 3 deletions
io_mesh_uv_layout/export_uv_eps.py
io_mesh_uv_layout/export_uv_png.py
+24
-9
24 additions, 9 deletions
io_mesh_uv_layout/export_uv_png.py
io_mesh_uv_layout/export_uv_svg.py
+8
-4
8 additions, 4 deletions
io_mesh_uv_layout/export_uv_svg.py
with
37 additions
and
16 deletions
io_mesh_uv_layout/export_uv_eps.py
+
5
−
3
View file @
77774b1f
...
...
@@ -16,7 +16,7 @@
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
# <pep8
-80
compliant>
import
bpy
...
...
@@ -27,7 +27,8 @@ def write(fw, mesh, image_width, image_height, opacity, face_iter_func):
fw
(
"
%%Pages: 1
\n
"
)
fw
(
"
%%Orientation: Portrait
\n
"
)
fw
(
"
%%%%BoundingBox: 0 0 %d %d
\n
"
%
(
image_width
,
image_height
))
fw
(
"
%%%%HiResBoundingBox: 0.0 0.0 %.4f %.4f
\n
"
%
(
image_width
,
image_height
))
fw
(
"
%%%%HiResBoundingBox: 0.0 0.0 %.4f %.4f
\n
"
%
(
image_width
,
image_height
))
fw
(
"
%%EndComments
\n
"
)
fw
(
"
%%Page: 1 1
\n
"
)
fw
(
"
0 0 translate
\n
"
)
...
...
@@ -45,7 +46,8 @@ def write(fw, mesh, image_width, image_height, opacity, face_iter_func):
fw
(
"
/DRAW_%d {
"
%
i
)
fw
(
"
gsave
\n
"
)
if
mat
:
color
=
tuple
((
1.0
-
((
1.0
-
c
)
*
opacity
))
for
c
in
mat
.
diffuse_color
)
color
=
tuple
((
1.0
-
((
1.0
-
c
)
*
opacity
))
for
c
in
mat
.
diffuse_color
)
else
:
color
=
1.0
,
1.0
,
1.0
fw
(
"
%.3g %.3g %.3g setrgbcolor
\n
"
%
color
)
...
...
This diff is collapsed.
Click to expand it.
io_mesh_uv_layout/export_uv_png.py
+
24
−
9
View file @
77774b1f
...
...
@@ -16,7 +16,7 @@
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
# <pep8
-80
compliant>
import
bpy
...
...
@@ -25,7 +25,9 @@ def write(fw, mesh_source, image_width, image_height, opacity, face_iter_func):
filepath
=
fw
.
__self__
.
name
fw
.
__self__
.
close
()
material_solids
=
[
bpy
.
data
.
materials
.
new
(
"
uv_temp_solid
"
)
for
i
in
range
(
max
(
1
,
len
(
mesh_source
.
materials
)))]
material_solids
=
[
bpy
.
data
.
materials
.
new
(
"
uv_temp_solid
"
)
for
i
in
range
(
max
(
1
,
len
(
mesh_source
.
materials
)))]
material_wire
=
bpy
.
data
.
materials
.
new
(
"
uv_temp_wire
"
)
scene
=
bpy
.
data
.
scenes
.
new
(
"
uv_temp
"
)
...
...
@@ -39,15 +41,21 @@ def write(fw, mesh_source, image_width, image_height, opacity, face_iter_func):
faces_source
=
mesh_source
.
faces
# get unique UV's in case there are many overlapping which slow down filling.
# get unique UV's in case there are many overlapping
# which slow down filling.
face_hash_3
=
set
()
face_hash_4
=
set
()
for
i
,
uv
in
face_iter_func
():
material_index
=
faces_source
[
i
].
material_index
if
len
(
uv
)
==
3
:
face_hash_3
.
add
((
uv
[
0
][
0
],
uv
[
0
][
1
],
uv
[
1
][
0
],
uv
[
1
][
1
],
uv
[
2
][
0
],
uv
[
2
][
1
],
material_index
))
face_hash_3
.
add
((
uv
[
0
][
0
],
uv
[
0
][
1
],
uv
[
1
][
0
],
uv
[
1
][
1
],
uv
[
2
][
0
],
uv
[
2
][
1
],
material_index
))
else
:
face_hash_4
.
add
((
uv
[
0
][
0
],
uv
[
0
][
1
],
uv
[
1
][
0
],
uv
[
1
][
1
],
uv
[
2
][
0
],
uv
[
2
][
1
],
uv
[
3
][
0
],
uv
[
3
][
1
],
material_index
))
face_hash_4
.
add
((
uv
[
0
][
0
],
uv
[
0
][
1
],
uv
[
1
][
0
],
uv
[
1
][
1
],
uv
[
2
][
0
],
uv
[
2
][
1
],
uv
[
3
][
0
],
uv
[
3
][
1
],
material_index
))
# now set the faces coords and locations
# build mesh data
...
...
@@ -58,13 +66,20 @@ def write(fw, mesh_source, image_width, image_height, opacity, face_iter_func):
current_vert
=
0
for
face_data
in
face_hash_3
:
mesh_new_vertices
.
extend
([
face_data
[
0
],
face_data
[
1
],
0.0
,
face_data
[
2
],
face_data
[
3
],
0.0
,
face_data
[
4
],
face_data
[
5
],
0.0
])
mesh_new_face_vertices
.
extend
([
current_vert
,
current_vert
+
1
,
current_vert
+
2
,
0
])
mesh_new_vertices
.
extend
([
face_data
[
0
],
face_data
[
1
],
0.0
,
face_data
[
2
],
face_data
[
3
],
0.0
,
face_data
[
4
],
face_data
[
5
],
0.0
])
mesh_new_face_vertices
.
extend
([
current_vert
,
current_vert
+
1
,
current_vert
+
2
,
0
])
mesh_new_materials
.
append
(
face_data
[
6
])
current_vert
+=
3
for
face_data
in
face_hash_4
:
mesh_new_vertices
.
extend
([
face_data
[
0
],
face_data
[
1
],
0.0
,
face_data
[
2
],
face_data
[
3
],
0.0
,
face_data
[
4
],
face_data
[
5
],
0.0
,
face_data
[
6
],
face_data
[
7
],
0.0
])
mesh_new_face_vertices
.
extend
([
current_vert
,
current_vert
+
1
,
current_vert
+
2
,
current_vert
+
3
])
mesh_new_vertices
.
extend
([
face_data
[
0
],
face_data
[
1
],
0.0
,
face_data
[
2
],
face_data
[
3
],
0.0
,
face_data
[
4
],
face_data
[
5
],
0.0
,
face_data
[
6
],
face_data
[
7
],
0.0
])
mesh_new_face_vertices
.
extend
([
current_vert
,
current_vert
+
1
,
current_vert
+
2
,
current_vert
+
3
])
mesh_new_materials
.
append
(
face_data
[
8
])
current_vert
+=
4
...
...
This diff is collapsed.
Click to expand it.
io_mesh_uv_layout/export_uv_svg.py
+
8
−
4
View file @
77774b1f
...
...
@@ -16,7 +16,7 @@
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
# <pep8
-80
compliant>
import
bpy
...
...
@@ -29,9 +29,11 @@ def write(fw, mesh, image_width, image_height, opacity, face_iter_func):
fw
(
'
<?xml version=
"
1.0
"
standalone=
"
no
"
?>
\n
'
)
fw
(
'
<!DOCTYPE svg PUBLIC
"
-//W3C//DTD SVG 1.1//EN
"
\n
'
)
fw
(
'
"
http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd
"
>
\n
'
)
fw
(
'
<svg width=
"
%dpx
"
height=
"
%dpx
"
viewBox=
"
0px 0px %dpx %dpx
"
\n
'
%
(
image_width
,
image_height
,
image_width
,
image_height
))
fw
(
'
<svg width=
"
%dpx
"
height=
"
%dpx
"
viewBox=
"
0px 0px %dpx %dpx
"
\n
'
%
(
image_width
,
image_height
,
image_width
,
image_height
))
fw
(
'
xmlns=
"
http://www.w3.org/2000/svg
"
version=
"
1.1
"
>
\n
'
)
desc
=
"
%r, %s, (Blender %s)
"
%
(
basename
(
bpy
.
data
.
filepath
),
mesh
.
name
,
bpy
.
app
.
version_string
)
desc
=
(
"
%r, %s, (Blender %s)
"
%
(
basename
(
bpy
.
data
.
filepath
),
mesh
.
name
,
bpy
.
app
.
version_string
))
fw
(
'
<desc>%s</desc>
\n
'
%
escape
(
desc
))
# svg colors
...
...
@@ -39,7 +41,9 @@ def write(fw, mesh, image_width, image_height, opacity, face_iter_func):
fill_default
=
'
fill=
"
grey
"'
for
mat
in
mesh
.
materials
if
mesh
.
materials
else
[
None
]:
if
mat
:
fill_settings
.
append
(
'
fill=
"
rgb(%d, %d, %d)
"'
%
tuple
(
int
(
c
*
255
)
for
c
in
mat
.
diffuse_color
))
fill_settings
.
append
(
'
fill=
"
rgb(%d, %d, %d)
"'
%
tuple
(
int
(
c
*
255
)
for
c
in
mat
.
diffuse_color
))
else
:
fill_settings
.
append
(
fill_default
)
...
...
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