hi,
maybe some of you can help me out...
i have two objects that intersects each other. is it possible to emit particles from that "colliding/intersecting" positions?
i want to generate a splash from two colliding objects...
maybe graph? scripting?
emit particles from colliding objects
- ChristianZ
- Posts: 3427
- Joined: Sat Sep 09, 2006 11:37 am
- Location: CH
- Contact:
Re: emit particles from colliding objects
Hi
this is a classic job for an "event" script. I don't have much experience with scripting, but basically you want to obtain the collision points of the first object where the second object hits. This gives you a list of points. Then you need an additional emitter somewhere in the scene with speed set to zero. In the script make a loop through the list of collision points and create new particles with the properties of the emitter at these collision sites. It may be harder to emit so many particles that it looks like a splash. Might be faster to hand-animate an emitter and use keyframes.
this is a classic job for an "event" script. I don't have much experience with scripting, but basically you want to obtain the collision points of the first object where the second object hits. This gives you a list of points. Then you need an additional emitter somewhere in the scene with speed set to zero. In the script make a loop through the list of collision points and create new particles with the properties of the emitter at these collision sites. It may be harder to emit so many particles that it looks like a splash. Might be faster to hand-animate an emitter and use keyframes.
RF10 standard + RFC4D
Re: emit particles from colliding objects
Here's a very basic script to illustrate the concept - add it to the "StepsPre" section of the Simulation Flow events tree:
Line 1 gets all collision points (= positions) from the interaction between Sphere01 and Cube01
Line 2 loops through these points/positions
Line 3 adds particles to the Dyverso domain DY_Domain01. This function requires a position and a velocity, which is 0 in this case.
Cheers,
Thomas
Code: Select all
collPoints = Sphere01.getCollisionPoints(scene.getObject("Cube01"))
for position in collPoints:
DY_Domain01.addParticle(position, Vector.new(0,0,0))
Line 1 gets all collision points (= positions) from the interaction between Sphere01 and Cube01
Line 2 loops through these points/positions
Line 3 adds particles to the Dyverso domain DY_Domain01. This function requires a position and a velocity, which is 0 in this case.
Cheers,
Thomas
-
- Posts: 10
- Joined: Thu Jul 15, 2010 1:14 pm
Re: emit particles from colliding objects
hi thomas,
thank you very much. this helps.
do you know if there is a function to get the normal vector of this collision points. i want to use this normal rotated by 90 degrees to give the particles this direction velocity...
thank you very much. this helps.
do you know if there is a function to get the normal vector of this collision points. i want to use this normal rotated by 90 degrees to give the particles this direction velocity...
-
- Posts: 10
- Joined: Thu Jul 15, 2010 1:14 pm
Re: emit particles from colliding objects
hi thomas,
just tried your code-snippet and it doesnt work. i get no particles at all...
do i miss something? tried also to make the objects passive rigid bodies...but also no particles are generated...
also with a scene.message(str(position)) within the for-loop i get no colliding debug values...
did your script work for you?
just tried your code-snippet and it doesnt work. i get no particles at all...
do i miss something? tried also to make the objects passive rigid bodies...but also no particles are generated...
also with a scene.message(str(position)) within the for-loop i get no colliding debug values...
did your script work for you?
Re: emit particles from colliding objects
do you know if there is a function to get the normal vector of this collision points.
Not directly, but via a detour. There's the following function for Dyverso particles:
[Vector, Vector, int, float] getNearestPointToObject( Vector, string )
Find the nearest point in the object to the particle in a specific direction. If direction is set to 0 then just the nearest point is found.
Arguments: 1) Direction which is normalized internally. 2) Object's name.
Return:
1) Nearest point 2) normal at the nearest point 3) index of the face and distance 4) None if no nearest point is found.
Here's some code that should work.
Code: Select all
velScale = 2.5
collPoints = Sphere01.getCollisionPoints(scene.getObject("Cube01"))
for point in collPoints:
DY_Domain01.addParticle(point, Vector.new(0,0,0))
for particle in DY_Domain01.getParticles():
results = particle.getNearestPointToObject(particle.getPosition(), "Sphere01")
if (len(results) > 1 and results[1] == True):
velDir = results[1]
velScaled = velDir.scale(velScale)
particle.setVelocity(velScaled)
I've never used this function, but "result" contains vectors at least

Re: emit particles from colliding objects
did your script work for you?
Yes, it works. I guess your cube object doesn't have enough resolution. And I've put the script under StepsPre. You can use a batch script to subdivide the cube - that's what I did:
Code: Select all
Cube01.tesselate(0.02)
And if you need a sphere with more vertices:
Code: Select all
scene.addSphere(4) or scene.addSphere(5)
-
- Posts: 10
- Joined: Thu Jul 15, 2010 1:14 pm
Re: emit particles from colliding objects
thank you soooo much.
i will try it as soon as i am back in the office...
i will try it as soon as i am back in the office...
Re: emit particles from colliding objects
Hey, you're welocme. Just one last thing on this line of code:
Instead of >1 it should be >0. It doesn't make too much difference (in fact none at all, since the second condition implies that there are either 4 or no entries in "results"), but I feel better when it's correct
Code: Select all
if (len(results) > 1 and results[1] == True):
Instead of >1 it should be >0. It doesn't make too much difference (in fact none at all, since the second condition implies that there are either 4 or no entries in "results"), but I feel better when it's correct

Re: emit particles from colliding objects

Very cool! We can all, every one of us, use this!

Windows 7 Pro 64 - Realflow 10.1.2.0162 (Nov 2017 patched) Standard Version
Who is online
Users browsing this forum: No registered users and 1 guest