Early work in Python and proposal. Data expansion of Houdini particles
For this project we are to come up with an interesting and useful use of Python. I have chosen to use this oportunity to begin working on the logic of my thesis work which will also have to do with data expansion. I am going to begin with simple clustering style expansion and when I have that working move on to velocity transfer. First off a bit about basic cluster data expansion. In this type theres a simulation of some sort containing particles which are called seed particles. These seed's positions are processed and then at render time other particles are spawned around them in a random distance from the seed based on a radius around it. I have a working model of this that ends up spawning particels in a square around the seeds. In the end these will be in a sphere around the seeds. The are also just traveling in the exact same velocity as the seed. I will be altering this to make them varry their velocity by random variations. After that is working I plan to get velocity transfering working in which each spawned particle will look up the nearest neighbor particles and take an average of their velocities. I would after like to get a script working that will take a ramped average of those velocities based on their distance from the influencing seed particles.
So for this project I have setup a Python digital asset that takes in one input from a file node that is reading in cached out particle data or output from a POPnet. To use data from a FLIP fluid simulation you must add a POPsolver to the fourth input of the FLIPsolver in the DOPnet. This gives the particles a particle id attribute which my code needs. The code that I wrote processes the incoming data for each frame and based on user input spawns particles around the incoming particles and each frame takes the velocity from the other particles around them and uses that to determin their velocity for that frame. While working on this I ran into many problems. One problem was that of the best way to find the nearest neighbors of the particle to use to calculate the expanded particle's new velocity. I found a bit of Python code on the internet that does just that. It can be found at http://en.wikipedia.org/wiki/K-d_tree and HERE is the kd tree code. I'm then able to use the position of the nearest neightbors to find their velocities and create a weighted average of that velocity and use that to calculate the position of each new particle. I am using a for loop to cycle through the expanded particles each frame and calculate their new positions. I am not going to post my code here because I am still working on it but I can be emailed with questions. These next two videos show the particles I used to mesh the previous simulations.
Here are two videos showing the expansion of qa simple particle network.
These videos show that I need to alter the way the expanded particles velocities are calculated. The are not moving as quickly as they should. They are remaining more cluimped together and should be moving more. TODO: For this specific algorithm I have much work and to do and improvements to make. Of course in the end this will be implimented using C++ and HDK. -allow for new spawning particles and particles dying I know I have many more changes to make to my code and will be spending the next year altering it and developing new algorithms |