Hello,
(Using Python)
I have a particle cloud of 60 particles, all in one row (all Y and Z
are at 0). These 60 particles instantiate 8 characters.
I want to randomize these characters along the X axis.
For far, I have been using this approach:
- Get the position array
- Create a list
- "Group" the X, Y, Z axes of the position array into one tuple per
particle id, put this tuple into the list
- When all id tuples are done, shuffle the list in-place
- To do the shuffle, do it in two steps:
- find a new seed by getting a random number between 1 and 648914,
using random.seed( random.randrange( 1, 648914, 1 ) )
- use that seed number to shuffle the list elements with random.shuffle().
- "Ungroup" the tuples to rebuild the position array
- Set the position array
I'm getting mixed results. Some parts of the row (especially near the
higher X values) is well randomized, but the particles in the smaller
range of X are not so well randomized. There are many "pairs" of
characters, where two instances of the same character are next to each
other. I'd post an image but I can't atm.
Any suggestion about improving the randomization?
Below is my randomization code.
Thanks
Bernard
"""
Group position arrays in trios (xyz for a single particle).
list [
[x1,x2,x3],
[y1,y2,y3],
[z1,z2,z3]
]
-> becomes ->
list [
[x1,y1,z1],
[x2,y2,z2],
[x3,y3,z3]
]
-> Then shuffles these trios. ->
list [
[x2,y2,z2],
[x1,y1,z1],
[x3,y3,z3],
]
-> Then rebuilds the original arrays. ->
list [
[x1,x2,x3],
[y1,y2,y3],
[z1,z2,z3]
]
"""
# Create empty list to store trios of points
aPoints = []
# Iterate the points of the grid
for i in range( len( aOldPositionArray ) ):
iX = aOldPositionArray[0][i]
iY = aOldPositionArray[1][i]
iZ = aOldPositionArray[2][i]
# Put XYZ values of this iIndex into a tuple
tParticleTuple = ( iX, iY, iZ )
aPoints.append( tParticleTuple )
# Get new random seed
random.seed( random.randrange( 1, 648914, 1 ) )
# Shuffule in place
random.shuffle( aPoints )
# Create lists to store individual axes of the new position array
aNewX = []
aNewY = []
aNewZ = []
# Iterate tuples of particle coordinates
for tParticleTuple in aPoints:
aNewX.append( tParticleTuple[0] )
aNewY.append( tParticleTuple[1] )
aNewZ.append( tParticleTuple[2] )
aNewPositionArray = [ aNewX, aNewY, aNewZ ]
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi