|
 |
"Samuel B." <stb### [at] hotmail com> wrote:
> Macro incoming...
Second version of the macro.
Changes:
* glass now renders correctly
* can specify the position of the bottom horizontal frame member
* various clarification of comments
The macro:
#macro Gothic_Window
(
WW, // window box width (total window width divided by two)
WH, // window box height
WD, // window box depth
AH, // arch height (beginning from top [-y], should be >=window width and
<window height)
HY, // y-position for horizontal cross member (beginning from y, will only be
used if there is room for it)
FR, // frame radius (thickness of the frame)
ET, // enclosure thickness (window box, should be qual or less than frame
radius)
NA, // number of arch pieces
PT, // number of arch pieces
BW // window pane bevel width
)
#local Eps = .0001; // a small value
union{
// -< window width, arch height, 0 >
#local P = -<WW, AH, 0>;
// arch circle center
#local CC = <.5*(P.x-P.y/(WW/AH)), -AH, 0>;
// arch circle radius
#local CR = vlength(CC);
// window box
box{<-WW, -WH+ET, -Eps>, <-WW+ET, -AH, WD+Eps>}
box{<WW-ET, -WH+ET, -Eps>, <WW, -AH, WD+Eps>}
box{<-WW, -WH, -Eps>, <WW, -WH+ET, WD+Eps>}
difference{
box{<-WW, -AH, 0>, <WW, 0, WD>}
intersection{
cylinder{<CC.x, CC.y, -Eps>, <CC.x, CC.y, WD+Eps>, CR-ET}
cylinder{<-CC.x, CC.y, -Eps>, <-CC.x, CC.y, WD+Eps>, CR-ET}
}
}
#local FR2 = .4 * FR;
// horizontal frame at bottom of curved arch
cylinder{-<WW, AH, 0>, <WW, -AH, 0>, FR}
cylinder{-<WW, AH, FR>, <WW, -AH, -FR>, FR2}
cylinder{-<WW, WH, 0>, <WW, -WH, 0>, FR}
cylinder{-<WW, WH, FR>, <WW, -WH, -FR>, FR2}
// bottom horizontal frame piece
#if(HY<WH-AH)
cylinder{<-WW, -WH+HY, 0>, <WW, -WH+HY, 0>, FR}
cylinder{<-WW, -WH+HY, -FR>, <WW, -WH+HY, -FR>, FR2}
#end
// multiarch setup
#for(I, 0, NA)
#if(I<NA)
#local ArchPiece =
intersection{
merge{
torus{
CR, FR
rotate x*90
translate CC+2*x*WW*I/NA
}
torus{
CR, FR2
rotate x*90
translate CC-z*FR+2*x*WW*I/NA
}
}
plane{y, -AH inverse}
// use vertical cut for first item, otherwise use a cylinder
#if(I=0)
plane{x, 0}
#else
cylinder{<-CC.x, CC.y, -2*FR>, <-CC.x, CC.y, 2*FR>, CR}
#end
}
object{ArchPiece}
object{ArchPiece scale <-1, 1, 1>}
#end
cylinder{-<WW, WH, 0>, -<WW, AH, 0>, FR translate x*2*WW*I/NA}
cylinder{-<WW, WH, FR>, -<WW, AH, FR>, FR2 translate x*2*WW*I/NA}
#end
// fill the corners
sphere{-<WW, WH, 0>, FR}
sphere{<WW, -WH, 0>, FR}
sphere{-<WW, WH, FR>, FR2}
sphere{<WW, -WH, -FR>, FR2}
#local TexWindow =
texture{
pigment{rgb .75 transmit .85}
finish{reflection{0, 1 fresnel} conserve_energy}
}
// glass window pane
#if(true)
union{
box{
<-WW+Eps, -WH+Eps, PT>, <WW-Eps, -Eps, PT>
texture{TexWindow}
inverse
}
box{
<-WW+Eps, -WH+Eps, Eps>, <WW-Eps, -Eps, Eps>
texture{
TexWindow
normal{
#local CX = CC.x;
#local CY = CC.y;
#local FA =
function{
min(
1
#for(I, 0, NA-1)
,abs(sqrt(pow(x-CX-2*WW*I/NA, 2)+pow(y-CY, 2)*(y>-AH))-CR)
#end
)
}
function{
min(
1,
min(
FA(x, y, 0),
FA(-x, y, 0),
abs(y+AH),
abs(y+WH)
#if(HY<WH-AH)
,abs(y+WH-HY)
#end
) / BW
)
}
bump_size 1
accuracy .003
}
}
}
interior{ior 1.5}
double_illuminate
}
#end
// place object at y=0
translate y*WH
}
#end
Macro invocation:
object{
Gothic_Window(
1.0, // window box width (total window width divided by two)
4.0, // window box height
0.75, // window box depth
1.875, // arch height (beginning from top [-y], should be >=window width and
<window height)
0.375, // y-position for horizontal cross member (beginning from y, will only
be used if there is room for it)
0.05, // frame radius (thickness of the frame)
0.01, // enclosure thickness (window box, should be qual or less than frame
radius)
3, // number of arch pieces
0.01, // window pane thickness
0.125 // window pane bevel width
)
// window box material goes here
pigment{rgb .75}
}
Sam
Post a reply to this message
Attachments:
Download 'gothicarchb0m_59s.jpg' (73 KB)
Preview of image 'gothicarchb0m_59s.jpg'

|
 |