POV-Ray : Newsgroups : povray.general : Random Object Placement Server Time
31 Oct 2024 23:31:04 EDT (-0400)
  Random Object Placement (Message 1 to 4 of 4)  
From: Sven Littkowski
Subject: Random Object Placement
Date: 20 Feb 2005 11:55:00
Message: <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,

Sven Littkowski


Post a reply to this message

From: Ross
Subject: Re: Random Object Placement
Date: 20 Feb 2005 15:54:39
Message: <4218f90f@news.povray.org>
Sven Littkowski wrote:

> 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,
> 
> Sven Littkowski

As someone mentioned to your previous post on the subject, you could try a
combination of min_extent, max_extent and trace. as far as I know,
min_extent and max_extent have to do with finding the coordinates of the
objects bounding box, which is sort of a security frame. But you really
can't avoid math when doing collision detection in povray, because it has
no built in push-button approach. There have been people who do similar
things, you might want to try searching the povray news forums through the
web interface http://www.povray.org/search/

good luck!


Post a reply to this message

From: Thomas de Groot
Subject: Re: Random Object Placement
Date: 22 Feb 2005 08:59:00
Message: <421b3aa4@news.povray.org>
"Sven Littkowski" <wrt### [at] yahoocom> 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

From: Sven Littkowski
Subject: Re: Random Object Placement
Date: 24 Feb 2005 08:00:00
Message: <web.421dcfb11dea58a0f98c4a480@news.povray.org>
Thomas,

thank you very much for your help. I am going to try it out.

I also want to express my appreciation for all other replies. Thanks to
everyone!

Sven Littkowski


Post a reply to this message

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