POV-Ray : Newsgroups : povray.advanced-users : Trees on height-field Server Time
29 Jul 2024 08:13:47 EDT (-0400)
  Trees on height-field (Message 1 to 1 of 1)  
From: John Haiducek
Subject: Trees on height-field
Date: 25 Nov 2002 12:38:53
Message: <3de2602d$1@news.povray.org>
I'm trying to place trees on a landscape using the trace() function so
they're only placed in view of the camera.  The script I have places most of
the trees very close to the camera.  Does anyone know how to do this so I
get an even distribution of trees, all within the camera's view?

Here's my code:
#declare i=0;
#declare r1=seed(256);
#declare r2=seed(100);
#declare N=<0,0,0>;
while(i<10000)
  #declare
dir=vaxis_rotate(camera_look_at-camera_location,vcross(camera_look_at-camera
_location,camera_up),(rand(r1)-.5)*camera_angle);
  #declare dir=vaxis_rotate(dir,camera_up,(rand(r1)-.5)*camera_angle*4/3);
  #declare X=trace(terrain,camera_location,dir,N);
  #if(vlength(N)>0)
      object{
        cone{0,1.5,7*y,0 pigment{rgb <0,1,0>} scale .5+.5*rand(r1) translate
X}
      }
  #end
  #declare N=<0,0,0>;
  #declare i=i+1;
#end


Post a reply to this message

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