FORUMS: list search recent posts

Somebody analyses this Mel Command

COW Forums : Autodesk Maya

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Mostafa Talebi
Somebody analyses this Mel Command
on Oct 18, 2011 at 8:44:08 pm

vector $camPosition = <>;

vector $particlePosition = dirtParticle.worldPosition;

float $distance = mag( $camPosition - $particlePosition);

float $opacityDepth = 1 - linstep(0,50,$distance);


--------------------------

Hello
here you see the command in Maya MEL, it sets the opacity of the particles in a certain distance from the camera. It works well and I
got the result working. But can somebody break it down into edible pieces so that I could find it out far better!!!!! THANKS


Return to posts index


Steve Sayer
Re: Somebody analyses this Mel Command
on Oct 19, 2011 at 7:14:51 pm

"vector $camPosition = <>;This line probably didn't copy correctly from your code. It probably has some coordinates on the right side, correct? Like = < < 1, 2, 3 > >? The brackets seem to get interpreted as HTML tags by the COW.

Anyway, this line is setting the value of our first variable to be equal to a point in space, which I assume is the position of your camera. If your camera moves, this won't work anymore.

vector $particlePosition = dirtParticle.worldPosition;This line sets our second variable to be equal to the position of the particle.

float $distance = mag( $camPosition - $particlePosition);This line finds the difference between those two vectors, which will itself be a vector, and then finds the magnitude of that vector (i.e. the distance between the two points in 3D).

float $opacityDepth = 1 - linstep(0,50,$distance);"Finally, this line sets the value of the '$opacityDepth' variable based on the distance calculated in the previous line.

The linstep function goes from 0 to 1 as the value of '$distance' goes from 0 to 50. Used on its own, it would make the particles transparent when right on top of the camera, and change to fully transparent as they get farther away, to a maximum of 50 units. By using '1 - linstep' this gets reversed, so instead the particles are visible next to the camera and become transparent as they move farther away. (I'm assuming that '$opacityDepth' is then used to affect opacityPP in a proportional way.)

Hope that helps. You can also look up all these concepts in the Maya documentation.

-Steve


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]