<< 「実践CGへの誘い」例題をPythonで行う その9 戻る 「実践CGへの誘い」例題をPythonで・・その11 >>

「実践CGへの誘い」例題をPythonで・・その10

list42.jpg
「実践CGへの誘い」p.65
Listing 4.2



#list42.py
#/* Copyrighted Pixar 1989 */
#/* From the RenderMan Companion p. 65 */
#/* Listing 4.2 Using hyperboloids to create a surface of revolution */

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

NPOINTS=16

points = [
[1.5000,.0000],
[1.4600,.0900],
[1.3500,.1273],
[1.2625,.1203],
[1.1750,.1047],
[1.0875,.0935],
[1.0000,.0899],
[0.9375,.0982],
[0.8625,.1236],
[0.7250,.1851],
[0.5875,.2281],
[0.4500,.2383],
[0.3375,.2255],
[0.2250,.1953],
[0.0750,.1414],
[0.0000,.1125]
]

color = (1,0.26,0.15)

def Go():
global color
RiColor(color)
RiSurface ("plastic", Kd=1.0)
RiRotate(-90.0, 1.0, 0.0, 0.0)
SurfOR(points, NPOINTS)


#/* Listing 4.2 Using hyperboloids to create a surface of revolution */

def SurfOR(points, npoints):
#/*
# * For each adjacent pair of x,y points in the outline description,
# * draw a hyperboloid by sweeping the line segment defined by
# * those points about the z axis.
# */
pp1 =[ points[0][1], 0, points[0][0]]
for pt in range(1, npoints):
pp2 =[ points[pt][1], 0, points[pt][0]]
RiHyperboloid(pp1, pp2, 360.0, RI_NULL)
tmp = pp1
pp1 = pp2
pp2 = tmp


RiBegin (RI_NULL) #/* Start Renderer */
RiDisplay("list42.tif", RI_FILE, "rgb", RI_NULL)
RiFormat( 512, 372, -1.0)
RiProjection (RI_PERSPECTIVE,RI_FOV,45)
RiTranslate (0.0, -0.75, 2.2)
RiWorldBegin ()
RiLightSource ("distantlight", RI_NULL)
RiAttributeBegin()

Go()
RiAttributeEnd()
RiWorldEnd()
RiEnd()

  • -
  • -

<< 「実践CGへの誘い」例題をPythonで行う その9 戻る 「実践CGへの誘い」例題をPythonで・・その11 >>