Bryan Woods
Forum Replies Created
-
Ah, I see. have to be more specific now I guess. Thanks!
-
Bryan Woods
October 11, 2017 at 3:36 pm in reply to: The right way to precompose a bunch of layers you generate from script?Awesome, I’ll give this a try. Thanks!
-
Thanks Dan. What is the benefit of checking
.canSetExpressionif we can already identify Point of Interest? Is it necessary? -
I was able to figure out a solution to my problem. I needed to add the camera’s current positions to the spherical coordinates in order to offset the origin. Because its based around the active camera, regardless what camera is used, the objects will always remain locked in a sphere around the current camera.
Try copy/pasting the below script onto a 3D layer’s position, with a single-node camera in the scene. Now reposition the 3D layer, and you’ll see it moves around in a sphere. Switch to top view and move the 3D layer around for a better idea of how it works.
r= transform.position[2]+1000*-1;//convert X,Y 2D coordinates with the comp dimensions as a reference
convertX = transform.position[0]/thisComp.width*2*Math.PI-Math.PI;
convertY = transform.position[1]/thisComp.width*2*Math.PI-Math.PI/2;//spherical coordinates
sX = -(Math.cos(convertX-Math.PI/2))*(Math.cos(convertY))*r+thisComp.activeCamera.position[0];
sY = -Math.sin(convertY)*r+thisComp.activeCamera.position[1];
sZ = (Math.sin(convertX-Math.PI/2))*(Math.cos(convertY))*r+thisComp.activeCamera.position[2];[sX,sY,sZ]
-
Well, part of this code comes from another script I wrote that would take a 2D coordinate on a latlong image, and represent it on a sphere in a separate comp. This was great for motion tracking an object in a 360 video. Track the object in the footage as a latlong, then concert that tracking data to spherical coordinates and attach other objects, masks, etc. to it. The code above is a conversion from cartesian to spherical coordinates, and requires the width of the image and assumes a 2:1 aspect ratio for a lat long image.
I’m trying to adapt this code to now work independently of any dimensions. Essentially I’m trying to get a 3D layer to be able to orbit around the camera in a scene. As I drag the layer up/down/left/right, it maintains its distance away from the camera and moves in an arc around the camera, being locked to a sphere. The distance from the camera to the object is the sphere’s radius.
My biggest issue is that I have to set my camera to be at world 0 for this to work as I intend. However, AE cameras when first created, are not placed exactly at world 0, but have an offset of about 1500 in the neg Z.
Hope that helps. If you take my code right now and apply it to the position of a 3D object with a camera in the scene at world 0, it will work correctly and you can see how it orbits around you as you drag the object around.
-
No ideas how to get the inverse of the linear function?
-
The problem I’m having is that i’m getting the inverse of the thickness. As I move the layer closer in Z, the thickness shrinks, and visa versa. I need to get the inverse result.
-
Thanks Dan. I’m also trying to link the beam’s starting thickness to the distance of the layer’s parent position, relative to the camera.
I’ve got this working in the beam’s start thickness parameter:
p1 = thisLayer.parent.position[2];
p2 = thisComp.activeCamera.position;value+length(p1, p2);
but I notice as the layer moves in z towards the camera, the thickness decreases, and visa versa, when it should be the other way around. I thought I could invert the result by multiplying by -1, but that doesn’t seem to be doing anything.
-
I came across this and I wanted to use it for a shape layer, but apparently there’s no such thing as thisLayer.duration? What is the equivalent to get this code to work for a shape layer?
-
Ah, makes sense. Thanks for the explanation.