random box creator

Hi all,

I need some help. I'm fairly new to MaxScript and I have a site plan (as a editable poly plane) and I want to populate it randomly with boxes. These boxes represent different uses of the building proposal, there are 8 in total. Although the cross sectional area of the boxes can be random the overall volume of each of the boxes has to be a fixed amount.

For example one box will be a workshop so have a volume of 150 cubic metres, and another box will be a shop and therefore require a volume of only 50 cubic metres and so on.

I'm ok with creating the rollout dialog with the buttons (one for each different use) and creating a randomly sized box with a fixed height but a variable length and width but am not sure about a couple of things:

How does one ensure that the volume remains a constant?
How can I ensure that the boxes created sit within the site boundary poly?

Any help would be hugely helpful.

Thanks

Ben

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
PerfectCell's picture

.

For the volume you'll need to make sure the length x width x height = your desired volume,. If you're fixing the height, subtract that from your volume. Then with that remaining amount determine a random number within that amount (or an amount you set that is within that amount, but not too large or small) which could be the width, then whatever value is left could be the length.

i.e. length = volume - height(defined) - width(random)

As for the boundary. When setting the random position for the boxes just make it so that the x,y values stay between a set amount, such as -50 to 50.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.