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>2014-03-12 10:51:56 +0400
committerMaurice Raybaud <mauriceraybaud@hotmail.fr>2014-03-12 10:51:56 +0400
commita7da6cfa5b2190e7a41c73e33396969d04f48c2f (patch)
treeef1862ccc181e5c531bf718259a43dafa2021472 /render_povray
parent8ad356e3324cddef42d41f9b9b588ef1ebd2f8bf (diff)
added: textured hair now works with procedural and UV mapped bitmaps (but slower for the second)
Diffstat (limited to 'render_povray')
-rw-r--r--render_povray/render.py34
1 files changed, 24 insertions, 10 deletions
diff --git a/render_povray/render.py b/render_povray/render.py
index 2c4532d7..87f7ac91 100644
--- a/render_povray/render.py
+++ b/render_povray/render.py
@@ -1320,7 +1320,7 @@ def write_pov(filename, scene=None, info_callback=None):
tstart = time.time()
texturedHair=0
if ob.active_material is not None:
- pmaterial = ob.material_slots[pSys.settings.material-1].material
+ pmaterial = ob.material_slots[pSys.settings.material - 1].material
for th in pmaterial.texture_slots:
if th and th.use:
if (th.texture.type == 'IMAGE' and th.texture.image) or th.texture.type != 'IMAGE':
@@ -1361,16 +1361,30 @@ def write_pov(filename, scene=None, info_callback=None):
else:
file.write('linear_spline ')
file.write('%i,\n' % (steps))
-
- initCo = pSys.co_hair(ob, pindex, 0)
+ #changing world coordinates to object local coordinates by multiplying with inverted matrix
+ initCo = ob.matrix_world.inverted()*(pSys.co_hair(ob, pindex, 0))
if ob.active_material is not None:
pmaterial = ob.material_slots[pSys.settings.material-1].material
for th in pmaterial.texture_slots:
- if th and th.use:
- if (th.texture.type == 'IMAGE' and th.texture.image) or th.texture.type != 'IMAGE':
- if th.use_map_color_diffuse:
- #only overwrite variable for each competing texture for now
- initColor=th.texture.evaluate((initCo[0],initCo[1],initCo[2]))
+ if th and th.use and th.use_map_color_diffuse:
+ #treat POV textures as bitmaps
+ if (th.texture.type == 'IMAGE' and th.texture.image and th.texture_coords == 'UV' and ob.data.uv_textures != None): # or (th.texture.pov.tex_pattern_type != 'emulator' and th.texture_coords == 'UV' and ob.data.uv_textures != None):
+ image=th.texture.image
+ image_width = image.size[0]
+ image_height = image.size[1]
+ image_pixels = image.pixels[:]
+ uv_co = pSys.uv_on_emitter(mod, pSys.particles[pindex], pindex, 0)
+ x_co = round(uv_co[0] * (image_width - 1))
+ y_co = round(uv_co[1] * (image_height - 1))
+ pixelnumber = (image_width * y_co) + x_co
+ r = image_pixels[pixelnumber*4]
+ g = image_pixels[pixelnumber*4+1]
+ b = image_pixels[pixelnumber*4+2]
+ a = image_pixels[pixelnumber*4+3]
+ initColor=(r,g,b,a)
+ else:
+ #only overwrite variable for each competing texture for now
+ initColor=th.texture.evaluate((initCo[0],initCo[1],initCo[2]))
for step in range(0, steps):
co = pSys.co_hair(ob, pindex, step)
#for controlPoint in particle.hair_keys:
@@ -1399,7 +1413,7 @@ def write_pov(filename, scene=None, info_callback=None):
file.write(',\n')
else:
if texturedHair:
- # Write pigment
+ # Write pigment and alpha (between Pov and Blender alpha 0 and 1 are reversed)
file.write('\npigment{ color rgbf < %.3g, %.3g, %.3g, %.3g> }\n' %(initColor[0], initColor[1], initColor[2], 1.0-initColor[3]))
# End the sphere_sweep declaration for this hair
file.write('}\n')
@@ -1490,7 +1504,7 @@ def write_pov(filename, scene=None, info_callback=None):
#############################################
# Generating a name for object just like materials to be able to use it
# (baking for now or anything else).
- # XXX I don't understand that: if we are here, sel if a non-empty iterable,
+ # XXX I don't understand that:&nbsp;if we are here, sel if a non-empty iterable,
# so this condition is always True, IMO -- mont29
if sel:
name_orig = "OB" + ob.name