PDA

View Full Version : About goalWeightPP


looksoon
03-01-2011, 10:24 AM
I have one particle object and collise and goal with two objects, and I want when one particle collision with one object then goal with it, How can I do this?

ginodauri
03-01-2011, 02:50 PM
I don't understand.
Try to make it more clear , maybe with some illustration showing your problem.

Xsiv
03-02-2011, 05:12 PM
I think I get what you want.

Particles, called 'ps', are flying along and are going to collide
with something. 'Sphere' or 'Torus' is in the path of the particles.

a) Create a sphere
b) Create a torus
c) Create a particle system - named 'ps'
d) make the sphere a goal for 'ps'
e) make the torus a goal for 'ps'

now if you playback and have the two object separated, the particles will fly between them.

f) make the goalWeight 100% as it will be a multiplier

select the particle and in the attribute channel box:
goalWeight[0] = 1
goalWeight[1] = 1

g) make the particle system collide with both objects.

Now try something easy:
if the particles hit the sphere turn RED.
if the particles hit the torus turn GREEN.

For this you need to add PP attributes to the ps system
1) rgbPP - color PP button
2) Add general PP attribute: collisionGeometryIndex

Add Runtime before dynamics expression:

if(collisionGeometryIndex==0) // This is the sphere - set to collide first
rgbPP=<<1,0,0>>;

if(collisionGeometryIndex==1) // This is the torus - set to collide second
rgbPP=<<0,1,0>>;


So, now if you play back and scale up the 2 objects in the scene, the particles will bounce and change from black to a color - if your BG color is black you will only see the particles once they bounce!

Now it is working, making the particles become a goal for each object should be straight forward:

1) add goalU, goalV, collisionU/V and goalweight0PP/goalweight1PP to the particle system:

modify the expression above:

// check for a collision
//
if (collisionU != -1){
goalPP = 1;
goalU = collisionU;
goalV = collisionV;
}
if(collisionGeometryIndex==0){
rgbPP=<<1,0,0>>;
goalWeight0PP = 1;
goalWeight1PP = 0;
}
if(collisionGeometryIndex==1){
rgbPP=<<0,1,0>>;
goalWeight0PP = 0;
goalWeight1PP = 1;
}

Make sure that in your creation you zero out your PP weights:

goalPP = 0;
goalWeight0PP = goalWeight1PP = 0;

Have fun!

Xsiv

EightBit
11-29-2011, 06:37 AM
I'm trying to do something similar.
I have particles running through a volume axis field, and when they exit, I want them to stick to a goal. I have an expression to measure the distance between the particles and the goal, but as soon as the first particle get within that distance, the goal weight is set to 1 for all the particles and they all snap to the goal. Anyone know what's wrong?
I initialize the goal strength to 0 w/a creation expression
Thanks.
vector $goal0Pos=forensicsParticleShape.goalWorldPosition0PP;// Get the WPos of each goal for each particle
vector $pos=forensicsParticleShape.position; // the particle's positionPP

// When the particle is close to the goal (out of the volume axis), set the goal weight to 1:
if (abs($pos-$goal0Pos)<0.4) forensicsParticleShape.goalWeight0PP = 1;

CGTalk Moderation
11-29-2011, 06:37 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.