Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 20-05-2008, 12:05 AM   #1
RaginRob
Registered User
 
Join Date: May 2008
Location: Europe (Germany)
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Thumbs up Solved: How to check for collision with a particular object?

Hi there,

I'm looking for a solution to this:

I want to create a moving vacuum cleaner with particles and fields. My scene contains a plane (the floor), a moving polygon bar that emits the dust particles and spreads them over the floor, and the "head" of the cleaner.

The dust particles "rain" down on the floor and collide with it (without resilience). Once the floor is full of particles, the cleaner starts moving along a motion path over the particles. The cleaner head has a parented newton field with a cube volume which sucks in the particles within the volume shape.

Up to this point everything works just fine. The problem is: I need the particles to die as soon as they are sucked in, otherwise they gather around the field and occasionally show up. So I thought it would be best to make the particles collide with the cleaner head and then let them die via the Collision Event Editor. The problem is, the particles now die as soon as they touch the floor as this also is a collision. How can I tell them to only die when they collide with the cleaner head geometry? Is there a way to check with wich object the particles actually collides?

[UPDATE]

I found a way to distinguish the collision object! Now I can check if the particle collides with the floor or any other object. See the simplified scene file here:

http://www.megaupload.com/?d=LLPGILIL

I wrote an expression that changes the color of the particle to red as soon as it collides with the cleaner head. It doesn't react when colliding with the floor. Now all I have to figure out is how to let the particle die instead of turning red? I've been playing around with lifespanPP but it didn't work so far. Here's the expression I use:

Code:
int $idx = particleShape1.collisionGeometryIndex;
if( $idx != -1 )
{
string $geoC[] = `listConnections particleShape1.collisionGeometry[$idx]`;
string $shape[] = `listConnections ( $geoC[0] + ".localGeometry" )`;
// print( $shape[0] + "\n");
if ($shape[0] == "Staubsauger")
{
particleShape1.rgbPP = <<1,0,0>>;
particleShape1.lifespanPP = -1;
}
}

Last edited by RaginRob : 20-05-2008 at 01:55 PM.
RaginRob is offline   Reply With Quote
Old 20-05-2008, 01:19 AM   #2
ragecgi
Super Moderator
 
ragecgi's Avatar
 
Join Date: Sep 2002
Location: Minnesota, USA
Posts: 3,709
Thanks: 0
Thanked 13 Times in 12 Posts
Default

Sadly no, not in one uncut shot without mel anyway that I know of.

However, after trying a setup like you described, before I pass along my solution, are you really tied to your story of the falling dust first?
Because if you could get rid of that one collision, then things MAY be easier for you if you MUST do this all in one shot.

I ask because I think you may need to do this using a simple editing technique called a "cutaway".

TRIAL AND ERROR:
The first thing I tried was setting up your situation as you have it now, with the exception of when the dust fell to the floor for the first collision, I setup an event that killed the particle dust, and IMMEDIATELY spawned new particles with a conserve of 0 so they appear to the camera as the same piece of dust.
Then I created ANOTHER collision event with a new name that was setup like you had it originally and that seemed to work ok........ sortof.

The SECOND thing that worked PERFECTLY was to not show the falling dust at all.
Simply emit the dust from the floor geometry as a surface emitter with a conserve of 0 and an initially high rate till the floor filled up with dust then I killed the rate.

Then all I had to do was use only ONE collision event with the vacum-head geo and the particles dissapeared like they were supposed to.
(see my Maya 8.5 Unl. attachment for this example)


Of all of this, I believe the BEST solution for you would be to use a cutaway.
This is simply what it sounds like:

One rendered sequence is of the dust falling.
One sequence is a super-quick 1-2 second cutaway of the vacum cleaner beauty shot.
Then, render a final sequence for the part with the vacum head moving & killing particles.

This way you only have to deal with one collision at a time.

Lemme know if ANY of this gibberish helped
Attached Files
File Type: mb vacum_demo.mb (71.3 KB, 52 views)
__________________
Israel "Izzy" Long
Motion and Title Design for Broadcast-Film-DS
izzylong.com
ragecgi is offline   Reply With Quote
Old 20-05-2008, 01:37 AM   #3
RaginRob
Registered User
 
