|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi everyone. I need help. I have a scene in which I created an object, so
far it works. At the end of the scene I want to create a random-generated
number how often that object will be placed in the scene (minimum 10x,
maximum 20x), and I also want random-generated locations (x,y,z) and
rotation (again x, y, z axis). That I was not able to do successfully. Who
can help me? Thanks.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
First, initialize a random stream like this:
#declare Random_Value=seed(12345);
Then, whenever you need a random number between 0 and 1, use
rand(Random_Value).
Multiplying that with values and clipping it with either floor() or ceil()
should get you integers. For example, for a random number between 10 and 20,
do this:
#declare Random_Number = floor(10+10*rand(Random_Value));
Consult the documentation about rand() and seed() for more insight. This
post should only get you started. :-)
Regards,
Tim
--
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Sven Littkowski" <wrt### [at] yahoocom> wrote in message
news:web.420a2c0a5473d9f07e561af90@news.povray.org...
> Hi everyone. I need help. I have a scene in which I created an object, so
> far it works. At the end of the scene I want to create a random-generated
> number how often that object will be placed in the scene (minimum 10x,
> maximum 20x), and I also want random-generated locations (x,y,z) and
> rotation (again x, y, z axis). That I was not able to do successfully. Who
> can help me? Thanks.
>
>
Something like:
#declare Rand1 = seed(43552);
#declare ObjCount = int(rand(Rand1)*10)+10;
#declare N = 1;
#while(N<=ObjCount)
object{
cylinder{0,y*2,0.25 pigment{Red}}
rotate<rand(Rand1)*360, rand(Rand1)*360, rand(Rand1)*360>
translate<rand(Rand1)*10-5,rand(Rand1)*10-5,rand(Rand1)*10-5>
}
#declare N=N+1;
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Sven,
In addition to the other postings, you might want to look at:
http://www.wikipov.org/ow.asp?DropOnSurface
This gives an example of random placement and also demonstrates a technique
to allow your random objects to be placed on surfaces that might not be
regular or flat.
Neil
"Sven Littkowski" <wrt### [at] yahoocom> wrote in message
news:web.420a2c0a5473d9f07e561af90@news.povray.org...
> Hi everyone. I need help. I have a scene in which I created an object, so
> far it works. At the end of the scene I want to create a random-generated
> number how often that object will be placed in the scene (minimum 10x,
> maximum 20x), and I also want random-generated locations (x,y,z) and
> rotation (again x, y, z axis). That I was not able to do successfully. Who
> can help me? Thanks.
>
>
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Tim Nikias" <JUSTTHELOWERCASE:timISNOTnikias(at)gmx.netWARE> schreef in
bericht news:420a2f16@news.povray.org...
> First, initialize a random stream like this:
>
> #declare Random_Value=seed(12345);
>
> Then, whenever you need a random number between 0 and 1, use
> rand(Random_Value).
>
> Multiplying that with values and clipping it with either floor() or ceil()
> should get you integers. For example, for a random number between 10 and
20,
> do this:
> #declare Random_Number = floor(10+10*rand(Random_Value));
>
> Consult the documentation about rand() and seed() for more insight. This
> post should only get you started. :-)
>
Consider also the use of RRand(Min,Max,Stream) where you can define your
minimum and maximum values directly.
Thomas
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
FROM THE AUTHOR SVEN LITTKOWSKI:
Thanks to everyone of you all for your nice and helping replies! You all
helped me a lot, and I appreciate it very much. It works well now!
If you are interested to follow up a related question, you can find it
posted in this forum. It is about how to prevent these random-generated
objects are being placed INTO each other.
Sven Littkowski
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|