Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE AFTER EFFECTS: HomeForumBasicsExpressionsTutorialsPodcastsMotion GraphicsTrainingCinema 4DFAQ

Expression for Making a Layer Travel in a Triangle

Cow Forums : Adobe After Effects Expressions

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>
Expression for Making a Layer Travel in a Triangle
by Mark Walczak on Jul 22, 2009 at 7:42:21 pm

Hey Everone,

So, I don't mean to saturate this forum, but what can I say, I need some more help!

My post this time is related to my previous post found here: http://forums.creativecow.net/readpost/227/13654

Now, however, I need to find an expression that will allow me to animate with a triangle motion path. Again, I would love to animate using a mask as a motion path, but that method has a tendency to be less graceful than some simple scripting. I basically need to animate an object traveling in a triangle shape with the equilateral triangle pointing upwards.

Thoughts?

PS - The triangle shape driving the motion needs to have rounded corners - eek!

What makes you explode?
www.explosivegraffix.com


Respond to this post   •   Return to posts index

Re: Expression for Making a Layer Travel in a Triangle
by ben rollason on Jul 23, 2009 at 10:34:08 am

The following draws a triangle between the three points defined by three layers. They could equally well be points that you have inputed manually.

The rounded corner thing is tricky. Either the math gets really complicated. You'd need to have a point moving distant from your original point, but perpendicular to it. At each vertex, you would pause the initial movement for a time and instead animate the point in the arc of a circle around the vertex.

How long that time is depends on the relative length of the sides of the triangle to the arcs of the circles.

Like I said, complicated.

Couldn't you just get the damn thing to follow a spline path? :)

-Ben.



www.benrollason.com

Respond to this post   •   Return to posts index

Re: Expression for Making a Layer Travel in a Triangle
by ben rollason on Jul 23, 2009 at 10:35:28 am

Hmmm. I posted the expression in the box, but it didn't come up, so here it is again...

-Ben.


p1 = thisComp.layer(1).position;
p2 = thisComp.layer(2).position;
p3 = thisComp.layer(3).position;

tpoints = [p1, p2,p3];

tduration = 300; //frames

tFrame = time/thisComp.frameDuration;

tSector = Math.ceil((tFrame) / (tduration/3));

tSector = (tSector < 1?1:(tSector>3?3:tSector));

tBetween = [tSector % 3,tSector -1];

tStage = tFrame % 100;

tP = (tpoints[tBetween[0]]*tStage+ tpoints[tBetween[1]]*(100-tStage))/100;

if (tFrame > tduration) { tP = p1 };




www.benrollason.com

Respond to this post   •   Return to posts index


Re: Expression for Making a Layer Travel in a Triangle
by Mark Walczak on Jul 23, 2009 at 2:37:54 pm

Wow, Ben, that's really incredible stuff. This is a great help!

I could animate the object with a motion path, but I was looking for a more simple solution (as I need to do all sorts of funky stuff with ramping the rate of travel around the triangle, etc). Also, using an expression forces me to learn the code and sort of reverse-engineer certain scripting concepts, as I am still a novice. Your help is very, very much appreciated.

Also, I checked out your reel and was floored - you have some killer work!

Thanks again, this is very helpful,

Mark

What makes you explode?
www.explosivegraffix.com


Respond to this post   •   Return to posts index

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>


FORUMSTUTORIALSMAGAZINETRAININGVIDEOS - REELSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]