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

toWorld/toComp question

Contributor ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

I've got a sphere created using VideoCopilot's Orb effect, and a camera. I want to find the 2d comp position of the middle of that sphere, and it's giving me a headache... I've tried this, which just gives me the centre of the comp (applied to a 2d null):

q = thisComp.layer("ORB").toComp(thisComp.layer("ORB").effect("VC Orb")("Position"));
[q[0], q[1]]

I'm guessing this is because the orb layer is 2d, and in the middle of frame (as normal) so it's just finding the coordinates given by the orb's position (960,540,0). I've tried positioning a 3d null at [960,540,0] and converting its coordinates with one of these options:

L = thisComp.layer("Null");
option1 = L.toComp(L.position);
option2 = L.fromComp(L.position);
option3 = L.toWorld(L.position);
option4 = L.fromWorld(L.position);

None of them work. I'd expect toComp to be the one to use, but although the values it gives change when the null is moved, they don't bear any resemblance to the actual frame size - top left comes out at [178, -52] and bottom right at about [2740, 1432]. The only thing that's causing the orb not to appear in the centre of frame is the camera... here's a screenshot of the null (selected), and a text layer that shows the 2d coordinates I'm getting with toComp().

NoMagnolia_0-1620145431266.png

 

TOPICS
Expressions

Views

1.1K

Translate

Translate

Report

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 ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

VC orb gives you the 3D position of the orb. No need to use anything else. If you offset the position of the layer then you have to compensate for X and Y but as long as the layer is a comp center the Position property is accurate. I'm not sure about what you are trying to do but if you want to position a null at the center of the orb all you need to do is open the Parent/Link column (Shift + F4) and drag the pickwhip from the 3D null's position to the Position property of VC Orb.

VC Orb.png

 

Votes

Translate

Translate

Report

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
Contributor ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

Thanks Rick. That's not quite what I mean: the Position property on the effect is [960,540,0] but that's not actually where the sphere is centred, because there's a camera involved which is to the right of the sphere and tilted slightly downwards. So the sphere looks like it's somewhere around [432,540] according to the info panel. I can put a 3d null at the same point to make it easier to work out, I just need to convert that null's position in 3d space into 2d screen coordinates. 

Votes

Translate

Translate

Report

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 ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

If the Layer with VC Orb is at comp center then the Position value for VC orb is the 3D position value in the comp. All I did was drag the pickwhip from the position property of the Null to the Position Property of VC Orb and the null follows the orb no matter where you put it or where the camera is. 

 

If you want to get the 2D position value then you would use the position of a null tied to the VC Orb effect as the source. 

 

What are you trying to accomplish? The beauty of VC Orb is that it uses AE/s 3D space perfectly as long as the 2D layer is at the default position, scale and rotation. I don't have time to show you how to do that, but it's the same way you would do it with any 3D layer. 

 

If you told me exactly what you are trying to accomplish I could point you to a solution.

 

 

Votes

Translate

Translate

Report

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 ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

I made a simple comp using a 3D null tied to VC Orb/Position with a simple pickwhip expression, then used Dan Ebberts' Layer Space Transformations expression to point at the null and move the position of Lens Flare on a 2D solid layer. It took about 2 minutes. 

Orb.gif

All that is left is to use Dan's expression for lens flare brightness to complete the composite. 

Votes

Translate

Translate

Report

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
Contributor ,
May 05, 2021 May 05, 2021

Copy link to clipboard

Copied

Hi Rick

 

That still isn't what I'm after, sorry! I've made a short video showing the problem...

 

It's the presence of the camera that's complicating it - this ought to be simple, but I just can't think how to get the 2d coords I need here! I want to use them to feed into the position on a (2d) shape layer so it's locked to wherever the middle of the sphere is, whatever the camera's doing. [Obviously, there could be situations where there isn't a corresponding 2d position, eg if the sphere goes behind the camera, but I'm not really worried about those]

Votes

Translate

Translate

Report

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
Contributor ,
May 05, 2021 May 05, 2021

Copy link to clipboard

Copied

Aaaargh please ignore me. I am a total dummy. It's fixed!! I thought I'd tried everything but I hadn't. I'm off now to hang myhead in shame 🙂

Votes

Translate

Translate

Report

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 ,
May 05, 2021 May 05, 2021

Copy link to clipboard

Copied

LATEST

The toComp() method returns the 2D coordinates of a 3D layer in the comp view and returns the X and Y position of the target layer and the Zoom value of the comp camera.

toComp.gif

The zoom value is used to help calculate the 2D position value for a 3D layer. It works with the distance from the camera. 

 

This is my expression for the text layer:

 

 

L = thisComp.layer("Null 1");
P = L.toComp([0, 0, 0]);
X = Math.round(P[0]);
Y = Math.round(P[1]);
Z = Math.ceil(P[2]); // Camera Zoom Value 
"[" + X + ", " + Y + ", Zoom: " + Z + "]"

 

 

You need to attach the Null to the VC Orb/Position property using an expression because toComp works on a layer, not on a property. Here's a funky project you might want to play with.

vc orb.gif

Glad you figured it out. 

Votes

Translate

Translate

Report

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