FORUMS: list search recent posts

Assist me on Writing this Expression

COW Forums : Autodesk Maya

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Mostafa Talebi
Assist me on Writing this Expression
on Nov 2, 2011 at 12:27:58 am

Hello Friends

I have a scene with snow particles being emitted.

I need an expression to operate me the following operation:

The camera moves and the snow being to a certain distant from the camera have a range of scale, and the particles out of that camera have another range of scale. to my simple language something like this:

variable $certainDistance = rand(48, 52)// the specified extent
if ( snowParticle is in $certainDistance from the camera ) {

snowParticle.scale = rand(.5, 1.5);{
else{
snowParticle.scale = rand(.1, .6)
}
//

finished :D


Return to posts index


Steve Sayer
Re: Assist me on Writing this Expression
on Nov 2, 2011 at 7:53:37 pm

To find the distance from the camera, you just need to subtract one position vector from the other. So it would start off something like this:

float $camPosition[] = `getAttr camera1.translate`;
vector $camVector = < <$camPosition[0], $camPosition[1], $camPosition[2]> >;
vector $difference = $camVector - particleShape1.position;
float $distance = mag($difference);
I'm assuming you're using it as a creation expression.

(Remember to remove the spaces between the < and > symbols. I have to use those extra spaces otherwise the COW thinks I'm entering HTML codes.)

Hope that helps.

-Steve


Return to posts index

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