PDA

View Full Version : melscript for this?


joel3d
06-05-2007, 09:44 PM
has anyone ever seen an effect like this? Id want it to be effecting more many polys.
heres a simple animation, just using keyframes

Quicktime (http://www.joel3d.com/Special/polyFlip.mov)

I thought it wold be cool if there was Melscript, perhaps the Yrotation being triggered by an influence object

azshall
06-05-2007, 09:58 PM
you could do it using the mag function to tell how far away an object (like a locator) is from said array .. might be easier and faster to do with particles and instancing.... However definitely doable through mel..

Seth

azshall
06-05-2007, 11:21 PM
I've actually setup a scene for you... I'll upload it to the web or attach it to this response when I'm done.. Works nicely :)

So here's the goodness... Distance Driven Card Flip (http://www.polygonkickstand.com/cg/distanceDrivenCardFlip.mb)

Here is the expression in the scene, below is a brief explanation..


float $degrees = 180;

string $objs[] = `listRelatives flippers`;
vector $loctrans = <<locator1.translateX, locator1.translateY, locator1.translateZ>>;

int $i;
for ($i = 0; $i < size($objs); $i++) {
float $trans[] = `getAttr ($objs[$i] + ".translate")`;
vector $objpos = <<$trans[0], $trans[1], $trans[2]>>;

float $distance = mag($loctrans - $objpos);

float $rotate = linstep(6,12,$distance) * $degrees;
float $rotY = `getAttr ($objs[$i] + ".rotateY")`;

if (`currentTime -q` == `playbackOptions -q -min`) {
setAttr ($objs[$i] + ".rotateY") $degrees;
} else {

if ($rotY <= 7) {
setAttr ($objs[$i] + ".rotateY") 0;
} else {
setAttr ($objs[$i] + ".rotateY") $rotate;
}
}
}

clear $objs;


$degrees is how much you want them to rotate ... $objs is just getting a list of objects in a group, all of your cards/whatever...

The linstep function is the falloff. Increasing the 6/12 value will make the influence of effect bigger and lower values will make it so the locator/object has to be almost right on top of them to flip...

This uses a locator or translating object as a basis of its animation ... Works on proximity based on the mag function calculating the distance from our locator/object to each object in the array. If it is in the range, it will begin flipping it.

Seth

Sick Spider
06-06-2007, 12:18 AM
There you go:
You can change whatever you want, just play with the values of move, rotation, num of cubes and rows.

int $cubes = 10;
int $rows = 5;
int $i = 0;
int $rotOnMyKey = 0;
for ($i=0;$i<$rows;$i++)
{
int $r =0;
for ($r=0;$r<$cubes;$r++)
{
string $myPolyCube[] = `polyCube -subdivisionsX 1 -subdivisionsY 1 -name ("polyCube_"+($i+1))`;scale 0.2 1 1 $myPolyCube[0];
move 0 $i ($r*-1) $myPolyCube[0];

currentTime $rotOnMyKey;
$rotOnMyKey++;
setAttr ($myPolyCube[0]+".ry") 0;
setKeyframe ($myPolyCube[0]+".ry");

currentTime ($rotOnMyKey+1);
$rotOnMyKey++;
setAttr ($myPolyCube[0]+".ry") 0;
setKeyframe ($myPolyCube[0]+".ry");

currentTime ($rotOnMyKey+80);
$rotOnMyKey++;
setAttr ($myPolyCube[0]+".ry") 180;
setKeyframe ($myPolyCube[0]+".ry");

$rotOnMyKey++;
}
select -cl;
}

joel3d
06-07-2007, 08:38 PM
thats just crazy guys!

I knew it could be done, just not by me.

good work! thanks.

CGTalk Moderation
06-07-2007, 08:38 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.