|
![](/i/fill.gif) |
"Sven Littkowski" <wrt### [at] yahoo com> schreef in bericht
news:web.4218c0d378fbdd6c96ad883b0@news.povray.org...
> Hello everyone,
>
> assuming I placed by random values (rotation and location) a random-amount
> of objects into a scene, how can i prevent these objects sometimes placed
> INTO each other?
>
> How can I establish something like a "security frame" around each object
and
> prevent any other object to be inside that frame?
>
> Thank you in advance,
>
The code below comes from an example file by Christoph Hormann (I think in
POV-Ray's scene files: about trace), somewhat changed by me for my latest
use of it.
The term Spacing is - I believe - what you are looking for. If you make it
at least equal to the largest diameter of your object(s), then there will be
no collision... Not sure about this, but it seems to work that way in my
scenes.
Thomas
//------------ starting code -------------------
#declare Spacing = 0.5;
#declare PosX = -20;
#while (PosX < 20)
#declare PosZ = -20;
#while (PosZ < 20)
// trace function
#declare Norm = <0, 0, 0>;
#declare Start = <PosX+(rand(Seed)-0.5)*Spacing,
UpperBound+Isotrans.y+Isoscale.y+1, PosZ+(rand(Seed)-0.5)*Spacing>;
#declare Pos = trace (
Island01, // object to test
Start, // starting point
-y, // direction
Norm ); // normal
#if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0) // if intersection is
found, normal differs from 0
#if ((vdot(Norm, y)>0.3) & (Pos.y > 9.3) & (Pos.y < 10.5)) //
criteria for placing trees: not too steep and not too high/low
object {
TREE
scale RRand(0.5, 2.0, Seed)
rotate RRand(0, 360, Seed2)*y
//Reorient_Trans (y, Norm)
translate Pos
}
#end
#end
#declare PosZ=PosZ+Spacing;
#end
#declare PosX=PosX+Spacing;
#end
//---------------- ending code ---------------------------
Post a reply to this message
|
![](/i/fill.gif) |