Last active
December 10, 2015 13:28
-
-
Save mattebb/4440723 to your computer and use it in GitHub Desktop.
Partio NumPy demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import partio | |
import numpy as np | |
p = partio.create() | |
size = 3 | |
posattr = p.addAttribute("pos",partio.FLOAT,size) | |
for i in range(8): | |
p.addParticle() | |
data = tuple(i+j*100 for j in range(size)) | |
p.set(posattr, i, data) | |
print( [p.get(posattr, i) for i in range(p.numParticles())] ) | |
print( p.getArray(posattr) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import partio | |
import numpy as np | |
ar = np.arange(24)[::-1] | |
print(ar) | |
p = partio.create() | |
posattr = p.addAttribute("pos",partio.VECTOR,3) | |
it = p.addParticles(8) | |
print( [p.get(posattr, i) for i in range(p.numParticles())] ) | |
p.setArray(posattr, ar) | |
print( [p.get(posattr, i) for i in range(p.numParticles())] ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment