POV-Ray : Newsgroups : povray.text.scene-files : Me walking! Server Time
25 Dec 2024 13:02:53 EST (-0500)
  Me walking! (Message 1 to 1 of 1)  
From: John Bauman
Subject: Me walking!
Date: 2 Sep 1999 20:39:08
Message: <37cf18ac@news.povray.org>
This is the source code for having part of myself walk.
The macro "walk" is generic and returns the angle of joints at
stage mclock(value: 0 to 1), so you could use it if you have any
walking animations of your own.




#macro walk (time,lhip,rhip,lknee,rknee,lankle,rankle)
 #if (mclock <= .5)
         #declare rhip = 15 - (60*mclock)
         #declare rknee = 0
         #declare rankle = -17 + (34*mclock)
 #else
         #if (mclock <= .75)
                 #declare clock2 = (mclock -.5) *4
                 #declare rhip =  -15 + (25*clock2)
                 #declare rknee = 60 * clock2
                 #declare rankle = 0
         #else
                 #declare clock2 = (mclock - .75) *4
                 #declare rhip = 10 + (5*clock2)
                 #declare rknee = 60 - (clock2 * 60)
                 #if (mclock > .85)
                         #declare  rankle = (.85 - mclock) * 100
                         //#warning "hi"rankle
                 #end

         #end
 #end
 #if (mclock <= .5)
         #if (mclock <= .25)
                 #declare clock2 = (mclock) *4
                 #declare lhip =  -15 + (25*clock2)
                 #declare lknee = 60 * clock2
                 #declare lankle = 0
         #else
                 #declare clock2 = (mclock - .25) *4
                 #declare lhip = 10 + (5*clock2)
                 #declare lknee = 60 - (clock2 * 60)
                 #if (mclock > .35)
                         #declare  lankle = (.35 - mclock) * 100
                         //#warning "hi"rankle
                 #end

         #end

 #else
         #declare clock2 = (mclock - .5) *2
         #declare lhip = 15 - (30*clock2)
         #declare lknee = 0
         #declare lankle = -17 + (17*clock2)
 #end
#end



#macro john (lhip,rhip,lknee,rknee,lankle,rankle)
 union {//me!
  union {//upper body
          cylinder {file://hips
                 <-4.5,0,0>
                 <4.5,0,0>
                 .5
         }
         sphere {//left hip
                 <6,0,0>
                 1.5
         }
         sphere {//right hip
                 <-6,0,0>
                 1.5
         }
         cylinder {//back
                 <0,0,0>
                 <0,17,0>
                 .5
         }
         sphere {//head
                 <0,21,0>
                 4
         }
 }

 union {//left leg
  cylinder {    //left upper leg
          <4.5,0,0>
          <4.5,-12,0>
          .5
  }
  union {//lower left leg
          cylinder {     //left lower leg
                  <4.5,-15,0>
                  <4.5,-28,0>
                  .5
          }
          sphere { //left knee
                  <4.5,-13.5,0>
                  1.5
          }
          sphere {  //left ankle
                  <4.5,-29.5,0>
                  1.5
          }
          cylinder { ://left foot
                  <4.5,-29.5,-1.5>
                  <4.5,-29.5,-9.5>
                  .5
                  translate y *29.5
                  rotate lankle * x
                  translate y * -29.5
          }
          translate y *13.5
          rotate -lknee * x
          translate y * -13.5
  }
  rotate lhip * x
 }
 union {//right leg
  cylinder {    //right upper leg
          <-4.5,0,0>
          <-4.5,-12,0>
          .5
  }

  union {//lower right leg

          cylinder {     //right lower leg
                  <-4.5,-15,0>
                  <-4.5,-28,0>
                  .5
          }
          sphere { //right knee
                  <-4.5,-13.5,0>
                  1.5
          }
          sphere { //right ankle
                  <-4.5,-29.5,0>
                  1.5
          }
          cylinder { //right foot
                  <-4.5,-29.5,-1.5>
                  <-4.5,-29.5,-9.5>
                  .5
                  translate y *29.5
                  rotate rankle * x
                  translate y * -29.5
          }
          translate y *13.5
          rotate -rknee * x
          translate y * -13.5
  }
   rotate rhip * x
 }
 pigment {color rgb <1,1,1>}

}
#end
// #declare f= mod(2, 1)








#declare c = 9
/*#declare calc = clock * c     //fake modulus operator, time setup
#declare cyc = 0
#while (calc > 1)
        #declare calc = calc - 1
        #declare cyc = cyc + 1
#end
#declare mclock = calc
*/
#declare mclock = mod(clock*c,1)
#declare cyc = int(clock*c)
#declare rhip = 0
#declare lhip = 0
#declare rknee = 0
#declare lknee = 0
#declare lankle = 0
#declare rankle = 0


walk (mclock,lhip,rhip,lknee,rknee,lankle,rankle) //get joint position

object {john (lhip,rhip,lknee,rknee,lankle,rankle)     //create me
        rotate y*90
        translate <-((cyc-1+mclock)*24),0,0>
}


camera {
        location <-00,0,-200>
        look_at <0,0,0>
}
light_source {<0,0,-100>,rgb <1,1,1>}
plane {
        <0,1,0>,-31
        pigment {color rgb <.5,.5,.5>}
}


Post a reply to this message

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