#version 3.7; #include "colors.inc" #include "skies.inc" global_settings{assumed_gamma 1.70} #debug concat("@@F:", str(frame_number,0,0), "\n") // Move a Vector from, to, increment #macro MoveV(_from, _to, __i) <_from.x+((_to.x-_from.x)*__i), _from.y+((_to.y-_from.y)*__i), _from.z+((_to.z-_from.z)*__i)> #end // Animate this segment of the clock from 0 to 1 #macro AniSegment(_start, _end) ((myclock-_start)/(_end-_start)) #end // return a vector as a debug string (truncated precision) #macro vdebug(vec) concat("<", str(vec.x,0,2), ", ",str(vec.y,0,2), ", ", str(vec.z,0,2), ">") #end // Convert this vector into its angle #macro VtoA(V) #local _V=vnormalize(V); #local rZ=degrees(acos(_V.z)); #local rY=0; #if (_V.y != 0) #local rY=degrees(atan2(_V.x,_V.y)); #end #debug concat("rY/Z=", str(rY,0,3), ", ", str(rZ,0,3), "\n") <-rZ,0,-rY> #end #declare myclock=clock*4; #declare Camera=<0,10,0>; #declare Lookat=<0,10,1>; // swivel up and down around the camera #local loffset0=<2,2,0>; #local loffset1=<2,-1,-2>; #local loffset2=<-2,1,-2>; #local loffset3=<-2,-2,2>; #switch (myclock) #range(0,1) #local _i=AniSegment(0,1); #declare Lookat=Lookat+MoveV(<0,0,0>,loffset0,_i); #break #range(1,2) #local _i=AniSegment(1,2); #declare Lookat=Lookat+MoveV(loffset0,loffset1,_i); #break #range(2,3) #local _i=AniSegment(2,3); #declare Lookat=Lookat+MoveV(loffset1,loffset2,_i); #break #range(3,4) #local _i=AniSegment(3,4); #declare Lookat=Lookat+MoveV(loffset2,loffset3,_i); #break #end #debug concat("Lookat=", vdebug(Lookat), "\n") #local V=vnormalize(Lookat-Camera); sphere {V+Camera,0.02 pigment {Red}} #local foo=<0,0,10>; #local fooVec=Lookat-Camera; #local fooRot=VtoA(fooVec); #local foof=vrotate(foo, fooRot); #debug concat ("fooRot=", vdebug(fooRot), "\n") sphere {foof+Camera, 0.5 pigment {Cyan}} #debug concat ("foof=", vdebug(foof), "\n") #local bar=<1,0,10>; //#local barRot=VtoA(bar-Camera); #local bar=vrotate(bar, fooRot); sphere {bar+Camera, 0.51 pigment {Green}} #debug concat ("bar=", vdebug(bar), "\n") camera { location Camera look_at Lookat } light_source {<0,20,0> rgb 1} sky_sphere { S_Cloud3 rotate y * 180} plane { y, 0 texture { checker texture { pigment {ForestGreen} }, texture { pigment{White} } } scale 12 } #debug "@@end\n"