POV-Ray : Newsgroups : povray.general : Objects on a slope : Re: Objects on a slope Server Time
31 Jul 2024 12:26:24 EDT (-0400)
  Re: Objects on a slope  
From: Bruno Cabasson
Date: 12 Mar 2007 08:25:01
Message: <web.45f553c07100fbbdf5fba6ef0@news.povray.org>
"Jim Holsenback" <jho### [at] hotmailcom> wrote:
> 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

Hello Jim.

Before you drop your objects onto the surface, you have to align them with
the normal of the surface at the place you drop. Have a look a
transforms.inc and at the doc on the subject. The Align_Trans() macro could
be helpful. As you sure know, the trace() primitive returns the normal of
the surface encountered.

    Bruno


Post a reply to this message

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