Integrating 3D models with photography
Interested in integrating your 3D work with the real world? This might help
# 1 29-09-2007 , 03:22 PM
Subscriber
Join Date: Oct 2005
Location: US of A
Posts: 114

Particle Simulation (Very Technical, Need Help!)

Hey all,
I'm working on a project, a sort of partical simulation. Basically the goal is to have a surface emit particles that float downward toward a sphere that attracts all nearby particles within a certain radius.

That was the easy part, and its all finished.

The task at hand is to be able to change the attributes of the particles once they've entered a certain radius around the sphere. For example, a particle enters the gravitational field of the sphere, and as it does so, it change color from blue to red and begins to emit a soft glow, growing stronger as it nears the sphere.

I've been doing some research and it looks like I'm going to have to do some MEL scripting to set it up correctly, and unfortunately I dont know a damn thing about MEL aside from what i've read today. I'm planning on learning MEL because I'm going to obviously need it to complete my goals, but any help, tips, pointers, or anything that could help would be much appreciated.

Thanks everyone!!!


Death is certain, Life is not.
# 2 30-09-2007 , 07:00 AM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
I at work now so I don't have time to finish this. Anyway here's one way for that particle going from blue to red within a specified radius of an object (pSphere1 in this case). Just add rgpPP and a cusom scalar attribute called effectRadius (set it bigger than the radius of your sphere to see the effect better) to your particle shape and enter the following into your runtime after dynamics expression:

Code:
vector $vWPos = worldPosition;
vector $vSPos = <<pSphere1.translateX, pSphere1.translateY, pSphere1.translateZ>>;
float $fDistance = mag($vWPos - $vSPos);

float $fEffect = 0;
if($fDistance < effectRadius);
	$fEffect = 1 - linstep(0, effectRadius, $fDistance);

rgbPP = <<$fEffect, 0, 1 - $fEffect>>;


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 3 30-09-2007 , 02:18 PM
Subscriber
Join Date: Oct 2005
Location: US of A
Posts: 114
Thanks a lot for the help! I'll give it a try tommorow and see how it work.


Death is certain, Life is not.
# 4 18-10-2007 , 07:07 PM
Subscriber
Join Date: Oct 2005
Location: US of A
Posts: 114
Thanks a lot for the help!

However, I've been playing around with the expressions and I'm trying to get the particles to die now once they are inside the target sphere, and well, its not working the way I would like.

When I try it one way, the particles die before moving, and then the other way nothing happens. Its almost as if the particles have a world position of 0,0,0 when they are born.

Any thoughts?

Thanks again all!


Death is certain, Life is not.
# 5 18-10-2007 , 07:21 PM
Subscriber
Join Date: Oct 2005
Location: US of A
Posts: 114
Never mind, got it to work user added image


Death is certain, Life is not.
# 6 20-10-2007 , 03:15 PM
Subscriber
Join Date: Oct 2005
Location: US of A
Posts: 114
Ok, now for something a little more complicated...

To recap, there is a plane emitting particles downward toward the origin, where a sphere rests. This sphere attracts all nearby particles, and the particles that get close change color from blue to red.

My next goal is to make it so the surface of the sphere changes color as a particle nears it. I dont mean the entire sphere, I just mean a small localized region that is near the particle.

For example, I have a green sphere, and as a particle approaches it, I want the point on the surface of the sphere to glow orange gradually as the particle moves closer to the surface of the sphere.

Thanks all!


Death is certain, Life is not.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads