楽しみです。
odedynamics.pyをアップデートしないと、サンプルは動かないです。
http://cgkit.sourceforge.net/tutorials/
- -
- -
日々3DCGの世界は進歩しているけど、勉強して理解したことをまとめていきたい。RenderMan互換レンダラーやグローバル・イルミネーション。いろんなことに好奇心を持ち面白くなってくる。目指せShader書き!!
rml=RMLightSource(name = "RMLightSource", shader = "occlight")
rml.shader.declare('uniform float samples=128')
w=WorldObject()
w.rib='Attribute "visibility" "trace" [0]\nAttribute "visibility" "transmission" ["opaque"]'
w2=WorldObject()
w2.rib='Attribute "visibility" "trace" [1]\nAttribute "visibility" "transmission" ["transparent"]'
load("tank_test.obj")
objs =['syatai', 'houtou', 'futa', 'gun', 'gunbase', 'hou', 'wheel', 'd_wheel', 'chata', 'obj1']
models = worldObjects(objs)
for i in range(9):
link(models[i],parent=w)
link(models[9],parent=w2)
#list21.py
#/* Copyrighted Pixar 1989 */
#/* From the RenderMan Companion p. 18 */
#/* Listing 2.1 A minimal program using RenderMan */
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())
square=[.5,.5,.5,.5,-.5,.5,-.5,-.5,.5,-.5,.5,.5]
RiBegin(RI_NULL)
RiFormat(640,480,1)
RiDisplay("list21.tif", RI_FRAMEBUFFER, RI_RGB)
#RiPixelSamples(3,3)
#RiProjection(RI_ORTHOGRAPHIC)
#RiScale(vec3(0.8))
#RiTranslate(0,0.55,5)
RiWorldBegin()
RiSurface("constant",RI_NULL)
RiPolygon(P=square)
RiWorldEnd()
RiEnd()
#list22.py
#/* Copyrighted Pixar 1989 */
#/* From the RenderMan Companion p. 20 */
#/* Listing 2.2 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())
square=[.5,.5,.5,.5,-.5,.5,-.5,-.5,.5,-.5,.5,.5]
color=(.2,.4,.6)
RiBegin(RI_NULL)
RiLightSource("distantlight",RI_NULL)
RiProjection(RI_PERSPECTIVE)
RiTranslate(0.0,0.0,1.0)
RiRotate(40,-1,1,0)
RiDisplay("list22.tif", RI_FRAMEBUFFER, RI_RGB)
RiWorldBegin()
RiColor(color)
RiSurface("constant",RI_NULL)
RiPolygon(P=square)
RiWorldEnd()
RiEnd()
#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()
#list25.py
#/* Copyrighted Pixar 1989 */
#/* From the RenderMan Companion p. 28 */
#/* Listing 2.5 Another cube definition */
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())
#/* UnitCube(): Enter a unit cube into the scene */
def UnitCube():
square = [ [.5,.5,.5], [-.5,.5,.5], [-.5,-.5,.5], [.5,-.5,.5] ]
RiTransformBegin()
#/* far square */
RiPolygon( RI_P, square, RI_NULL)
#/* right face */
RiRotate(90.0, 0.0, 1.0, 0.0)
RiPolygon( RI_P, square, RI_NULL)
#/* near face */
RiRotate(90.0, 0.0, 1.0, 0.0)
RiPolygon( RI_P, square, RI_NULL)
#/* left face */
RiRotate(90.0, 0.0, 1.0, 0.0)
RiPolygon( RI_P, square, RI_NULL)
RiTransformEnd()
RiTransformBegin()
#/* bottom face */
RiRotate(90.0, 1.0, 0.0, 0.0)
RiPolygon( RI_P, square, RI_NULL)
RiTransformEnd()
RiTransformBegin()
#/* top face */
RiRotate(-90.0, 1.0, 0.0, 0.0)
RiPolygon( RI_P, square, RI_NULL)
RiTransformEnd()
color=(.9,.1,.2)
RiBegin(RI_NULL)
RiDisplay("list25.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()
RiWorldEnd()
RiEnd()
#list26.py
#/* Copyrighted Pixar 1989 */
#/* From the RenderMan Companion p. 30 */
#/* Listing 2.6 Defining a larger cube from smaller minicubes */
#/*
# * ColorCube(): create a unit color cube from smaller cubes
# * Parameters:
# * n: the number of minicubes on a side
# * s: a scale factor for each minicube
# */
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())
#/* UnitCube(): Enter a unit cube into the scene */
def ColorCube(n, s):
if n<=0:
return
RiAttributeBegin()
RiTranslate(-.5, -.5, -.5 )
RiScale(1.0/n, 1.0/n, 1.0/n)
color=[0,0,0]
for x in range(n):
for y in range(n):
for z in range(n):
color[0] = (x+1)/float(n)
color[1] = (y+1)/float(n)
color[2] = (z+1)/float(n)
RiColor(color)
RiTransformBegin()
RiTranslate (x+.5, y+.5, z+.5)
RiScale(s, s, s)
UnitCube()
RiTransformEnd ()
RiAttributeEnd();
def UnitCube():
square = [ [.5,.5,.5], [-.5,.5,.5], [-.5,-.5,.5], [.5,-.5,.5] ]
RiTransformBegin()
#/* far square */
RiPolygon( RI_P, square, RI_NULL)
#/* right face */
RiRotate(90.0, 0.0, 1.0, 0.0)
RiPolygon( RI_P, square, RI_NULL)
#/* near face */
RiRotate(90.0, 0.0, 1.0, 0.0)
RiPolygon( RI_P, square, RI_NULL)
#/* left face */
RiRotate(90.0, 0.0, 1.0, 0.0)
RiPolygon( RI_P, square, RI_NULL)
RiTransformEnd()
RiTransformBegin()
#/* bottom face */
RiRotate(90.0, 1.0, 0.0, 0.0)
RiPolygon( RI_P, square, RI_NULL)
RiTransformEnd()
RiTransformBegin()
#/* top face */
RiRotate(-90.0, 1.0, 0.0, 0.0)
RiPolygon( RI_P, square, RI_NULL)
RiTransformEnd()
color = ( .2, .4, .6 )
RiBegin(RI_NULL); #/* Start the renderer */
RiDisplay("colormain.tiff", RI_FILE, "rgb", RI_NULL)
RiFormat(512, 384, -1.0)
RiShadingRate(1.0)
RiLightSource("distantlight", RI_NULL)
RiProjection(RI_PERSPECTIVE,RI_FOV,65)
RiWorldBegin()
RiSides(1) # /* N E W */
RiTranslate(0.0, 0.0, 1.5)
RiRotate(30.0, -1.0, 0.0, 0.0)
RiRotate(30.0, 0.0, -1.0, 0.0)
RiColor(color) # /* Declare the color */
ColorCube(4, .8) #/* Define the cube */
RiWorldEnd()
RiEnd() #/* Clean up after the renderer */