Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Dynamics & Special Effects (https://simplymaya.com/forum/forumdisplay.php?f=33)
-   -   EXPRESSIONS FOR ALL! (knowledge tidbits) (https://simplymaya.com/forum/showthread.php?t=5601)

mind_raper 03-05-2003 05:57 PM

EXPRESSIONS FOR ALL! (knowledge tidbits)
 
Sorry to break-in mind-raper, but I'm making this thread STICKY so it will always be at the top for everyone to learn from!

Post your particle/dynamics EXPRESSIONS here for everyone to learn from!

Please write a little "how-to" along with your expression, so we will all know how to try it, and experiment with applying it to our dynamics/particle scenes!

Thanks all!:beer:


THREAD STARTS HERE first post by mind_raper
here's a little nice expression to .. colorize you particles system,
i have learnd it from gnomon workshop well its really good & ...
is very simply

first from general options add per particle attribute
the rightclick---> write creation expression::

take ur your are particle shape node (particleShape1) and add per particle attiribute (rgbPP)
and then assign a random value b/w (minVector i.e <<.3,5,7>>) and (maxVector i.e <<.5,7,1>>).

select the render type streaks or multi-streaks or what ever u want check on the color Accum button and the lightining button too

play around the values to see different color effects...


particleShape1.rgbPP = rand(<<.3,5,7>>,<<.5,7,1>>);



hope u find it usefull
enjoy - -> :banana:

ragecgi 03-05-2003 06:25 PM

Thanks mind-raper!

I think everyone should know the power of using expressions with particle systems, and your post will help others "EXPERIMENT" and learn, rather than be affraid, or overwhelmed.

Good job m8!

ragecgi 03-05-2003 06:44 PM

Here is a little expression tidbit from me to help this thread along:

TO RANDOMIZE STUFF: selectedObjectname.tx = rand(-10,10);

"tx", or whatever, is the attribute you can choose to have the expression applied to.

So, for random particle ROTATION:

selectedObjectname.rotX = rand(0,360);
selectedObjectname.roty = rand(0,360);
selectedObjectname.rotz = rand(0,360);

Try this as a CREATION expression, AND then try it as a RUNTIME expression to see the difference between these calculation types:)

mind_raper 08-05-2003 06:07 PM

Speed, Stuff
 
i think that was difficult...
well no prb....

tell u one thing....they are very easy just u need little bit of understanding......here's one more example from maya's documentation!
moving the particles.....

Use the Particle Tool to place a collection of particles in the workspace. You then create the following creation expression to control their velocity:

particleShape1.velocity = <<0,1,0>>;

All the particles move in a Y-axis direction at one grid unit per second as the animation plays.

explaination

"particleShape1" is the shape node for ur particle object that can be anything that u have named

"velocity" is the attirbute for shape node.

"<<0,1,0>>" is the value for X, Y, Z Respectivly
try to change the values and make it more dynamic with coditional statments

like if frame==something
move in X direction

or the way u wanted.


hope this works for u ....!

enjoy coding...! :beer:

mind_raper 20-05-2003 08:04 AM

Kill particles a few moments after they reach a specified locator
 
create an emitter and a locator and create another locator
first select the particle and shift select the 1st locator
goto --- > Particles -- > goals--option reset the setting
and press ok
do the same with other locator
Animate the particle from one locator to another using Goalweight attribute

then add the following script and see the magic of expressions
thanks for the cool expression
<< Daniele Tosti >>

<b>
vector $partPos = particleShape1.position;
if ($partPos > locatorName.ty)
{
particleShape1.lifespanPP = rand (5);
}
else
{
particleShape1.lifespanPP = 5 ;
}</b>

enjoy coding :beer:
:banana:

mind_raper 02-07-2003 01:40 PM

Attribute of an object at a certain
 
This expression will take the attribute of an object at a certain “offset” time, and apply it to another objects attribute. For instance it will take it off a cubes translateZ attribute, and assign it to a spheres translateZ attribute.

-Create a new scene.

-Create a polyCube.

-Create a polySphere.

-Translate the sphere about 10 units in Y.

-Open the Expressions editor, then Select Filter/By Expression Name.

-Type in the following:

int $offset = 10;
int $currentTime = `currentTime -q`;
$offsetTime = $currentTime - $offset;
$cube1Zpos = `getAttr -t $offsetTime pCube1.tz`;
pSphere1.translateZ = $cube1Zpos;

-Hit Create.

and here is the explaination !


//Time offset expression
//offset length (in frames)
int $offset = 10;


//Get current time
int $currentTime = `currentTime -q`;


//Substract the offset to the current time
//so if current time is 10,
//and offset is 2, offsetTime will be 8
$offsetTime = $currentTime - $offset;


//Get the value of pCube1.translateZ
//at frame $offsetTime (8 in our example)
$cube1Zpos = `getAttr -t $offsetTime pCube1.tz`;


//Assign it to pSphere1.translateZ
pSphere1.translateZ = $cube1Zpos;

This could be taken much further, you could for example setup joints and IK so it looks like power tubes are going from the mothership to the children, you could also add a custom attribute called “motion” and multiply the “noise” section of the expression by it, so that if you decide to turn you noisy motion off you would just have to set the custom attribute to 0. You could keyframe that attribute so you could control the random “floating” motion of the ship throughout the scene so it stops looking as if it were floating if it lands for example.

This type of setup could also be applied to a cranefly, or any other type of futuristic flying object etc. Experiment with setting all sorts of different relationships etc until you are comfortable with this expression.


this is very handy little snippet from
Oliver Shyal Beardsley
thanks alot for .......it

hope you enjoy it...........

schmick 03-07-2003 03:06 AM

Nice thread here, i know i'll be learning from it, just hope it sticks :D

brian_ellebracht 03-07-2003 12:06 PM

Wow nice thread :) THis is a really good idea
brian

ragecgi 03-07-2003 02:38 PM

It can only get bigger:)

mind_raper 04-07-2003 08:14 AM

yes absolutly !
Cause expression makes ur animation look more healthy and realistic
support is all needed...!

kbrown 04-07-2003 08:35 AM

Here's a little tip. If you use the seed() function you can be sure your expression with rand() functions run always the same way.

Code:

{
        seed(1234);

        float $foo = rand(-5, 5);
}

The $foo will contain a random value, but it is allways the same in a given frame...

ragecgi 04-07-2003 04:03 PM

Cool K!!

mind_raper 06-07-2003 06:31 PM

Removing linear breaks
 
Moving a turbulance field with object the problem is..
noise patterens move slong with it
if u we want remove linear breaks
we use turbulance phase attribute

let say you....want to move a turbulance field...through particles and want to....
effect its nearest as u know turbulance field is not good at moving, thats why to aviod that we use phase as per need


Example script :


turbulance field.phaseX = times * 4;

play wid it....
it really handy in particle system..!

enjoying coding..!

ragecgi 06-07-2003 11:12 PM

Rock on m8!

mind_raper 16-07-2003 12:11 PM

Some Handly Little Expressions
 
Rotating Wheels of Car or anything

Wheels on a car: apply to the wheel rotate in z channel
wheel.rz=car.tx/(2*3.145) * 1*360;

Wind shield wipers

Windshield wipers: apply to the wiper rotate in x channel
wiper.rx = (sin (.9 *time)*45)+10;
wiper = wiper
sine = sine
speed = how much fast you want() here i have put .9
time = time
degree = i put (45)
offset for position i put (10)


Random

Imbedded Sin Waves for a Random Effect
ty = sin (sin (.5 * time) * time);


enjoy ~ !


All times are GMT. The time now is 05:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018