Skip to content

Instantly share code, notes, and snippets.

@jl2
Created August 11, 2010 04:29
Show Gist options
  • Save jl2/518486 to your computer and use it in GitHub Desktop.
Save jl2/518486 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# Really simple example of usint cgkit's RenderMan
# Interface binding to generate a RIB file.
from cgkit.ri import *
from math import *
import sys
def x(u,v):
return u
def y(u,v):
return v
def z(u,v):
return sin(u)*cos(v)
def main(args):
if len(args)<1:
print("No argument given!")
return
RiBegin(RI_NULL)
RiFormat(1024, 1024, 1)
usteps = 24
vsteps = 24
tsteps = 32
t = 0
umin = -pi
vmin = -pi
umax = pi
vmax = pi
tdiff = (2*pi)/tsteps
udiff = (umax-umin)/usteps
vdiff = (vmax-vmin)/vsteps
fname=args[0]
for i in range(0, tsteps):
RiFrameBegin(i);
RiDisplay('output/{0}{1:04d}.tif'.format(fname, i),
"file","rgba", RI_NULL)
RiLightSource("distantlight", RI_NULL)
RiShutter(0.1, 0.9)
RiProjection("perspective", RI_NULL)
RiTranslate(0.0, 0.0, 6.0)
RiRotate(45.0, -1.0,1.0,0.0)
RiWorldBegin()
u = umin
for j in range(0,usteps):
v = vmin
for k in range(0,vsteps):
v += vdiff
RiAttributeBegin()
RiColor([0,1,0])
RiSurface("plastic",RI_NULL)
RiTranslate(x(u,v),
sin(t-tdiff)*z(u,v),
y(u,v))
RiSphere(pi/20,-pi/20,pi/20, 360.0, RI_NULL)
RiAttributeEnd()
v += vdiff
u += udiff
RiWorldEnd()
RiFrameEnd()
t += tdiff
RiEnd()
if __name__=='__main__':
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment