Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Tracking mask path vertices?

New Here ,
Jun 27, 2013 Jun 27, 2013

Hi all

I've tried many ways to track vertex coordinates of a path(beign it mask or shape path). And the only solution i've found until now was making scripts, which works well, but is not ideal, since running a script everytime a modification is done on the path is not workflow-friendly, specially when making 2D shape animation, where you are always making tiny adjustments on the path and RAM-previewing it like 10 times in 2 minutes, to feel the flow of the motion.

The other way, that was almost perfect for me, was trying to take the vertices data through expressions, but when you get the shape object from the expression, example: thisComp.layer("some-solid").mask("my mask").maskPath.value ...... the value inside after effects becomes an empty [object Object], and in Extendscript Tool, that same object is a [object Shape] with all the information in it. I guess Adobe took off that particular object from expression for perfomance reasons, but i'm not sure.

So, i became aware of things like PathDataSuite and PF_PathVertex from the SDK, which is exaclty what i was looking for, but i was wondering how would be the best way to ouput that data through Effects, to be accessible by expressions, and then, inside After Effects, with expressions, i decide what to do with the path data given by the plugin. But, looking at all the other existing plugins, i realized that the only properties that are accessible by expressions, are things like point, rotation, sliders, dropdown menus, etc....

My question is: How can i output path data through an Effect's property, reachable by expressions. Could be something similar to "Source Text" property, with a string in array format, like [ verticesArray , inTangentsArray ,outTangentsArray ].

Example of 1 segment: [ [ [0,0] , [10,0] ] , [ [-10,-10] , [10,10] ] , [ [10,10] , [-9,0] ] ]

And then, on the position property of a null, i could write the expression: effect("My Effect")("Path data")[0][0]; to get the first vertex position data, and then, doesn't matter where i put that vertex, the null will always follow it's position(relatively).

Finally, in the SDK i was looking for something like PF_ADD_PARAM that could act as if it was PF_ADD_TEXT If you know what i mean.

Any ideas?

P.S. if you made it through here, thank you for reading all this.

TOPICS
SDK
5.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 27, 2013 Jun 27, 2013

Hi Griebel!

I can't tell you about PF_ADD_TEXT, but I've written an effect close to what you want to do.

Here 's the solution I found :

I have 300 Point parameters, representing either vertices ot tangents. (a pain to write, so I wrote a simple app just to write the parameters...)

They are enabled / disabled according to PathNumVertices.

In my case, the points control the path, but you can do the opposite.

The main issue is that parameters are modified during Render call, so, for example, if you attach a layer's position to a Vertex via expression, you'll see that your layer is at the right place, but its "render" hasn't been affected.

After effects computes the geometry first, then comes the rendering. So your layer's position is computed before your parameter is modified.

Then comes the render: your parameter changes, the layer's position changes too, but doesn't generate a new render call, so AE makes a render of your layer at the position your layer was before render call...

But if you intend to use this parameters to control other Effects, then the render calls will occure at the same time... tricky, right?

you can find some informations here: http://forums.adobe.com/thread/1141646?start=0&tstart=0

The discussion's been really further than just Effect's index.

I've been bothering Shachar Carmi with my mask issues for monthes 🙂

Hope it helps!

François

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 28, 2013 Jun 28, 2013

Hi Griebel. (wassup leroy?)

i think there's a way of doing what you wanted, but in a slightly different way than you imagined.

i'll try to give you a broader picture.

there are 2 kinds of parameters in AE:

1. params that affect the render. (normal behavior of params)

2. params that are for UI purposes only, and don't affect the render.

(you can set a flag on param setup to determine this behavior)

when you change a param that affect the render (either by UI or by API), AE invalidates the current frames buffers and triggers a re-render.

changing params that don't affect the render won't help as well, because the user can't draw data from them. (they don't have a data stream)

so whenver you'll try to read a mask and export it's vertices to param values, you encounter the problems Francios has described.

what's my suggestion?

1. create a text sting, defining your masks vertices in java:

"var vertices = [[10, 10], [20, 20], [30, 30], [40, 40]]; \

var layer = app.project.item("this comp's name").layer(thisLayerIndex);"

get a text input from the user in one of the following ways: (there is no "ADD_TEXT" sort of param)

1. http://forums.adobe.com/message/3742840#3742840 (simplest solution)

2. have the user put an expression on another param and read the expresion text from within the pluing. (also pretty simple)

3. learn how to open an os level window. (not so simple)

that text should be java code with a simple syntax such as:

vertices[7] = layer.position + [20, 20]; (just an example!!!)

join your pre-difined string with the user sting and get them to execute via ExecuteScript(). (along with java code to change the mask accoring to the manipulated data)

that way, the java API will do the parsing for you, and the user will nver know java was involved.

of course this method not perfect, but hey, neither are we.

at least it will allow the user to manipulate the mask mathemtically.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 28, 2013 Jun 28, 2013

Hi everyone,

Thank you very much for your reply. It helped me a lot to understand how things works behind the scenes.

Actually, i was trying to get data from a path. Changing a path's shape would be a second step. Right now i only needed the coordinates of every vertex and tangent, so i could attach layers transform properties to it.(but i'm interested in controling individual vertex via keyframe, just not right now).

