[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1669] trunk/py/scripts/addons/ render_povray: Added : Option to replace material properties with custom pov code from text data blocks

Maurice Raybaud mauriceraybaud at hotmail.fr
Tue Mar 1 12:55:56 CET 2011


Revision: 1669
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1669
Author:   mauriceraybaud
Date:     2011-03-01 11:55:55 +0000 (Tue, 01 Mar 2011)
Log Message:
-----------
Added : Option to replace material properties with custom pov code from text data blocks

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-03-01 04:47:40 UTC (rev 1668)
+++ trunk/py/scripts/addons/render_povray/__init__.py	2011-03-01 11:55:55 UTC (rev 1669)
@@ -41,14 +41,21 @@
 else:
     import bpy
     from bpy.props import StringProperty, BoolProperty, IntProperty, FloatProperty, FloatVectorProperty, EnumProperty
+    from render_povray import render
     from render_povray import ui
-    from render_povray import render
 
 
+
 def register():
     bpy.utils.register_module(__name__)
 
     Scene = bpy.types.Scene
+    Mat = bpy.types.Material
+    Tex = bpy.types.Texture
+    Obj = bpy.types.Object
+    Cam = bpy.types.Camera
+    Text = bpy.types.Text
+    ###########################SCENE##################################
 
     # File Options
     Scene.pov_tempfiles_enable = BoolProperty(
@@ -243,9 +250,9 @@
             name="Pretrace End", description="Fraction of the screen width which sets the size of the blocks in the mosaic preview last pass",
             min=0.001, max=1.00, soft_min=0.01, soft_max=1.00, default=0.04, precision=3)
 
-    ###########################################################################
-    Mat = bpy.types.Material
+    #############################MATERIAL######################################
 
+
     Mat.pov_irid_enable = BoolProperty(
             name="Enable Iridescence",
             description="Newton's thin film interference (like an oil slick on a puddle of water or the rainbow hues of a soap bubble.)",
@@ -329,12 +336,31 @@
                    ],
             name="Refractive",
             description="use fake caustics (fast) or true photons for refractive Caustics",
-            default="1")  # ui.py has to be loaded before render.py with this.
+            default="1")
+    ##################################CustomPOV Code############################
+    Mat.pov_replacement_text = StringProperty(
+            name = "Declared name:",
+            description="Type the declared name in custom POV code or an external .inc it points at. texture {} expected",
+            default="")
 
-    ###########################################################################
+    #Only DUMMIES below for now: 
+    Tex.pov_replacement_text = StringProperty(
+            name = "Declared name:",
+            description="Type the declared name in custom POV code or an external .inc it points at. pigment {} expected",
+            default="")
 
-    Tex = bpy.types.Texture
+    Obj.pov_replacement_text = StringProperty(
+            name = "Declared name:",
+            description="Type the declared name in custom POV code or an external .inc it points at. Any POV shape expected e.g: isosurface {}",
+            default="")
 
+    Cam.pov_replacement_text = StringProperty(
+            name = "Texts in blend file",
+            description="Type the declared name in custom POV code or an external .inc it points at. camera {} expected",
+            default="")
+    ##############################TEXTURE######################################
+
+
     #Custom texture gamma
     Tex.pov_tex_gamma_enable = BoolProperty(
             name="Enable custom texture gamma",
@@ -346,9 +372,8 @@
             description="value for which the file was issued e.g. a Raw photo is gamma 1.0",
             min=0.45, max=5.00, soft_min=1.00, soft_max=2.50, default=1.00)
 
-    ###########################################################################
+    #################################OBJECT####################################
 
-    Obj = bpy.types.Object
 
     #Importance sampling
     Obj.pov_importance_value = FloatProperty(
@@ -362,10 +387,8 @@
             description="Enable object to collect photons from other objects caustics. Turn off for objects that don't really need to receive caustics (e.g. objects that generate caustics often don't need to show any on themselves) ",
             default=True)
 
-    ###########################################################################
+    ##################################CAMERA###################################
 
-    Cam = bpy.types.Camera
-
     #DOF Toggle
     Cam.pov_dof_enable = BoolProperty(
             name="Depth Of Field",
@@ -399,9 +422,15 @@
             description="Probability to reach the real color value. Larger confidence values will lead to more samples, slower traces and better images.",
             min=0.01, max=0.99, default=0.90)
 
-    ###########################################################################
+    ###################################TEXT####################################
 
 
+    Text.pov_custom_code = BoolProperty(
+            name="Custom Code",
+            description="Add this text at the top of the exported POV-Ray file",
+            default=False)
+
+
 def unregister():
     import bpy
 
@@ -412,6 +441,7 @@
     Tex = bpy.types.Texture
     Obj = bpy.types.Object
     Cam = bpy.types.Camera
+    Text = bpy.types.Text
     del Scene.pov_tempfiles_enable  # CR
     del Scene.pov_scene_name  # CR
     del Scene.pov_deletefiles_enable  # CR
