POV-Ray : Newsgroups : povray.general : looking for a box macro : Re: looking for a box macro Server Time
7 Aug 2024 21:21:06 EDT (-0400)
  Re: looking for a box macro  
From: Rich
Date: 3 Jun 2001 23:01:43
Message: <Xns90B5D5F09D985spammindspringcom@204.213.191.228>
SrP### [at] ricoswebcom (Rich) wrote in
<Xns90B5C64211218spammindspringcom@204.213.191.228>:

> Warp <war### [at] tagpovrayorg> wrote in <3b1a9fc8@news.povray.org>:
> 
>> #macro Box(Point1, Point2, Width, Height, Rotation)
> 
>   Excellent, thank you VERY much!  I'm trying it out now.
> 

Unfortunately, most of the boxes are rotated incorrectly along their length,
depending on the angle between the points I'm assuming.  Here is a sample
scene showing what I mean:

//----------------
camera {
  location  <0.0, 3.0, -6.000001>
  //location  <0.0, 10.0, -0.000001>
  direction 1.5*z
  right     4/3*x
  look_at   <0.0, 2.0,  0.0>
}

light_source { <-3, 30, -3> color rgb 1.5 }

#macro Wall(Point1, Point2, Width, Height, Rotation)
  #local Len = vlength(Point2-Point1);
  #local Dir = vnormalize(Point2-Point1);
  box
  { <-Width/2, 0, 0>, <Width/2, Len, Height>
    rotate y*Rotation
    #local VY=vcross(Dir,y);
    #if(vlength(VY)>0)
      #local VY=vnormalize(VY);
      #local VZ1=vcross(VY,y);
      #local VZ2=vcross(VY,Dir);
      matrix <     0, VY.x, VZ1.x,
                   1, VY.y, VZ1.y,
                   0, VY.z, VZ1.z,
                   0,    0,     0 >
      matrix < Dir.x, Dir.y, Dir.z,
                VY.x,  VY.y,  VY.z,
               VZ2.x, VZ2.y, VZ2.z,
                   0,     0,     0 >
    #end
    pigment { color rgb .5 }
    translate Point1
  }
#end

sky_sphere {
  pigment {
    gradient y
    color_map { [0.0 color blue 0.6] [1.0 color rgb 1] }
  }
}

#declare Tower = cylinder { <0,0,0>, <0,.2,0>, .1 pigment { color rgb .5 } translate
<0,2,0> }

#declare H = 0.15;
#declare W = 0.15;

object { Tower translate <-1.94, 0,-0.44> }
Wall(<-1.94, 2.0,-0.44>, <-2.05, 2.0,-0.20>,W, H, 0)
object { Tower translate <-2.05, 0,-0.20> }
Wall(<-2.05, 2.0,-0.20>, <-1.65, 2.0, 0.70>,W, H, 0)
object { Tower translate <-1.65, 0, 0.70> }
Wall(<-1.65, 2.0, 0.70>, <-1.72, 2.0, 1.13>,W, H, 0)
object { Tower translate <-1.72, 0, 1.13> }
Wall(<-1.72, 2.0, 1.13>, <-1.10, 2.0, 1.37>,W, H, 0)
object { Tower translate <-1.10, 0, 1.37> }
Wall(<-1.10, 2.0, 1.37>, <-0.20, 2.0, 1.38>,W, H, 0)
object { Tower translate <-0.20, 0, 1.38> }
Wall(<-0.20, 2.0, 1.38>, < 0.30, 2.0, 1.20>,W, H, 0)
object { Tower translate < 0.30, 0, 1.20> }
Wall(< 0.30, 2.0, 1.20>, < 0.92, 2.0, 1.41>,W, H, 0)
object { Tower translate < 0.92, 0, 1.41> }
Wall(< 0.92, 2.0, 1.41>, < 1.32, 2.0, 1.25>,W, H, 0)
object { Tower translate < 1.32, 0, 1.25> }
Wall(< 1.32, 2.0, 1.25>, < 1.90, 2.0, 1.35>,W, H, 0)
object { Tower translate < 1.90, 0, 1.35> }
Wall(< 1.90, 2.0, 1.35>, < 1.95, 2.0, 0.68>,W, H, 0)
object { Tower translate < 1.95, 0, 0.68> }
Wall(< 1.95, 2.0, 0.68>, < 1.32, 2.0, 0.10>,W, H, 0)
object { Tower translate < 1.32, 0, 0.10> }
Wall(< 1.32, 2.0, 0.10>, < 0.90, 2.0, 0.15>,W, H, 0)
object { Tower translate < 0.90, 0, 0.15> }
Wall(< 0.90, 2.0, 0.15>, < 0.21, 2.0,-0.50>,W, H, 0)
object { Tower translate < 0.21, 0,-0.50> }
Wall(< 0.21, 2.0,-0.50>, <-0.15, 2.0,-0.55>,W, H, 0)
object { Tower translate <-0.15, 0,-0.55> }
Wall(<-0.15, 2.0,-0.55>, <-0.55, 2.0,-1.09>,W, H, 0)
object { Tower translate <-0.55, 0,-1.09> }
Wall(<-0.55, 2.0,-1.09>, <-0.85, 2.0,-1.00>,W, H, 0)
object { Tower translate <-0.85, 0,-1.00> }
Wall(<-0.85, 2.0,-1.00>, <-1.10, 2.0,-0.45>,W, H, 0)
object { Tower translate <-1.10, 0,-0.45> }
Wall(<-1.10, 2.0,-0.45>, <-1.45, 2.0,-0.30>,W, H, 0)
object { Tower translate <-1.45, 0,-0.30> }
Wall(<-1.45, 2.0,-0.30>, <-1.94, 2.0,-0.44>,W, H, 0)


-- 
Rich Allen
(Remove SPAM from my address to reply by e-mail)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.