I played with animating mitosis in Houdini last year (see Simulating Mitosis in Houdini), but the math wasn't quite right, so I thought I'd revisit my VEX to see if it could be improved. After some tinkering, the video above shows my latest (hopefully improved) results.
The basic project remains the same:
- A point generate geometry node creates a single source point
- An attribute wrangle creates three new attributes for the point used for the mitosis animation:
- float @age
- float @numChildren
- vector @velocity
- A jitter node which is useful if the generate node is used to create more than one point
- A solver node to iterate over the geometry and is where the magic happens
The VEX inside the solver is where the point separation and generation happens:
int pointCloud = pcopen(0, "P", @P, 3 , 50);
vector localCentre = pcfilter(pointCloud, "P");
vector direction = normalize(v@P - localCentre);
float r = distance(v@P, localCentre);
if(r < 1) {
r = 2 - (r * 2);
}
v@velocity += (direction / (r * r)) * 0.1;
if (@age > 1 && @numChildren < 3) {
vector randOffset;
randOffset.x = -0.01 + (noise(localCentre.x + @Time + @age) * 0.02);
randOffset.y = -0.01 + (noise(localCentre.y + @Time + @age) * 0.02);
randOffset.z = -0.01 + (noise(localCentre.z + @Time + @age) * 0.02);
@age = 0;
@numChildren += 1;
int newPoint = addpoint(geoself(), @P + randOffset);
}
else {
@age += abs((random($FF * @ptnum)) * 0.05);
}
@P += @velocity;
v@velocity *= 0.5;
As in my previous version, I find the average position of each point's neighbors. However, this time, I create a direction vector that is normalized (i.e. always has a length of 1) and a separate float, r, which is the distance of each point to the local average position. This approach allows me to fake the distance for points close to the local center (so they don't fly off into infinity) and get a bit Newtonian with the math used to calculate the velocity (i.e. by dividing by r²).
The mitosing point cloud is used to generate two VDB based polygon surfaces, the larger of which is smoothed to give the nice metaball effect as the points move apart:
Finally, I gave the outer surface a thin film refracting material, added some depth-of-field, and, voilà , little mitosing blobs!
This clips are interesting and great explanation. for further information-
ReplyDeleteGOLD TRADING TIPS
ACCURATE COMMODITY TIPS
Hi there... Thanks for sharing the code.
ReplyDeleteWondering if you ever thought of making the cells into FEMs and having them collide instead of join?
It's very satisfying to watch
ReplyDeletethanks for sharing!
ReplyDelete