how to script a fade out

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 08 August 2009   #1
how to script a fade out

I have some news papers falling which I have simulating with ncloth. I would like to be able to control their opacity so that at a certain distance from the camera they start to fade out.
I don't really know how to do this.

Could someone give me some advice of how to achieve this?
Thanks
 
Old 08 August 2009   #2
Hi flore33

I would prefer to build a node network to achieve what you ask for, but if you want to do it with an expression then you could writ it like this:

//*********************************************


//Give Name of current camera

//Get cameraPosition

vector $camPosV = `xform -q -ws -t camera1`;




//Give Name of clothmesch

vector $spherePosV = `xform -q -ws -t pSphere1`;




// PosCamera minus PosMesh

vector $lenghtV = abs( $camPosV - $spherePosV);




// Lengh of Vector

float $lenghF = mag($lenghtV);




//Change Expression like this: linstep "your startFade", "your endFade"

float $oppacety = `linstep 18 25 $lenghF`;




// revers

float $oppacetyNeu = ($oppacety*(-1)+1);




// set the transparenty attribute of the shader: "your Shader.transparency. ..."

lambert1.transparencyR = $oppacety;

lambert1.transparencyG = $oppacety;

lambert1.transparencyB = $oppacety;




//*********************************************

Cheers,

Ruth
 
Old 08 August 2009   #3
I am trying to learn more how to script so thank you very much for your help.
 
Old 08 August 2009   #4
Hi flore33

I did not consider that the transform of your clothmesh will not move so better calculate the boundingBox:

//Give Name of clothmesch
float $spherePosFArry[] = `xform -q -ws -bb pSphere1`;
vector $bbmin = <<$spherePosFArry[0],$spherePosFArry[1], $spherePosFArry[2]>>;
vector $bbmax = <<$spherePosFArry[3],$spherePosFArry[4], $spherePosFArry[5]>>;
vector $spherePosV = `hermite $bbmax $bbmin <<0, 0, 0>> <<0, 0, 0>> 0.5`;

instate.

Cheers,
R
 
Old 08 August 2009   #5
Hi RuthW

Thank you so much
 
Old 08 August 2009   #6
Thread automatically closed

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.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

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


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.