View Full Version : Animate visibility of many objects
fredriklar 04-25-2008, 01:37 PM Can anybody help me with following task?
I want to animate the visibility of several objects as the camera gets near.
The ideal thing would be a locator that I can animate and who turns on the visibility attribute of each object as it reaches the objects boundingbox. The object should stay visible when the locator leaves and goes to next object.
Regards Fredrik
|
|
isamuraiqat
04-25-2008, 09:33 PM
did ya try to do an expression which goes sth like this
supposing the locator is goin in a straight line along an axis
if ((object.translateX - locator.translateX)<0){
object.visibility = 1;}
run this expression over all the objects, and voila
if its not goin in a straight line, then u just have to go over some more calculations and you'll have another condition over the for loop to specify, ther's a really awesome one in the mel scripting session, ive seen it a couple of months back
you can also use distance dimension nodes which will setup 2 locators
In my head I imagine you would have 1 locator on each object and 1 for the camera.
then create a distance dimension node between the camera and the first object (will have to do this one at a time.)
check the measurements of the distancedimension node, after it reaches a specified proximity set the visibility and then reconnect the distance dimension to use the next objects locator and begin measuring again.
its not the greatest solution but you were not very descriptive as to the application of the script.
oh and I would probably make this an expression if you are using this for time based animations.
Here's a basic distance calculating script. Just set it up for how you need to use it in an expression and you should be good to go. You'll need to add stuff like:
if ($fDistance < $someGivenAmount)
setAttr ($disappearingObject+".visiblity") 0;
else
setAttr ($disappearingObject+".visiblity") 1;
The actual calculation:
float $faObjectA_Xforms[] = `xform -q -ws -t $sObjectA`;
float $faObjectB_Xforms[] = `xform -q -ws -t $sObjectB`;
float $dx = ($faObjectA_Xforms[0] - $faObjectB_Xforms[0]);
float $dy = ($faObjectA_Xforms[1] - $faObjectB_Xforms[1]);
float $dz = ($faObjectA_Xforms[2] - $faObjectB_Xforms[2]);
$fDistance = sqrt(($dx*$dx) + ($dy*$dy) + ($dz*$dz));
CGTalk Moderation
04-30-2008, 06:16 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.