PDA

View Full Version : Changing particles look on camera distance


nelsig
01-14-2007, 08:38 AM
Hi

I have a points cloud and when it comes near the camera I want to change it to diamonds shapes.
Any idea for an expression changing the look from point to an instanced objet based on the camera distance ... ?

Thanks a lot

nelsig
01-14-2007, 10:08 AM
Ok with help of some existing threads

I'm happy with this script... but there is just someting I would like to add... it's when the diamonds appear I want to scale it from zero to 1... any Idea how to do it ?

// DISTANCE BETWEEN PARTICLE AND CAMERA
vector $camPosition = <<camera1.translateX, camera1.translateY, camera1.translateZ>>;
vector $particlePosition = particleShape1.worldPosition;
particleShape1.distanceToCamPP = mag($particlePosition-$camPosition);

// ATTRIBUTE NULL OR DIAMOND OBJECT
if (particleShape1.distanceToCamPP < 20)
{
particleShape1.customIndex = 1;
}
else
{
particleShape1.customIndex = 0;
}

// SCALE DIAMONDS WITH CAM DISTANCE
particleShape1.distanceSize = ?????

du-j
01-14-2007, 01:01 PM
I just added couple lines of code.
Try this one:

// DISTANCE BETWEEN PARTICLE AND CAMERA
vector $camPosition = <<camera1.translateX, camera1.translateY, camera1.translateZ>>;
vector $particlePosition = particleShape1.worldPosition;
particleShape1.distanceToCamPP = mag($particlePosition-$camPosition);
// ATTRIBUTE NULL OR DIAMOND OBJECT

if (particleShape1.distanceToCamPP < 20)
{

particleShape1.customIndex = 1;


float $smoothScale = smoothstep(particleShape1.changeTime,(particleShape1.changeTime+particleShape1.interval),age);
if ($smoothScale !=1)
particleShape1.distanceSize = $smoothScale;

//Change scale smoothly from 0 to 1
}

else
{
particleShape1.customIndex = 0;
particleShape1.distanceSize =1;


particleShape1.changeTime = time;
//Remember the time the diamonds appear

}

"changeTime" is the time that the diamonds appear.
"interval" desides how long the diamonds will take to change scale from 0 to 1.
I chose command "smoothstep" ,and you can try the "linstep" as well.
Hope that will work.
And good luck!

nelsig
01-15-2007, 04:55 AM
Thanks for that great scripting ... I was asking me how to create smooth transition... your answer just come well

Thanks

CGTalk Moderation
01-15-2007, 04:55 AM
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.