ranman38 opened this issue on Feb 04, 2013 · 34 posts
Snarlygribbly posted Mon, 04 February 2013 at 5:11 PM
Sometime ago I wrote something quick and dirty that does this. It has no UI - you have to edit the values in a the parameters section of the code, near the top:
import poser, random
'''
ALL MEASUREMENTS ARE IN INCHES!!!
'''
PROP = 'RuntimelibrariespropsVegetationTreesBlossom tree.pp2'
XTRANSNAME = 'xTran'
ZTRANSNAME = 'zTran'
YROTATENAME = 'yRotate'
MAXIMUM_NO_OF_INSTANCES = 30
MIN_X = -500
MAX_X = 500
MIN_Z = -500
MAX_Z = 500
RANDOM_ROTATE = True
MINIMUM_SEPARATION = 100
GIVE_UP_AFTER = 8
scene = poser.Scene()
count = 0
rangeX = MAX_X - MIN_X
rangeZ = MAX_Z - MIN_Z
done =
print 'Starting prop generation ...'
while count < MAXIMUM_NO_OF_INSTANCES:
# Load the prop
scene.LoadLibraryProp(PROP)
prop = scene.CurrentActor()
print 'nProp #%s loaded' % (count + 1)
# Generate random co-ordinates
attempt = 0
give_up = True
while attempt < GIVE_UP_AFTER:
bx = (random.randint(0, rangeX) + MIN_X)
bz = (random.randint(0, rangeZ) + MIN_Z)
x = bx / 103.2
z = bz / 103.2
block = (int(bx / MINIMUM_SEPARATION), int(bz / MINIMUM_SEPARATION))
print 'Attempt %s: x,z = %s,%s, block = %s' % (attempt, bz, bx, block)
if not done.get(block, None):
done[block] = prop
give_up = False
break
else:
attempt += 1
if give_up:
print 'n--- GIVING UP!! ---'
break
# Place prop
prop.SetParameter(XTRANSNAME, x)
prop.SetParameter(ZTRANSNAME, z)
print 'Positioned at %s, %s' % (x, z)
# Rotate if requested
if RANDOM_ROTATE:
r = random.randint(0, 360)
prop.SetParameter(YROTATENAME, r)
print 'Rotated to %s degrees' % r
count += 1
print 'nAnalysis of prop generation:'
for k, v in done.items():
print 'Block %s : %s' % (k, v.Name())
Free stuff @ https://poser.cobrablade.net/