## Orb Null Position

Improve and Enhance Video Copilot Plugins

### Orb Null Position

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: 20
Joined: 03/12/2012, 9:18 am

### Re: Orb Null Position

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

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: 20
Joined: 03/12/2012, 9:18 am

### Re: Orb Null Position

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 maptextureSizeY=2048; //height of the texture maporbCenter = 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 maptextureSizeY=2048; //height of the texture maporbCenter = 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 maptextureSizeY=2048; //height of the texture maporbCenter = 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

An example project with three linked nulls.

Orb Null Position example.aep
star+circle

Posts: 935
Joined: 12/6/2014, 3:07 pm
Location: Finland

### Re: Orb Null Position

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

Wow. Thank you so much for doing this. I'll test it on Monday
stevesideas

Posts: 20
Joined: 03/12/2012, 9:18 am