@@ -470,16 +500,21 @@
     del Mat.pov_photons_dispersion  # MR
     del Mat.pov_photons_reflection  # MR
     del Mat.pov_refraction_type  # MR
+    del Mat.pov_replacement_text  # MR
     del Tex.pov_tex_gamma_enable  # MR
     del Tex.pov_tex_gamma_value  # MR
+    del Tex.pov_replacement_text  # MR
     del Obj.pov_importance_value  # MR
     del Obj.pov_collect_photons  # MR
+    del Obj.pov_replacement_text  # MR
     del Cam.pov_dof_enable  # MR
     del Cam.pov_dof_aperture  # MR
     del Cam.pov_dof_samples_min  # MR
     del Cam.pov_dof_samples_max  # MR
     del Cam.pov_dof_variance  # MR
     del Cam.pov_dof_confidence  # MR
-
+    del Cam.pov_replacement_text  # MR
+    del Text.pov_custom_code  #MR
+    
 if __name__ == "__main__":
     register()

Modified: trunk/py/scripts/addons/render_povray/render.py
===================================================================
--- trunk/py/scripts/addons/render_povray/render.py	2011-03-01 04:47:40 UTC (rev 1668)
+++ trunk/py/scripts/addons/render_povray/render.py	2011-03-01 11:55:55 UTC (rev 1669)
@@ -195,9 +195,9 @@
 ##############end safety string name material
 ##############################EndSF###########################
 
+
 tabLevel = 0
 
-
 def write_pov(filename, scene=None, info_callback=None):
     import mathutils
     #file = filename
@@ -957,135 +957,141 @@
                                 t_alpha = t
 
                 ##############################################################################################################
-                file.write("\n")
-                tabWrite("texture {\n")  # THIS AREA NEEDS TO LEAVE THE TEXTURE OPEN UNTIL ALL MAPS ARE WRITTEN DOWN.   --MR
+                    
+                if material.pov_replacement_text != "":
+                    file.write("\n")
+                    file.write(" texture{%s}\n" % material.pov_replacement_text)
 
-                ##############################################################################################################
-                if material.diffuse_shader == 'MINNAERT':
-                    tabWrite("\n")
-                    tabWrite("aoi\n")
-                    tabWrite("texture_map {\n")
-                    tabWrite("[%.3g finish {diffuse %.3g}]\n" % (material.darkness / 2.0, 2.0 - material.darkness))
-                    tabWrite("[%.3g" % (1.0 - (material.darkness / 2.0)))
-######TO OPTIMIZE? or present a more elegant way? At least make it work!##################################################################
-                #If Fresnel gets removed from 2.5, why bother?
-                if material.diffuse_shader == 'FRESNEL':
+                else:
+                    file.write("\n")
+                    tabWrite("texture {\n")  # THIS AREA NEEDS TO LEAVE THE TEXTURE OPEN UNTIL ALL MAPS ARE WRITTEN DOWN.   --MR
 
-######END of part TO OPTIMIZE? or present a more elegant way?##################################################################
+                    ##############################################################################################################
+                    if material.diffuse_shader == 'MINNAERT':
+                        tabWrite("\n")
+                        tabWrite("aoi\n")
+                        tabWrite("texture_map {\n")
+                        tabWrite("[%.3g finish {diffuse %.3g}]\n" % (material.darkness / 2.0, 2.0 - material.darkness))
+                        tabWrite("[%.3g" % (1.0 - (material.darkness / 2.0)))
+    ######TO OPTIMIZE? or present a more elegant way? At least make it work!##################################################################
+                    #If Fresnel gets removed from 2.5, why bother?
+                    if material.diffuse_shader == 'FRESNEL':
 
-##                        #lampLocation=lamp.position
-##                        lampRotation=
-##                        a=lamp.Rotation[0]
-##                        b=lamp.Rotation[1]
-##                        c=lamp.Rotation[2]
-##                        lampLookAt=tuple (x,y,z)
-##                        lampLookAt[3]= 0.0 #Put 'target' of the lamp on the floor plane to elimianate one unknown value
-##                                   degrees(atan((lampLocation - lampLookAt).y/(lampLocation - lampLookAt).z))=lamp.rotation[0]
-##                                   degrees(atan((lampLocation - lampLookAt).z/(lampLocation - lampLookAt).x))=lamp.rotation[1]
-##                                   degrees(atan((lampLocation - lampLookAt).x/(lampLocation - lampLookAt).y))=lamp.rotation[2]
-##                        degrees(atan((lampLocation - lampLookAt).y/(lampLocation.z))=lamp.rotation[0]
-##                        degrees(atan((lampLocation.z/(lampLocation - lampLookAt).x))=lamp.rotation[1]
-##                        degrees(atan((lampLocation - lampLookAt).x/(lampLocation - lampLookAt).y))=lamp.rotation[2]
+    ######END of part TO OPTIMIZE? or present a more elegant way?##################################################################
 
-                                #color = tuple([c * lamp.energy for c in lamp.color]) # Colour is modified by energy
+    ##                        #lampLocation=lamp.position

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list