Rendering学習日記

日々3DCGの世界は進歩しているけど、勉強して理解したことをまとめていきたい。RenderMan互換レンダラーやグローバル・イルミネーション。いろんなことに好奇心を持ち面白くなってくる。目指せShader書き!!

jrManのsrcのコンパイル

クラスパスを指定しておくのですね。
C:\jrman-0_4\src>javac -classpath %JRMAN_HOME%\jar\jrman.jar;%JRMAN_HOME%\jar\vecmath.jar;%JRMAN_HOME%\jar\commons-cli-1.0.jar DisplacementBumptest.java


C:\jrman-0_4\src>javac -classpath %JRMAN_HOME%\jar\jrman.jar;%JRMAN_HOME%\jar\vecmath.jar;%JRMAN_HOME%\jar\commons-cli-1.0.jar SurfaceClouds.java

コンパイルはできましたが、サーフィスとディスプレイスメント、使い方どうなんでしょう。
課題です。
RenderMan | - | -

jrMan

jrMan is an open source.
javaは、使ったことがないが、jrManのsrcフォルダにあるjavaファイルをコンパイルする。

>javac GenCubes.java

GenCubes.classが作成される。
次に、

>java GenCubes

と打つと、RIBが表示される。
RIBをファイル出力したいなら、

>java GenCubes >cubes.rib

と打つと、cubes.ribが出力される。

こんな感じです。
TransformBegin
Translate -40 10 -40
Scale 2 2 2
ReadArchive "cube.rib"
TransformEnd
TransformBegin
Translate -20 10 -40
Scale 2 2 2
ReadArchive "cube.rib"
TransformEnd
TransformBegin
Translate 0 10 -40
Scale 2 2 2
ReadArchive "cube.rib"
TransformEnd
TransformBegin
Translate 20 10 -40
Scale 2 2 2
ReadArchive "cube.rib"
TransformEnd
・・・・・・・
ひさしぶり、振り返ってみると
忘れていますね。くりかえし勉強です。
ありがとうございます。


jrManのダウンロードはこちら

javacを使うためには、JRE JDKをインストールしておきます。
さらに、Pathに
インストール先を追加
たとえば、
;C:\Program Files (x86)\Java\jdk1.6.0_22\bin
を環境変数Pathに追加しておきます。
RenderMan | - | -

PythonからRenderManシーン記述

レイトレーシングを使わないで、それらしく見せる反射トリックですね。
レンダリングは速いです。
過去のPixarのC言語によるシーン記述をPythonで書き換えてみました。
まだまだ課題がありますが、チャレンジですね。ありがとうございます。
generate_scn.jpg


#generate_scn_pr.py
#Modified from a C program that generates a scene, May,1990, Pixar
#set PYTHONPATH=C:\Python25;C:\Python\Scripts;%RMANTREE%\bin
# import the python renderman library
import prman

ri = prman.Ri() # create an instance of the RenderMan interface
ri.Option("rib", {"string asciistyle": "indented"})

filename = "generate_scn.rib"

"""
* Set RenderMan options for medium quality/speed tradeoff.
"""

REFLECTION=0


def SetupOptions():
global REFLECTION
ASPECT_RATIO=1.33333
TEXTURE_ROWS=256
IMAGE_ROWS=300
gsz = 32
bktsz = [12, 12]
splits = 5

#ri.Option("limits", {"gridsize": gsz,"eyesplits",:splits,"bucketsize": bktsz})
ri.ShadingRate(2.)
ri.PixelSamples(2., 2.)
ri.PixelFilter(ri.BoxFilter, 1., 1.)

if REFLECTION:
ri.Display("refl.tif","file", "rgb")
ri.Format(TEXTURE_ROWS, TEXTURE_ROWS, ASPECT_RATIO);
else:
ri.Display("generate_scn.tif","file", "rgb")
ri.Format(512, 384, -1.0)


"""
/*
* Set RenderMan camera parameters.
*/
"""

def SetupCamera():
global REFLECTION
m = [
.970143, -0.004705, -.24249, 0,
0, .999812, -0.0193992, 0,
.242536, 0.01882, .96996, 0,
-7.27607, -1.96434, 53.406, 1
]

fov = 25.0

ri.Projection(ri.PERSPECTIVE,{ri.FOV:fov})
ri.Transform(m)

if REFLECTION:
#/* Transform z=0 plane to coincide with reflection plane. */
ri.Translate(0., 0., -0.05)

