Last updated: March 2008. Kajiyama             [ 目次に戻る ]

積み木を #declare #whileで作る


サンプル box06.pov

//box06A.pov
// POV-Ray 3.6 scene file by Kajiyama

#include "colors.inc"
#include "shapes.inc"

//カメラ設定
camera{
    location < 6,10,-25>
    look_at <6,7,6>
    angle 45
}
//ライト設定
light_source{
    <-10,30,-20> color White*1.9
}

// XYZ座標空間
// チェック柄の床
object{
    Plane_XZ
    pigment{checker color Gray color White*0.9}
    translate <0,0,0>
}

// 座標系の表示
// Z軸
cylinder{<0,0,-5>,<0,0,10>,0.05
pigment{color Red}
finish{phong 1 reflection 0.1}
}
cone{<0,0,10>,0.3
<0,0,11.5>,0
pigment{color Red}
}
// Z文字
cylinder{<-0.5,0.5,0>,<0.5,0.5,0>,0.08
pigment{color Red}
finish{phong 1 reflection 0.1}
translate <0,1.1,12>
}
cylinder{<0.5,0.5,0>,<-0.5,-0.5,0>,0.08
pigment{color Red}
finish{phong 1 reflection 0.1}
translate <0,1.1,12>
}
cylinder{ <-0.5,-0.5,0>, <0.5,-0.5,0>,0.08
pigment{color Red}
finish{phong 1 reflection 0.1}
translate <0,1.1,12>
}
// X軸
cylinder{<-5,0,0>,<12,0,0>,0.05
pigment{color Green}
finish{phong 1 reflection 0.1}
}
cone{<12,0,0>,0.3
<13.5,0,0>,0
pigment{color Green}
}
// X文字
cylinder{<-0.5,-0.5,0>,<0.5,0.5,0>,0.08
pigment{color Green}
finish{phong 1 reflection 0.1}
rotate y*90
translate <13,1.1,0>
}
cylinder{ <-0.5,0.5,0>, <0.5,-0.5,0>,0.08
pigment{color Green}
finish{phong 1 reflection 0.1}
rotate y*90
translate <13,1.1,0>
}

// Y軸
cylinder{<0,-5,0>,<0,7,0>,0.05
pigment{color Blue}
finish{phong 1 reflection 0.1}
}
cone{<0,7,0>,0.3
<0,8.5,0>,0
pigment{color Blue}
}
// Y文字
cylinder{<-0.5,0.5,0>,<0,0,0>,0.08
pigment{color Blue}
finish{phong 1 reflection 0.1}
translate <0,9,0>
}
cylinder{<0.5,0.5,0>,<0,0,0>,0.08
finish{phong 1 reflection 0.1}
translate <0,9,0>
}
cylinder{ <0,0,0>, <0,-0.5,0>,0.08
pigment{color Blue}
finish{phong 1 reflection 0.1}
translate <0,9,0>
}

//■■■ボックスの図形操作■■■
box{<0,0,0>,<1,3,1>
pigment{color Red} //オリジナル
}

//一段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.7,0.6,0.7>}
translate <2*1,0,0> //オリジナルの平行移動
}
//一段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.7,0.6,0.7>}
translate <2*2,0,0> //オリジナルの平行移動
}
//一段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.7,0.6,0.7>}
translate <2*3,0,0> //オリジナルの平行移動
}
//一段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.7,0.6,0.7>}
translate <2*4,0,0> //移動先へ平行移動
}
//一段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.7,0.6,0.7>}
translate <2*5,0,0> //移動先へ平行移動
}

//二段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.7,0.8,0.7>}
translate <2*1+1,3,0> //オリジナルの平行移動
}
//二段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.7,0.8,0.7>}
translate <2*2+1,3,0> //オリジナルの平行移動
}
//二段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.7,0.8,0.7>}
translate <2*3+1,3,0> //移動先へ平行移動
}
//二段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.7,0.8,0.7>}
translate <2*4+1,3,0> //移動先へ平行移動
}

//三段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.7,0.9,0.7>}
translate <2*1+2,3*2,0> //移動先へ平行移動
}
//三段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.7,0.9,0.7>}
translate <2*2+2,3*2,0> //移動先へ平行移動
}
//三段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.7,0.9,0.7>}
translate <2*3+2,3*2,0> //移動先へ平行移動
}

