File talk:Drawbridge.gif

来自Wikimedia Commons
跳转到导航 跳转到搜索

POV-Ray source file

[编辑]

To render the scene file below, an include file (puppet.inc) is required.

//movable bridge -- 11:catsle drawbridge
//for POV-Ray3.6 (created by MacMegaPOV)
//by Y tambe
//You can use this source file under either GFDL or CC-by-sa (dual license)
//You can use the images you render as free.

#include "puppet.inc"

//camera
camera {
    angle 15
    location <0.0, 0.0, 60>
    look_at <0.0, 0.0, 0.0>

    rotate -20*x
    rotate -25*y
    translate 2*y
}

//lights
light_source {//main light
    <-20, 50,10>
    rgb <1, 1, 1>
    shadowless
}
light_source {//sub
    <0, 0,100>
    rgb <1, 1, 1>*.2
    shadowless
}
light_source {//sub
    <-50, -50,-50>
    rgb <1, 1, 1>*.2
    shadowless
}

//for animation

#declare counter = clock;
#declare mix = clock;

#switch (clock)
    #range (0.0, 0.25)
        #declare counter = (0.25-clock)*4;
        #declare mix = 1;
        #break
    #range (0.25, 0.3)
        #declare counter = 0;
        #declare mix = (0.3-clock)*20;
        #break
    #range (0.3, 0.65)
        #declare counter = 0;
        #declare mix = 0;
        #break
    #range (0.65, 0.75)
        #declare counter = 0;
        #declare mix = (clock-0.65)*10;
        #break
    #range (0.75, 1.0)
        #declare counter = (clock-0.75)*4;
        #declare mix = 1;
        #break
    #default
        #declare counter = 0;
        #declare mix = 0;
        #break
#end



//chainpos
#declare chainPos = array[21][3];

#declare a=0;
#while (a<21)
    #declare chainPos[a][0] =<a/20, a/20,0>;
    #declare chainPos[a][1] =<a/20, (cosh(a/20*1)-1)/(cosh(1)-1),0>;

    #declare chainPos[a][2] = chainPos[a][0] *mix + chainPos[a][1]*(1-mix);

    #declare a=a+1;
#end


//puppetPos
        #declare puppetPos = 5-2.5*(clock-0.30)*10;
        #declare walk = sin( (clock-0.30)*2*pi*6);
        #declare pAngle = array[6] {15*walk, -10*walk, 30*walk,-30*walk,-60*walk,60*walk};

//
//#declare counter = 1;
//
#declare bridgeTexture = texture{
    pigment{color rgb <0.8,0.0,0.2>}
    finish{ambient 0.2 diffuse 0.8}
}

#declare roadTexture = texture{
    pigment{color rgb 0.6}
    finish{ambient 0.2 diffuse 0.8}
}

//movable parts

union{
    box{<0,0.0,-2>, <-7, -0.25, 2>}
    rotate -88*counter*z
    translate 4*x
    texture{bridgeTexture}    
}

//chain

union{

#if (counter=0)
    #declare a=0;
    #while (a<20)
        cylinder{ <chainPos[a][2].x*6.5, chainPos[a][2].y*6.5, -1.8>, <chainPos[a+1][2].x*6.5, chainPos[a+1][2].y*6.5, -1.8>, 0.05}
        cylinder{ <chainPos[a][2].x*6.5, chainPos[a][2].y*6.5, 1.8>, <chainPos[a+1][2].x*6.5, chainPos[a+1][2].y*6.5, 1.8>, 0.05}
        #declare a=a+1;
    #end
    translate -2.5*x
#else
    cylinder{<0.1,6.9,-1.8>, vaxis_rotate(<-6.5,0,-1.8>, z, -88*counter),0.05 translate 4*x}
    cylinder{<0.1,6.9,1.8>, vaxis_rotate(<-6.5,0,1.8>, z, -88*counter),0.05 translate 4*x}
#end
    texture{
        pigment{ color rgb 0.3}
        finish{ambient 0.4 diffuse 0.6}
    }
}


//static parts and road

difference{
    box{ <9, 10, 999>, <3.75, -0.5, -999> }
    box{ <10, 7.2, 2.1>, <0, -1, -2.1>}
    texture {
        pigment{brick color rgb <0.7, 0.6, 0.5> color rgb <0.8, 0.8, 0.6> turbulence 0.5 scale <0.15, 0.15, 0.32> }
        finish{ambient 0.7 diffuse 0.3}
    }
}

