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

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Rahn <conz@vrchannel.de>2011-01-24 14:44:01 +0300
committerConstantin Rahn <conz@vrchannel.de>2011-01-24 14:44:01 +0300
commitcd36f92c7890474dd6a08a10e18bd426e784c15c (patch)
tree09030e1470486dc89fdab5de46ebd9a2f026f075 /render_povray
parentb473917eb208c43bd580b48d84df876a18b4a057 (diff)
Optimized export to OS Tempfiles.
The output to Tempfiles no longer exports comments, indentations or LFs (in lists). New option in Export settings to deactivate LF (line brakes) in lists. Fixed a material export for normal maps. Was exported two times. Paths to images are now realpaths, no /../ in absolut paths.
Diffstat (limited to 'render_povray')
-rw-r--r--render_povray/__init__.py5
-rw-r--r--render_povray/render.py141
-rw-r--r--render_povray/ui.py2
3 files changed, 98 insertions, 50 deletions
diff --git a/render_povray/__init__.py b/render_povray/__init__.py
index 234761b6..e346fc16 100644
--- a/render_povray/__init__.py
+++ b/render_povray/__init__.py
@@ -70,6 +70,10 @@ def register():
name="Rendered image path",
description="Full path to directory where the rendered image is saved.",
default="", maxlen=1024, subtype="DIR_PATH")
+ Scene.pov_list_lf_enable = BoolProperty(
+ name="LF in lists",
+ description="Enable line brakes in lists (vectors and indices). Disabled: lists are exported in one line.",
+ default=True)
# Not a real pov option, just to know if we should write
Scene.pov_radio_enable = BoolProperty(
@@ -318,6 +322,7 @@ def unregister():
del Scene.pov_deletefiles_enable # CR
del Scene.pov_scene_path # CR
del Scene.pov_renderimage_path # CR
+ del Scene.pov_list_lf_enable # CR
del Scene.pov_radio_enable
del Scene.pov_radio_display_advanced
del Scene.pov_radio_adc_bailout
diff --git a/render_povray/render.py b/render_povray/render.py
index 6996ee53..38450d74 100644
--- a/render_povray/render.py
+++ b/render_povray/render.py
@@ -157,6 +157,7 @@ def path_image(image):
fn_strip = os.path.basename(fn)
if not os.path.isfile(fn):
fn = findInSubDir(splitFile(fn), splitPath(bpy.data.filepath))
+ fn = os.path.realpath(fn)
return fn
##############end find image texture
@@ -224,18 +225,21 @@ def write_pov(filename, scene=None, info_callback=None):
tab = setTab(scene.pov_indentation_character, scene.pov_indentation_spaces)
def tabWrite(str_o):
- global tabLevel
- brackets = str_o.count("{") - str_o.count("}") + str_o.count("[") - str_o.count("]")
- if brackets < 0:
- tabLevel = tabLevel + brackets
- if tabLevel < 0:
- print("Indentation Warning: tabLevel = %s" % tabLevel)
- tabLevel = 0
- if tabLevel >= 1:
- file.write("%s" % tab * tabLevel)
- file.write(str_o)
- if brackets > 0:
- tabLevel = tabLevel + brackets
+ if not scene.pov_tempfiles_enable:
+ global tabLevel
+ brackets = str_o.count("{") - str_o.count("}") + str_o.count("[") - str_o.count("]")
+ if brackets < 0:
+ tabLevel = tabLevel + brackets
+ if tabLevel < 0:
+ print("Indentation Warning: tabLevel = %s" % tabLevel)
+ tabLevel = 0
+ if tabLevel >= 1:
+ file.write("%s" % tab * tabLevel)
+ file.write(str_o)
+ if brackets > 0:
+ tabLevel = tabLevel + brackets
+ else:
+ file.write(str_o)
def uniqueName(name, nameSeq):
@@ -332,19 +336,19 @@ def write_pov(filename, scene=None, info_callback=None):
def povHasnoSpecularMaps(Level):
if Level == 1:
tabWrite("#declare %s = finish {" % safety(name, Level=1))
- if comments:
+ if not scene.pov_tempfiles_enable and comments:
file.write(" //No specular nor Mirror reflection\n")
else:
tabWrite("\n")
elif Level == 2:
tabWrite("#declare %s = finish {" % safety(name, Level=2))
- if comments:
+ if not scene.pov_tempfiles_enable and comments:
file.write(" //translation of spec and mir levels for when no map influences them\n")
else:
tabWrite("\n")
elif Level == 3:
tabWrite("#declare %s = finish {" % safety(name, Level=3))
- if comments:
+ if not scene.pov_tempfiles_enable and comments:
file.write(" //Maximum Spec and Mirror\n")
else:
tabWrite("\n")
@@ -638,7 +642,7 @@ def write_pov(filename, scene=None, info_callback=None):
# TODO - blenders 'motherball' naming is not supported.
- if scene.pov_comments_enable and len(metas) >= 1:
+ if not scene.pov_tempfiles_enable and scene.pov_comments_enable and len(metas) >= 1:
file.write("//--Blob objects--\n\n")
for ob in metas:
@@ -704,7 +708,7 @@ def write_pov(filename, scene=None, info_callback=None):
tabWrite("}\n") # End of Metaball block
- if scene.pov_comments_enable and len(metas) >= 1:
+ if not scene.pov_tempfiles_enable and scene.pov_comments_enable and len(metas) >= 1:
file.write("\n")
objectNames = {}
@@ -774,8 +778,12 @@ def write_pov(filename, scene=None, info_callback=None):
tabStr = tab * tabLevel
for v in me.vertices:
- file.write(",\n")
- file.write(tabStr + "<%.6f, %.6f, %.6f>" % v.co[:]) # vert count
+ if not scene.pov_tempfiles_enable and scene.pov_list_lf_enable:
+ file.write(",\n")
+ file.write(tabStr + "<%.6f, %.6f, %.6f>" % v.co[:]) # vert count
+ else:
+ file.write(", ")
+ file.write("<%.6f, %.6f, %.6f>" % v.co[:]) # vert count
#tabWrite("<%.6f, %.6f, %.6f>" % v.co[:]) # vert count
file.write("\n")
tabWrite("}\n")
@@ -798,8 +806,12 @@ def write_pov(filename, scene=None, info_callback=None):
idx = 0
tabStr = tab * tabLevel
for no, index in uniqueNormals.items():
- file.write(",\n")
- file.write(tabStr + "<%.6f, %.6f, %.6f>" % no) # vert count
+ if not scene.pov_tempfiles_enable and scene.pov_list_lf_enable:
+ file.write(",\n")
+ file.write(tabStr + "<%.6f, %.6f, %.6f>" % no) # vert count
+ else:
+ file.write(", ")
+ file.write("<%.6f, %.6f, %.6f>" % no) # vert count
index[0] = idx
idx += 1
file.write("\n")
@@ -828,8 +840,12 @@ def write_pov(filename, scene=None, info_callback=None):
idx = 0
tabStr = tab * tabLevel
for uv, index in uniqueUVs.items():
- file.write(",\n")
- file.write(tabStr + "<%.6f, %.6f>" % uv)
+ if not scene.pov_tempfiles_enable and scene.pov_list_lf_enable:
+ file.write(",\n")
+ file.write(tabStr + "<%.6f, %.6f>" % uv)
+ else:
+ file.write(", ")
+ file.write("<%.6f, %.6f>" % uv)
index[0] = idx
idx += 1
'''
@@ -976,7 +992,7 @@ def write_pov(filename, scene=None, info_callback=None):
# continue # Some texture found
#if special_texture_found:
- if texturesSpec != "" or texturesAlpha != "" or texturesNorm != "":
+ if texturesSpec != "" or texturesAlpha != "":
if texturesSpec != "":
# tabWrite("\n")
tabWrite("pigment_pattern {\n")
@@ -1156,8 +1172,12 @@ def write_pov(filename, scene=None, info_callback=None):
if not me_materials or me_materials[material_index] is None: # No materials
for i1, i2, i3 in indices:
- file.write(",\n")
- file.write(tabStr + "<%d,%d,%d>" % (fv[i1], fv[i2], fv[i3])) # vert count
+ if not scene.pov_tempfiles_enable and scene.pov_list_lf_enable:
+ file.write(",\n")
+ file.write(tabStr + "<%d,%d,%d>" % (fv[i1], fv[i2], fv[i3])) # vert count
+ else:
+ file.write(", ")
+ file.write("<%d,%d,%d>" % (fv[i1], fv[i2], fv[i3])) # vert count
else:
material = me_materials[material_index]
for i1, i2, i3 in indices:
@@ -1176,8 +1196,12 @@ def write_pov(filename, scene=None, info_callback=None):
diffuse_color = material.diffuse_color
ci1 = ci2 = ci3 = vertCols[diffuse_color[0], diffuse_color[1], diffuse_color[2], f.material_index][0]
- file.write(",\n")
- file.write(tabStr + "<%d,%d,%d>, %d,%d,%d" % (fv[i1], fv[i2], fv[i3], ci1, ci2, ci3)) # vert count
+ if not scene.pov_tempfiles_enable and scene.pov_list_lf_enable:
+ file.write(",\n")
+ file.write(tabStr + "<%d,%d,%d>, %d,%d,%d" % (fv[i1], fv[i2], fv[i3], ci1, ci2, ci3)) # vert count
+ else:
+ file.write(", ")
+ file.write("<%d,%d,%d>, %d,%d,%d" % (fv[i1], fv[i2], fv[i3], ci1, ci2, ci3)) # vert count
file.write("\n")
tabWrite("}\n")
@@ -1195,15 +1219,26 @@ def write_pov(filename, scene=None, info_callback=None):
for i1, i2, i3 in indices:
if me_faces[fi].use_smooth:
- file.write(",\n")
- file.write(tabStr + "<%d,%d,%d>" %\
- (uniqueNormals[verts_normals[fv[i1]]][0],\
- uniqueNormals[verts_normals[fv[i2]]][0],\
- uniqueNormals[verts_normals[fv[i3]]][0])) # vert count
+ if not scene.pov_tempfiles_enable and scene.pov_list_lf_enable:
+ file.write(",\n")
+ file.write(tabStr + "<%d,%d,%d>" %\
+ (uniqueNormals[verts_normals[fv[i1]]][0],\
+ uniqueNormals[verts_normals[fv[i2]]][0],\
+ uniqueNormals[verts_normals[fv[i3]]][0])) # vert count
+ else:
+ file.write(", ")
+ file.write("<%d,%d,%d>" %\
+ (uniqueNormals[verts_normals[fv[i1]]][0],\
+ uniqueNormals[verts_normals[fv[i2]]][0],\
+ uniqueNormals[verts_normals[fv[i3]]][0])) # vert count
else:
idx = uniqueNormals[faces_normals[fi]][0]
- file.write(",\n")
- file.write(tabStr + "<%d,%d,%d>" % (idx, idx, idx)) # vert count
+ if not scene.pov_tempfiles_enable and scene.pov_list_lf_enable:
+ file.write(",\n")
+ file.write(tabStr + "<%d,%d,%d>" % (idx, idx, idx)) # vert count
+ else:
+ file.write(", ")
+ file.write("<%d,%d,%d>" % (idx, idx, idx)) # vert count
file.write("\n")
tabWrite("}\n")
@@ -1226,12 +1261,18 @@ def write_pov(filename, scene=None, info_callback=None):
uvs = uv.uv1[:], uv.uv2[:], uv.uv3[:]
for i1, i2, i3 in indices:
- file.write(",\n")
- file.write(tabStr + "<%d,%d,%d>" % (
- uniqueUVs[uvs[i1]][0],\
- uniqueUVs[uvs[i2]][0],\
- uniqueUVs[uvs[i3]][0],
- ))
+ if not scene.pov_tempfiles_enable and scene.pov_list_lf_enable:
+ file.write(",\n")
+ file.write(tabStr + "<%d,%d,%d>" % (
+ uniqueUVs[uvs[i1]][0],\
+ uniqueUVs[uvs[i2]][0],\
+ uniqueUVs[uvs[i3]][0]))
+ else:
+ file.write(", ")
+ file.write("<%d,%d,%d>" % (
+ uniqueUVs[uvs[i1]][0],\
+ uniqueUVs[uvs[i2]][0],\
+ uniqueUVs[uvs[i3]][0]))
file.write("\n")
tabWrite("}\n")
@@ -1404,32 +1445,32 @@ def write_pov(filename, scene=None, info_callback=None):
sel = scene.objects
comments = scene.pov_comments_enable
- if comments:
+ if not scene.pov_tempfiles_enable and comments:
file.write("//---------------------------------------------\n//--Exported with POV-Ray exporter for Blender--\n//---------------------------------------------\n\n")
file.write("#version 3.7;\n")
- if comments:
+ if not scene.pov_tempfiles_enable and comments:
file.write("\n//--Global settings and background--\n\n")
exportGlobalSettings(scene)
- if comments:
+ if not scene.pov_tempfiles_enable and comments:
file.write("\n")
exportWorld(scene.world)
- if comments:
+ if not scene.pov_tempfiles_enable and comments:
file.write("\n//--Cameras--\n\n")
exportCamera()
- if comments:
+ if not scene.pov_tempfiles_enable and comments:
file.write("\n//--Lamps--\n\n")
exportLamps([l for l in sel if l.type == 'LAMP'])
- if comments:
+ if not scene.pov_tempfiles_enable and comments:
file.write("\n//--Material Definitions--\n\n")
# Convert all materials to strings we can access directly per vertex.
@@ -1438,12 +1479,12 @@ def write_pov(filename, scene=None, info_callback=None):
for material in bpy.data.materials:
if material.users > 0:
writeMaterial(material)
- if comments:
+ if not scene.pov_tempfiles_enable and comments:
file.write("\n")
exportMeta([l for l in sel if l.type == 'META'])
- if comments:
+ if not scene.pov_tempfiles_enable and comments:
file.write("//--Mesh objects--\n")
exportMeshs(scene, sel)
@@ -1717,7 +1758,7 @@ class PovrayRender(bpy.types.RenderEngine):
# renderImagePath = renderImagePath + "\\" + povSceneName # for now this has to be the same like the pov output. Bug in POV-Ray RC3.
renderImagePath = povPath # Bugfix for POV-Ray RC3 bug
- renderImagePath = os.path.realpath(renderImagePath)
+ # renderImagePath = os.path.realpath(renderImagePath) # Bugfix for POV-Ray RC3 bug
#print("Export path: %s" % povPath)
#print("Render Image path: %s" % renderImagePath)
diff --git a/render_povray/ui.py b/render_povray/ui.py
index 678314f1..722622e1 100644
--- a/render_povray/ui.py
+++ b/render_povray/ui.py
@@ -181,6 +181,8 @@ class RENDER_PT_povray_export_settings(RenderButtonsPanel, bpy.types.Panel):
split = layout.split()
col = split.column()
col.prop(scene, "pov_comments_enable", text="Comments")
+ col = split.column()
+ col.prop(scene, "pov_list_lf_enable", text="Line brakes in lists")
class RENDER_PT_povray_render_settings(RenderButtonsPanel, bpy.types.Panel):