1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
24 def write(fw
, mesh
, image_width
, image_height
, opacity
, face_iter_func
):
25 fw("%!PS-Adobe-3.0 EPSF-3.0\n")
26 fw("%%%%Creator: Blender %s\n" % bpy
.app
.version_string
)
28 fw("%%Orientation: Portrait\n")
29 fw("%%%%BoundingBox: 0 0 %d %d\n" % (image_width
, image_height
))
30 fw("%%%%HiResBoundingBox: 0.0 0.0 %.4f %.4f\n" %
31 (image_width
, image_height
))
36 fw("0 0 0 setrgbcolor\n")
38 fw("1 setlinewidth\n")
45 for i
, mat
in enumerate(mesh
.materials
if mesh
.materials
else [None]):
49 color
= tuple((1.0 - ((1.0 - c
) * opacity
))
50 for c
in mat
.diffuse_color
)
53 fw("%.3g %.3g %.3g setrgbcolor\n" % color
)
60 for i
, uvs
in face_iter_func():
62 for j
, uv
in enumerate(uvs
):
63 uv_scale
= (uv
[0] * image_width
, uv
[1] * image_height
)
65 fw("%.5f %.5f moveto\n" % uv_scale
)
67 fw("%.5f %.5f lineto\n" % uv_scale
)
70 fw("DRAW_%d\n" % polys
[i
].material_index
)
73 for i
, uvs
in face_iter_func():
75 for j
, uv
in enumerate(uvs
):
76 uv_scale
= (uv
[0] * image_width
, uv
[1] * image_height
)
78 fw("%.5f %.5f moveto\n" % uv_scale
)
80 fw("%.5f %.5f lineto\n" % uv_scale
)