align image to vertex pair
Posted: Sat Sep 07, 2013 1:30 pm
I've got "grass" that I align to the surface of a fixture. This script requires the user to select two vertices and an image, and then automatically aligns the image to the angle of the vertices:
Code: Select all
vertex[] vertList = getSelectedVertices();
image [] images = getSelectedImages();
if ((vertList.length == 2) || (images.length == 0))
{
vertex directedVert;
directedVert.wx = vertList[0].wx - vertList[1].wx;
directedVert.wy = vertList[0].wy - vertList[1].wy;
float angle = atan2(directedVert.wy,directedVert.wx);
for (int i = 0; i < images.length; i++)
{
images[i].setAngle(angle);
}
}