[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4246] trunk/py/scripts/addons/ render_povray/render.py: Added Hair Child Support
Maurice Raybaud
mauriceraybaud at hotmail.fr
Fri Feb 8 16:03:52 CET 2013
Revision: 4246
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4246
Author: mauriceraybaud
Date: 2013-02-08 15:03:51 +0000 (Fri, 08 Feb 2013)
Log Message:
-----------
Added Hair Child Support
note: rendersteps seem closer to BI with power of 3 rather than 2 as said in the UI Py tooltip.
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 2013-02-08 11:12:21 UTC (rev 4245)
+++ trunk/py/scripts/addons/render_povray/render.py 2013-02-08 15:03:51 UTC (rev 4246)
@@ -845,47 +845,54 @@
strandStart = 0.01
strandEnd = 0.01
strandShape = 0.0
-
- totalNumberOfHairs = len(pSys.particles)
- hairCounter = 0
+ # Set the number of particles to render count rather than 3d view display
+ pSys.set_resolution(scene, ob, 'RENDER')
+ steps = pSys.settings.draw_step
+ steps = 3 ** steps # or (power of 2 rather than 3) + 1 # Formerly : len(particle.hair_keys)
+
+ totalNumberOfHairs = ( len(pSys.particles) + len(pSys.child_particles) )
+ #hairCounter = 0
file.write('#declare HairArray = array[%i] {\n' % totalNumberOfHairs)
- for particle in pSys.particles:
- if particle.is_exist and particle.is_visible:
- hairCounter += 1
- controlPointCounter = 0
+ for pindex in range(0, totalNumberOfHairs):
+
+ #if particle.is_exist and particle.is_visible:
+ #hairCounter += 1
+ #controlPointCounter = 0
# Each hair is represented as a separate sphere_sweep in POV-Ray.
file.write('sphere_sweep{')
if pSys.settings.use_hair_bspline:
file.write('b_spline ')
- file.write('%i,\n' % (len(particle.hair_keys) + 2)) # +2 because the first point needs tripling to be more than a handle in POV
-
+ file.write('%i,\n' % (steps + 2)) # +2 because the first point needs tripling to be more than a handle in POV
else:
file.write('linear_spline ')
- file.write('%i,\n' % (len(particle.hair_keys)))
- for controlPoint in particle.hair_keys:
+ file.write('%i,\n' % (steps))
+
+ for step in range(0, steps):
+ co = pSys.co_hair(ob, mod, pindex, step)
+ #for controlPoint in particle.hair_keys:
if pSys.settings.clump_factor != 0:
hDiameter = pSys.settings.clump_factor / 200.0 * random.uniform(0.5, 1)
- elif controlPointCounter == 0:
+ elif step == 0:
hDiameter = strandStart
else:
- hDiameter += (strandEnd-strandStart)/(len(particle.hair_keys)+1) #XXX +1 or not?
- if controlPointCounter == 0 and pSys.settings.use_hair_bspline:
+ hDiameter += (strandEnd-strandStart)/(pSys.settings.draw_step+1) #XXX +1 or not?
+ if step == 0 and pSys.settings.use_hair_bspline:
# Write three times the first point to compensate pov Bezier handling
- file.write('<%.6g,%.6g,%.6g>,%.7g,\n' % (controlPoint.co[0], controlPoint.co[1], controlPoint.co[2], abs(hDiameter)))
- file.write('<%.6g,%.6g,%.6g>,%.7g,\n' % (controlPoint.co[0], controlPoint.co[1], controlPoint.co[2], abs(hDiameter)))
+ file.write('<%.6g,%.6g,%.6g>,%.7g,\n' % (co[0], co[1], co[2], abs(hDiameter)))
+ file.write('<%.6g,%.6g,%.6g>,%.7g,\n' % (co[0], co[1], co[2], abs(hDiameter)))
#file.write('<%.6g,%.6g,%.6g>,%.7g' % (particle.location[0], particle.location[1], particle.location[2], abs(hDiameter))) # Useless because particle location is the tip, not the root.
#file.write(',\n')
- controlPointCounter += 1
+ #controlPointCounter += 1
#totalNumberOfHairs += len(pSys.particles)# len(particle.hair_keys)
# Each control point is written out, along with the radius of the
# hair at that point.
- file.write('<%.6g,%.6g,%.6g>,%.7g' % (controlPoint.co[0], controlPoint.co[1], controlPoint.co[2], abs(hDiameter)))
+ file.write('<%.6g,%.6g,%.6g>,%.7g' % (co[0], co[1], co[2], abs(hDiameter)))
# All coordinates except the last need a following comma.
- if controlPointCounter != len(particle.hair_keys):
+ if step != steps - 1:
file.write(',\n')
else:
# End the sphere_sweep declaration for this hair
@@ -893,7 +900,7 @@
# All but the final sphere_sweep (each array element) needs a terminating comma.
- if hairCounter != totalNumberOfHairs:
+ if pindex != totalNumberOfHairs:
file.write(',\n')
else:
file.write('\n')
@@ -951,7 +958,10 @@
file.write('}')
print('Totals hairstrands written: %i' % totalNumberOfHairs)
print('Number of tufts (particle systems)', len(ob.particle_systems))
-
+
+ # Set back the displayed number of particles to preview count
+ pSys.set_resolution(scene, ob, 'PREVIEW')
+
if renderEmitter == False:
continue #don't render mesh, skip to next object.
try:
More information about the Bf-extensions-cvs
mailing list