Added sun lamp exporting to PsychoBlend.
Psychopath does not yet use this info, however.
This commit is contained in:
parent
0e8d708ff0
commit
c3f3599c09
|
@ -83,7 +83,7 @@ class IndentedWriter:
|
||||||
self.f.write(' '*self.indent_level + text)
|
self.f.write(' '*self.indent_level + text)
|
||||||
else:
|
else:
|
||||||
self.f.write(text)
|
self.f.write(text)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PsychoExporter:
|
class PsychoExporter:
|
||||||
|
@ -182,7 +182,7 @@ class PsychoExporter:
|
||||||
# Camera section end
|
# Camera section end
|
||||||
self.w.unindent()
|
self.w.unindent()
|
||||||
self.w.write("}\n")
|
self.w.write("}\n")
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# World section begin
|
# World section begin
|
||||||
self.w.write("World {\n")
|
self.w.write("World {\n")
|
||||||
|
@ -198,6 +198,11 @@ class PsychoExporter:
|
||||||
self.w.unindent();
|
self.w.unindent();
|
||||||
self.w.write("}\n")
|
self.w.write("}\n")
|
||||||
|
|
||||||
|
# Infinite light sources
|
||||||
|
for ob in self.scene.objects:
|
||||||
|
if ob.type == 'LAMP' and ob.data.type == 'SUN':
|
||||||
|
self.export_world_distant_disk_lamp(ob, "")
|
||||||
|
|
||||||
# World section end
|
# World section end
|
||||||
self.w.unindent()
|
self.w.unindent()
|
||||||
self.w.write("}\n")
|
self.w.write("}\n")
|
||||||
|
@ -246,7 +251,7 @@ class PsychoExporter:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
name = None
|
name = None
|
||||||
|
|
||||||
# Write object data
|
# Write object data
|
||||||
if ob.type == 'EMPTY':
|
if ob.type == 'EMPTY':
|
||||||
if ob.dupli_type == 'GROUP':
|
if ob.dupli_type == 'GROUP':
|
||||||
|
@ -266,11 +271,11 @@ class PsychoExporter:
|
||||||
name = self.export_sphere_lamp(ob, group_prefix)
|
name = self.export_sphere_lamp(ob, group_prefix)
|
||||||
elif ob.type == 'LAMP' and ob.data.type == 'AREA':
|
elif ob.type == 'LAMP' and ob.data.type == 'AREA':
|
||||||
name = self.export_area_lamp(ob, group_prefix)
|
name = self.export_area_lamp(ob, group_prefix)
|
||||||
|
|
||||||
# Write object instance, with transforms
|
# Write object instance, with transforms
|
||||||
if name != None:
|
if name != None:
|
||||||
time_mats = []
|
time_mats = []
|
||||||
|
|
||||||
if needs_xform_mb(ob):
|
if needs_xform_mb(ob):
|
||||||
for i in range(self.time_samples):
|
for i in range(self.time_samples):
|
||||||
self.set_frame(self.fr, self.shutter_start + (self.shutter_diff*i))
|
self.set_frame(self.fr, self.shutter_start + (self.shutter_diff*i))
|
||||||
|
@ -285,7 +290,7 @@ class PsychoExporter:
|
||||||
mat[1][3] += translation_offset[1]
|
mat[1][3] += translation_offset[1]
|
||||||
mat[2][3] += translation_offset[2]
|
mat[2][3] += translation_offset[2]
|
||||||
time_mats += [mat]
|
time_mats += [mat]
|
||||||
|
|
||||||
self.w.write("Instance {\n")
|
self.w.write("Instance {\n")
|
||||||
self.w.indent()
|
self.w.indent()
|
||||||
self.w.write("Data [$%s]\n" % name)
|
self.w.write("Data [$%s]\n" % name)
|
||||||
|
@ -297,7 +302,7 @@ class PsychoExporter:
|
||||||
self.w.unindent()
|
self.w.unindent()
|
||||||
self.w.write("}\n")
|
self.w.write("}\n")
|
||||||
|
|
||||||
|
|
||||||
def export_mesh_object(self, ob, group_prefix):
|
def export_mesh_object(self, ob, group_prefix):
|
||||||
# Determine if and how to export the mesh data
|
# Determine if and how to export the mesh data
|
||||||
has_modifiers = len(ob.modifiers) > 0
|
has_modifiers = len(ob.modifiers) > 0
|
||||||
|
@ -327,37 +332,37 @@ class PsychoExporter:
|
||||||
self.mesh_names[mesh_name] = True
|
self.mesh_names[mesh_name] = True
|
||||||
self.w.write("SubdivisionSurface $%s {\n" % escape_name(mesh_name))
|
self.w.write("SubdivisionSurface $%s {\n" % escape_name(mesh_name))
|
||||||
self.w.indent()
|
self.w.indent()
|
||||||
|
|
||||||
# Write vertices
|
# Write vertices
|
||||||
for ti in range(len(time_meshes)):
|
for ti in range(len(time_meshes)):
|
||||||
self.w.write("Vertices [")
|
self.w.write("Vertices [")
|
||||||
for v in time_meshes[ti].vertices:
|
for v in time_meshes[ti].vertices:
|
||||||
self.w.write("%f %f %f " % (v.co[0], v.co[1], v.co[2]), False)
|
self.w.write("%f %f %f " % (v.co[0], v.co[1], v.co[2]), False)
|
||||||
self.w.write("]\n", False)
|
self.w.write("]\n", False)
|
||||||
|
|
||||||
# Write face vertex counts
|
# Write face vertex counts
|
||||||
self.w.write("FaceVertCounts [")
|
self.w.write("FaceVertCounts [")
|
||||||
for p in time_meshes[0].polygons:
|
for p in time_meshes[0].polygons:
|
||||||
self.w.write("%d " % len(p.vertices), False)
|
self.w.write("%d " % len(p.vertices), False)
|
||||||
self.w.write("]\n", False)
|
self.w.write("]\n", False)
|
||||||
|
|
||||||
# Write face vertex indices
|
# Write face vertex indices
|
||||||
self.w.write("FaceVertIndices [")
|
self.w.write("FaceVertIndices [")
|
||||||
for p in time_meshes[0].polygons:
|
for p in time_meshes[0].polygons:
|
||||||
for v in p.vertices:
|
for v in p.vertices:
|
||||||
self.w.write("%d " % v, False)
|
self.w.write("%d " % v, False)
|
||||||
self.w.write("]\n", False)
|
self.w.write("]\n", False)
|
||||||
|
|
||||||
# MeshSurface/SubdivisionSurface section end
|
# MeshSurface/SubdivisionSurface section end
|
||||||
self.w.unindent()
|
self.w.unindent()
|
||||||
self.w.write("}\n")
|
self.w.write("}\n")
|
||||||
|
|
||||||
return mesh_name
|
return mesh_name
|
||||||
|
|
||||||
|
|
||||||
def export_surface_object(self, ob, group_prefix):
|
def export_surface_object(self, ob, group_prefix):
|
||||||
name = group_prefix + "__" + escape_name(ob.name)
|
name = group_prefix + "__" + escape_name(ob.name)
|
||||||
|
|
||||||
# Collect time samples
|
# Collect time samples
|
||||||
time_surfaces = []
|
time_surfaces = []
|
||||||
for i in range(self.time_samples):
|
for i in range(self.time_samples):
|
||||||
|
@ -377,13 +382,13 @@ class PsychoExporter:
|
||||||
bpy.data.curves.remove(s)
|
bpy.data.curves.remove(s)
|
||||||
self.w.unindent()
|
self.w.unindent()
|
||||||
self.w.write("}\n")
|
self.w.write("}\n")
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
def export_sphere_lamp(self, ob, group_prefix):
|
def export_sphere_lamp(self, ob, group_prefix):
|
||||||
name = group_prefix + "__" + escape_name(ob.name)
|
name = group_prefix + "__" + escape_name(ob.name)
|
||||||
|
|
||||||
# Collect data over time
|
# Collect data over time
|
||||||
time_col = []
|
time_col = []
|
||||||
time_rad = []
|
time_rad = []
|
||||||
|
@ -402,12 +407,12 @@ class PsychoExporter:
|
||||||
|
|
||||||
self.w.unindent()
|
self.w.unindent()
|
||||||
self.w.write("}\n")
|
self.w.write("}\n")
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def export_area_lamp(self, ob, group_prefix):
|
def export_area_lamp(self, ob, group_prefix):
|
||||||
name = group_prefix + "__" + escape_name(ob.name)
|
name = group_prefix + "__" + escape_name(ob.name)
|
||||||
|
|
||||||
# Collect data over time
|
# Collect data over time
|
||||||
time_col = []
|
time_col = []
|
||||||
time_dim = []
|
time_dim = []
|
||||||
|
@ -418,8 +423,8 @@ class PsychoExporter:
|
||||||
time_dim += [(ob.data.size, ob.data.size_y)]
|
time_dim += [(ob.data.size, ob.data.size_y)]
|
||||||
else:
|
else:
|
||||||
time_dim += [(ob.data.size, ob.data.size)]
|
time_dim += [(ob.data.size, ob.data.size)]
|
||||||
|
|
||||||
|
|
||||||
# Write out sphere light
|
# Write out sphere light
|
||||||
self.w.write("RectangleLight $%s {\n" % name)
|
self.w.write("RectangleLight $%s {\n" % name)
|
||||||
self.w.indent()
|
self.w.indent()
|
||||||
|
@ -427,9 +432,36 @@ class PsychoExporter:
|
||||||
self.w.write("Color [%f %f %f]\n" % (col[0], col[1], col[2]))
|
self.w.write("Color [%f %f %f]\n" % (col[0], col[1], col[2]))
|
||||||
for dim in time_dim:
|
for dim in time_dim:
|
||||||
self.w.write("Dimensions [%f %f]\n" % dim)
|
self.w.write("Dimensions [%f %f]\n" % dim)
|
||||||
|
|
||||||
self.w.unindent()
|
self.w.unindent()
|
||||||
self.w.write("}\n")
|
self.w.write("}\n")
|
||||||
|
|
||||||
|
return name
|
||||||
|
|
||||||
|
def export_world_distant_disk_lamp(self, ob, group_prefix):
|
||||||
|
name = group_prefix + "__" + escape_name(ob.name)
|
||||||
|
|
||||||
|
# Collect data over time
|
||||||
|
time_dir = []
|
||||||
|
time_col = []
|
||||||
|
time_rad = []
|
||||||
|
for i in range(self.time_samples):
|
||||||
|
self.set_frame(self.fr, self.shutter_start + (self.shutter_diff*i))
|
||||||
|
time_dir += [tuple(ob.matrix_world * Vector((0, 0, -1)))]
|
||||||
|
time_col += [ob.data.color * ob.data.energy]
|
||||||
|
time_rad += [ob.data.shadow_soft_size]
|
||||||
|
|
||||||
|
# Write out sphere light
|
||||||
|
self.w.write("DistantDiskLight $%s {\n" % name)
|
||||||
|
self.w.indent()
|
||||||
|
for direc in time_dir:
|
||||||
|
self.w.write("Direction [%f %f %f]\n" % (direc[0], direc[1], direc[2]))
|
||||||
|
for col in time_col:
|
||||||
|
self.w.write("Color [%f %f %f]\n" % (col[0], col[1], col[2]))
|
||||||
|
for rad in time_rad:
|
||||||
|
self.w.write("Radius [%f]\n" % rad)
|
||||||
|
|
||||||
|
self.w.unindent()
|
||||||
|
self.w.write("}\n")
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user