I read all the threads you linked me and the "bake" solution made me wonder:

Is it a good idea to make the plugin hold a backed version of the animated path?(that would be a lot of data, i guess)

That will solve the problems of render calls, since, as far as i understand, that problem will exist if i try to communicate with the plugin via expressions.

lets say, i have a 300 frames timespan and, for every frame of the comp, the plugin stores the vertices and tangents data inside an array. So, i could access every frame's data through a "timeToFrames()" expression.

So a null's position could be like:

effect("My Effect")("Path data")[ timeToFrames("params to get current frame") ][0][0]

BUT, again, the problem is, how to make this data available to the expression scenario

François, that solution of your's was something i though at first, and then i though "that would take a lot of work to code"(guess i was right hehe), and the other question that i thought was "if i want to get the data, not set it, is point param really going to give me data? Since, in my understanding, this params doesn't change over time, unless it has keyframes or expressions attached to it, which is not what i'm looking for, and since disabling the 'keyframability' of a param makes it unrechable by expressions, i find myself stuck again."

getting a string from an effect's property through expressions, just like i do with a Text Layer's Source Text would be perfect, cause it would give me lots of flexibility to create any kind of calc i wanted in expressions, like calculating rotation of a vertex based os the position of it's tangents and so on...

My main needs right now are not on masking things, but animating 2D charaters, like, the arm of a character is a stroke, and i want the hand(another layer) to stick with the arm, so i could wave it like shit and still have my hand rightly attached to it.

For now i'll try to learn a bit of Cinema 4D and try this solution out http://www.curiousanimal.tv/blog/point-autorig-tutorial/

But i'm lean to find out a solution for this. If we only could pass data as a string to expressions, that would open a world of possibilities for lots of things.

Again,Thank you very much for your time.

Any news would be appreciated.

P.S. François, dyou have a vídeo showing how your plugin works?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 28, 2013 Jun 28, 2013

Hi Griebel (and: fine, thanx Shachar!)

Reading what you describe, I think I have a solution. I didn't use it with the SDK, but I did with scripts and it worked just fine:

_your plugin reads the path data, then writes it to a .txt file. You can choose the way you write your datas. When I did it, it looked like this:

     vert1 = [1,2];

     inTan1 = [0,0];

     outTan1 = [5,6];

     etc...

_your expression reads this .txt file with an "eval()" expression. You can see details here: http://www.graymachine.com/2009/04/expressions-and-external-documents-revisited/

The expression can call any variable from this .txt file, so if you type "vert1", you just get this value: [1,2]

The advantage is that the .txt file should call a new render for your layer, so, no more worries about synch.

The bad part is your layer will call a render twice, and writing to external file and re-read from it can take some time, if you have a lot of points... But if you work on light projects, then you won't even notice the difference.

François

PS: About my plugin, It'll be finished soon (other stuff involved...), so I can show you when it's ready.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 01, 2013 Jul 01, 2013

Hi François

That was exactly what i've done after my first response, haha!!(guess we're on the same vibe)

But i stored the baked data in a text layer. then i've done the eval(sourceText) and accessed the data like "data.frames[0].v[0]"

It worked!

Then i thought "if i can pass a path's data to another path property and it works, but i can't read it through expressions, what if i eval() a string of a function that returns an object properly structured?"

what i mean is: I can take mask2 and link its path to mask1's path through mask("mask1).maskPath , After Effects understands it, even if we can't access the whole data.

I didn't test it yet, but if we make something like a function that return a maskPath property object structured exaclty as a maskPath property must be, and eval it inside mask path property as eval(stringWithFunctionThatReturnsAMaskPath) and inside our script we set the "value" property of our maskPath Object as a properly structured Shape Object, MAYBE After Effects will recognize it! If it works, we can pass any kind of shape we want through a .txt file or a sourceText (i fear textLayers have a char limit).

I'll try it when i have time.

Thanks again...

Griebel

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 01, 2013 Jul 01, 2013

Hi Griebel, glad it works!

I've been digging this way too (you're right, it seems we're on the same vibe!), but maskPath seems to be really opaque... I tried with the Reflection Properties (in the JS Tools Guide), but didn't get anywhere.

I also tried with Shape...

If you find any info, I'd be happy to know!

Cheers,

François

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 11, 2013 Jul 11, 2013

Hi Griebel!

Did you manage to build a structure? I'd be curious to know...

I'm gonna release my plugin soon, so if you wanna see the demo:

http://www.youtube.com/watch?v=J3dWu3Nhtgg

and

http://www.youtube.com/watch?v=UFRZhpG3-V8

Hope you like it!

François

Ce message a été modifié par: françois leroy mistake on the link...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 12, 2013 Jul 12, 2013

Hi François

Unfortunately i didn't have time to do that, because i had to start to work on the animation i was referring to when i was looking for those workarounds.

When the work is finished and published, i'll post the link here, so you guys can see and understand some of my needs and how some things could get a better result if i had control over every vertex.

Right now i'm in the step of doing a custom UI for the script(i'm trying the script approach), maybe next month i'll have those things done.

P.S. This plugin of yours will rock!!! so many possibilities, congratulations! =D

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 12, 2013 Jul 12, 2013
LATEST

Then see you next month!

PS: thanx

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines