// Persistence Of Vision raytracer version 3.5 sample file. // File: splinefollow.pov // Desc: Spline demo animation that shows how to make an object // fly along a spline. This is a cyclic animation. // Date: August 30 2001 // Auth: Rune S. Johansen // +kff30 +kc #include "math.inc" #include "transforms.inc" #declare ShowPath = no; camera { location <2,12,-10> look_at <0,2,3> } light_source {<1,3,-2>*1000, color 1} plane { // checkered plane y, 0 pigment {checker color rgb 1.0, color rgb 0.9} } cylinder { // start/stop location 0, y, 2 pigment {color <1,0,0>} } torus { // yellow ring 1.2, 0.3 pigment {color <1,1,0>} rotate 90*x rotate 45*y translate <5,3,0> } cylinder { // green pole 0, 7*y, 0.4 pigment {color <0,1,0>} translate 7*z } torus { // blue ring 1.2, 0.3 pigment {color <0,0,1>} rotate 90*x rotate -45*y translate <-5,3,0> } #declare MySpline = spline { cubic_spline -1, <-2, 2, 0>, // control point 00, < 0, 2, 0>, // start 01, < 2, 2, 0>, 02, < 5, 3, 0>, // through yellow ring first time 02.5, < 7, 3, 0>, 04.5, < 5, 3,-2>, 05, < 5, 3, 0>, // through yellow ring second time 06, < 5, 5, 5>, 07, < 0, 5, 9>, // around 08, <-2, 4, 5>, // the 09, < 2, 3, 5>, // green 10, < 0, 2, 9>, // pole 11, <-5, 2, 5>, 12, <-5, 3, 0>, // through blue ring first time 12.5, <-5, 3,-2>, 14.5, <-7, 3, 0>, 15, <-5, 3, 0>, // through blue ring second time 16, <-2, 2, 0>, 17, < 0, 2, 0>, // stop 18, < 2, 2, 0>, // control point } // Fly_Along_Spline macro // // usage: object { MyObject Fly_Along_Spline( ... ) } // The Z axis of the object will point forward and the Y axis // of the object will point upwards. // // Spline: The spline to fly along. // // Time: The time value to feed to the spline, for example clock. // // SkyVector: The vector that is upwards in your scene, usually y. // // ForeSight: How much in advance of the object will turn. // // Banking: How much the object tilts when turning. Note that the amount // of tilting is equally much controlled by the ForeSight value. // #macro Fly_Along_Spline (Spline, Time, SkyVector, ForeSight, Banking) #local Location = <0,0,0>+Spline(Time); #local LocationNext = <0,0,0>+Spline(Time+ForeSight); #local LocationPrev = <0,0,0>+Spline(Time-ForeSight); #local Forward = vnormalize(LocationNext-Location); #local Right = VPerp_To_Plane(SkyVector,Forward); #local Up = VPerp_To_Plane(Forward,Right); #local Transform = Matrix_Trans(Right,Up,Forward,Location) #local Banking = VRotationD( (LocationNext-Location), (Location-LocationPrev), Up )*Banking; rotate Banking*z transform {Transform} #end #declare AirCraft = union { cone { -z, 1, 2*z, 0.1 scale <0.7,0.4,0.7> pigment {color rgb 1} } sphere { 0.3*y, 0.3 scale <1,1,1.5> pigment {color <0,0,1>} } } object { AirCraft Fly_Along_Spline (MySpline, (clock/3 + 0/3) *17, y, 0.1, 3) } object { AirCraft Fly_Along_Spline (MySpline, (clock/3 + 1/3) *17, y, 0.1, 3) } object { AirCraft Fly_Along_Spline (MySpline, (clock/3 + 2/3) *17, y, 0.1, 3) } #if (ShowPath=yes) #declare C = 0; #declare Cmax= 100; #while (C<=Cmax) #declare Value = C/Cmax*17; sphere {MySpline(Value), 0.2 pigment {color <1,1,0>}} #declare C = C+1; #end #end