ケッソン先生のページを参照しました。Thank you
import prmanを使っています。
ありがとうございます。さらに勉強ですね。
#spheres_pr.py
#Modified from RenderMan Procedural Primitives/ Randomness Examples
# in CG References & Tutorials(fundza.com)
#set PYTHONPATH=C:\Python25;C:\Python\Scripts;%RMANTREE%\bin
import getpass
import time
# import the python renderman library
import prman
import random,math
def randBetween(min, max):
return random.random() * (max - min) + min
def length(x, y, z):
return math.sqrt(x*x + y*y + z*z)
def normalize(x, y, z):
len = length(x, y, z)
return x/len, y/len, z/len
def scaleVector(x, y, z, sc):
return x*sc, y*sc, z*sc
def spheres(rad, num, size):
for n in range(num):
x = randBetween(-1.0, 1.0)
y = randBetween(-1.0, 1.0)
z = randBetween(-1.0, 1.0)
x,y,z = normalize(x,y,z)
ri.TransformBegin()
ri.Translate(x,y,z)
ri.Color((x,y,z))
ri.Sphere(size, -size, size,360)
ri.TransformEnd()
ri = prman.Ri() # create an instance of the RenderMan interface
ri.Option("rib", {"string asciistyle": "indented"})
filename = "spheres_pr.rib"
ri.Begin(ri.RENDER)
#ri.Begin(filename)
# ArchiveRecord is used to add elements to the rib stream in this case comments
# note the function is overloaded so we can concatinate output
ri.ArchiveRecord(ri.COMMENT, 'File ' +filename)
ri.ArchiveRecord(ri.COMMENT, "Created by " + getpass.getuser())
ri.ArchiveRecord(ri.COMMENT, "Creation Date: " +time.ctime(time.time()))
# now we add the display element using the usual elements
# FILENAME DISPLAY Type Output format
ri.Display("spheres_pr.png", "file", "rgb")
ri.Format(512, 384, -1.0)
ri.Imager("background", {"color color":(.76,.79,.82)})
# now set the projection to perspective
ri.Projection(ri.PERSPECTIVE,{ri.FOV:50})
# now we start our world
ri.WorldBegin()
ri.LightSource("distantlight", {ri.HANDLEID: "1","to":[0,1,1]})
ri.LightSource("ambientlight", {ri.HANDLEID: "2", "intensity":[0.4]})
ri.Translate(0,0,3)
ri.Rotate(-40,1,0,0)
ri.TransformBegin()
ri.Rotate(35,0,1,0)
ri.Surface("plastic")
spheres(1.2, 1000, 0.06)
ri.TransformEnd()
ri.WorldEnd()
ri.End()
- -
- -