#/* Reflect camera through the reflection plane z=0. */
ri.Scale(1., 1., -1.)
#/* Transform reflection plane back to z=0. */
ri.Translate(0., 0., 0.05);


"""
* The model consists of three "walls" of a room (actually two
* walls and the floor) with a mirror on one of the walls.
* When rendering the REFLECTION image, the mirror
* and the wall it is hanging on are both removed so that
* the camera can see into the room from the other side of
* the wall.
"""

def SetupModel():
global REFLECTION
c = [[ 0.5, 0.4, 0.1], [ 0.3, 0.5, 0.5],[ 1, 1, 1], [ 0.4, 0.2, 0.7]]

if REFLECTION:
NWALLS=2 #/* Just do two walls. */
walls = [ [0, 0, -100, 0, 0, 0, 100, 0, -100, 100, 0, 0],[0, 100, -100, 0, 100, 0, 0, 0, -100, 0, 0, 0]]
else:
#ri.MakeTexture( "refl.tif", "refl.tex", "periodic", "periodic", "gaussian", 1, 1)
NWALLS=3 #/* Do three walls and mirror. */
walls = [ [0, 0, -100, 0, 0, 0, 100, 0, -100, 100, 0, 0],[ 0, 100, -100, 0, 100, 0, 0, 0, -100, 0, 0, 0],[ 0, 100, 0, 100, 100, 0, 0, 0, 0 , 100, 0, 0]]
mirror = [ 5, 10.5, -.05, 10, 10.5, -.05,5, 0.5, -.05, 10, 0.5, -.05]

ri.AttributeBegin()
ri.Color(c[2])
ri.Surface("texmap",{'string texname':"refl.tex"})
#ri.Surface("shinymetal",{'string texturename':"refl.tex"})
ri.Patch("bilinear",{'P': mirror})
ri.AttributeEnd()


ri.Color(c[0])
for i in range(NWALLS):
ri.Patch("bilinear",{'P': walls[i]})
ri.Color(c[1])

#/* Put a teapot in the room. */
ri.Color(c[3])
ri.TransformBegin()
ri.Translate(5., 1., -2.)
ri.Rotate(90., 0., 1., 0.)
ri.Rotate(-90., 1., 0., 0.)
ri.Geometry("teapot")
ri.TransformEnd()


ri.Begin(ri.RENDER)

SetupCamera()

SetupOptions()

# start our world
ri.WorldBegin()
ri.LightSource("distantlight", {ri.HANDLEID: "1","to":[0,0,1]})
ri.LightSource("ambientlight", {ri.HANDLEID: "2", "intensity":[0.4]})

SetupModel()

ri.WorldEnd()
ri.End()



テクスチャについては、
MakeTexture "refl.tif" "refl.tex" "periodic" "periodic" "gaussian" 1 1
を記述したRIBを使ってtexファイルを出力しました。
Wrong state to call RiMakeTexture.なので、調べます。ありがとうございます。
RenderMan | - | -

PythonからRenderMan その13

ドーナツ作り。以前の記事を書き換えたものです。ありがとうございます。



#proc_torus2_pr.py
#set PYTHONPATH=C:\Python25;C:\Python\Scripts;%RMANTREE%\bin
import getpass
import time
# import the python renderman library
import prman

ri = prman.Ri() # create an instance of the RenderMan interface
ri.Option("rib", {"string asciistyle": "indented"})

filename = "proc_geom.rib"

ri.Begin(ri.RENDER)

def TorusWave(ri,nwaves,thetamax) :
if(nwaves < 1) :
print "need positive number of waves"
return
innerrad = 2.0/(8.0 * nwaves +2)
ri.Rotate(90.0,1.0,0.0,0.0)
ri.Sphere(innerrad,-innerrad,0,thetamax)
outerrad =0.0
for wave in range(1,nwaves) :
outerrad=outerrad+(innerrad*2)
ri.Torus(outerrad,innerrad,0.0,180.0,thetamax)
outerrad=outerrad+(innerrad*2)
ri.Torus(outerrad,innerrad,180.0,360.0,thetamax)


#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("proc_torus2.png", "file", "rgb")
ri.Format(512, 384, -1.0)
ri.Projection(ri.PERSPECTIVE,{ri.FOV:30})

# now we start our world
colours ={
"red":[1,0,0],
"white":[1,1,1],
"green":[0,1,0],
"blue":[0,0,1],
"black":[0,0,0],
"yellow":[1,1,0]
}

