PDA

View Full Version : Help on Maya Mel script particle. Create Water drop on glass surface.


stanleyw
10-17-2007, 05:20 AM
Hi,

I am creating a water drip on glass surface with maya particle and I found a tutorial for it. The tutorial is 'AW-MayaTechniques-ParticleEffectsTutorial', which is for maya 4.0.
After following the step on it, I stuck on somewhere asking us to make the particle going in zip zap moment. So I need the particle move from one goal to the other, so it can blend the animation.

Just want to know, Is anyone going though this tutorial before?. Any solution on this.

For those never go though this tutorial, here is the situation. I try to write it step by step.



I create emit from object particle for a nurbs surface. After that I need the particle attach on the glass surface. Select the particle that I emit and surface geometry, apply goal.
On the attributes / particleShape1 / add dynamic attributes, click on General.
Select Paticle/goalU, goalV, parentU and parentV, and click Add.
On the PerParticle (Arry) Attributes, right click on goalV or goalU and select create Expression. (Just to launch the Expression Editor)
In the Expression Editor under Creation, write down this scrip.



//define initial goal position
goalU = parentU
goalV = parentV

//make sure goalPP is set on 1 to lock particle to goal position.
goalPP = 1



Now we need to make the particle drip down on the glass surface.
First I create a Float call dripSpeed under add dynamic attributes / General/ New
Apply this scrip on Run time After Dynamic.

//For control the particle drip with number
float $minU = glassOuterShape.minValueU;
float $maxU = glassOuterShape.maxValueU;

particleShape2.goalU -= (particleShape2.dripSpeed / 100) * ($maxU - $minU);




Try to give some number on you dripSpeed attributes at the Channel Box.
Realistically, water will travel zip zap direction on object surface. Now we want the particle travel on V.
To do that, we create 3 more new Float, but Per particle (array) under attribute type.
First will be call target VPP, second will be call oldTargetVPP and last will be targetWeightVPP.
Also create 2 more new float, using Scalar under attribute type.
It call amplitude and frequency.
Open Epression editor under Creation apply following scrip.

//define initial target position in V
targetVPP = rand ( parentV * (1 - amplitude), parentV * (1 + amplitude) );

//define old target position as goalV position
oldTargetVPP = parentV;




Swith to Runtime after dynamic
Here is the error for the scrip.

//the particle has reached its target position
//and a new goal position need to be set
if (particleShape2.goalV == particleShape2.targetVPP) {

//save old target position
particleShape2.oldTargetVPP = particleShape2.targetVPP;

//determine new target position
particleShape2.targetVPP = rand( particleShape2.goalV * (1 - particleShape2.amplitude), particleShape2.goalV * (1 + particleShape2.amplitude) );

//reset targetWeightVPP
particleShape2.targetWeightVPP = 0;

//if the particle hasn't reached it's goal, calculate goalV
}else{

//move particle in between old and new target position
goalV = oldTargetVPP + ( smoothstep(0,1,targetWeightVPP) * (targetVPP - oldTargetVPP)

//increment frequency
targetWeightVPP += frequency;
Here is the Syntax error
Error: targetWeightVPP += frequency;

Guillermo
10-17-2007, 05:23 AM
There is a specific forum for maya mel scripting under the Maya Forums list here at cgtalk. Ask there :)

Good luck!

-

stanleyw
10-17-2007, 05:33 AM
Hi,

Thanks for collection.

CGTalk Moderation
10-17-2007, 05:33 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.