<< Lightflow円柱と立方体 戻る Lightflowブーリアン演算その2 >>

Lightflowブーリアン演算その1

立方体からふたつき円柱を使ってくり貫いた。
bool042.jpg

csg1 = s.newObject( "solid",[ "type", "difference",
"solids", box1, hole ] )
"difference"差集合を表す。
box1-holeを行っている。

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

#! /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 ] )

#box1
s.materialBegin( plastic2 )
s.transformBegin( transform().translation( vector3( 0, 0, 1.2 ) ) )
s.transformBegin( transform().rotationAroundY( pi*45.0/180 ) )
box1=s.newObject( "box", [ "position",vector3( -1.0, -1.0, -1.0 ),vector3( 1.0, 1.0, 1.0 )] )
s.transformEnd()
s.transformEnd()
s.materialEnd()


csg1 = s.newObject( "solid",
[ "type", "difference",
"solids", box1, hole ] )

s.addObject(csg1)


saver = s.newImager( "tga-saver", [ "file", "bool04.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 )


逆にすれば形も変わる。
csg1 = s.newObject( "solid",[ "type", "difference",
"solids", hole, box1 ] )
bool041.jpg
ありがとうございます。
  • -
  • -

<< Lightflow円柱と立方体 戻る Lightflowブーリアン演算その2 >>