# Generates a RenderMan RIB Archive file that can be imported into
# Maya using a RenderMan->Archive->Import Archive node.
from random import uniform
import os
import os.path
import inspect
  
num_particles = 1000
dia_particles = 0.07
bb = 10   # boudning box
  
# Get the path to the current directory
scptpth = inspect.getframeinfo(inspect.currentframe()).filename
dirpath = os.path.dirname(os.path.abspath(scptpth))
  
output_rib = os.path.join(dirpath, 'partices.rib')
f = open(output_rib, 'w')
f.write('##RenderMan RIB\n')
f.write('##bbox: %1.3f %1.3f %1.3f %1.3f %1.3f %1.3f\n' % (-bb/2,-bb/2,-bb/2, bb/2, bb/2, bb/2)) 
  
f.write('Points "P" [\n')
  
for n in range(num_particles):
    x = uniform(-bb, bb)
    y = uniform(-bb, bb)
    z = uniform(-bb, bb)
    f.write('%1.3f %1.3f %1.3f ' % (x,y,z))
    if n > 0 and n % 5 == 0:
        f.write('\n')
f.write('] \n"constantwidth" [%1.3f]\n' % dia_particles) 
f.close()