#!/usr/bin/env python
from cgkit.ri import *
"""
RiProcedural(data, bound, subdividefunc, freefunc=None)
Declare a procedural model.
subdividefunc and freefunc may either be the standard RenderMan
procedurals (RiProcDelayedReadArchive, RiProcRunProgram,
RiProcDynamicLoad and RiProcFree) or Python callables.
In the former case, data must be a sequence of strings or a single
string containing the data for the functions. In the latter case,
data may be any Python object which is just passed on to the
functions.
freefunc is optional and defaults to None.
Because this module can only produce RIB, a custom subdivide function is
simply called with a detail value of RI_INFINITY to generate all the
data at once.
Example: RiProcedural("mymodel.rib", [-1,1,-1,1,-1,1], \
RiProcDelayedReadArchive, RI_NULL)
RiProcedural(["python teapot.py",""],[0,1,0,1,0,1], \
RiProcRunProgram, RI_NULL)
RiProcedural(["teapot.so",""],[0,1,0,1,0,1], \
RiProcDynamicLoad, RI_NULL)
"""
import sys
args = sys.stdin.readline()
while args:
arg = args.split()
size=float(arg[0])
parts=int(arg[1])
seed=int(arg[2])
childCount=int(arg[2])
childSeed = seed
for xstep in range(parts):
for ystep in range(parts):
for zstep in range(parts):
xmin = xstep - 0.5*size/parts - size*0.5
xmax = xstep + 0.5*size/parts - size*0.5
ymin = ystep - 0.5*size/parts- size*0.5
ymax = ystep + 0.5*size/parts- size*0.5
zmin = zstep - 0.5*size/parts- size*0.5
zmax = zstep + 0.5*size/parts- size*0.5
childSeed+=1
print RiProcedural(["python voxelChild.py","%s %s %s %s %s %s %s %s" % (xmin,xmax,ymin,ymax,zmin,zmax,childSeed, childCount)],[xmin,xmax,ymin,ymax,zmin,zmax], RiProcRunProgram, RI_NULL)
sys.stdout.write('\377')
sys.stdout.flush()
args = sys.stdin.readline() |