difference{
    box{ <8, 9, 999>, <4.05, -0.5, -999> }
    box{ <10, 4, 1.2>, <0, 0, -1.2> }
    cylinder{ <10, 4, 0>, <0, 4,0>, 1.2}
    texture{
        pigment{color rgb <0.75, 0.65, 0.55>}
        normal{dents 1 scale 0.2}
        finish{ambient 0.4 diffuse 0.6}
    }
}

//ground
union{
    difference{
        blob{threshold 0.5
            cylinder{ <0,0,-99>, <0,0,99>, 2,1 translate <0,-1,0>}
            cylinder{ <0,0,0>, <-1,0,0>, 4,0.6}
            scale <1.5,1,1>
            translate <-2,0,0>
        }
        box{ <9,0,-999>, <-9,4,999>}
    }
    box{<-2,0,-99>,<-9,-9,99>}
    translate <-2.5, -0.25,0>
    texture{
            pigment{color rgb <0.3,0.5,0.1>}
            finish{ambient 0.2 diffuse 0.8}
            normal{bozo 5 scale 0.2}
        }
}

union{
    difference{
        blob{threshold 0.5
            cylinder{ <0,0,-99>, <0,0,99>, 2,1 translate <0,-1,0>}
            cylinder{ <0,0,0>, <-1,0,0>, 4,0.5}
            scale <1.5,1,1>
            translate <-2,0,0>
        }
        box{ <9,0,-999>, <-9,4,999>}
    }
    box{<-2,0,-99>,<-9,-9,99>}
    rotate 180*y
    translate <2.5, -0.25,0>
    texture{
            pigment{color rgb <0.3,0.5,0.1>}
            finish{ambient 0.2 diffuse 0.8}
            normal{bozo 5 scale 0.2}
        }
}

object {puppet(pAngle[0], pAngle[1], pAngle[2], pAngle[3], pAngle[4], pAngle[5])
    translate (1.85+0.15+0.5)*y
    scale 0.25
    rotate -90*y
    translate <puppetPos,0,0>
    #if (puppetPos<-3)
        translate -0.25*y
    #end
}

plane{y,-4
    texture{
        pigment{color rgbt <.3,.6,1,0>}
        finish{ambient 0.5 diffuse 0.7}
        normal{
            bozo 5
            scale <0.2,0.2,1>
            }
        }
}

include_file

[编辑]
//puppet.inc  --a simple human model, likely so call LEGOMAN, for puppet animation
//for POV-Ray3.6 (created with MacMegaPOV)
//by Y tambe
//You can use this source file under either GFDL or CC-by-sa (dual license)
//You can use the images you render as free.

#macro puppet(Neck,Waist,RightFoot,LeftFoot,RightArm,LeftArm)    

#ifndef(Neck)
    #declare Neck = 0;
#end

#ifndef(Waist)
    #declare Waist = 0;
#end

#ifndef(RightFoot)
    #declare RightFoot = 0;
#end

#ifndef(LeftFoot)
    #declare LeftFoot = 0;
#end

#ifndef(LeftArm)
    #declare LeftArm = 0;
#end

#ifndef(RightArm)
    #declare RightArm = 0;
#end

#ifndef(SkinTexture)
    #declare SkinTexture=
        texture{
            pigment{color rgb <1,0.9,0.6>}
            finish{ambient 0.4 diffuse 0.6}
        }
#end

#ifndef(HandTexture)
    #declare HandTexture=
        texture{
            pigment{color rgb <1,0.9,0.6>}
            finish{ambient 0.4 diffuse 0.6}
        }
#end

#ifndef(HairTexture)
    #declare HairTexture=
        texture{
            pigment{color rgb <0.4,0.2, 0.1>}
            finish{ambient 0.4 diffuse 0.6}
        }
#end

#ifndef(BodyTexture1)
    #declare BodyTexture1=
        texture{
            pigment{color rgb <0.2,0.2,0.6>}
            finish{ambient 0.4 diffuse 0.6}
        }
#end

#ifndef(BodyTexture2)
    #declare BodyTexture2=
        texture{
            pigment{color rgb 0.5}
            finish{ambient 0.4 diffuse 0.6}
        }
#end

#ifndef(FootTexture1)
    #declare FootTexture1=
        texture{
            pigment{color rgb <0.2,0.6,0.2>}
            finish{ambient 0.4 diffuse 0.6}
        }
#end

#ifndef(FootTexture2)
    #declare FootTexture2=
        texture{
            pigment{color rgb 0.2}
            finish{ambient 0.4 diffuse 0.6}
        }
#end

#ifndef(ArmTexture)
    #declare ArmTexture=
        texture{
            pigment{color rgb <0.2,0.2,0.6>}
            finish{ambient 0.4 diffuse 0.6}
        }
