POV-Ray : Newsgroups : povray.general : Objects on a slope : Objects on a slope Server Time
31 Jul 2024 12:23:24 EDT (-0400)
  Objects on a slope  
From: Jim Holsenback
Date: 12 Mar 2007 07:43:50
Message: <45f54b06@news.povray.org>
Hello,

I trying to place objects on the slope of a height_field. From the 
documentation I was able to figure out how to get the "Y" direction problem 
solved by using the trace command to place the objects, but now another 
issue has cropped up. Some of the objects are partically covered (see 
attached image). I'm wondering if if vrotate (A,B) A being the camera 
location, and B.z or B.x is would fix this. I'm having a problem figuring 
how to intergrate that into what I've already done. Pointers appreciated 
better than an actual solution as I'll end up understanding it better.

Thanks Jim
----

#macro PlaceDBs (Target, Location, Object)

  #local Dither = 1;
  #while (Dither)
    #local DFactor = 1 * rand(Rand);
    #if (DFactor >= 0.75 & DFactor <= 1)
      #local Dither = 0;
    #end
  #end

  #local Norm = <0, 0, 0>;
  #local Start = <0, 10, 0>;
  #local Intercept = trace (Target, Start, Location-Start ,Norm);

  #if (vlength(Norm) != 0)
    object {Object rotate y*(360 * DFactor) scale (0.1 * DFactor) translate 
Intercept}
  #end

#end

// -----

#declare NumberOfObjects = 50;
#declare Collision = 0.6;
#declare ObjectBox = <-5,0,-5>;
#declare Locations = array[NumberOfObjects];
#declare Rand = seed(49+16+80+87+33+5);

#declare i = 0;

#while (i < NumberOfObjects)
  #declare Locations[i] = (<rand(Rand),rand(Rand),rand(Rand)> - 0.5) * 
ObjectBox;
  #declare TooClose = 0;
  #declare j = 0;

  #while (j < i)
    #if (vlength(Locations[i] - Locations[j]) < Collision)
      #declare TooClose = 1;
      #declare j = i;
    #end
    #declare j = j + 1;
  #end

  #if (TooClose = 0)
    PlaceDBs (Terrain, Locations[i], DogBerries)
    #declare i = i + 1;
  #end
#end


Post a reply to this message


Attachments:
Download 'scratch.jpg' (42 KB)

Preview of image 'scratch.jpg'
scratch.jpg


 

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