4
Name: 'Radiosity (.radio)...'
7
Tooltip: 'Import Radiosity File Format (.radio) with vertex colors'
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 imports Radiosity files to Blender.
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
Execute this script from the "File->Import" menu and choose a Radiosity
27
# $Id: radiosity_import.py,v 1.13 2007/01/27 04:58:09 campbellbarton Exp $
29
# +---------------------------------------------------------+
30
# | Copyright (c) 2002 Anthony D'Agostino |
31
# | http://www.redrival.com/scorpius |
32
# | scorpius@netzero.com |
34
# | Read and write Radiosity File Format (*.radio) |
35
# +---------------------------------------------------------+
37
# ***** BEGIN GPL LICENSE BLOCK *****
39
# This program is free software; you can redistribute it and/or
40
# modify it under the terms of the GNU General Public License
41
# as published by the Free Software Foundation; either version 2
42
# of the License, or (at your option) any later version.
44
# This program is distributed in the hope that it will be useful,
45
# but WITHOUT ANY WARRANTY; without even the implied warranty of
46
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47
# GNU General Public License for more details.
49
# You should have received a copy of the GNU General Public License
50
# along with this program; if not, write to the Free Software Foundation,
51
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
53
# ***** END GPL LICENCE BLOCK *****
55
import Blender, meshtools
62
# ===============================
63
# ====== Read Radio Format ======
64
# ===============================
66
start = Blender.sys.time()
67
Blender.Window.WaitCursor(1)
68
file = open(filename, "rb")
69
mesh = Blender.NMesh.GetRaw()
70
#mesh.addMaterial(Blender.Material.New())
72
NULL_UV3= [ (0,0), (0,1), (1,1) ]
73
NULL_UV4= [ (0,0), (0,1), (1,1), (1,0) ]
77
namelen, = struct.unpack("<h", file.read(2))
78
objname, = struct.unpack("<"+`namelen`+"s", file.read(namelen))
81
Vert= Blender.NMesh.Vert
82
numverts, = struct.unpack("<l", file.read(4))
84
# Se we can run in a LC
86
x,y,z= struct.unpack('<fff', file.read(12))
89
mesh.verts= [_vert_() for i in xrange(numverts)]
94
Face= Blender.NMesh.Face
95
Col= Blender.NMesh.Col
96
numfaces, = struct.unpack("<l", file.read(4))
97
for i in xrange(numfaces):
98
#if not i%100 and meshtools.show_progress:
99
# Blender.Window.DrawProgressBar(float(i)/numfaces, "Reading Faces")
102
numfaceverts, = struct.unpack("<b", file.read(1))
108
struct.unpack("<h", file.read(2))[0]] for j in xrange(numfaceverts)\
112
face.col= [ Col(r, g, b, a) \
114
for r,g,b,a in ( struct.unpack("<BBBB", file.read(4)), )]
123
mesh.faces.append(face)
125
scn= Blender.Scene.GetCurrent()
126
scn.objects.selected = []
129
scn.objects.new(mesh)
131
Blender.Window.DrawProgressBar(1.0, '') # clear progressbar
133
end = Blender.sys.time()
134
message = 'Successfully imported "%s" in %.2f seconds' % (Blender.sys.basename(filename), end-start)
135
meshtools.print_boxed(message)
136
Blender.Window.WaitCursor(0)
137
Blender.Window.RedrawAll()
142
Blender.Draw.PupMenu('ERROR%t|Error: you need a full Python install to run this script')
145
Blender.Window.FileSelector(read, 'Import Radio', '*.radio')
147
if __name__ == '__main__':