Author : afisher


Reply
Reply
 
Thread Tools Display Modes
kodde's Avatar
Old (#1)
Hey all,

Sorry if this has been covered, could not find it.

I'm using particles and the Instancer feature to scatter geometry around. I have three different source meshes and I created my own UserScalarPP value that use use as my index value. This value is used to choose which of these three meshes will be used for that specific particle.

0 = mesh1
1 = mesh2
2 = mesh3

Here's my question. How do I get a random feature which should give me an even distribution of probabilities between these three integers?

particleShape1.userScalar1PP = rand(0,2); <- This just gives me a float between 0.00-2.00, which is convereted? to an integer. It does work, but is far from even when it comes to probability.

I've tried the usage of +0.5 together with the Floor() command, but that doesn't give an even probability either right?

Thanks!
Offline , dedicated polycounter, 1,366 Posts, Join Date Dec 2004, Location Malmö, Sweden  
   Reply With Quote

CrazyButcher's Avatar
Old (#2)
you would want [0,3[, so you get even intervals 0-1, 1-2, 2-3
could do 0,2.999999 or to make sure you never get 3 ;)

is there no integer rand? then you could just do rand() % 3;
3dsmax scripts and .fx - pixeljetstream - expressing my own opinions
Offline , dedicated polycounter, 1,346 Posts, Join Date Nov 2004, Location Germany Send a message via ICQ to CrazyButcher  
   Reply With Quote

Surfa's Avatar
Old (#3)
Yeah you are going to want to use rand(0,3) and if the rounding doesn't work you could always implement that yourself with some simple if statements.
Offline , spline, 164 Posts, Join Date Mar 2009,  
   Reply With Quote

kodde's Avatar
Old (#4)
Thanks guys,

So floor(rand(0,3) would work right? Floor will round downwards to the nearest integer right?

Or even floor(rand(0,2.99999).

CrazyButcher> I tried searching for an integer rand earlier, but couldn't find one.

EDIT:
Tried it out this morning and seemed to work good at glance. I did not do any exact measuring though.

Last edited by kodde; 08-31-2011 at 03:57 AM..
Offline , dedicated polycounter, 1,366 Posts, Join Date Dec 2004, Location Malmö, Sweden  
   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright 1998-2012 A. Risch