// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 // By Tor Olav Kristensen, http://subcube.com // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 #version 3.7; #include "colors.inc" #include "skies.inc" #include "transforms.inc" // Or get my Reorient_Trans() from here: // http://news.povray.org/povray.general/thread/%3C48f52373%40news.povray.org%3E/ global_settings { assumed_gamma 1.70 } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 #macro Debug3D(v0) concat("<", vstr(3, v0, ", ", 0, -1), ">") #end // macro Debug3D // 0 <= Fraction <= 1 #macro Interpolate(Fraction, A, B) ((1 - Fraction)*A + Fraction*B) #end // macro Interpolate #macro CalcTimeFraction(tNow, tStart, tEnd) ((tNow - tStart)/(tEnd - tStart)) #end // macro CalcTimeFraction // Somewhat similar to Scott's macro #macro RelativeToCamera(pRelative, pCameraLocation, pCameraLookAt) #local vUp = y; // NB: Take care if the camera is looking up #local vZ = vnormalize(pCameraLookAt - pCameraLocation); #local vX = vnormalize(vcross(vUp, vZ)); #local vY = vcross(vZ, vX); #local vOffset = pRelative.x*vX + pRelative.y*vY + pRelative.z*vZ; #local pOffset = pCameraLocation + vOffset; pOffset #end // macro RelativeToCamera #macro MakeFlashLight(BeamLength) #local L1 = 0.3; #local L2 = 0.1; #local L3 = L1 + L2; #local RF = 0.01; #local R1 = 0.04; #local R2 = 2*R1; #local R3 = R1 - RF; #local Body = union { cone { L1*y, R1, L3*y, R2 } cylinder { 0*y, L1*y, R1 } torus { R3, RF } cylinder { -RF*y, RF*y, R3 } translate -L3*y pigment { color Gray } } #local RB = R2 - R1/4; #local Beam = cylinder { 0*y, BeamLength*y, RB pigment { color 10*White } no_shadow } union { object { Body } object { Beam } } #end // macro MakeFlashLight // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9 #declare MyClock = clock*4; // #declare MyClock = 0.6*4; #declare pCamLoc = <3, 10, 0>; #declare pCamLookAt = <3, 10, 6>; #declare vOffset_0 = < 0, 0, 0>; #declare vOffset_1 = < 2, 2, 0>; #declare vOffset_2 = < 2, -1, -2>; #declare vOffset_3 = <-2, 1, -2>; #declare vOffset_4 = <-2, -2, 2>; #declare R = 0.02; /* #declare p0 = <0, 0, 0>; union { cylinder { p0 + vOffset_0, p0 + vOffset_1, R } cylinder { p0 + vOffset_1, p0 + vOffset_2, R } cylinder { p0 + vOffset_2, p0 + vOffset_3, R } cylinder { p0 + vOffset_3, p0 + vOffset_4, R } pigment { color Yellow } translate pCamLookAt } */ #switch (MyClock) #range(0, 1) #declare F = CalcTimeFraction(MyClock, 0, 1); #declare vOffset = Interpolate(F, vOffset_0, vOffset_1); #break #range(1, 2) #declare F = CalcTimeFraction(MyClock, 1, 2); #declare vOffset = Interpolate(F, vOffset_1, vOffset_2); #break #range(2, 3) #declare F = CalcTimeFraction(MyClock, 2, 3); #declare vOffset = Interpolate(F, vOffset_2, vOffset_3); #break #range(3, 4) #declare F = CalcTimeFraction(MyClock, 3, 4); #declare vOffset = Interpolate(F, vOffset_3, vOffset_4); #break #end // switch #declare pCamLookAt = pCamLookAt + vOffset; sphere { pCamLookAt, 6*R pigment { color Red } } #declare pRelative = <-0.4, -0.3, 0.9>; #declare pFlashLight = RelativeToCamera(pRelative, pCamLoc, pCamLookAt); #declare vLight = pCamLookAt - pFlashLight; #declare LengthBeam = 1e6; // #declare LengthBeam = vlength(vLight); object { MakeFlashLight(LengthBeam) Reorient_Trans(y, vLight) translate pFlashLight } plane { y, 0 texture { checker texture { pigment { color ForestGreen } }, texture { pigment { color White } } } scale 12*<1, 1, 1> } camera { location pCamLoc look_at pCamLookAt angle 90 } light_source { <0, 40, -10> color White } sky_sphere { S_Cloud3 rotate 180*y } // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8 ======= 9