4
Name: 'Radiosity (.radio)...'
7
Tooltip: 'Export selected mesh (with vertex colors) to Radiosity File Format (*.radio)'
7
Tooltip: 'Export selected mesh (with vertex colors) to Radiosity File Format (.radio)'
10
__author__ = "Anthony D'Agostino (Scorpius)"
11
__url__ = ("blender", "elysiun",
12
"Author's homepage, http://www.redrival.com/scorpius")
13
__version__ = "Part of IOSuite 0.5"
16
This script exports meshes to Radiosity file format.
18
The Radiosity file format is my own personal format. I created it to
19
learn how meshes and vertex colors were stored. See IO-Examples.zip, the
20
example *.radio files on my web page.
23
Select meshes to be exported and run this script from "File->Export" menu.
26
Before exporting to .radio format, the mesh must have vertex colors.
27
Here's how to assign them:
31
2. Set up lights and materials, select a mesh, switch the drawing mode
32
to "textured," press the VKEY.
34
3. Press the VKEY and paint manually.
36
4. Use a custom script to calculate and apply simple diffuse shading and
37
specular highlights to the vertex colors.
39
5. The Videoscape format also allows vertex colors to be specified.
42
# $Id: radiosity_export.py,v 1.7 2005/03/21 05:26:52 ianwill Exp $
10
44
# +---------------------------------------------------------+
11
45
# | Copyright (c) 2002 Anthony D'Agostino |
12
# | http://ourworld.compuserve.com/homepages/scorpius |
13
# | scorpius@compuserve.com |
46
# | http://www.redrival.com/scorpius |
47
# | scorpius@netzero.com |
14
48
# | April 11, 2002 |
15
49
# | Released under the Blender Artistic Licence (BAL) |
16
50
# | Import Export Suite v0.5 |
18
52
# | Read and write Radiosity File Format (*.radio) |
19
53
# +---------------------------------------------------------+
55
import Blender, meshtools
23
import mod_flags, mod_meshtools
27
61
msg = "Error: you need a full Python install to run this script."
28
mod_meshtools.print_boxed(msg)
62
meshtools.print_boxed(msg)
63
Blender.Draw.PupMenu("ERROR%t|"+msg)
30
65
# ================================
31
66
# ====== Write Radio Format ======
40
75
mesh = Blender.NMesh.GetRaw(meshname)
41
76
obj = Blender.Object.Get(objname)
43
if not mesh.hasVertexColours():
44
message = "Please assign vertex colors before exporting.\n"
78
if not meshtools.has_vertex_colors(mesh):
79
message = "Please assign vertex colors before exporting. \n"
45
80
message += objname + " object was not saved."
46
mod_meshtools.print_boxed(message)
81
meshtools.print_boxed(message)
82
Blender.Draw.PupMenu("ERROR%t|"+message)
49
85
# === Object Name ===
53
89
# === Vertex List ===
54
90
file.write(struct.pack("<l", len(mesh.verts)))
55
91
for i in range(len(mesh.verts)):
56
if not i%100 and mod_flags.show_progress:
92
if not i%100 and meshtools.show_progress:
57
93
Blender.Window.DrawProgressBar(float(i)/len(mesh.verts), "Writing Verts")
59
95
x, y, z = mesh.verts[i].co
62
98
# === Face List ===
63
99
file.write(struct.pack("<l", len(mesh.faces)))
64
100
for i in range(len(mesh.faces)):
65
if not i%100 and mod_flags.show_progress:
101
if not i%100 and meshtools.show_progress:
66
102
Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing Faces")
68
104
file.write(struct.pack("<b", len(mesh.faces[i].v)))
80
116
#end = time.clock()
81
117
#seconds = " in %.2f %s" % (end-start, "seconds")
82
118
message = "Successfully exported " + Blender.sys.basename(filename)# + seconds
83
mod_meshtools.print_boxed(message)
119
meshtools.print_boxed(message)
85
121
def fs_callback(filename):
86
122
if filename.find('.radio', -6) <= 0: filename += '.radio'
89
Blender.Window.FileSelector(fs_callback, "Radio Export")
125
Blender.Window.FileSelector(fs_callback, "Export Radio")