#end

//head
#declare head=
union{
    //face
    union{
        sphere{<0,0,0>,1 scale<1,0.75,1> translate <0,0.75,0> }
        sphere{<0,0,0>,1 scale<1,0.75,1>}
        cylinder{<0,0.75,0>,<0,0,0>,1}
        //neck
        cylinder{<0,0.5,0>,<0,-1,0>,0.3}
        texture{SkinTexture}
    }
    //hair
    intersection{
        union{
            sphere{<0,0,0>,1 scale<1,0.75,1> translate <0,0.75,0> }
            sphere{<0,0,0>,1 scale<1,0.75,1>}
            cylinder{<0,0.75,0>,<0,0,0>,1}
        scale 1.05
        }
        union{
            cylinder{<0,0,1.2>,<0,0,-1.2>, 1.5 translate <1,1.7,0>}
            cylinder{<0,0,1.2>,<0,0,-1.2>, 1.5 translate <-1,1.7,0>}
            cylinder{<1.2,0,0>, <-1.2,0,0>,1.65 translate<0,1,-1>}
        }
        texture{HairTexture}
    }
}

//body
#declare body_front=
intersection{
    superellipsoid{<0.2,0.2>
    matrix <    1.0, 0.0, 0.0,
                0.1, 1.0, -0.25,
                0.0, 0.0, 1.0,
                0.0, 0.0, 0.0>
    }
    box{<0,-1.2,0>,<-1.2,1.2,1.2>}
}

#declare body_back=
intersection{
    superellipsoid{<0.2,0.2>
    matrix <    1.0, 0.0, 0.0,
                0.1, 1.0, 0.1,
                0.0, 0.0, 1.0,
                0.0, 0.0, 0.0>
    }
    box{<0,-1.2,0>,<-1.2,1.2,-1.2>}
}


#declare body1=
union{
    object{ body_front}
    object{ body_front
    matrix <-1,0,0,
                0,1,0,
                0,0,1,
                0,0,0>
    }
    object{ body_back}
    object{ body_back
    matrix <-1,0,0,
                0,1,0,
                0,0,1,
                0,0,0>
    }
    texture{BodyTexture1}
}

#declare body2=
union{
    difference{
        superellipsoid{<0.1,0.1> scale <0.95,0.95,0.7> translate<0,-0.4,0>}
        plane{-y,0.8}
        cylinder{<-1.1,0,0>,<1.1,0,0>, 0.6 translate<0,-1.5,0>}
    }
    cylinder{<-0.1,0,0>,<0.1,0,0>, 0.6 translate<0,-1.5,0>}
        
    texture{BodyTexture2}
}

#declare foot=
union{
    cylinder{<0.1,0,0>,<0.95,0,0>, 0.6}
    superellipsoid{<0.25,0.25>    
        translate <1,1,1>
        scale <0.4,1,0.55>
        translate <0.1,-2,-0.55>
    }
    superellipsoid{<0.2,0.2>    
        translate <1,-1,1>
        scale<0.45, 0.25, 0.8>
        translate <0.05, -1.6, -0.575>
        
        texture{FootTexture2}
    }
    texture{FootTexture1}
}

//arm
#declare arm=
union{
    union{
        union{
            sphere{ <0,0,0>, 0.4}
            cylinder{ <0,0,0>, <0,-0.7,0> ,0.4}
            sphere{ <0,-0.7,0>, 0.4}
            translate <0,0.7,0>
            rotate 30*x
        }
        cylinder{ <0,0,0>, <0,-1,0> ,0.4}
        //hand
        sphere{ <0,-1.3,0>, 0.35
            texture{HandTexture}
        }
        rotate -30*x
        translate <0,-0.7,0>
        rotate 15*x
        rotate -20*z
    }
    cylinder{<0,0,0>, <1,0,0>, 0.4}
    translate <-1.1,0,0>
    texture{ArmTexture}
}

//
union{
    union{
        object{head
            rotate Neck*y
            translate <0,3.3,0>
        }
        union{
            object{arm rotate LeftArm*x}
            object{arm 
                matrix <-1,0,0,
                            0,1,0,
                            0,0,1,
                            0,0,0>
                rotate RightArm*x}
             translate <0,2.0,0>
        }
        object{body1 translate <0,1.5,0>}
        rotate Waist*y
    }
    
    object{body2 translate <0,1.5,0>}

    object{foot rotate RightFoot*x}
    object{foot 
        matrix <-1,0,0,
                    0,1,0,
                    0,0,1,
                    0,0,0>
    rotate LeftFoot*x}

    }

#end