PDA

View Full Version : can someone help with particles and dist camera


flore33
09-21-2009, 12:34 PM
This is from thread from last week and so far it' what I did with the advice I receive but something is not quite right and I don't knopw what it is.

vector $camPos =`xform -q -ws -t camera1`;
vector $pos=particleShape8.worldPosition;
float $fadeDist=100;
float $dist=`abs(mag($camPos-$pos))`;
float $fadeMultiplier=`linstep 0 $fadeDist $dist`;
$radiusPP=particleShape8.radiusPP;
particleShape8.DistRadiusMulti =$radiusPP*$fadeMultiplier;

I am trying to have the particles getting smaller when they come towards the camera, but I still have some quite big, not sure where i am going wrong.

DistRadiusMulti is an extra attribute and the number go quite small but nevertheless the particles are not so they must be something I am not connected properly.

Thanks

JoshM
09-21-2009, 05:56 PM
What particleRenderType are you using for the particles? Also, how are you setting the DistRadiusMulti to the particles? This would only work if the particles are instances and the ScalePP attr is set to DistRadiusMulti.

Josh

flore33
09-21-2009, 06:28 PM
I'm using blobbysurface.
the distRaduis mult is an extra attribute, which I thought will be connected to the radius pp by stating
$radiusPP=particleShape8.radiusPP;
particleShape8.DistRadiusMulti =$radiusPP*$fadeMultiplier;, but may be I'm wrong.

JoshM
09-21-2009, 08:05 PM
Ahh, ok. Basically, $radiusPP is just a user defined variable that will just hold the value of whatever radiusPP is. So nothing is really updating / changing the per-particle attr radiusPP, which is needed for controlling the size of the blobby surface. It sounds like you don't even need the DistRadiusMulti being that the blobby surface can't use it for size. I think the following lines will fix the expression and control the blobby surface radius as desired:


vector $camPos =`xform -q -ws -t camera1`;
vector $pos=particleShape8.worldPosition;
float $fadeDist=100;
float $dist=`abs(mag($camPos-$pos))`;
float $fadeMultiplier=`linstep 0 $fadeDist $dist`;

//note that there is no $ before radiusPP
//Otherwise mel will create it as a user-defined variable
radiusPP = radiusPP * $fadeMultiplier;

//this is also equivalent
//radiusPP *= $fadeMultiplier;


HTH,
Josh

flore33
09-21-2009, 08:19 PM
ok, I'll try this. the thing also is that the raduisPP is also connected to a ramp, that why there was an other attribute but I'll see, this might fix the problem. thanks.

JoshM
09-21-2009, 09:04 PM
if radiusPP is already connected to the ramp you are going to need to adjust the per-particle attrs.

First, break the connection of the ramp to the radiusPP attr. What you should try to do now is create another per-particle (float) attr named 'radiusScalePP' or something. Then create apply your ramp to this attr (you can use your already existing ramp through the options box Map To attr). Now right click on the radiusScalePP attr and go to arrayMapper1.outValuePP -> Edit Array Mapper and rename the array mapper to something unique like 'scaleArrayMapper'. Then you can access the values of the ramp through the following lines of code:


//same code as earlier

//the outValuePP attr will give the correct value from the ramp
radiusPP = radiusPP * $fadeMultiplier * scaleArrayMapper.outValuePP;


If this doesn't work I over looked something simple being that I didn't really test it before hand. But I'm pretty confident that it will.

HTH,
Josh

flore33
09-21-2009, 09:22 PM
Ok i'll try that in the morning. I left the office now.thanks for ur help..

flore33
09-22-2009, 10:06 PM
Ok it resolveS part of the problem thanks 4 ur help

CGTalk Moderation
09-22-2009, 10:06 PM
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.