<< Lightflow円柱にふたをする 戻る Lightflowブーリアン演算その1 >>

Lightflow円柱と立方体

ブーリアン演算をするために、円柱は傾けたまま、立方体は回転させてみた。元ねたは、「はじめてのCG」POV-Ray本を参考にした。

まずは円柱と立方体を表示する。
bool03.jpg

サンプルファイルはこちら

#! /usr/bin/env python
from lightflowPM import *
from math import *

s = scene()

s.lightOn( s.newLight( "point", [ "position", vector3( 5.0, -5.0, 3.0 ), "color", vector3( 300.0, 300.0, 300.0 ) ] ) )

s.lightOn( s.newLight( "point", [ "position", vector3( -3.0, -3.0, 3.0 ), "color", vector3( 300.0, 300.0, 300.0 ) ] ) )

s.lightOn( s.newLight( "point", [ "position", vector3( 3.0, 3.0, 3.0 ), "color", vector3( 300.0, 300.0, 300.0 ) ] ) )

plastic = s.newMaterial( "standard", [ "kc", vector3( 0.096, 0.252, 0.504 ), "kd", 0.5, "km", 0.1 ] )

#cylinder
s.materialBegin( plastic )
s.transformBegin( transform().rotationAroundX( pi*5.0/180 ) )
s.transformBegin( transform().translation( vector3( 0, 0, 2.4 ) ) )
cap1=s.newObject( "disc", [ "radius", 1.0 ] )
s.transformEnd()

s.transformBegin( transform().translation( vector3( 0, 0, 0 ) ) )
cap2=s.newObject( "disc", [ "radius", 1.0 ] )
s.transformEnd()

cyl=s.newObject( "cylinder", [ "radius", 1.0 ,"height",2.4] )
s.transformEnd()
s.materialEnd()

#cylinder with double caps
hole = s.newObject( "boundary", [ "surfaces", cyl, cap1, cap2 ] )



plastic2 = s.newMaterial( "standard", [ "kc", vector3(0.556863,0.137255,0.137255), "kd", 0.5, "km", 0.1 ] )

#box
s.materialBegin( plastic2 )
s.transformBegin( transform().translation( vector3( 0, 0, 1.2 ) ) )
s.transformBegin( transform().rotationAroundY( pi*45.0/180 ) )
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.addObject(hole)


saver = s.newImager( "tga-saver", [ "file", "bool03.tga" ] )

s.imagerBegin( saver )

camera = s.newCamera( "pinhole", [ "eye", vector3( -1.5, -4, 3 ),
"aim", vector3( 0, 0, 1 ),
"aa-samples", 2,5
] )

s.imagerEnd()

s.render( camera, 400, 400 )


面白いですね。ありがとうございます。
  • -
  • -

<< Lightflow円柱にふたをする 戻る Lightflowブーリアン演算その1 >>