Orb Null Position

Improve and Enhance Video Copilot Plugins

Orb Null Position

Postby stevesideas on 05/23/2019, 2:46 am

Is it possible to create nulls on the texture layer for the diffuse and then get those null positions to be able to place pins that stick to the surface ?
stevesideas
 
Posts: 18
Joined: 03/12/2012, 9:18 am

Re: Orb Null Position

Postby star+circle on 05/28/2019, 11:30 am

Seems to me it would be relatively easy to write an expression that converts a 2D position on the texture map into a 3D position on the Orb surface. You know the center point of the Orb, and the radius. The X and Y coordinates would convert to rotations around the center point at a distance equal to the radius.
star+circle
 
Posts: 935
Joined: 12/6/2014, 3:07 pm
Location: Finland

Re: Orb Null Position

Postby stevesideas on 05/29/2019, 12:58 am

I've found this function from here: https://forums.tigsource.com/index.php?topic=17522.0

// Let x, y be a point on your plane (0..1).
function mapPlaneToSphere(x, y)
z = -1 + 2 * x;
phi = 2 * PI * y;
theta = asin(z);
return vector3(cos(theta) * cos(phi),
cos(theta) * sin(phi),
z);

I wouldn't even know where to begin on how to adapt this for aftereffects and its coordinate system.
stevesideas
 
Posts: 18
Joined: 03/12/2012, 9:18 am

Re: Orb Null Position

Postby star+circle on 06/1/2019, 1:07 am

Yeah, that seems to be doing something similar yet different. Here's what I came up with.

You need a comp named "diffuse texture map" with a 2D null named "Position 01" in it, and a master comp with the Orb, with a 3D null "Orb Position 01" in it. To calculate the position of the "Orb Position 01" 3D null, you would use the following expressions.

Position:
Code: Select all
textureSizeX=4096; //width of the texture map
textureSizeY=2048; //height of the texture map

orbCenter = thisComp.layer("Orb").effect("VC Orb")("Position");
orbRadius = thisComp.layer("Orb").effect("VC Orb")("Radius");
xPos = comp("diffuse texture map").layer("Position 01").transform.position[0]/textureSizeX;
yPos = (textureSizeY-comp("diffuse texture map").layer("Position 01").transform.position[1])/textureSizeY;
orbPositionY = orbCenter[1]+orbRadius*Math.cos(yPos*Math.PI);
orbPositionX = orbCenter[0]+orbRadius*Math.sin((xPos+.5)*Math.PI*2)*Math.abs(Math.sin(yPos*Math.PI));
orbPositionZ = orbCenter[2]-orbRadius*Math.cos((xPos+.5)*Math.PI*2)*Math.abs(Math.sin(yPos*Math.PI));
[orbPositionX, orbPositionY, orbPositionZ]


However, the null will not be correctly oriented so needs this:

Orientation:
Code: Select all
textureSizeX=4096; //width of the texture map
textureSizeY=2048; //height of the texture map

orbCenter = thisComp.layer("Orb").effect("VC Orb")("Position");
orbRadius = thisComp.layer("Orb").effect("VC Orb")("Radius");
xPos = comp("diffuse texture map").layer("Position 01").transform.position[0]/textureSizeX;
yPos = (textureSizeY-comp("diffuse texture map").layer("Position 01").transform.position[1])/textureSizeY;
orbOrientationY = -360*(xPos+.5);
[0, orbOrientationY,0]


X Rotation:
Code: Select all
textureSizeX=4096; //width of the texture map
textureSizeY=2048; //height of the texture map

orbCenter = thisComp.layer("Orb").effect("VC Orb")("Position");
orbRadius = thisComp.layer("Orb").effect("VC Orb")("Radius");
xPos = comp("diffuse texture map").layer("Position 01").transform.position[0]/textureSizeX;
yPos = (textureSizeY-comp("diffuse texture map").layer("Position 01").transform.position[1])/textureSizeY;
orbRotationX = -180*(yPos-.5);
orbRotationX   


Note that the layer names are fixed here, so for the subsequent pairs of 2D and 3D nulls, you will have to change the layer names in each of the expressions to "Position 02", "Position 03", etc.
star+circle
 
Posts: 935
Joined: 12/6/2014, 3:07 pm
Location: Finland

Re: Orb Null Position

Postby star+circle on 06/1/2019, 1:14 am

An example project with three linked nulls.

Orb Null Position example.aep
(234.74 KiB) Downloaded 61 times
star+circle
 
Posts: 935
Joined: 12/6/2014, 3:07 pm
Location: Finland

Re: Orb Null Position

Postby star+circle on 06/1/2019, 1:18 am

Some extra lines there, you don't need the orbRadius and orbCenter lines in the Orientation and X Rotation expressions...
star+circle
 
Posts: 935
Joined: 12/6/2014, 3:07 pm
Location: Finland

Re: Orb Null Position

Postby stevesideas on 06/1/2019, 4:47 am

Wow. Thank you so much for doing this. I'll test it on Monday :)
stevesideas
 
Posts: 18
Joined: 03/12/2012, 9:18 am


Return to VC Plugin Support

cron