I'm working on some code to pack a number of objects - presumably
vegetable-based, but I guess a person could pack anything they want -
into a rectangular area. It uses arrays to store the locations of
individual "trees", and tests randomly-placed trees against those
already in the arrays to make sure that their "clear areas" don't
overlap. A confidence value tells the code to give up and stop placing
trees after a user-defined number of placement failures.
Because of the random nature of the code and the need to test against
every other tree when placing a new one, scenes with a lot of trees take
a long time to parse; the example below using "clear area = 4" took 31
minutes on my Mac G4/867! I'm contemplating some kind of automatic
bounding so the code only tests new trees against old trees in the same
area, which should help more the more trees there are. Other planned
improvements include the ability to use multiple patterns to affect the
success of tree placement, the ability to have any number of "layers" of
trees with different placement characteristics, and some kind of
probability system using either a user-defined threshold or a random
test to determine whether placement in an unlikely area (such as on a
steep slope, or close to another tree) succeeds.
Whether I'll actually MAKE any of these improvements remains to be seen...
-Xplo
Post a reply to this message
Attachments:
Download 'forgenc16.png' (9 KB)
Download 'forgenc8.png' (12 KB)
Download 'forgenc4.png' (19 KB)
Preview of image 'forgenc16.png'
Preview of image 'forgenc8.png'
Preview of image 'forgenc4.png'
|