Join Date: May 2008
Location: Europe (Germany)
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks for your quick response!

Your solution is an interesting approach. The reason I'm using a newton field is to accelerate the particles towards the head when it's approaching, like in real world. The idea is to actually see them get sucked in the cleaner head.

As I wrote in the updated post above, all I need is a way to make the particular particle (lol!) stop existing when the collision with the head occurs. I think there must be a kind of command that can be executed in the expression (exactly where I change the particle color to red at the moment) that makes the particle die.

In my first post I somehow missed the chance of adding an attachment with the scene file, so here it is again.

There must be a way =)
Attached Files
File Type: mb cleaner.mb (72.4 KB, 46 views)
RaginRob is offline   Reply With Quote
Old 20-05-2008, 03:05 AM   #4
ragecgi
Super Moderator
 
ragecgi's Avatar
 
Join Date: Sep 2002
Location: Minnesota, USA
Posts: 3,709
Thanks: 0
Thanked 13 Times in 12 Posts
Default

Sadly with longform expressions like that I am clueless, hehe, so I wouln't be the one to ask about that

Regarding your collision event, however, have you checked the event editor at the bottom of the dialog is a checkmark to "Kill" the particles rather than split or emit others?

Just making sure, as mine kept defaulting to split, so I had to check it twice before it took correctly
__________________
Israel "Izzy" Long
Motion and Title Design for Broadcast-Film-DS
izzylong.com
ragecgi is offline   Reply With Quote
Old 20-05-2008, 03:39 AM   #5
RaginRob
Registered User
 
Join Date: May 2008
Location: Europe (Germany)
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default

Dynamics, especially expression driven, is also totally new to me. But hey, there's always one day when you have to jump into the cold water and get along with it - somehow :headbang:

If I could manually do what this kill checkbox does in the event editor, I'd be happy. Well, I'll keep searching. Perhaps there's one expression magician out there who stumbles over this thread one day.

For now I'll call it a day


greetings,
Rob
RaginRob is offline   Reply With Quote
Old 20-05-2008, 02:59 PM   #6
RaginRob
Registered User
 
Join Date: May 2008
Location: Europe (Germany)
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default

It's done, there was just a little tweak to be done :attn: . So here's a little walkthrough for those who want to use it. Quite simple, but it's just to get the idea across:

Let's say you want to have particles raining down on two cubes. Particles that collide with cube 1 shall become red and bounce off the cube (and eventually collide with cube 2), cube 2 shall kill the particles once they collide with it.


- Create an emitter that lets the particles rain down (omni, gravity field)
- Create 2 (or more, it doesn't matter) poly cubes and place them under the emitter in a way that some particles collide with cube 1 and some with cube 2
- name the transform node (pcube1 not pcube1shape) to cube_A and the other one to cube_B
- Make the particles collide with both of them (Particles-->Make collide)
- Select the particleShape and add a per particle collisionGeometryIndex via Add Dynamics Attibutes-->General-->Particle-->collisionGeometryIndex
- Also add an rgbPP Attribute (Add Dynamics Attibutes-->Color-->Add per particle attribute)
- now create a runtime expression on the lifespanPP and rgbPP attribute:

Code:
int $index = particleShape1.collisionGeometryIndex;
if( $index != -1 )
{ 
	string $geoC[] = `listConnections particleShape1.collisionGeometry[$index]`;
	string $shape[] = `listConnections ( $geoC[0] + ".localGeometry" )`;
	
	if ($shape[0] == "cube_A") 
		{
		particleShape1.rgbPP = <<1,0,0>>;
		}
	if ($shape[0] == "cube_B") 
		{
		particleShape1.lifespanPP=0;
		}
}
Important!!! You have to set the lifespan mode to "lifespanPP only" under Attribute Editor --> particleShape1 --> Lifespan Attributes. It took me hours and buckets of coffee to notice that. Rob was raging again

You can easily add more collision objects with different effects on the particles, I think a switch-case condition would be more elegant for that.

I attached a scene file with the stuff above, have fun!
Attached Files
File Type: mb collisions.mb (59.9 KB, 82 views)

Last edited by RaginRob : 20-05-2008 at 03:03 PM.
RaginRob is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.