POV-Ray : Newsgroups : povray.animations : Animating Lego Garage door : Animating Lego Garage door Server Time
25 Apr 2024 00:00:42 EDT (-0400)
  Animating Lego Garage door  
From: Thomas
Date: 11 Jun 2012 16:55:01
Message: <web.4fd65ad8e7ec90d9a6b6bd7e0@news.povray.org>
Hi,

Years ago I started modelling a Lego fire station (set 6382) with Anton Raves
Lego library. It has two sliding garage doors (have a google for the set). I
recently returned to this model and wondered how I could make a macro that would
allow me to control the garage door with a single parameter. I played around
with it a bit and I managed to get the lower bit that just slides up and down.
Based on a clock from 0 (closed) to 1 (open).

What I am struggling with is the bit where the shutter has to rotate and follow
the groove. Any ideas how this can be achieved?

TIA

Thomas

Here is a cut down version that gives an orthographic view of the problem from
the side:


// render with +KFI0 -KFF100

background { color rgb .75}

// pieces used by animation

#declare shutter =
difference {
  merge {
    cylinder { -33.9*x, -30*x, 1.5 pigment {color rgb <0,0,1> } finish {ambient
1}}
    cylinder { 30*x, 33.9*x, 1.5 pigment {color rgb <0,0,1>} finish {ambient 1}}
    sphere { <-30.5, 0, 0> 1 }
    sphere { <30.5, 0, 0> 1 }
    box { <-32, -6.1, -0.9> <-30, 0, 0.9> }
    box { <30, -6.1, -0.9> <32, 0, 0.9> }
    box { <-30.000001, -8.700001, -0.900001> <30.000001, -1.9, 0.900001> }
    cylinder { -30.000002*x, 30.000002*x, 0.9 translate <0, -8.7, 0> }
  }
  sphere { <-30.5, -8.7, 0> 1.1 }
  sphere { <30.5, -8.7, 0> 1.1 }
  box { <-28.8, -8.7, -1> <-15.1, -2.9, -0.3> }
  box { <-14.1, -8.7, -1> <-0.5, -2.9, -0.3> }
  box { <28.8, -8.7, -1> <15.1, -2.9, -0.3> }
  box { <14.1, -8.7, -1> <0.5, -2.9, -0.3> }
  bounded_by { box { <-34, -9.7, -1.6> <34, 1.6, 1.6> } }
pigment {color rgb <1,0,0>} finish {ambient 1}
}

#declare shutter_with_handle =
difference {
  merge {
    cylinder { -33.9*x, -30*x, 1.5 pigment {color rgb <0,0,1> } finish {ambient
1}}
    cylinder { 30*x, 33.9*x, 1.5 pigment {color rgb <0,0,1> } finish {ambient
1}}
    cylinder { -33.9*x, -30*x, 1.5 translate <0, -8.1, 0> }
    cylinder { 30*x, 33.9*x, 1.5 translate <0, -8.1, 0> }
    sphere { <-30.5, 0, 0> 1 }
    sphere { <30.5, 0, 0> 1 }
    box { <-32, -6.1, -0.9> <-30, 0, 0.9> }
    box { <30, -6.1, -0.9> <32, 0, 0.9> }
    box { <-32.000001, -8.700001, -0.900001> <32.000001, -1.9, 0.900001> }
    cylinder { -32.000002*x, 32.000002*x, 0.9 translate <0, -8.7, 0> }
    difference {
      cylinder { -2.4*z, 2.4*z, 2.3 }
      box { <-3, 0.9, -3> <3, 5, 3> }
      box { <-3, -5, -3> <3, -0.9, 3> }
      translate <0, -4.5, 0>
    }
  }
  box { <-28.8, -8.7, -1> <-15.1, -2.9, -0.3> }
  box { <-14.1, -8.7, -1> <-0.5, -2.9, -0.3> }
  box { <28.8, -8.7, -1> <15.1, -2.9, -0.3> }
  box { <14.1, -8.7, -1> <0.5, -2.9, -0.3> }
  bounded_by { box { <-34, -9.7, -2.5> <34, 1.6, 2.5> } }
  pigment {color rgb <1,0,0>} finish {ambient 1}
}

