|
|
I am not a new user, but this must be a basic concept I am missing. I
have the following file:
//---------------------- begin file ----------------------
camera {location <5,5,2>
look_at 2*x
angle 40
right <-1.33,0,0> //right-handed system
sky z
}
light_source {<0,3,3>
color rgb 2
}
#macro cushion(size_x,size_y,size_z)
superellipsoid{<.2, .4 >
scale .5*<size_x,size_y,size_z>
translate .5*<size_x,size_y,size_z>
}
#end //macro cushion
#macro sofa_seat(cushion_wd,segments) //calls cushion
union{
#while (segments>0)
object {cushion(cushion_wd,cushion_dp,cushion_ht)
translate (segments-1)*cushion_wd*x}
#local segments = segments -1;
#end //while
}
#end //macro sofa_seat
#macro sofa(sofa_wd,segments) //calls sofa_seat
union{
object{sofa_seat(sofa_wd/segments,segments)} //the seat
object{sofa_seat(sofa_wd/segments,segments) rotate 90*x} //the back
texture{pigment{color rgb <1,0,0>}}
}
#end //macro sofa
#declare cushion_dp = .6;
#declare cushion_ht = .2;
#declare sofa_width = 4;
#declare segments = 5;
sofa(sofa_width, segments)
//---------------------- end file ----------------------
It is meant to draw a sofa, with a seat and a back. "sofa()" calls
sofa_seat() twice, once to create the seats, and once to create the
back. The number of cushions (or segments) is passed via "segments".
Here is the problem. Running the program produces only the seat, not
the back. Seems by the time the program gets to the line marked as
"//the back", "segment" has been reset to zero, hence nothing is
produced by that line. If you comment out the line before this one,
marked "//the seat" you will see that the back is now produced, but not
the seat obviously.
I think there is a fundamental point here about macro arguments which I
need to learn. Why is segments zero in the line marked "//the back"?
Any pointers welcome.
Post a reply to this message
|
|