PDA

View Full Version : Interaction between two nParticle simulations


Saxcore
10-08-2009, 02:25 PM
Hiya. I'm working on a project that will involve bath water taking the shape of a human. The key idea here is that some water will remain in the bath while the rest of the water takes on a human form. So this figure, created from water, is also bathing in water.

The best way to achieve this as far as I can tell (although I have little experience, so correct me if I'm wrong), is to use two separate nParticle objects. One will simulate the remaining bath water, while the other will simulate the human form. With the correct settings, I'm hoping to make this seamless with both of the particle systems interacting through the nucleus node.

Now, assuming this is the best way of going about this particular task, is there a way in which i can render both systems under the same "Blobby surface" shader, so that particles from both systems within close proximity will render combined, under the same isosurface?

I hope I've got the idea/problem across! Thanks in advance.

arkangel-fx
10-08-2009, 05:50 PM
Well, afaik you can combine 2 particle objects into 1. And the blobby is a render type, so there's no node you could connect.

Duncan
10-08-2009, 05:52 PM
You would need to combine the two systems into a third particle system to create the mesh.
There is currently no direct way to create a composite isosurface from two separate particle systems (I can see where it would be handy, though). There are a variety of ways of combining the two to a third(one could use the emit command inside an expression, for example), but offhand I don't know a really good method. If there were a depency graph node that merged two vectorArray or doubleArray data types one could use it to directly connect to the 3d particle system values from all the various per particle arrays. I don't know if there is such a utility (or perhaps someone has created a plugin for this).

It might be simplest just to do it all on a single particle system. One can distinguish the two particle "types" by using per particle arrays. One can define magnitude strength per/particle for different fields by naming a per particle attribute based on the field and attribute name. For example one could create a per particle attribute named "gravityField1_magnitude", which would then control the effect of that field per particle. Most of the attribute on the particle system can be controlled per particle, so it should be possible to manage on 1 system.

Another way of merging the systems comes to mind. On the third one could have a lifespan of one frame, and the two original systems could emit into that system at a rate of 1 particle per frame (per particle).

Duncan

Saxcore
10-08-2009, 07:09 PM
Thanks for the prompt replies. Some great ideas Duncan. The simplest method for me would probably be to simulate the whole thing in one particle system. However, the one thing that put me off of this initially is that I couldn't think of a decent way to define which particles made up the human figure, and which would make up the remaining water. Potentially it would be easy to divide the particles into two groups with a per-particle expression that took in their Particle ID, for example; however it crossed my mind that this system didn't take into account their world position at the time that they would be required to make up the human form (initially all of the particles would make up the normal bath water). This would mean that using a human mesh as a goal for the particles would inevitably make particles "jump" to a seemingly random vertex on this mesh.

So, I guess I'm wondering if there is a way to have greater control as to which vertex a particle uses as a goal. This way, I could get all particles to aim for the closest vertex of the goal mesh, making a seamless transition.

Duncan
10-08-2009, 08:25 PM
You could perhaps use the nParticle fill creation to fill your character with water then use collisions with the deforming character over time to keep the particles inside. (might be computationally expensive given the number of particles you would need however)

Note also that a colliding mesh(nRigid) can also attract particles using the field attribute on the mesh. You could set this to only attract particles that are relatively close to the surface, so that all the bath water is not sucked up on the surface. For creating the initial distribution of particles you could perhaps create a boolean mesh of the initial character and the bathtub water region and use that with the fill object particle creation.

Another approach might be to continually emit particles from the character, giving them an inward velocity. These particles could potentially be short lived and shrink and die, or they could fill the tub which could also drain at the fill rate.

If one is using the emit from surface the emission overlap pruning would be useful. In this way new particles are only created at the surface when they don't overlap existing ones.

Another way to have the character push particles along with the motion is to make the drag on the particles relatively high and use the airPushDistance attribute on the nrigid. This will pull any particles along with the motion of the surface that are within the push distance of the surface. This might work best combined with a little attractive force.

Duncan

Saxcore
10-08-2009, 10:29 PM
Some excellent ideas Duncan. I'll be running some tests over the next few days, so I'll get back to you with the results.

arkangel-fx
10-09-2009, 05:44 PM
Thanks for the prompt replies. Some great ideas Duncan. The simplest method for me would probably be to simulate the whole thing in one particle system. However, the one thing that put me off of this initially is that I couldn't think of a decent way to define which particles made up the human figure, and which would make up the remaining water. Potentially it would be easy to divide the particles into two groups with a per-particle expression that took in their Particle ID, for example; however it crossed my mind that this system didn't take into account their world position at the time that they would be required to make up the human form (initially all of the particles would make up the normal bath water). This would mean that using a human mesh as a goal for the particles would inevitably make particles "jump" to a seemingly random vertex on this mesh.

So, I guess I'm wondering if there is a way to have greater control as to which vertex a particle uses as a goal. This way, I could get all particles to aim for the closest vertex of the goal mesh, making a seamless transition.

Aside from duncans methods, you could also use a goalU and goalV per-particle expression to calculate the distance between the particles and you body mesh and assign uvgoal depending on the distance. And if the particles have to flow through the body you can increment the goalUV frame by frame.

CGTalk Moderation
10-09-2009, 05:44 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.