// several different gold colors, finishes and textures
#include "golds.inc"
#include "finish.inc"
#include "metals.inc"

//torso
#declare shoulderw=.55;
#declare shoulderh=.1;
#declare hipw=.4;
#declare hiph=.1;
#declare torsoh=.8;
#declare torsot=.3;
#declare torso=union{
     cone { <0, 0, 0>, hipw/2, <0, torsoh, 0>, shoulderw/2 }
     intersection{sphere{0,hipw/2} box{-hipw/2,hipw/2*(z+x)} scale<1,hiph/(hipw/2),1>}
     intersection{sphere{0,shoulderw/2} box{shoulderw/2,-shoulderw/2*(z+x)}  scale<1,shoulderh/(shoulderw/2),1> translate torsoh*y}
     scale <1,1,torsot/shoulderw>
}

//leg
//all radii
#declare hipb=.1;
#declare thightop=.07;
#declare thighbot=.05;
#declare thighlen=.6;
#declare kneeb=.07;
#declare calftop=.05;
#declare calfbot=.03;
#declare calflen=.45;
#declare ankleb=.03;
#declare footl=.2;
#declare footw=1.8*ankleb;
#declare leg=union{
     union{              //thigh
          sphere{0,hipb}
          cone{0,thightop,-thighlen*y,thighbot}
          sphere{-thighlen*y,kneeb}
     }
     union{              //calf and foot
          cone{0,calftop,-calflen*y,calfbot}
          sphere{-calflen*y,ankleb}
          intersection{
               cone{z*ankleb,footw,-footl*z,.6*footw}
               box{footw*(x+y+z),-footw*x-footl*z}
               translate -y*(calflen+ankleb)
          }     
     translate -y*thighlen     
     }

}
//arm
//all radii
#declare shoulderb=.10;
#declare uarmtop=.08;
#declare uarmbot=.05;
#declare uarmlen=.45;
#declare elbowb=.07;
#declare farmtop=.05;
#declare farmbot=.03;
#declare farmlen=.4;
#declare wristb=.04;
#declare handl=.2;
#declare Larm=union{
     union{              //upper arm
          sphere{0,shoulderb}
          cone{0,uarmtop,-uarmlen*y,uarmbot}
          sphere{-uarmlen*y,elbowb}
     }
     union{              //forearm and hand
          cone{0,farmtop,-farmlen*y,farmbot}
          sphere{-farmlen*y,wristb}
          cone{0,1.5*wristb,-handl*y,1.0*wristb 
               scale <.3,1,1> translate -farmlen*y}
          rotate x*15
          translate -y*uarmlen     
     }

}
#declare Rarm=union{
     union{              //upper arm
          sphere{0,shoulderb}
          cone{0,uarmtop,-uarmlen*y,uarmbot}
          sphere{-uarmlen*y,elbowb}
     }
     union{              //forearm and hand
          cone{0,farmtop,-farmlen*y,farmbot}
          sphere{-farmlen*y,wristb}
          cone{0,1.5*wristb,-handl*y,1.0*wristb 
               scale <.3,1,1> translate -farmlen*y}
          rotate x*40
          translate -y*uarmlen     
     }

}

//neck and head
#declare necklen=.05;
#declare neckrad=.08;
#declare headrad=.13;
#declare eyerad=.020;
#declare socrad=.025;
#declare socaz=10;
#declare socal=20;
#declare mouthw=.05;
#declare mouthh=.02;
#declare maz=-25;
#declare eyetxt=texture{
     pigment{color rgb <0,.0,.2>}
     finish{Glossy}
     //finish{ambient .2 diffuse .2 phong .6}
}

#declare face=union{
     difference{
          sphere{0,headrad texture{T_Gold_1C}}
          sphere{-z*headrad,socrad rotate x*socaz rotate y*socal texture{T_Gold_1C}}
          sphere{-z*headrad,socrad rotate x*socaz rotate -y*socal texture{T_Gold_1C}}
          box{mouthw*(x+2*z)/2,-mouthw*(x+z)/2-mouthh*y translate -z*headrad rotate x*maz texture{T_Chrome_1A}}
          
     }
          sphere{-z*(headrad-socrad/2),eyerad rotate x*socaz rotate y*socal texture{eyetxt}}
          sphere{-z*(headrad-socrad/2),eyerad rotate x*socaz rotate -y*socal  texture{eyetxt}}
}

#declare head=union{
     cone{0,neckrad,necklen*y,neckrad*.8 texture{T_Gold_1C}}
     object{face translate y*(necklen+headrad*.9)}
     
}     






#declare body=union{
     object{torso texture{T_Gold_1C}}
     object{leg texture{T_Gold_1C} translate -(hipw-hipb)/2*x-hipb/2*y}
     object{leg texture{T_Gold_1C} translate +(hipw-hipb)/2*x-hipb/2*y }
     object{Rarm texture{T_Gold_1C} rotate x*90 rotate z*-10 translate -(shoulderw-.0*shoulderb)/2*x+torsoh*y }
     object{Larm texture{T_Gold_1C} rotate z*10 translate (shoulderw-.0*shoulderb)/2*x+torsoh*y }
     object{ head translate y*(torsoh+shoulderh)}
translate (thighlen+calflen+ankleb)*y
}

