avd_Logo

avd_Logo
Welcome to the world of mystery.

New Developments

Using Python

I have begun to play around with the Python programming language. And MAN, this shit is powerful! In terms of 3D production, there has yet to be a language like this. It has both power and simplicity. In this example, I created a realflow sim that would calculate particle velocity and age, and then depending on how old the particle was or how fast it was going, it is then turned into a more surface-tensioned liquid and gravity begins to take hold.  

here is the script:

def onSimulationStep():
factor = 3
emitter1 = scene.getEmitter("Circle01")
emitter2 = scene.getEmitter("Circle02")
particle = emitter1.getFirstParticle()
while(particle):
life = particle.getAge()
vel_g = particle.getVelocity()
vel_x = vel_g.getX()
vel_y = vel_g.getY()
vel_z = vel_g.getZ()
speed = abs(vel_x+vel_y+vel_z)/3
if (speed>factor):
pID = particle.getId()
pos = particle.getPosition()
emitter2.addParticle(pos, vel_g)
emitter1.removeParticle(pID)
(factor+speed)/2
scene.message(factor)
if(life >= 1):
pID = particle.getId()
pos = particle.getPosition()
emitter2.addParticle(pos, vel_g)
emitter1.removeParticle(pID)
scene.message(factor)
particle = particle.getNextParticle()



Python liquid burst from alex van dyne` on Vimeo.


Mixing Liquids in C4D using Realflow and C4D


I also figured out an interesting way to simulate two(or as many as your rig can handle) mixing liquids using realflow and c4d, despite c4d's lack of a melt material! If you care, the rough directions are as follows. 

1. sim out your mixing liquid being careful to note where it is exporting not just your mesh, but your particles as well.

2. import the 3 .bin files into c4d using the realflow plugin.
       A. your mesh.bin
       B. the first particle cache.bin
       C. the second particle cache.bin

3. create a cloner object and set it's mode to object mode.

4. create any polygon shape and delete all but one vertice. then zero out the vertice in local an world space and drag it into your cloner object.

5. go to the thinking particle menu and drag one of the particle groups into the object link in the cloner object, effectively cloning a vertice to each particle in one of your mixed fluids.

6. create a material and use a proximal shader in whatever channel you like.

7. Drag the cloner object containg the verticies into the proximal shader. be sure to set the check boxes ON marked "inlcude subobjects" and "use vertices" inside your proximal shader.

8. now your proximal shader is effectivly an alpha map based on how close your mesh is to a particular particle cache. you can insert this proximal shader into anything from the color channel to the alpha channel and by setting the falloff of the proximal shader accordingly, you can have color changes or anything really!

if anyone needs a better explaination than this let me know!




Mixing liquid colors using c4d and realflow. from alex van dyne` on Vimeo.

3 comments:

  1. Just by chance, do you know if there's any way to get the colors 100% mixed, I mean.. imagine you have a yellow stream and a blue one... then I'd want to see green as the result of their mixing.
    I tried in Cinema 4D but I only got some weird dispersation.
    Thanks in advance! =)

    ReplyDelete
  2. I've been trying to figure this out. as far as i can tell, the best way seems to be this.

    first, in realflow, make sure that your mesh is the standard mesh and not the render kit mesh. inside c4d the standard mesh will import vertex maps of each fluids color.

    Then use a layer shader inside the color channel of your material, and fill it with a vertex shader for each vertex map on your object(one for each color).

    then try setting the blend mode inside your layer shader to add for each color. finally, set a blank black background inside the layer shader as well as a base.

    this should work and by adjusting the blend mode settings inside the layer shader, you should be able to adjust how the liquids mix.

    all in all, its pretty hard to get 100% mixed liquids using my method above because it only detects particles near the surface and what color group they belong to, as opposed to an actual vertex map of the color on the surface.


    hope that helps!

    ReplyDelete
  3. That's a pretty interesting technique!! Thanks a lot for sharing. I'll give a try as soon as I can. I really appreciate your time. Cheers!

    ReplyDelete