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

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

「実践CGへの誘い」p.61
Listing 4.1

基本プリミティブの表示をします。いろいろと工夫できますね。


#list41.py
#/* Copyrighted Pixar 1989 */
#/* From the RenderMan Companion p. 61 */
#/* Listing 4.1 Routine generating quadric surfaces shown in Figure 4.1 */
#/*

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

def Go():
ShowQuads()

OFFSET = 1.2

def ShowQuads():
RiRotate(-90.0, 1.0, 0.0, 0.0)

RiTranslate(-OFFSET, 0.0, (OFFSET/2))
RiSphere(0.5, -0.5, 0.5, 360.0, RI_NULL) #/* Declare a sphere */

RiTranslate(OFFSET, 0.0, 0.0)
RiTranslate(0.0, 0.0, -0.5)
RiCone(1.0, 0.5, 360.0, RI_NULL) #/* Declare a cone */

RiTranslate(0.0, 0.0, 0.5)
RiTranslate(OFFSET, 0.0, 0.0)
RiCylinder(0.5, -0.5, 0.5, 360.0, RI_NULL) #/* Declare cylinder */

RiTranslate(-(OFFSET*2), 0.0, -OFFSET)
hyperpt1 =[ 0.4, -0.4, -0.4]
hyperpt2 =[ 0.4, 0.4, 0.4]

#/* Declare hyperboloid */
RiHyperboloid(hyperpt1, hyperpt2, 360.0, RI_NULL)

RiTranslate(OFFSET, 0.0, -0.5)
RiParaboloid(0.5, 0.0, 0.9, 360.0, RI_NULL) #/* Declare paraboloid */

RiTranslate(OFFSET, 0.0, 0.5)
RiTorus(.4, .15, 0.0, 360.0, 360.0, RI_NULL) #/* Declare torus */


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

RiSurface ("plastic", Kd=1.0)
RiColor((0.97,0.64,0.39))
Go()
RiAttributeEnd()
RiWorldEnd()
RiEnd()




quadsmain.jpg
  • -
  • -

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