Pinning an object on the surface of cc Sphere (rotation bug)

Scripting for After Effects

Pinning an object on the surface of cc Sphere (rotation bug)

Postby brurpo on 07/15/2015, 12:49 pm

Hi there!

I'm no programmer, far from it, I am just an artist.

I need to streamline the process of pinning icons on a globe for less experienced users to use it on a daily basis.

So I made this script after a lot of trial and error.

Code: Select all
p1 = transform.position;
p2 = thisComp.layer("CENTRO").transform.position;
p3 =  thisComp.layer("ESFERA").effect("CC Sphere")("Radius");
VECTOR = p1 - p2;
VECN = normalize(VECTOR);
DIS = length(VECTOR);
DISR = p3;
DISP = p3*VECN;
DISP + p2


It works, it pins the icon to the sphere so anyone can just drag the icon and the script automatically pins it to the globe.

Thing is it pins, but it slides in relation to the texture beneath it.
To confirm if the problem was on the script that rotates the sphere, I used 2 lines of 3d stroke, and bingo, it snaps perfectly, so the problem lies on the script that rotates the CCSphere.

I tried various scripts that I found on the internet that rotates CCSphere according to the camera, with and without the script on z axis, but no luck.

Any Ideas?

Thanks!!
brurpo
 
Posts: 3
Joined: 07/15/2015, 12:39 pm
System Specs: i7 3930k
2x GTX680
32Gb RAM

Re: Pinning an object on the surface of cc Sphere (rotation bug)

Postby star+circle on 07/15/2015, 10:19 pm

I guess the first question is what is the script that you are using to rotate the sphere in relation to the 3D camera...
star+circle
 
Posts: 764
Joined: 12/6/2014, 3:07 pm
Location: Finland

Re: Pinning an object on the surface of cc Sphere (rotation bug)

Postby star+circle on 07/15/2015, 11:34 pm

This code works fine in connecting camera to cc sphere, assuming you just want to rotate the view around, and don't move on the z-axis:

http://www.motion-graphics-exchange.com ... 39a347c787
star+circle
 
Posts: 764
Joined: 12/6/2014, 3:07 pm
Location: Finland

Re: Pinning an object on the surface of cc Sphere (rotation bug)

Postby brurpo on 07/16/2015, 11:35 am

Thanks a lot man!
Sorry for the late response.

I saw the same script here:
https://forums.creativecow.net/thread/227/452

It is much much better, thanks!

It now behaves properly!

I was using the default lookat expression, described by Andrew, but it does not behave properly.

Still, there is some minor sliding, but I am pretty sure its because the internal focal length of ccSphere is unknown, I got the best result with ae camera set at 200mm.

I saw a script somewhere that uses a displacement map on ccSphere to simulate AE camera focal length. Will research some more.
brurpo
 
Posts: 3
Joined: 07/15/2015, 12:39 pm
System Specs: i7 3930k
2x GTX680
32Gb RAM


Return to After Effects Expressions