# start our world
ri.WorldBegin()
ri.LightSource("distantlight", {ri.HANDLEID: "1","to":[0,0,1]})
ri.LightSource("ambientlight", {ri.HANDLEID: "2", "intensity":[0.4]})

ri.Translate(0,0,9) #move the global view position
ri.Surface("plastic")

ri.TransformBegin()
ri.Rotate(40,1,0,0)
ri.Color(colours["red"])
ri.Attribute ("identifier",{"name": "Wave1"})
TorusWave(ri,8,360.0)
ri.TransformEnd()

ri.TransformBegin()
ri.Rotate(55,1,0,0)
ri.Color(colours["green"])
ri.Translate(2.2,0,0)
ri.Attribute( "identifier",{ "name" :"Wave2"})
TorusWave(ri,8,360.0)
ri.TransformEnd()

ri.TransformBegin()
ri.Rotate(35,1,0,0)
ri.Color(colours["blue"])
ri.Translate(-2.2,0,0)
ri.Attribute("identifier",{ "name" : "Wave3"})
TorusWave(ri,8,360.0)
ri.TransformEnd()
#end our world

ri.WorldEnd()
ri.End()


RenderMan | - | -

PythonからRenderMan その12

Jon Macey Computer Animation Pages参考にしています。Thank you.
Torus animationです。
ProcGeom001.jpg
ProcGeom002.jpg
ProcGeom003.jpg
ProcGeom014.jpg
ProcGeom029.jpg


#proc_geom.py
#set PYTHONPATH=C:\Python25;C:\Python\Scripts;%RMANTREE%\bin
import getpass
import time
# import the python renderman library
import prman

def TorusWave(ri,nwaves,thetamax) :
if(nwaves < 1) :
print "need positive number of waves"
return
innerrad = 2.0/(8.0 * nwaves +2)
ri.Rotate(90.0,1.0,0.0,0.0)
ri.Sphere(innerrad,-innerrad,0,thetamax)
outerrad =0.0
for wave in range(1,nwaves) :
outerrad=outerrad+(innerrad*2)
ri.Torus(outerrad,innerrad,0.0,180.0,thetamax)
outerrad=outerrad+(innerrad*2)
ri.Torus(outerrad,innerrad,180.0,360.0,thetamax)



ri = prman.Ri() # create an instance of the RenderMan interface
ri.Option("rib", {"string asciistyle": "indented"})


for frame in range(1,30) :
filename = "Wave.%03d.rib" %(frame)
ri.Begin(ri.RENDER)
# this is the begining of the rib archive generation we can only
# make RI calls after this function else we get a core dump
# 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("ProcGeom%03d.tif" %(frame), "file", "rgb")
# Specify PAL resolution 1:1 pixel Aspect ratio
ri.Format(512, 384, -1.0)
# now set the projection to perspective
ri.Projection(ri.PERSPECTIVE,{ri.FOV:50})

# now we start our world
ri.WorldBegin()

ri.Translate(0,0,2)

ri.Rotate(-25,1,0,0)

ri.TransformBegin()
ri.Color([1,0,0])
TorusWave(ri,frame,360.0)
ri.TransformEnd()
ri.WorldEnd()

# and finally end the rib file
ri.End()


RenderMan | - | -

PythonからRenderMan その11

球体つくりました。
ケッソン先生のページを参照しました。Thank you
import prmanを使っています。
ありがとうございます。さらに勉強ですね。
spheres_pr.jpg


#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()

RenderMan | - | -

PythonからRenderMan その10

円柱つくりました。
ケッソン先生のページを参照しました。Thank you
import prmanを使っています。
ありがとうございます。
cylinder_pr.jpg


#cylinder_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 cylinder(rad, depth, height, num, size):
points=[]
pappend=points.append
for n in range(num):
x = randBetween(-1, 1)
y = 0
z = randBetween(-1, 1)
x,y,z = normalize(x,y,z)
y = randBetween(depth, height) # <<---
pappend(x)
pappend(y)
pappend(z)
colour=[]
for n in range(num):
r = randBetween(0, 1)
g = randBetween(0, 1)
b = randBetween(0, 1)
colour.append(r)
colour.append(g)
colour.append(b)


ri.Points({ri.P:points,ri.CS:colour,ri.CONSTANTWIDTH:size})



