[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1447] trunk/py/scripts/addons/ render_povray/render.py: Fix exported numbers of materials per object
Constantin Rahn
conz at vrchannel.de
Wed Jan 19 20:30:34 CET 2011
Revision: 1447
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1447
Author: conz
Date: 2011-01-19 19:30:30 +0000 (Wed, 19 Jan 2011)
Log Message:
-----------
Fix exported numbers of materials per object
Modified Paths:
--------------
trunk/py/scripts/addons/render_povray/render.py
Modified: trunk/py/scripts/addons/render_povray/render.py
===================================================================
--- trunk/py/scripts/addons/render_povray/render.py 2011-01-19 14:53:30 UTC (rev 1446)
+++ trunk/py/scripts/addons/render_povray/render.py 2011-01-19 19:30:30 UTC (rev 1447)
@@ -60,9 +60,9 @@
def imgMap(ts):
image_map=''
- if ts.mapping=='FLAT':image_map= ' map_type 0 '
- if ts.mapping=='SPHERE':image_map= ' map_type 1 '# map_type 7 in megapov
- if ts.mapping=='TUBE':image_map= ' map_type 2 '
+ if ts.mapping=='FLAT':image_map= 'map_type 0 '
+ if ts.mapping=='SPHERE':image_map= 'map_type 1 '# map_type 7 in megapov
+ if ts.mapping=='TUBE':image_map= 'map_type 2 '
#if ts.mapping=='?':image_map= ' map_type 3 '# map_type 3 and 4 in development (?) for POV-Ray, currently they just seem to default back to Flat (type 0)
#if ts.mapping=='?':image_map= ' map_type 4 '# map_type 3 and 4 in development (?) for POV-Ray, currently they just seem to default back to Flat (type 0)
if ts.texture.use_interpolation: image_map+= ' interpolate 2 '
@@ -182,7 +182,7 @@
def tabWrite(str_o):
global TabLevel
- brackets = str_o.count('{') - str_o.count('}')
+ brackets = str_o.count('{') - str_o.count('}') + str_o.count('[') - str_o.count(']')
if brackets < 0:
TabLevel = TabLevel + brackets
if TabLevel < 0:
@@ -921,80 +921,95 @@
#if material.diffuse_shader == 'FRESNEL': pigment pattern aoi pigment and texture map above, the rest below as one of its entry
- ##########################################################################################################################
- 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 / t_spec.scale.x, 1 / t_spec.scale.y, 1 / t_spec.scale.z))
- tabWrite('uv_mapping image_map{%s \"%s\" %s}%s}\n' % (imageFormat(texturesSpec) ,texturesSpec ,imgMap(t_spec),mappingSpec))
- tabWrite('texture_map {\n')
- tabWrite('[0 \n')
+ ##########################################################################################################################
- 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 !='' or texturesNorm !='':
+ 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 / t_alpha.scale.x, 1 / t_alpha.scale.y, 1 / t_alpha.scale.z))
- tabWrite('pigment {pigment_pattern {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 color rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>]\n' % (col[0], col[1], col[2], 1.0 - material.alpha, trans) )
+ mappingSpec = ('translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>\n' % (-t_spec.offset.x ,t_spec.offset.y ,t_spec.offset.z, 1 / t_spec.scale.x, 1 / t_spec.scale.y, 1 / 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('}\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 / t_alpha.scale.x, 1 / t_alpha.scale.y, 1 / 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], 1.0 - material.alpha, trans) )
+ tabWrite('}\n')
+ tabWrite('}\n')
- tabWrite('pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>}\n' % (col[0], col[1], col[2], 1.0 - material.alpha, 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], 1.0 - material.alpha, trans))
+
+ 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 spec
+
else:
- tabWrite('finish {%s}\n' % (safety(material_finish, Level=2)))# Level 2 is translated spec
-
- 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>\n' % (-t_dif.offset.x,t_dif.offset.y,t_dif.offset.z, 1 / t_dif.scale.x, 1 / t_dif.scale.y, 1 / 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>\n' % (t_alpha.offset.x,t_alpha.offset.y,t_alpha.offset.z,1 / t_alpha.scale.x, 1 / t_alpha.scale.y, 1 / t_alpha.scale.z))
- tabWrite('pigment {pigment_pattern {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')
+ mappingDif = ('translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>' % (-t_dif.offset.x,t_dif.offset.y,t_dif.offset.z, 1 / t_dif.scale.x, 1 / t_dif.scale.y, 1 / 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 / t_alpha.scale.x, 1 / t_alpha.scale.y, 1 / 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:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list