//The guiding blocks
#macro guiding_h_block1_14()
merge {
  difference {
    box { <-3.9, 0, -3.9> <107.9, 9.5, 3.9> }
    difference {
      box { <-2.4, -1, -2.4> <106.4, 8.6, 2.4> }
      #declare counter = 0;
      #while (counter < 13)
        cylinder { -2*y, 9*y, 1.5 translate <(counter*8)+4, 0, 0> }
      #declare counter = counter + 1;
      #end
      box { <4, 4, -4> <100, 10, -1> }
      difference {
        box { <0.1, -2, -2.4> <7.9, 11, 0> }
        cylinder { -1*y, 9*y, 2.4 translate <0.1, 0, 0> }
        cylinder { -1*y, 9*y, 2.4 translate <7.9, 0, 0> }
      }
      difference {
        box { <0.1, -2, -2.4> <7.9, 11, 0> }
        cylinder { -1*y, 9*y, 2.4 translate <0.1, 0, 0> }
        cylinder { -1*y, 9*y, 2.4 translate <7.9, 0, 0> }
        translate <96, 0, 0>
      }
    }
    box { <2.25, -1, -4> <5.75, 3.500001, -1.9> pigment {color rgb 1 } finish
{ambient 1} }
    box { <98.25, -1, -4> <101.75, 3.500001, -1.9> pigment {color rgb 1 } finish
{ambient 1} }
    box { <7.249999, 4.999999, -4> <96.750001, 8.499999, -1.900001> pigment
{color rgb 1 } finish {ambient 1}}
    intersection {
      difference {
        cylinder { -4*z, -1.900002*z, 5 }
        cylinder { -5*z, 0*z, 1.5  }
      }
      box { <-10, 0, -5> <0, 10, 0> }
      translate <7.25, 3.5, 0>
    }
    intersection {
      difference {
        cylinder { -4*z, -1.900002*z, 5 pigment {color rgb 1 } finish {ambient
1} }
        cylinder { -5*z, 0*z, 1.5  }
      }
      box { <0, 0, -5> <10, 10, 0> }
      translate <96.75, 3.5, 0>
    }
  }
  #declare counter = 0;
  #while (counter < 14)
    difference {
      cylinder { 9.4*y, 11.2*y, 2.3 }
      cylinder { 9*y, 12*y, 1.6 }
      translate <(counter*8), 0, 0>
    }
  #declare counter = counter + 1;
  #end
  pigment {color rgb <0,0,0>} finish {ambient 1}
  bounded_by { box { <-4, -0.1, -4> <108, 11.3, 4> } }
}
#end

#macro guiding_h_block1_2()
merge {
  difference {
    merge {
      box { <-3.9, 0, -3.9> <11.9, 9.5, 3.9> }
      cylinder { 9.4*y, 11.2*y, 2.3 }
      cylinder { 9.4*y, 11.2*y, 2.3 translate <8, 0, 0> }
    }
    box { <2.2, -1, -4> <5.8, 10, -1.9> pigment {color rgb 1 } finish {ambient
1}}
    cylinder { -1*y, 8.6*y, 2.4 }
    cylinder { -1*y, 8.6*y, 2.4 translate <8, 0, 0> }
    box { <-2.4, -1, 2.4> <10.4, 8.6, 0>  }
    box { <-2.4, -1, -2.4> <0, 8.6, 0> }
    box { <8, -1, -2.4> <10.4, 8.6, 0> }
    cylinder { 7.4*y, 10.4*y, 1.2 }
    cylinder { 7.4*y, 10.4*y, 1.2 translate <8, 0, 0> }
  }
  cylinder { 0*y, 8.7*y, 1.5 translate <4, 0, 0> }
  pigment {color rgb <0,0,0>} finish {ambient 1}
  bounded_by { box { <-4, -0.1, -4> <12, 11.3, 4> } }
}
#end



/*****************************************************************/
/*
camera {
  location  <0, 32*8, 24>
  direction 2*z
  up        y
  right     4/3*x
  look_at   <0, 5*8, 24>
} */

camera {
  orthographic
  location <0*8, 5*9.6, -40*8>
  right <15*4/3*8, 0, 0>      // length determines size of view
  up <0, 15*8, 0>             // length determines size of view
  direction <0, 0, 1>              // length isn't used
  look_at <0*8, 5*9.6,0*8 >
}


/****************************************************************/

#macro ShutterBottomPart(Opened)
union
{
    #declare Counter = 0;
    #declare NumberOfShutters= ceil((.9-Opened)*10);
    #if (Opened <0.9)
        #while ( Counter < NumberOfShutters)
            #if ( Counter = 0)
                object {shutter_with_handle translate <0, Counter*8+8,0> }
            #else
                object {shutter translate <0, Counter*8+8,0> }
            #end
            #declare Counter = Counter + 1;
        #end
    #end
}
#end


object {ShutterBottomPart(clock) rotate -90*y translate <0,clock*83.55,0>}


object {guiding_h_block1_2() translate <-4,0,6*8> }
object {guiding_h_block1_2() translate <-4,9.6,6*8> }
object {guiding_h_block1_2() translate <-4,2*9.6,6*8> }
object {guiding_h_block1_2() translate <-4,3*9.6,6*8> }
object {guiding_h_block1_2() translate <-4,4*9.6,6*8> }
object {guiding_h_block1_2() translate <-4,5*9.6,6*8> }
object {guiding_h_block1_2() translate <-4,6*9.6,6*8> }
object {guiding_h_block1_2() translate <-4,7*9.6,6*8> }
object {guiding_h_block1_14() translate <-4-12*8,8*9.6,6*8> }


Post a reply to this message

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