ri = prman.Ri() # create an instance of the RenderMan interface
ri.Option("rib", {"string asciistyle": "indented"})

filename = "cylinder_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("cylinder_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.25,3)
ri.Rotate(-40,1,0,0)
ri.TransformBegin()
ri.Rotate(35,0,1,0)
ri.Surface("plastic")
cylinder(1.5, -1.2, 1.0, 20000, 0.02)
ri.TransformEnd()
ri.WorldEnd()
ri.End()

RenderMan | - | -

PythonからRenderMan その9

ケッソン先生のページを参照しました。Thank you
import prmanを使っています。
ありがとうございます。円すいを作ってみました。
cone_pr.jpg


#cone_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 cone(rad, num, size):
points=[]
pappend=points.append
for n in range(num):
x = randBetween(-1, 1)
y = 0
z = randBetween(-1, 1)
x,y,z = normalize(x,y,z)
randRadius = randBetween(0, rad)
x,y,z = scaleVector(x,y,z,randRadius)
y += 1 - randRadius # <<---
pappend(x)
pappend(y)
pappend(z)
colour=[]
for n in range(num):
r = randBetween(0, 1)
g = randBetween(0, 1)
b = randBetween(0, 1)
colour.append(r)
colour.append(g)
colour.append(b)


ri.Points({ri.P:points,ri.CS:colour,ri.CONSTANTWIDTH:size})



ri = prman.Ri() # create an instance of the RenderMan interface
ri.Option("rib", {"string asciistyle": "indented"})

filename = "cone_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("cone_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.25,3)
ri.Rotate(-40,1,0,0)
ri.TransformBegin()
ri.Rotate(35,0,1,0)
ri.Surface("plastic")
cone(1.5, 10000, 0.02)
ri.TransformEnd()
ri.WorldEnd()
ri.End()

RenderMan | - | -

PythonからRenderMan その8

さらに、diskでやってみました。面白いですね。
import prmanを使っています。
disk_pr.jpg


#disk_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 disk(rad, num, size):
points=[]
pappend=points.append
for n in range(num):
x = randBetween(-1, 1)
y = 0
z = randBetween(-1, 1)
x,y,z = normalize(x,y,z)
randRadius = randBetween(0, rad)
x,y,z = scaleVector(x,y,z,randRadius)
pappend(x)
pappend(y)
pappend(z)
colour=[]
for n in range(num):
r = randBetween(0, 1)
g = randBetween(0, 1)
b = randBetween(0, 1)
colour.append(r)
colour.append(g)
colour.append(b)


ri.Points({ri.P:points,ri.CS:colour,ri.CONSTANTWIDTH:size})



ri = prman.Ri() # create an instance of the RenderMan interface
ri.Option("rib", {"string asciistyle": "indented"})

filename = "rectangularbox.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("disk_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.25,3)
ri.Rotate(-40,1,0,0)
ri.TransformBegin()
ri.Rotate(35,0,1,0)
ri.Surface("plastic")
disk(1.5, 10000, 0.02)
ri.TransformEnd()
ri.WorldEnd()
ri.End()

RenderMan | - | -

PythonからRenderMan その7

ケッソン先生のページを参照しました。Thank you
import prmanを使っています。
ありがとうございます。
ring(rad, num, size)
ring(1.5, 150, 0.2)
ring_pr.jpg


#ring_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 ring(rad, num, size):
points=[]
pappend=points.append
for n in range(num):
x = randBetween(-1, 1)
y = 0
z = randBetween(-1, 1)
x,y,z = normalize(x,y,z)
x,y,z = scaleVector(x,y,z,rad)
pappend(x)
pappend(y)
pappend(z)
colour=[]
for n in range(num):
r = randBetween(0, 1)
g = randBetween(0, 1)
b = randBetween(0, 1)
colour.append(r)
colour.append(g)
colour.append(b)


ri.Points({ri.P:points,ri.CS:colour,ri.CONSTANTWIDTH:size})



ri = prman.Ri() # create an instance of the RenderMan interface
ri.Option("rib", {"string asciistyle": "indented"})

filename = "rectangularbox.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("ring_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.25,3)
ri.Rotate(-40,1,0,0)
ri.TransformBegin()
ri.Rotate(35,0,1,0)
ri.Surface("plastic")
ring(1.5, 150, 0.2)
ri.TransformEnd()
ri.WorldEnd()
ri.End()

RenderMan | - | -
1/4 >>