赤色の立方体が原点にあります。
後は3ずつ前後左右に移動させています。
サンプルmy_b7.py
----------------------------------------------------
#! /usr/bin/env python
from lightflowPM import *
from math import * #数学関数モジュールを使うときに書いておく。ここでは円周率piを利用している。pi=3.14159265358979です。
s = scene()
s.lightOn( s.newLight( "point", [ "position", vector3( 3.0, -5.0, 8.0 ), "color", vector3( 300.0, 300.0, 300.0 ) ] ) )
s.lightOn( s.newLight( "ambient", [ "color", vector3( 0.2, 0.2, 0.2 ) ] ) ) #環境光を加える。
plastic = s.newMaterial( "standard",[ "kc", vector3( 1, 0, 0 ) ] ) #赤
plastic2 = s.newMaterial( "standard",[ "kc", vector3( 0, 1, 0 ) ] ) #緑
plastic3 = s.newMaterial( "standard",[ "kc", vector3( 0, 0, 1 ) ] ) #青
plastic4 = s.newMaterial( "standard",[ "kc", vector3( 1, 1, 0 ) ] ) #黄色
plastic5 = s.newMaterial( "standard",[ "kc", vector3( 1, 0, 1 ) ] ) #紫
plastic6 = s.newMaterial( "standard",[ "kc", vector3( 0, 1, 1 ) ] ) #水色
plastic7 = s.newMaterial( "standard",[ "kc", vector3( 1, 1, 1 ) ] ) #青
ground=s.newMaterial( "standard",[ "kc", vector3( 1, 1, 1 ) ] ) #地面
s.materialBegin( plastic ) #赤の箱は原点にある。
s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )
s.materialEnd()
s.materialBegin( plastic2 )
s.transformBegin( transform().translation( vector3(-3.0,0,0))) #緑の箱をx方向に-3移動させた。
s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )
s.transformEnd()
s.materialEnd()
s.materialBegin( plastic3 )
s.transformBegin( transform().translation( vector3(3.0,0,0)))
s.transformBegin( transform().rotationAroundZ( pi/4 ))
s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )
s.transformEnd()
s.transformEnd()
s.materialEnd()
s.materialBegin( plastic4 )
s.transformBegin( transform().translation( vector3(0,0.75,3.0)))
s.transformBegin( transform().rotationAroundZ( pi/6 ))
s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )
s.transformEnd()
s.transformEnd()
s.materialEnd()
s.materialBegin( plastic5 )
s.transformBegin( transform().translation( vector3(-5.0,4.0,0)))
s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )
s.transformEnd()
s.materialEnd()
s.materialBegin( plastic6 )
s.transformBegin( transform().translation( vector3(3.0,3.0,0)))
s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )
s.transformEnd()
s.materialEnd()
s.materialBegin( plastic7 )
s.transformBegin( transform().translation( vector3(-0.9,-3.5,0)))
s.transformBegin( transform().rotationAroundZ( -pi/10 ))
s.addObject( s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] ) )
s.transformEnd()
s.transformEnd()
s.materialEnd()
s.materialBegin( ground )
s.addObject( s.newObject( "patch", [ "points",vector3( -50, -50, -1.0 ),vector3( -50, 50, -1.0 ),vector3( 50, -50, -1.0 ),vector3( 50, 50, -1.0 )] ) )
s.materialEnd()
saver = s.newImager( "tga-saver", [ "file", "my_b7.tga" ] )
s.imagerBegin( saver )
#カメラは真正面の上の方から見ています。
camera = s.newCamera( "pinhole", [ "eye", vector3( 0, -10, 7 ), "aim", vector3( 0, 0, 0 ),"aa-samples", 3,5 ] ) #ギザギザを減らす、時間かかる。通常は"aa-samples", 2,4
s.imagerEnd()
s.render( camera, 300, 300 )
- -
- -