SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.


SM Forums / Maya Questions / Dynamics & Special Effects / EXPRESSIONS FOR ALL! (knowledge tidbits)

Dynamics & Special Effects Maya Particles, nDynamics, Fluids, Rigid Bodies & General VFX

Join the conversation. Reply to post
Page 4 of 5 « First 2 3 4 5
 
Thread Tools
11-06-2004, 08:09 PM   #46
mind_raper
Registered User
 
Join Date: Nov 2002
Location: Pakistan
Posts: 57
while i was searching for my answers, i found this very usefull information from a siggraph contents



Understanding colorAtPoint MEL Command:



One of the most visible and difficult aspects of water interaction is floating objects, such as particle foam and certain types of objects. Maya has a number of built-in tools to float boats and boat-like objects, tools such as addBuoy, addBoat, and addMotorBoat.

All these tools have one very important thing in common, they’re all based on the colorAtPoint MEL command, By mastering this function, we can expand Maya’s capabilities and use it to create custom tools and effects such as floating curves

or particles on the ocean shader.

colorAtPoint can sample any combination of colors (RGBA) on an Ocean shader (or other texture) at a given UV address. While this can be put to many uses, we are primarily concerned with retrieving the height of the waves and applying it to the Y position of objects and particles. Like most displacement maps in Maya, Ocean outAlpha is used to calculate the displacement height. Since the Ocean shader’s UVs are based on Worldspace (X 3, Z 4 in Maya Worldspace = U 3, V 4 in Ocean shader UV) we can directly convert any point’s Worldspace to ocean UV space and sample the Alpha to get the appropriate Y height of the waves.

colorAtPoint

use: -convert point (object) Worldspace to Ocean UV;

-sample Alpha at given UV address;

-use returned Alpha value as Y height of point (object);

floatSphere is ur object


//myFloat_expression
//float an object on the ocean surface
//translate XZ are free, Y is constrained to ocean
float $posu = floatSphere.translateX;
float $posv = floatSphere.translateZ;
float $posy[] = `colorAtPoint -o A -u $posu -v $posv oceanShader1`;
floatSphere.translateY = $posy[0];


Expression explained:

-o A : “A” samples the Alpha only. Other options are “RGB” and “RGBA”;

-u and –v : place input variable for the Worldspace point you wish to sample
(object’s position XZ you wish to float)

