Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-08-07 05:05:33 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-08-07 05:05:33 +0400
commit917fce65a631f500359146854018522602d5496d (patch)
tree62f4f5c6e43c897541a28538ab2b9a8dd638b161 /release
parent0ac90cabe142d685d12662bb12be3775cd58e335 (diff)
Povray
* Sun lamp type export (known as parallel lights in povray) * Native support for blenders metaballs, currently exports - ball and ellipsoid types - radius, stiffness - ellipsoid xyz scale - negative elements - single material (like blender) Renamed rna props. elem.sizex -> size_x mball.last_selected_element -> mball.active_element minor changes to UI scripts.
Diffstat (limited to 'release')
-rw-r--r--release/io/engine_render_pov.py131
-rw-r--r--release/ui/buttons_data_metaball.py22
-rw-r--r--release/ui/buttons_material.py18
-rw-r--r--release/ui/buttons_object_constraint.py11
4 files changed, 125 insertions, 57 deletions
diff --git a/release/io/engine_render_pov.py b/release/io/engine_render_pov.py
index 782d87fcdf3..b1281e73c95 100644
--- a/release/io/engine_render_pov.py
+++ b/release/io/engine_render_pov.py
@@ -19,8 +19,9 @@ def write_pov(filename, scene=None, info_callback = None):
# Only for testing
if not scene:
scene = bpy.data.scenes[0]
-
+
render = scene.render_data
+ world = scene.world
materialTable = {}
def saneName(name):
@@ -33,6 +34,39 @@ def write_pov(filename, scene=None, info_callback = None):
file.write('\tmatrix <%.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f>\n' %\
(matrix[0][0], matrix[0][1], matrix[0][2], matrix[1][0], matrix[1][1], matrix[1][2], matrix[2][0], matrix[2][1], matrix[2][2], matrix[3][0], matrix[3][1], matrix[3][2]) )
+ def blenderMaterialToPovString(material):
+ povstring = 'finish {'
+ if world != None:
+ povstring += 'ambient <%.6f, %.6f, %.6f> ' % tuple([c*material.ambient for c in world.ambient_color])
+
+ povstring += 'diffuse %.6f ' % material.diffuse_reflection
+ povstring += 'specular %.6f ' % material.specular_reflection
+
+
+ if material.raytrace_mirror.enabled:
+ #povstring += 'interior { ior %.6f } ' % material.IOR
+ raytrace_mirror= material.raytrace_mirror
+ if raytrace_mirror.reflect:
+ povstring += 'reflection {'
+ povstring += '<%.6f, %.6f, %.6f>' % tuple(material.mirror_color) # Should ask for ray mirror flag
+ povstring += 'fresnel 1 falloff %.6f exponent %.6f metallic %.6f} ' % (raytrace_mirror.fresnel, raytrace_mirror.fresnel_fac, raytrace_mirror.reflect)
+
+
+
+ if material.raytrace_transparency.enabled:
+ #povstring += 'interior { ior %.6f } ' % material.IOR
+ pass
+
+ #file.write('\t\troughness %.6f\n' % (material.hard*0.5))
+ #file.write('\t\t\tcrand 0.0\n') # Sand granyness
+ #file.write('\t\t\tmetallic %.6f\n' % material.spec)
+ #file.write('\t\t\tphong %.6f\n' % material.spec)
+ #file.write('\t\t\tphong_size %.6f\n' % material.spec)
+ povstring += 'brilliance %.6f ' % (material.specular_hardness/256.0) # Like hardness
+ povstring += '}'
+ #file.write('\t}\n')
+ return povstring
+
def exportCamera():
camera = scene.camera
matrix = camera.matrix
@@ -79,6 +113,10 @@ def write_pov(filename, scene=None, info_callback = None):
file.write('\ttightness 0\n') # 0:10f
file.write('\tpoint_at <0, 0, -1>\n')
+ elif lamp.type == 'SUN':
+ file.write('\tparallel\n')
+ file.write('\tpoint_at <0, 0, -1>\n') # *must* be after 'parallel'
+
elif lamp.type == 'AREA':
size_x = lamp.size
@@ -109,47 +147,68 @@ def write_pov(filename, scene=None, info_callback = None):
file.write('}\n')
- def exportMeshs(sel):
- def bMat2PovString(material):
- povstring = 'finish {'
- if world != None:
- povstring += 'ambient <%.6f, %.6f, %.6f> ' % tuple([c*material.ambient for c in world.ambient_color])
+ def exportMeta(metas):
+
+ # TODO - blenders 'motherball' naming is not supported.
+
+ for ob in metas:
+ meta = ob.data
- povstring += 'diffuse %.6f ' % material.diffuse_reflection
- povstring += 'specular %.6f ' % material.specular_reflection
+ file.write('blob {\n')
+ file.write('\t\tthreshold %.4g\n' % meta.threshold)
+ try:
+ material= meta.materials[0] # lame! - blender cant do enything else.
+ except:
+ material= None
- if material.raytrace_mirror.enabled:
- #povstring += 'interior { ior %.6f } ' % material.IOR
- raytrace_mirror= material.raytrace_mirror
- if raytrace_mirror.reflect:
- povstring += 'reflection {'
- povstring += '<%.6f, %.6f, %.6f>' % tuple(material.mirror_color) # Should ask for ray mirror flag
- povstring += 'fresnel 1 falloff %.6f exponent %.6f metallic %.6f} ' % (raytrace_mirror.fresnel, raytrace_mirror.fresnel_fac, raytrace_mirror.reflect)
+ for elem in meta.elements:
+
+ if elem.type not in ('BALL', 'ELLIPSOID'):
+ continue # Not supported
+ loc = elem.location
+ stiffness= elem.stiffness
+ if elem.negative:
+ stiffness = -stiffness
+
+ if elem.type == 'BALL':
- if material.raytrace_transparency.enabled:
- #povstring += 'interior { ior %.6f } ' % material.IOR
- pass
+ file.write('\tsphere { <%.6g, %.6g, %.6g>, %.4g, %.4g ' % (loc.x, loc.y, loc.z, elem.radius, stiffness))
+
+ # After this wecould do something simple like...
+ # "pigment {Blue} }"
+ # except we'll write the color
+
+ elif elem.type == 'ELLIPSOID':
+ # location is modified by scale
+ file.write('\tsphere { <%.6g, %.6g, %.6g>, %.4g, %.4g ' % (loc.x/elem.size_x, loc.y/elem.size_y, loc.z/elem.size_z, elem.radius, stiffness))
+ file.write( 'scale <%.6g, %.6g, %.6g> ' % (elem.size_x, elem.size_y, elem.size_z))
+
+ if material:
+ # materialString = materialTable[material.name]
+ diffuse_color = material.diffuse_color
+
+ file.write(
+ 'pigment {rgbf<%.3g, %.3g, %.3g, %.3g>} }\n' % \
+ (diffuse_color[0], diffuse_color[1], diffuse_color[2], 1-material.alpha)
+ )
+ else:
+ file.write('}\n')
- #file.write('\t\troughness %.6f\n' % (material.hard*0.5))
- #file.write('\t\t\tcrand 0.0\n') # Sand granyness
- #file.write('\t\t\tmetallic %.6f\n' % material.spec)
- #file.write('\t\t\tphong %.6f\n' % material.spec)
- #file.write('\t\t\tphong_size %.6f\n' % material.spec)
- povstring += 'brilliance %.6f ' % (material.specular_hardness/256.0) # Like hardness
- povstring += '}'
- #file.write('\t}\n')
- return povstring
+ # Write the finish last.
+ if material:
+ file.write('\t%s\n' % materialTable[material.name])
+
+ writeMatrix(ob.matrix)
+ file.write('}\n')
- world = scene.world
-
- # Convert all materials to strings we can access directly per vertex.
- for material in bpy.data.materials:
- materialTable[material.name] = bMat2PovString(material)
+
+
+ def exportMeshs(sel):
ob_num = 0
@@ -452,11 +511,15 @@ def write_pov(filename, scene=None, info_callback = None):
file.write('}\n')
+ # Convert all materials to strings we can access directly per vertex.
+ for material in bpy.data.materials:
+ materialTable[material.name] = blenderMaterialToPovString(material)
+
exportCamera()
#exportMaterials()
sel = scene.objects
- lamps = [l for l in sel if l.type == 'LAMP']
- exportLamps(lamps)
+ exportLamps([l for l in sel if l.type == 'LAMP'])
+ exportMeta([l for l in sel if l.type == 'META'])
exportMeshs(sel)
exportWorld(scene.world)
exportGlobalSettings(scene)
diff --git a/release/ui/buttons_data_metaball.py b/release/ui/buttons_data_metaball.py
index 08959dab085..a3781705799 100644
--- a/release/ui/buttons_data_metaball.py
+++ b/release/ui/buttons_data_metaball.py
@@ -54,12 +54,12 @@ class DATA_PT_metaball_element(DataButtonsPanel):
__label__ = "Active Element"
def poll(self, context):
- return (context.meta_ball and context.meta_ball.last_selected_element)
+ return (context.meta_ball and context.meta_ball.active_element)
def draw(self, context):
layout = self.layout
- metaelem = context.meta_ball.last_selected_element
+ metaelem = context.meta_ball.active_element
split = layout.split(percentage=0.3)
split.itemL(text="Type:")
@@ -81,30 +81,30 @@ class DATA_PT_metaball_element(DataButtonsPanel):
col = split.column(align=True)
col.itemL(text="Size:")
- col.itemR(metaelem, "sizex", text="X")
- col.itemR(metaelem, "sizey", text="Y")
- col.itemR(metaelem, "sizez", text="Z")
+ col.itemR(metaelem, "size_x", text="X")
+ col.itemR(metaelem, "size_y", text="Y")
+ col.itemR(metaelem, "size_z", text="Z")
elif metaelem.type == 'TUBE':
col = split.column(align=True)
col.itemL(text="Size:")
- col.itemR(metaelem, "sizex", text="X")
+ col.itemR(metaelem, "size_x", text="X")
elif metaelem.type == 'PLANE':
col = split.column(align=True)
col.itemL(text="Size:")
- col.itemR(metaelem, "sizex", text="X")
- col.itemR(metaelem, "sizey", text="Y")
+ col.itemR(metaelem, "size_x", text="X")
+ col.itemR(metaelem, "size_y", text="Y")
elif metaelem.type == 'ELLIPSOID':
col = split.column(align=True)
col.itemL(text="Size:")
- col.itemR(metaelem, "sizex", text="X")
- col.itemR(metaelem, "sizey", text="Y")
- col.itemR(metaelem, "sizez", text="Z")
+ col.itemR(metaelem, "size_x", text="X")
+ col.itemR(metaelem, "size_y", text="Y")
+ col.itemR(metaelem, "size_z", text="Z")
bpy.types.register(DATA_PT_context_metaball)
diff --git a/release/ui/buttons_material.py b/release/ui/buttons_material.py
index 4e03b2b4fd0..d401367008b 100644
--- a/release/ui/buttons_material.py
+++ b/release/ui/buttons_material.py
@@ -207,7 +207,8 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
def poll(self, context):
- return (context.material.type != 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
+ mat = context.material
+ return mat and (mat.type != 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -260,7 +261,8 @@ class MATERIAL_PT_specular(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
def poll(self, context):
- return (context.material.type != 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
+ mat = context.material
+ return mat and (mat.type != 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -311,7 +313,8 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER'])
def poll(self, context):
- return (context.material.type in ('SURFACE', 'WIRE')) and (context.scene.render_data.engine in self.COMPAT_ENGINES)
+ mat = context.material
+ return mat and (mat.type in ('SURFACE', 'WIRE')) and (context.scene.render_data.engine in self.COMPAT_ENGINES)
def draw_header(self, context):
layout = self.layout
@@ -352,7 +355,8 @@ class MATERIAL_PT_raymir(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER'])
def poll(self, context):
- return (context.material.type in 'SURFACE', 'WIRE') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
+ mat = context.material
+ return mat and (mat.type in 'SURFACE', 'WIRE') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
def draw_header(self, context):
layout = self.layout
@@ -403,7 +407,8 @@ class MATERIAL_PT_raytransp(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER'])
def poll(self, context):
- return (context.material.type in 'SURFACE', 'WIRE') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
+ mat = context.material
+ return mat and (mat.type in 'SURFACE', 'WIRE') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
def draw_header(self, context):
layout = self.layout
@@ -454,7 +459,8 @@ class MATERIAL_PT_halo(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER'])
def poll(self, context):
- return (context.material.type == 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
+ mat = context.material
+ return mat and (mat.type == 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
diff --git a/release/ui/buttons_object_constraint.py b/release/ui/buttons_object_constraint.py
index 7c352a7fb75..5606c6c258a 100644
--- a/release/ui/buttons_object_constraint.py
+++ b/release/ui/buttons_object_constraint.py
@@ -10,7 +10,6 @@ class ConstraintButtonsPanel(bpy.types.Panel):
layout = self.layout
box = layout.template_constraint(con)
- class_dict = self.__class__.__dict__
if box:
# match enum type to our functions, avoids a lookup table.
@@ -18,7 +17,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
# show/key buttons here are most likely obsolete now, with
# keyframing functionality being part of every button
- if con.type not in ("RIGID_BODY_JOINT", "NULL"):
+ if con.type not in ('RIGID_BODY_JOINT', 'NULL'):
box.itemR(con, "influence")
def space_template(self, layout, con, target=True, owner=True):
@@ -31,7 +30,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
row.itemR(con, "target_space", text="")
if target and owner:
- row.itemL(icon="ICON_ARROW_LEFTRIGHT")
+ row.itemL(icon='ICON_ARROW_LEFTRIGHT')
if owner:
row.itemR(con, "owner_space", text="")
@@ -47,7 +46,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
row = layout.row()
row.itemL(text="Head/Tail:")
row.itemR(con, "head_tail", text="")
- elif con.target.type in ("MESH", "LATTICE"):
+ elif con.target.type in ('MESH', 'LATTICE'):
layout.item_pointerR(con, "subtarget", con.target, "vertex_groups", text="Vertex Group")
def CHILD_OF(self, layout, con):
@@ -95,7 +94,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
self.target_template(layout, con)
layout.itemR(con, "pole_target")
- if con.pole_target and con.pole_target.type == "ARMATURE":
+ if con.pole_target and con.pole_target.type == 'ARMATURE':
layout.item_pointerR(con, "pole_subtarget", con.pole_target.data, "bones", text="Bone")
flow = layout.column_flow()
@@ -499,7 +498,7 @@ class BONE_PT_constraints(ConstraintButtonsPanel):
def poll(self, context):
ob = context.object
- return (ob and ob.type == "ARMATURE" and context.bone)
+ return (ob and ob.type == 'ARMATURE' and context.bone)
def draw(self, context):
layout = self.layout