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:
authorMaurice Raybaud <mauriceraybaud@hotmail.fr>2011-03-01 14:55:55 +0300
committerMaurice Raybaud <mauriceraybaud@hotmail.fr>2011-03-01 14:55:55 +0300
commit9675e883a25da73141b4a169263d537d95c94795 (patch)
treef410c2085efcb91f08b3e1f1d22c62b169f98846 /render_povray
parent4ca98abc8c39994786a328384b930ab26bb2176a (diff)
Added : Option to replace material properties with custom pov code from text data blocks
Diffstat (limited to 'render_povray')
-rw-r--r--render_povray/__init__.py63
-rw-r--r--render_povray/render.py259
-rw-r--r--render_povray/ui.py103
3 files changed, 288 insertions, 137 deletions
diff --git a/render_povray/__init__.py b/render_povray/__init__.py
index 2a94a6f3..b2010524 100644
--- a/render_povray/__init__.py
+++ b/render_povray/__init__.py
@@ -41,14 +41,21 @@ if "bpy" in locals():
else:
import bpy
from bpy.props import StringProperty, BoolProperty, IntProperty, FloatProperty, FloatVectorProperty, EnumProperty
- from render_povray import ui
from render_povray import render
+ from render_povray import ui
+
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,8 +250,8 @@ def register():
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",
@@ -329,11 +336,30 @@ def register():
],
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="")
+
+ 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######################################
- Tex = bpy.types.Texture
#Custom texture gamma
Tex.pov_tex_gamma_enable = BoolProperty(
@@ -346,9 +372,8 @@ def register():
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,9 +387,7 @@ def register():
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)
- ###########################################################################
-
- Cam = bpy.types.Camera
+ ##################################CAMERA###################################
#DOF Toggle
Cam.pov_dof_enable = BoolProperty(
@@ -399,7 +422,13 @@ def register():
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():
@@ -412,6 +441,7 @@ def unregister():
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 @@ def unregister():
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()
diff --git a/render_povray/render.py b/render_povray/render.py
index 3181f93e..f0eb3bf9 100644
--- a/render_povray/render.py
+++ b/render_povray/render.py
@@ -195,8 +195,8 @@ def safety(name, Level):
##############end safety string name material
##############################EndSF###########################
-tabLevel = 0
+tabLevel = 0
def write_pov(filename, scene=None, info_callback=None):
import mathutils
@@ -957,135 +957,141 @@ def write_pov(filename, scene=None, info_callback=None):
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':
-
-######END of part TO OPTIMIZE? or present a more elegant way?##################################################################
-
-## #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]
-
- #color = tuple([c * lamp.energy for c in lamp.color]) # Colour is modified by energy
+ else:
+ file.write("\n")
+ tabWrite("texture {\n") # THIS AREA NEEDS TO LEAVE THE TEXTURE OPEN UNTIL ALL MAPS ARE WRITTEN DOWN. --MR
- tabWrite("\n")
- tabWrite("slope { lampTarget }\n")
- tabWrite("texture_map {\n")
- tabWrite("[%.3g finish {diffuse %.3g}]\n" % (material.diffuse_fresnel / 2, 2.0 - material.diffuse_fresnel_factor))
- tabWrite("[%.3g\n" % (1 - (material.diffuse_fresnel / 2.0)))
-
- #if material.diffuse_shader == 'FRESNEL': pigment pattern aoi pigment and texture map above, the rest below as one of its entry
- ##########################################################################################################################
-
- #special_texture_found = False
- #for t in material.texture_slots:
- # if t and t.texture.type == 'IMAGE' and t.use and t.texture.image and (t.use_map_specular or t.use_map_raymir or t.use_map_normal or t.use_map_alpha):
- # special_texture_found = True
- # continue # Some texture found
- #if special_texture_found:
-
- if texturesSpec != "" or texturesAlpha != "":
- if texturesSpec != "":
- # tabWrite("\n")
- tabWrite("pigment_pattern {\n")
- # POV-Ray "scale" is not a number of repetitions factor, but its inverse, a standard scale factor.
- # Offset seems needed relatively to scale so probably center of the scale is not the same in blender and POV
- mappingSpec = "translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>\n" % (-t_spec.offset.x, -t_spec.offset.y, t_spec.offset.z, 1.0 / t_spec.scale.x, 1.0 / t_spec.scale.y, 1.0 / t_spec.scale.z)
- tabWrite("uv_mapping image_map{%s \"%s\" %s}\n" % (imageFormat(texturesSpec), texturesSpec, imgMap(t_spec)))
- tabWrite("%s\n" % mappingSpec)
- tabWrite("}\n")
+ ##############################################################################################################
+ 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':
+
+ ######END of part TO OPTIMIZE? or present a more elegant way?##################################################################
+
+ ## #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]
+
+ #color = tuple([c * lamp.energy for c in lamp.color]) # Colour is modified by energy
+
+ tabWrite("\n")
+ tabWrite("slope { lampTarget }\n")
tabWrite("texture_map {\n")
- tabWrite("[0 \n")
+ tabWrite("[%.3g finish {diffuse %.3g}]\n" % (material.diffuse_fresnel / 2, 2.0 - material.diffuse_fresnel_factor))
+ tabWrite("[%.3g\n" % (1 - (material.diffuse_fresnel / 2.0)))
+
+ #if material.diffuse_shader == 'FRESNEL': pigment pattern aoi pigment and texture map above, the rest below as one of its entry
+ ##########################################################################################################################
- if texturesDif == "":
- if texturesAlpha != "":
- tabWrite("\n")
+ #special_texture_found = False
+ #for t in material.texture_slots:
+ # if t and t.texture.type == 'IMAGE' and t.use and t.texture.image and (t.use_map_specular or t.use_map_raymir or t.use_map_normal or t.use_map_alpha):
+ # special_texture_found = True
+ # continue # Some texture found
+ #if special_texture_found:
+
+ if texturesSpec != "" or texturesAlpha != "":
+ if texturesSpec != "":
+ # tabWrite("\n")
+ tabWrite("pigment_pattern {\n")
# POV-Ray "scale" is not a number of repetitions factor, but its inverse, a standard scale factor.
# Offset seems needed relatively to scale so probably center of the scale is not the same in blender and POV
- mappingAlpha = " translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>\n" % (-t_alpha.offset.x, -t_alpha.offset.y, t_alpha.offset.z, 1.0 / t_alpha.scale.x, 1.0 / t_alpha.scale.y, 1.0 / t_alpha.scale.z)
- tabWrite("pigment {pigment_pattern {uv_mapping image_map{%s \"%s\" %s}%s" % (imageFormat(texturesAlpha), texturesAlpha, imgMap(t_alpha), mappingAlpha))
- tabWrite("}\n")
- tabWrite("pigment_map {\n")
- tabWrite("[0 color rgbft<0,0,0,1,1>]\n")
- tabWrite("[1 color rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>]\n" % (col[0], col[1], col[2], povFilter, trans))
- tabWrite("}\n")
+ mappingSpec = "translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>\n" % (-t_spec.offset.x, t_spec.offset.y, t_spec.offset.z, 1.0 / t_spec.scale.x, 1.0 / t_spec.scale.y, 1.0 / t_spec.scale.z)
+ tabWrite("uv_mapping image_map{%s \"%s\" %s}\n" % (imageFormat(texturesSpec), texturesSpec, imgMap(t_spec)))
+ tabWrite("%s\n" % mappingSpec)
tabWrite("}\n")
+ tabWrite("texture_map {\n")
+ tabWrite("[0 \n")
- else:
+ if texturesDif == "":
+ if texturesAlpha != "":
+ tabWrite("\n")
+ # POV-Ray "scale" is not a number of repetitions factor, but its inverse, a standard scale factor.
+ # Offset seems needed relatively to scale so probably center of the scale is not the same in blender and POV
+ mappingAlpha = " translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>\n" % (-t_alpha.offset.x, -t_alpha.offset.y, t_alpha.offset.z, 1.0 / t_alpha.scale.x, 1.0 / t_alpha.scale.y, 1.0 / t_alpha.scale.z)
+ tabWrite("pigment {pigment_pattern {uv_mapping image_map{%s \"%s\" %s}%s" % (imageFormat(texturesAlpha), texturesAlpha, imgMap(t_alpha), mappingAlpha))
+ tabWrite("}\n")
+ tabWrite("pigment_map {\n")
+ tabWrite("[0 color rgbft<0,0,0,1,1>]\n")
+ tabWrite("[1 color rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>]\n" % (col[0], col[1], col[2], povFilter, trans))
+ tabWrite("}\n")
+ tabWrite("}\n")
- tabWrite("pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>}\n" % (col[0], col[1], col[2], povFilter, trans))
+ else:
- if texturesSpec != "":
- tabWrite("finish {%s}\n" % (safety(material_finish, Level=1))) # Level 1 is no specular
+ tabWrite("pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>}\n" % (col[0], col[1], col[2], povFilter, trans))
- else:
- tabWrite("finish {%s}\n" % (safety(material_finish, Level=2))) # Level 2 is translated spec
+ if texturesSpec != "":
+ tabWrite("finish {%s}\n" % (safety(material_finish, Level=1))) # Level 1 is no specular
- else:
- # POV-Ray "scale" is not a number of repetitions factor, but its inverse, a standard scale factor.
- # Offset seems needed relatively to scale so probably center of the scale is not the same in blender and POV
- mappingDif = ("translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>" % (-t_dif.offset.x, -t_dif.offset.y, t_dif.offset.z, 1.0 / t_dif.scale.x, 1.0 / t_dif.scale.y, 1.0 / t_dif.scale.z))
- if texturesAlpha != "":
- # POV-Ray "scale" is not a number of repetitions factor, but its inverse, a standard scale factor.
- # Offset seems needed relatively to scale so probably center of the scale is not the same in blender and POV
- mappingAlpha = " translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>" % (-t_alpha.offset.x, -t_alpha.offset.y, t_alpha.offset.z, 1.0 / t_alpha.scale.x, 1.0 / t_alpha.scale.y, 1.0 / t_alpha.scale.z)
- tabWrite("pigment {\n")
- tabWrite("pigment_pattern {\n")
- tabWrite("uv_mapping image_map{%s \"%s\" %s}%s}\n" % (imageFormat(texturesAlpha), texturesAlpha, imgMap(t_alpha), mappingAlpha))
- tabWrite("pigment_map {\n")
- tabWrite("[0 color rgbft<0,0,0,1,1>]\n")
- tabWrite("[1 uv_mapping image_map {%s \"%s\" %s} %s]\n" % (imageFormat(texturesDif), texturesDif, (imgGamma + imgMap(t_dif)), mappingDif))
- tabWrite("}\n")
- tabWrite("}\n")
+ else:
+ tabWrite("finish {%s}\n" % (safety(material_finish, Level=2))) # Level 2 is translated spec
else:
- tabWrite("pigment {uv_mapping image_map {%s \"%s\" %s}%s}\n" % (imageFormat(texturesDif), texturesDif, (imgGamma + imgMap(t_dif)), mappingDif))
-
+ # POV-Ray "scale" is not a number of repetitions factor, but its inverse, a standard scale factor.
+ # Offset seems needed relatively to scale so probably center of the scale is not the same in blender and POV
+ mappingDif = ("translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>" % (-t_dif.offset.x, -t_dif.offset.y, t_dif.offset.z, 1.0 / t_dif.scale.x, 1.0 / t_dif.scale.y, 1.0 / t_dif.scale.z))
+ if texturesAlpha != "":
+ # POV-Ray "scale" is not a number of repetitions factor, but its inverse, a standard scale factor.
+ # Offset seems needed relatively to scale so probably center of the scale is not the same in blender and POV
+ mappingAlpha = " translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>" % (-t_alpha.offset.x, -t_alpha.offset.y, t_alpha.offset.z, 1.0 / t_alpha.scale.x, 1.0 / t_alpha.scale.y, 1.0 / t_alpha.scale.z)
+ tabWrite("pigment {\n")
+ tabWrite("pigment_pattern {\n")
+ tabWrite("uv_mapping image_map{%s \"%s\" %s}%s}\n" % (imageFormat(texturesAlpha), texturesAlpha, imgMap(t_alpha), mappingAlpha))
+ tabWrite("pigment_map {\n")
+ tabWrite("[0 color rgbft<0,0,0,1,1>]\n")
+ tabWrite("[1 uv_mapping image_map {%s \"%s\" %s} %s]\n" % (imageFormat(texturesDif), texturesDif, (imgGamma + imgMap(t_dif)), mappingDif))
+ tabWrite("}\n")
+ tabWrite("}\n")
+
+ else:
+ tabWrite("pigment {uv_mapping image_map {%s \"%s\" %s}%s}\n" % (imageFormat(texturesDif), texturesDif, (imgGamma + imgMap(t_dif)), mappingDif))
+
+ if texturesSpec != "":
+ tabWrite("finish {%s}\n" % (safety(material_finish, Level=1))) # Level 1 is no specular
+
+ else:
+ tabWrite("finish {%s}\n" % (safety(material_finish, Level=2))) # Level 2 is translated specular
+
+ ## scale 1 rotate y*0
+ #imageMap = ("{image_map {%s \"%s\" %s }\n" % (imageFormat(textures),textures,imgMap(t_dif)))
+ #tabWrite("uv_mapping pigment %s} %s finish {%s}\n" % (imageMap,mapping,safety(material_finish)))
+ #tabWrite("pigment {uv_mapping image_map {%s \"%s\" %s}%s} finish {%s}\n" % (imageFormat(texturesDif),texturesDif,imgMap(t_dif),mappingDif,safety(material_finish)))
+ if texturesNorm != "":
+ ## scale 1 rotate y*0
+ # POV-Ray "scale" is not a number of repetitions factor, but its inverse, a standard scale factor.
+ # Offset seems needed relatively to scale so probably center of the scale is not the same in blender and POV
+ mappingNor = " translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>" % (-t_nor.offset.x, -t_nor.offset.y, t_nor.offset.z, 1.0 / t_nor.scale.x, 1.0 / t_nor.scale.y, 1.0 / t_nor.scale.z)
+ #imageMapNor = ("{bump_map {%s \"%s\" %s mapping}" % (imageFormat(texturesNorm),texturesNorm,imgMap(t_nor)))
+ #We were not using the above maybe we should?
+ tabWrite("normal {uv_mapping bump_map {%s \"%s\" %s bump_size %.4g }%s}\n" % (imageFormat(texturesNorm), texturesNorm, imgMap(t_nor), t_nor.normal_factor * 10, mappingNor))
if texturesSpec != "":
- tabWrite("finish {%s}\n" % (safety(material_finish, Level=1))) # Level 1 is no specular
+ tabWrite("]\n")
+ ################################Second index for mapping specular max value##################################################################################################
+ tabWrite("[1 \n")
- else:
- tabWrite("finish {%s}\n" % (safety(material_finish, Level=2))) # Level 2 is translated specular
-
- ## scale 1 rotate y*0
- #imageMap = ("{image_map {%s \"%s\" %s }\n" % (imageFormat(textures),textures,imgMap(t_dif)))
- #tabWrite("uv_mapping pigment %s} %s finish {%s}\n" % (imageMap,mapping,safety(material_finish)))
- #tabWrite("pigment {uv_mapping image_map {%s \"%s\" %s}%s} finish {%s}\n" % (imageFormat(texturesDif),texturesDif,imgMap(t_dif),mappingDif,safety(material_finish)))
- if texturesNorm != "":
- ## scale 1 rotate y*0
- # POV-Ray "scale" is not a number of repetitions factor, but its inverse, a standard scale factor.
- # Offset seems needed relatively to scale so probably center of the scale is not the same in blender and POV
- mappingNor = " translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>" % (-t_nor.offset.x, -t_nor.offset.y, t_nor.offset.z, 1.0 / t_nor.scale.x, 1.0 / t_nor.scale.y, 1.0 / t_nor.scale.z)
- #imageMapNor = ("{bump_map {%s \"%s\" %s mapping}" % (imageFormat(texturesNorm),texturesNorm,imgMap(t_nor)))
- #We were not using the above maybe we should?
- tabWrite("normal {uv_mapping bump_map {%s \"%s\" %s bump_size %.4g }%s}\n" % (imageFormat(texturesNorm), texturesNorm, imgMap(t_nor), t_nor.normal_factor * 10, mappingNor))
- if texturesSpec != "":
- tabWrite("]\n")
- ################################Second index for mapping specular max value##################################################################################################
- tabWrite("[1 \n")
-
- if texturesDif == "":
+ if texturesDif == "" and material.pov_replacement_text == "":
if texturesAlpha != "":
# POV-Ray "scale" is not a number of repetitions factor, but its inverse, a standard scale factor.
# Offset seems needed relatively to scale so probably center of the scale is not the same in blender and POV
@@ -1106,7 +1112,7 @@ def write_pov(filename, scene=None, info_callback=None):
else:
tabWrite("finish {%s}\n" % (safety(material_finish, Level=2))) # Level 2 is translated specular
- else:
+ elif material.pov_replacement_text == "":
# POV-Ray "scale" is not a number of repetitions factor, but its inverse, a standard scale factor.
# Offset seems needed relatively to scale so probably center of the scale is not the same in blender and POV
mappingDif = ("translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>" % (-t_dif.offset.x, -t_dif.offset.y, t_dif.offset.z, 1.0 / t_dif.scale.x, 1.0 / t_dif.scale.y, 1.0 / t_dif.scale.z)) # strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal.
@@ -1137,7 +1143,7 @@ def write_pov(filename, scene=None, info_callback=None):
#imageMap = ("{image_map {%s \"%s\" %s }" % (imageFormat(textures),textures,imgMap(t_dif)))
#file.write("\n\t\t\tuv_mapping pigment %s} %s finish {%s}" % (imageMap,mapping,safety(material_finish)))
#file.write("\n\t\t\tpigment {uv_mapping image_map {%s \"%s\" %s}%s} finish {%s}" % (imageFormat(texturesDif),texturesDif,imgMap(t_dif),mappingDif,safety(material_finish)))
- if texturesNorm != "":
+ if texturesNorm != "" and material.pov_replacement_text == "":
## scale 1 rotate y*0
# POV-Ray "scale" is not a number of repetitions factor, but its inverse, a standard scale factor.
# Offset seems needed relatively to scale so probably center of the scale is not the same in blender and POV
@@ -1145,16 +1151,18 @@ def write_pov(filename, scene=None, info_callback=None):
#imageMapNor = ("{bump_map {%s \"%s\" %s mapping}" % (imageFormat(texturesNorm),texturesNorm,imgMap(t_nor)))
#We were not using the above maybe we should?
tabWrite("normal {uv_mapping bump_map {%s \"%s\" %s bump_size %.4g }%s}\n" % (imageFormat(texturesNorm), texturesNorm, imgMap(t_nor), t_nor.normal_factor * 10.0, mappingNor))
- if texturesSpec != "":
+ if texturesSpec != "" and material.pov_replacement_text == "":
tabWrite("]\n")
tabWrite("}\n")
#End of slope/ior texture_map
- if material.diffuse_shader in ('MINNAERT', 'FRESNEL'):
+ if material.diffuse_shader in ('MINNAERT', 'FRESNEL') and material.pov_replacement_text == "":
tabWrite("]\n")
tabWrite("}\n")
- tabWrite("}\n") # THEN IT CAN CLOSE IT --MR
+
+ if material.pov_replacement_text == "":
+ tabWrite("}\n") # THEN IT CAN CLOSE IT --MR
############################################################################################################
index[0] = idx
@@ -1456,14 +1464,25 @@ def write_pov(filename, scene=None, info_callback=None):
tabWrite("}\n")
+ def exportCustomCode():
+
+ for Text in bpy.data.texts:
+ if Text.pov_custom_code:
+ file.write("\n" + Text.as_string())
+ file.write("\n")
+
+
sel = scene.objects
comments = scene.pov_comments_enable
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 not scene.pov_tempfiles_enable and comments:
+ file.write("\n//--CUSTOM CODE--\n\n")
+ exportCustomCode()
+
+ if not scene.pov_tempfiles_enable and comments:
file.write("\n//--Global settings and background--\n\n")
exportGlobalSettings(scene)
diff --git a/render_povray/ui.py b/render_povray/ui.py
index d6000be7..2857dc28 100644
--- a/render_povray/ui.py
+++ b/render_povray/ui.py
@@ -19,13 +19,14 @@
# <pep8 compliant>
import bpy
+from bpy.props import EnumProperty
# Use some of the existing buttons.
import properties_render
properties_render.RENDER_PT_render.COMPAT_ENGINES.add('POVRAY_RENDER')
properties_render.RENDER_PT_dimensions.COMPAT_ENGINES.add('POVRAY_RENDER')
# properties_render.RENDER_PT_antialiasing.COMPAT_ENGINES.add('POVRAY_RENDER')
-properties_render.RENDER_PT_shading.COMPAT_ENGINES.add('POVRAY_RENDER') # We don't use it right now. Should be implemented later.
+properties_render.RENDER_PT_shading.COMPAT_ENGINES.add('POVRAY_RENDER')
properties_render.RENDER_PT_output.COMPAT_ENGINES.add('POVRAY_RENDER')
del properties_render
@@ -148,6 +149,19 @@ class CameraDataButtonsPanel():
return cam and (rd.use_game_engine == False) and (rd.engine in cls.COMPAT_ENGINES)
+class TextButtonsPanel():
+ bl_space_type = 'TEXT_EDITOR'
+ bl_region_type = 'UI'
+ bl_label = "P.O.V-Ray"
+ # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
+
+ @classmethod
+ def poll(cls, context):
+ text = context.space_data
+ rd = context.scene.render
+ return text and (rd.use_game_engine == False) and (rd.engine in cls.COMPAT_ENGINES)
+
+
class RENDER_PT_povray_export_settings(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Export Settings"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@@ -419,7 +433,7 @@ class MATERIAL_PT_povray_fade_color(MaterialButtonsPanel, bpy.types.Panel):
layout = self.layout
mat = context.material
- layout.active = mat.pov_interior_fade_color
+ #layout.active = mat.pov_interior_fade_color
class MATERIAL_PT_povray_conserve_energy(MaterialButtonsPanel, bpy.types.Panel):
@@ -501,6 +515,22 @@ class MATERIAL_PT_povray_caustics(MaterialButtonsPanel, bpy.types.Panel):
row.label(text="but you didn't chose any !")
+class MATERIAL_PT_povray_replacement_text(MaterialButtonsPanel, bpy.types.Panel):
+ bl_label = "Custom POV Code"
+ COMPAT_ENGINES = {'POVRAY_RENDER'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ mat = context.material
+ #layout.active = mat.pov_replacement_text
+ split = layout.split()
+
+ col = split.column()
+ col.label(text="Replace properties with:")
+ col.prop(mat, "pov_replacement_text", text="")
+
+
class TEXTURE_PT_povray_tex_gamma(TextureButtonsPanel, bpy.types.Panel):
bl_label = "Image Gamma"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@@ -522,6 +552,22 @@ class TEXTURE_PT_povray_tex_gamma(TextureButtonsPanel, bpy.types.Panel):
col.prop(tex, "pov_tex_gamma_value", text="Gamma Value")
+class TEXTURE_PT_povray_replacement_text(TextureButtonsPanel, bpy.types.Panel):
+ bl_label = "Custom POV Code"
+ COMPAT_ENGINES = {'POVRAY_RENDER'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ tex = context.texture
+ #layout.active = tex.pov_replacement_text
+ split = layout.split()
+
+ col = split.column()
+ col.label(text="Replace properties with:")
+ col.prop(tex, "pov_replacement_text", text="")
+
+
class OBJECT_PT_povray_obj_importance(ObjectButtonsPanel, bpy.types.Panel):
bl_label = "POV-Ray"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@@ -541,8 +587,23 @@ class OBJECT_PT_povray_obj_importance(ObjectButtonsPanel, bpy.types.Panel):
col.label(text="Photons")
col.prop(obj, "pov_collect_photons", text="Receive Photon Caustics")
+class OBJECT_PT_povray_replacement_text(ObjectButtonsPanel, bpy.types.Panel):
+ bl_label = "Custom POV Code"
+ COMPAT_ENGINES = {'POVRAY_RENDER'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ obj = context.object
+ #layout.active = obj.pov_replacement_text
+ split = layout.split()
+
+ col = split.column()
+ col.label(text="Replace properties with:")
+ col.prop(obj, "pov_replacement_text", text="")
+
-class Camera_PT_povray_cam_dof(CameraDataButtonsPanel, bpy.types.Panel):
+class CAMERA_PT_povray_cam_dof(CameraDataButtonsPanel, bpy.types.Panel):
bl_label = "POV-Ray Depth Of Field"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@@ -572,3 +633,39 @@ class Camera_PT_povray_cam_dof(CameraDataButtonsPanel, bpy.types.Panel):
col.prop(cam, "pov_dof_samples_max")
col.prop(cam, "pov_dof_confidence")
+
+
+class CAMERA_PT_povray_replacement_text(CameraDataButtonsPanel, bpy.types.Panel):
+ bl_label = "Custom POV Code"
+ COMPAT_ENGINES = {'POVRAY_RENDER'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ cam = context.camera
+ #layout.active = cam.pov_replacement_text
+ split = layout.split()
+
+ col = split.column()
+ col.label(text="Replace properties with:")
+ col.prop(cam, "pov_replacement_text", text="")
+
+
+class TEXT_PT_povray_custom_code(TextButtonsPanel, bpy.types.Panel):
+ bl_label = "P.O.V-Ray"
+ COMPAT_ENGINES = {'POVRAY_RENDER'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ textspace = context.space_data
+ #layout.active = text.pov_replacement_text
+ split = layout.split()
+ col = split.column()
+ text = textspace.text
+ if text:
+ col.prop(text, "pov_custom_code", text="Add as POV code")
+
+
+
+