<< 「実践CGへの誘い」例題をPythonで行う その2 戻る PythonからRenderManを使う その2 >>

「実践CGへの誘い」例題をPythonで行う その3

「実践CGへの誘い」p.25
Listing 2.3
list23.jpg


#list23.py
# Copyrighted Pixar 1989
# From the RenderMan Companion p. 25
# Listing 2.3 Control over viewer and color

import cgkit.cri
from cgkit.cgtypes import *

# Load the RenderMan API.
# Replace the library name with whatever renderer you want to use.
ri = cgkit.cri.loadRI("3delight")
cgkit.cri.importRINames(ri, globals())

L= -.5 #* For x: left side */
R= .5 # /* For x: right side */
D= -.5 # /* For y: down side */
U= .5 # /* For y: upper side */
F= .5 # /* For z: far side */
N= -.5 # /* For z: near side */

#/* UnitCube(): define a cube in the graphics environment */
def UnitCube():
Cube=[
[ [L,D,F], [L,D,N], [R,D,N], [R,D,F] ], #/* Bottom face */
[ [L,D,F], [L,U,F], [L,U,N], [L,D,N] ], #/* Left face */
[ [R,U,N], [L,U,N], [L,U,F], [R,U,F] ], #/* Top face */
[ [R,U,N], [R,U,F], [R,D,F], [R,D,N] ], #/* Right face */
[ [R,D,F], [R,U,F], [L,U,F], [L,D,F] ], #/* Far face */
[ [L,U,N], [R,U,N], [R,D,N], [L,D,N] ] #/* Near face */
];
for i in range(6):
RiPolygon(P=Cube[i])


#square=[.5,.5,.5,.5,-.5,.5,-.5,-.5,.5,-.5,.5,.5]

color=(.2,.4,.6)

RiBegin(RI_NULL)
RiDisplay("list23.tif", RI_FRAMEBUFFER, RI_RGB)
RiFormat(640,480, -1.0)
RiShadingRate(1.0)
RiLightSource("distantlight", RI_NULL)
RiProjection(RI_PERSPECTIVE)
RiWorldBegin()
RiTranslate(0.0, 0.0, 1.5)
RiRotate(40.0, -1.0, 1.0, 0.0)
RiSurface("matte",RI_NULL)
RiColor(color)
UnitCube()
#RiPolygon(P=square)
RiWorldEnd()
RiEnd()

  • -
  • -

<< 「実践CGへの誘い」例題をPythonで行う その2 戻る PythonからRenderManを使う その2 >>