IMPORTANT: since colorAtPoint is a MEL command,
you have to use “`” (not single quote, the other one above TAB on your keyboard) on either end when in an expression. Also, you should use $variables for –u and –v since MEL can’t convert expression syntax such as “locator1.translateX” (MEL sees
this as a string only).

$locY[] : Since colorAtPoint returns a float Array, you can’t use it directly in translateY (requires a single float).
NOTE : When a MEL commands such as colorAtPoint is embedded in an expression, it does not update when names it refers to are changed. E.g. If “oceanShader1” were changed to “myOcean”, the expression would return an error. Since many Maya floating tools (createBoat…) generate expressions with embedded MEL, it is very dangerous to rename the floating object/locator’s transform, or the oceanShader after the tool is invoked. You would have to manually edit the MEL lines in the expression after such a name change.



hope it helps
__________________
Learn the Rules|Then|
Burn the Rules Book
  Reply with quote
14-06-2004, 09:52 AM   #47
mind_raper
Registered User
 
Join Date: Nov 2002
Location: Pakistan
Posts: 57
well this script can help u float particles on ocean surface like a foam and can be manuplate as wake happens u see more control..over ur foam



//float particles on ocean surface (runtime)
//get ocean height at current particle position
vector $ppos = foam_particleShape.position;
float $pu = $ppos.x;
float $pv = $ppos.z;
float $cpoint[] = `colorAtPoint -u $pu -v $pv oceanShader1`;
//when particle position lower than ocean, stick to ocean
if($ppos.y <= $py)
foam_particleShape.position = <<$pu, $cpoint[0], $pv>>;


hope it helps !
__________________
Learn the Rules|Then|
Burn the Rules Book
  Reply with quote
19-08-2004, 07:19 PM   #48
GuardHom
Registered User
 
Join Date: Aug 2004
Posts: 1
WoW, Pretty Good expressions~
  Reply with quote
16-12-2004, 04:52 AM   #49
vivi3d
Registered User
 
Join Date: Dec 2004
Posts: 1
Pretty Good expressions~
  Reply with quote
18-12-2004, 06:09 PM   #50
ragecgi
Registered User
 
ragecgi's Avatar
 
Join Date: Sep 2002
Location: Minnesota, USA
Posts: 3,709
Holy cow Mind-raper!!!! GREAT posts bud!!!
__________________
Israel "Izzy" Long
Motion and Title Design for Broadcast-Film-DS
izzylong.com
  Reply with quote
15-01-2005, 05:46 PM   #51
mind_raper
Registered User
 
Join Date: Nov 2002
Location: Pakistan
Posts: 57
Emit More Particles as the emitter goes faster
here is the fairly advance trick you may find usefull ....Maya does not let u ...vary emission rates with velocity but this will allow such an effect


Create an Sphere and add expression to its Translation X attribute

tx = sin(time*3);

this will make the sphere oscillate back n forth along x smoothly

- with the ball selected, choose Surface emitter type, setting the rate (Particles/sec) to 2000
and turning to the speed of 0

- In the Particle1 attribute Editor, Turn in herit Factor to 1 under emission attributes

- Now, Under Lifespan Attributes, Select lifespanPP only. Go down to per particle (Array) attribute and right mouse click on lifespanPP and select runtime expression. Enter this expression:

$magv = mag(velocity);
if (rand(1)<linestep(0,1,$magv/3))
lifespanPP = 1
else
lifespanPP = 0



you are done....play with attribute for more finner result

this snippet was taken from Maya Killer tips book

hope it helps
__________________
Learn the Rules|Then|
Burn the Rules Book
  Reply with quote
15-01-2005, 06:13 PM   #52
ragecgi
Registered User
 
ragecgi's Avatar
 
Join Date: Sep 2002
Location: Minnesota, USA
Posts: 3,709
ROCK ON!!!

Thanks again MR!!

Now im off to test this on a shot where I use an exahust emitter that needs to slow to a crawl when my aircraft stalls out, then picks up again on desent!!

You fail to surprise us all bud!

Thankd again!
__________________
Israel "Izzy" Long
Motion and Title Design for Broadcast-Film-DS
izzylong.com
  Reply with quote
06-06-2006, 11:29 PM   #53
joed8349
Registered User
 
joed8349's Avatar
 
Join Date: Feb 2004
Posts: 261
How to convert particles to geometry, not just instances
I am creating a background scene that needs to be filled with a bunch of rocks and other small things. I figured I could place particles on a live surface, and then use the Instancer (Replacement) tool to add geometry in place of each particle.

Is there anyway to then convert each instanced geometry into its own object/geometry?

I know there is a feature to convert paint effects into geometry, but I don't think there is a way to convert particles into geometry.

I cannot select the instanced geometry, only the instancer node in the Outliner.

Thank you to anyone that can help me out.
__________________
<br><b><a href="http://euphrates.wpunj.edu/students/dimperioj" target = blank> My Website </a>
  Reply with quote
07-06-2006, 09:21 AM   #54
mirek03
Subscriber
 
mirek03's Avatar
 
Join Date: Feb 2006
Location: Australia
Posts: 2,752
wow, this is an increible thread, I know very little myself but just glacing through this stuff, it is great.
__________________
take it easy and life will be easy
  Reply with quote
13-07-2006, 12:32 PM   #55
mind_raper
Registered User
 
Join Date: Nov 2002
Location: Pakistan
Posts: 57
i guess there's an A.I plug for maya that give u more control over instanced geometry try googling for it, i really dont remmeber its offical web !!!!
__________________
Learn the Rules|Then|
Burn the Rules Book
  Reply with quote
13-07-2006, 01:11 PM   #56
mind_raper
Registered User
 
Join Date: Nov 2002
Location: Pakistan
Posts: 57
Emit more with speed change
here's an example of playing with particles as the object changes the speed as mention'd above in detail ))





enjoy! particling

:p
Attached Files
File Type: ma emitparticle.ma (61.1 KB, 208 views)
__________________
Learn the Rules|Then|
Burn the Rules Book
  Reply with quote
13-07-2006, 10:31 PM   #57
mirek03
Subscriber
 
mirek03's Avatar
 
Join Date: Feb 2006
Location: Australia
Posts: 2,752
a very beautiful effect. im just learning about particles now and that is one hell of a good look.
__________________
take it easy and life will be easy
  Reply with quote
25-11-2006, 12:25 PM   #58
mirek03
Subscriber
 
mirek03's Avatar
 
Join Date: Feb 2006
Location: Australia
Posts: 2,752
hey this is simply maya, not 'my space' drop the porn, be a good boy!
__________________
take it easy and life will be easy
  Reply with quote
22-05-2008, 06:22 PM   #59
RaginRob
Registered User
 
Join Date: May 2008
Location: Europe (Germany)
Posts: 7
how to make object-dependent collision effects
I was wondering if there's a way to make particles behave differently according to the object they collided with. After some hours of trial and error I found this solution:

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.

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 (0, 11 views)
  Reply with quote
14-09-2012, 03:13 PM   #60
David
SM Site Programmer
 
David's Avatar
 
Join Date: Apr 2002
Posts: 3,154
It's normaly bad practice to bring a thread back to life but this one popped up on a Google search I just did and as it's still relevant I thought I'd bump it back up to the top.

If anyone has anything they would like to share would be great to see it.

I might even turn each expression into a tutorial with example then throw the lot out for free.

All the best
Dave
__________________
Worst Response To A Crisis:
From a readers' Q and A column in TV GUIDE: "If we get involved in a nuclear war, would the electromagnetic pulses from exploding bombs damage my videotapes?"
  Reply with quote
Reply
Page 4 of 5 « First 2 3 4 5

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
exporting / importing expressions djb123 Maya Technical Issues 2 10-04-2012 11:52 PM
How are expressions processed? Vesuvian Maya Basics & Newbie Lounge 1 15-02-2010 02:16 PM
facial expressions grunze Maya Basics & Newbie Lounge 1 28-10-2003 07:39 PM
facial phenmones and expressions strytus Animation 4 19-10-2003 05:22 PM
Help with expressions for polyplanes Darkware Programming 10 16-01-2003 12:24 AM