[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1485] trunk/py/scripts/addons/ render_povray: Added file options for export.
Constantin Rahn
conz at vrchannel.de
Sun Jan 23 21:39:03 CET 2011
Revision: 1485
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1485
Author: conz
Date: 2011-01-23 20:39:02 +0000 (Sun, 23 Jan 2011)
Log Message:
-----------
Added file options for export.
Usage: Deactivate "OS Tempfile" to see the new options.
Some UI and code cleanup.
Modified Paths:
--------------
trunk/py/scripts/addons/render_povray/__init__.py
trunk/py/scripts/addons/render_povray/render.py
trunk/py/scripts/addons/render_povray/ui.py
Modified: trunk/py/scripts/addons/render_povray/__init__.py
===================================================================
--- trunk/py/scripts/addons/render_povray/__init__.py 2011-01-23 13:06:39 UTC (rev 1484)
+++ trunk/py/scripts/addons/render_povray/__init__.py 2011-01-23 20:39:02 UTC (rev 1485)
@@ -21,7 +21,7 @@
bl_info = {
"name": "POV-Ray 3.7",
"author": "Campbell Barton, Silvio Falcinelli, Maurice Raybaud, Constantin Rahn",
- "version": (0, 0, 6),
+ "version": (0, 0, 7),
"blender": (2, 5, 6),
"api": 34318,
"location": "Info Header (engine dropdown)",
@@ -33,7 +33,6 @@
"func=detail&aid=23145",
"category": "Render"}
-
if "bpy" in locals():
import imp
imp.reload(ui)
@@ -49,6 +48,29 @@
def register():
Scene = bpy.types.Scene
+ # File Options
+ Scene.pov_tempfiles_enable = BoolProperty(
+ name="Enable Tempfiles",
+ description="Enable the OS-Tempfiles. Otherwise set the path where to save the files.",
+ default=True)
+ Scene.pov_deletefiles_enable = BoolProperty(
+ name="Delete files",
+ description="Delete files after rendering. Doesn't work with the image.",
+ default=True)
+ Scene.pov_scene_name = StringProperty(
+ name="Scene Name",
+ description="Name of POV-Ray scene to create. Empty name will use the name of the blend file.",
+ default="", maxlen=1024)
+ Scene.pov_scene_path = StringProperty(
+ name="Export scene path",
+ # description="Path to directory where the exported scene (POV and INI) is created", # Bug in POV-Ray RC3
+ description="Path to directory where the files are created",
+ default="", maxlen=1024, subtype="DIR_PATH")
+ Scene.pov_renderimage_path = StringProperty(
+ name="Rendered image path",
+ description="Full path to directory where the rendered image is saved.",
+ default="", maxlen=1024, subtype="DIR_PATH")
+
# Not a real pov option, just to know if we should write
Scene.pov_radio_enable = BoolProperty(
name="Enable Radiosity",
@@ -78,11 +100,11 @@
items=(("0", "None", "No indentation"),
("1", "Tabs", "Indentation with tabs"),
("2", "Spaces", "Indentation with spaces")),
- default="1")
+ default="2")
Scene.pov_indentation_spaces = IntProperty(
name="Quantity of spaces",
description="The number of spaces for indentation",
- min=1, max=10, default=3)
+ min=1, max=10, default=4)
Scene.pov_comments_enable = BoolProperty(
name="Enable Comments",
@@ -291,6 +313,11 @@
Mat = bpy.types.Material # MR
Tex = bpy.types.Texture # MR
Obj = bpy.types.Object # MR
+ del Scene.pov_tempfiles_enable # CR
+ del Scene.pov_scene_name # CR
+ del Scene.pov_deletefiles_enable # CR
+ del Scene.pov_scene_path # CR
+ del Scene.pov_renderimage_path # CR
del Scene.pov_radio_enable
del Scene.pov_radio_display_advanced
del Scene.pov_radio_adc_bailout
Modified: trunk/py/scripts/addons/render_povray/render.py
===================================================================
--- trunk/py/scripts/addons/render_povray/render.py 2011-01-23 13:06:39 UTC (rev 1484)
+++ trunk/py/scripts/addons/render_povray/render.py 2011-01-23 20:39:02 UTC (rev 1485)
@@ -35,6 +35,8 @@
##############################SF###########################
##############find image texture
+
+
def splitExt(path):
dotidx = path.rfind(".")
if dotidx == -1:
@@ -42,7 +44,7 @@
else:
return path[dotidx:].upper().replace(".", "")
-
+
def imageFormat(imgF):
ext = ""
ext_orig = splitExt(imgF)
@@ -69,7 +71,7 @@
print(imgF)
if not ext:
- print(" WARNING: texture image format not supported ") # % (imgF , "")) #(ext_orig)))
+ print(" WARNING: texture image format not supported ") # % (imgF , "")) #(ext_orig)))
return ext
@@ -199,7 +201,7 @@
def write_pov(filename, scene=None, info_callback=None):
import mathutils
#file = filename
- file = open(filename.name, "w")
+ file = open(filename, "w")
# Only for testing
if not scene:
@@ -326,6 +328,7 @@
# Level=1 Means No specular nor Mirror reflection
# Level=2 Means translation of spec and mir levels for when no map influences them
# Level=3 Means Maximum Spec and Mirror
+
def povHasnoSpecularMaps(Level):
if Level == 1:
tabWrite("#declare %s = finish {" % safety(name, Level=1))
@@ -359,7 +362,7 @@
elif frontDiffuse == backDiffuse:
frontDiffuse = backDiffuse = 0.5 # Try to respect the user's 'intention' by comparing the two values but bringing the total back to one
elif frontDiffuse > backDiffuse: # Let the highest value stay the highest value
- backDiffuse = min(backDiffuse, (1.0 - frontDiffuse)) # clamps the sum below 1
+ backDiffuse = min(backDiffuse, (1.0 - frontDiffuse)) # clamps the sum below 1
else:
frontDiffuse = min(frontDiffuse, (1.0 - backDiffuse))
@@ -1455,10 +1458,10 @@
x = int(render.resolution_x * render.resolution_percentage * 0.01)
y = int(render.resolution_y * render.resolution_percentage * 0.01)
- file = open(filename_ini.name, "w")
+ file = open(filename_ini, "w")
file.write("Version=3.7\n")
- file.write("Input_File_Name='%s'\n" % filename_pov.name)
- file.write("Output_File_Name='%s'\n" % filename_image.name)
+ file.write("Input_File_Name='%s'\n" % filename_pov)
+ file.write("Output_File_Name='%s'\n" % filename_image)
file.write("Width=%d\n" % x)
file.write("Height=%d\n" % y)
@@ -1505,20 +1508,26 @@
bl_label = "POV-Ray 3.7"
DELAY = 0.5
- def _export(self, scene):
+ def _export(self, scene, povPath, renderImagePath):
import tempfile
+ import os
- # mktemp is Deprecated since version 2.3, replaced with NamedTemporaryFile() #CR
- self._temp_file_in = tempfile.NamedTemporaryFile(suffix=".pov", delete=False)
- self._temp_file_out = tempfile.NamedTemporaryFile(suffix=".png", delete=False) # PNG with POV 3.7, can show the background color with alpha. In the long run using the POV-Ray interactive preview like bishop 3D could solve the preview for all formats.
- #self._temp_file_out = tempfile.NamedTemporaryFile(suffix=".tga", delete=False)
- self._temp_file_ini = tempfile.NamedTemporaryFile(suffix=".ini", delete=False)
- '''
- self._temp_file_in = "/test.pov"
- self._temp_file_out = "/test.png" # PNG with POV-Ray 3.7, can show the background color with alpha. In the long run using the POV-Ray interactive preview like bishop 3D could solve the preview for all formats.
- #self._temp_file_out = "/test.tga"
- self._temp_file_ini = "/test.ini"
- '''
+ if scene.pov_tempfiles_enable:
+ self._temp_file_in = tempfile.NamedTemporaryFile(suffix=".pov", delete=False).name
+ self._temp_file_out = tempfile.NamedTemporaryFile(suffix=".png", delete=False).name # PNG with POV 3.7, can show the background color with alpha. In the long run using the POV-Ray interactive preview like bishop 3D could solve the preview for all formats.
+ #self._temp_file_out = tempfile.NamedTemporaryFile(suffix=".tga", delete=False).name
+ self._temp_file_ini = tempfile.NamedTemporaryFile(suffix=".ini", delete=False).name
+ else:
+ self._temp_file_in = povPath + ".pov"
+ self._temp_file_out = renderImagePath + ".png" # PNG with POV-Ray 3.7, can show the background color with alpha. In the long run using the POV-Ray interactive preview like bishop 3D could solve the preview for all formats.
+ #self._temp_file_out = renderImagePath + ".tga"
+ self._temp_file_ini = povPath + ".ini"
+ '''
+ self._temp_file_in = "/test.pov"
+ self._temp_file_out = "/test.png" # PNG with POV-Ray 3.7, can show the background color with alpha. In the long run using the POV-Ray interactive preview like bishop 3D could solve the preview for all formats.
+ #self._temp_file_out = "/test.tga"
+ self._temp_file_ini = "/test.ini"
+ '''
def info_callback(txt):
self.update_stats("", "POV-Ray 3.7: " + txt)
@@ -1528,7 +1537,7 @@
def _render(self, scene):
try:
- os.remove(self._temp_file_out.name) # so as not to load the old file
+ os.remove(self._temp_file_out) # so as not to load the old file
except OSError:
pass
@@ -1587,7 +1596,7 @@
if 1:
# TODO, when POV-Ray isn't found this gives a cryptic error, would be nice to be able to detect if it exists
try:
- self._process = subprocess.Popen([pov_binary, self._temp_file_ini.name] + extra_args) # stdout=subprocess.PIPE, stderr=subprocess.PIPE
+ self._process = subprocess.Popen([pov_binary, self._temp_file_ini] + extra_args) # stdout=subprocess.PIPE, stderr=subprocess.PIPE
except OSError:
# TODO, report api
print("POV-Ray 3.7: could not execute '%s', possibly POV-Ray isn't installed" % pov_binary)
@@ -1598,37 +1607,27 @@
else:
# This works too but means we have to wait until its done
- os.system("%s %s" % (pov_binary, self._temp_file_ini.name))
+ os.system("%s %s" % (pov_binary, self._temp_file_ini))
# print ("***-DONE-***")
return True
def _cleanup(self):
for f in (self._temp_file_in, self._temp_file_ini, self._temp_file_out):
- #print("Name: %s" % f.name)
- #print("File closed %s" % f.closed)
- f.close() # Why do I have to close them again? Without closeing the pov and ini files are not deletable. PNG is not closable!
try:
- os.unlink(f.name)
- #os.remove(f.name)
+ os.unlink(f)
except OSError: # was that the proper error type?
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list