POV-Ray : Newsgroups : povray.general : Illustrating a point ray-trace path : Re: Illustrating a point ray-trace path Server Time
30 Jul 2024 14:24:26 EDT (-0400)
  Re: Illustrating a point ray-trace path  
From: Tim Attwood
Date: 20 Dec 2008 05:19:05
Message: <494cc699$1@news.povray.org>
> Couldn't have done it without ppl like you. Amazing to me that I even 
> caught the
> request.

Indeed! Same here.

#version 3.6;
#include "colors.inc"
#include "rad_def.inc"

global_settings {
  assumed_gamma 1.0
  radiosity {Rad_Settings(Radiosity_Fast, on, off)}
}
camera {
   location  <6.0, 1.5, -35.0>
   direction 1.5*z
   right     x*image_width/image_height
   look_at   <4.0, 1.0,  0.0>
}

// bouncing laser macro by Tim Attwood 12/20/2008
#macro Laser_Trace(mirror_object, start_location, start_direction,
                   beam_radius, tail_length, bounce_limit, laser_texture)
   #local LOC = start_location;
   #local DIR = vnormalize(start_direction);
   #local bounces = 0;
   #local continue = true;
   #while ((continue = true) & (bounce_limit >= bounces))
      #local NORM = <0,0,0>;
      #local HIT = trace(mirror_object,LOC,DIR,NORM);
      #if (vlength(NORM)!=0)
         #local bounces = bounces + 1;
         cylinder{LOC,HIT,0.02
            texture{laser_texture}
         }
         #local DIR = -vaxis_rotate(DIR,NORM,180);
         #local LOC = HIT;
      #else
         cylinder{LOC,LOC+DIR*(tail_length),beam_radius
            texture{laser_texture}
         }
         #local continue = false;
      #end
   #end
#end

#declare laser_red = texture{pigment{Red}finish{ambient 1}};
#declare white_cell = difference {
   cylinder {
      <0,0,-1>,<0,0,1>,1
      open
      scale <5.001,10.001,1>
      pigment {Blue}finish{ambient 0}
   }
   cylinder {
      <0,0,-2>,<0,0,2>,1
      open
      scale <5,10,1>
      texture {
         pigment {White}
         finish {reflection 0.1 ambient 0}
      }
   }
   box{<-0.01,0,-2>,<0.01,100,2>}
}
sphere {0,100 texture{pigment{Black}finish{ambient 0}}}
plane{y,-10.002 pigment {checker Gray50,Tan scale 20}finish{ambient 0}}
object {white_cell}

#local LOC = <0.0,10.1,0>; // laser start point
#local DIR = -vnormalize(LOC-<1.4,-9.6,0>); // laser start direction
Laser_Trace(white_cell, LOC, DIR, 0.02, 40, 1000, laser_red)

// entry laser beam before known location
cylinder {<0.0,10.1,0>,<1.4,-9.6,0>,0.02
   translate <0.0,-10.1,0> rotate <0,0,180> translate <0.0,10.1,0>
   texture{laser_red}
}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.