//四段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.8,0.99,0.8>}
translate <2*1+3,3*3,0> //移動先へ平行移動
}
//四段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.8,0.99,0.8>}
translate <2*2+3,3*3,0> //移動先へ平行移動
}

//五段目平行移動
box{<0,0,0>,<1,3,1>
pigment{color rgb<0.5,0.99,0.5>}
translate <2*1+4,3*4,0> //移動先へ平行移動
}

background{color White}

サンプル box06B.pov

//box06B.pov
// POV-Ray 3.6 scene file by Kajiyama

#include "colors.inc"
#include "shapes.inc"

//カメラ設定
camera{
    location <3,10,-27>
    look_at <6,7,6>
    angle 48
}
//ライト設定
light_source{
    <-10,30,-20> color White*1.9
}

// XYZ座標空間
// チェック柄の床
object{
    Plane_XZ
    pigment{checker color Gray color White*0.9}
    translate <0,0,0>
}

// 座標系の表示
// Z軸
cylinder{<0,0,-5>,<0,0,10>,0.05
pigment{color Red}
finish{phong 1 reflection 0.1}
}
cone{<0,0,10>,0.3
<0,0,11.5>,0
pigment{color Red}
}
// Z文字
cylinder{<-0.5,0.5,0>,<0.5,0.5,0>,0.08
pigment{color Red}
finish{phong 1 reflection 0.1}
translate <0,1.1,12>
}
cylinder{<0.5,0.5,0>,<-0.5,-0.5,0>,0.08
pigment{color Red}
finish{phong 1 reflection 0.1}
translate <0,1.1,12>
}
cylinder{ <-0.5,-0.5,0>, <0.5,-0.5,0>,0.08
pigment{color Red}
finish{phong 1 reflection 0.1}
translate <0,1.1,12>
}
// X軸
cylinder{<-5,0,0>,<12,0,0>,0.05
pigment{color Green}
finish{phong 1 reflection 0.1}
}
cone{<12,0,0>,0.3
<13.5,0,0>,0
pigment{color Green}
}
// X文字
cylinder{<-0.5,-0.5,0>,<0.5,0.5,0>,0.08
pigment{color Green}
finish{phong 1 reflection 0.1}
rotate y*90
translate <13,1.1,0>
}
cylinder{ <-0.5,0.5,0>, <0.5,-0.5,0>,0.08
pigment{color Green}
finish{phong 1 reflection 0.1}
rotate y*90
translate <13,1.1,0>
}

// Y軸
cylinder{<0,-5,0>,<0,7,0>,0.05
pigment{color Blue}
finish{phong 1 reflection 0.1}
}
cone{<0,7,0>,0.3
<0,8.5,0>,0
pigment{color Blue}
}
// Y文字
cylinder{<-0.5,0.5,0>,<0,0,0>,0.08
pigment{color Blue}
finish{phong 1 reflection 0.1}
translate <0,9,0>
}
cylinder{<0.5,0.5,0>,<0,0,0>,0.08
finish{phong 1 reflection 0.1}
translate <0,9,0>
}
cylinder{ <0,0,0>, <0,-0.5,0>,0.08
pigment{color Blue}
finish{phong 1 reflection 0.1}
translate <0,9,0>
}

//■■■ボックスの図形操作■■■
box{<0,0,0>,<1,3,1>
pigment{color Red} //オリジナル
}

//一段目平行移動
#declare K=1;
#while(K<6)
box{<0,0,0>,<1,3,1>
pigment{color Red}
translate<K*2,0,0>//移動先の座標を指定
}
#declare K=K+1;
#end

//二段目平行移動
#declare K=1;
#while(K<5)
box{<0,0,0>,<1,3,1> //移動先の座標を指定
pigment{color Green}
translate<1+K*2,3,0>
}
#declare K=K+1;
#end

//三段目平行移動
#declare K=1;
#while(K<4)
box{<0,0,0>,<1,3,1> //移動先の座標を指定
pigment{color Yellow}
translate<2+K*2,6,0>
}
#declare K=K+1;
#end

//四段目平行移動
#declare K=1;
#while(K<3)
box{<0,0,0>,<1,3,1> //移動先の座標を指定
pigment{color Red}
translate<3+K*2,9,0>
}
#declare K=K+1;
#end

//五段目平行移動
#declare K=1;
#while(K<2)
box{<0,0,0>,<1,3,1> //移動先の座標を指定
pigment{color Green}
translate<4+K*2,12,0>
}
#declare K=K+1;
#end

background{color White}


[ 目次に戻る ]