Game Development Reference
In-Depth Information
vertexCoords = #()
for j=1 to numVertices do
(
if(triVertices[j] == true) then
(
vertexCoords[(vertexCoords.count + 1)] = meshOP.getVert customShapeMesh j
)
)
--compute the vectors
P = [A, B, 0]
v0 = vertexCoords[3] - vertexCoords[1]
v1 = vertexCoords[2] - vertexCoords[1]
v2 = P - vertexCoords[1]
--compute the dot products
dot00 = dot v0 v0
dot01 = dot v0 v1
dot02 = dot v0 v2
dot11 = dot v1 v1
dot12 = dot v1 v2
-- Compute barycentric coordinates
invDenom = 1 / (dot00 * dot11 - dot01 * dot01)
u = (dot11 * dot02 - dot01 * dot12) * invDenom
v = (dot00 * dot12 - dot01 * dot02) * invDenom
--Check if point is in triangle
if (u > 0 and v > 0 and u + v < 1 ) then
(
append polyVertices [A, B,0]
--exit --exit from the for loop
)
)
)
)
)
--find all the angles between the current vertex and all the voronoi vertices
A = polyOp.getVert outTriMesh j
for k = 1 to polyVertices.count do
(
--find the angle of B relative to A
B = polyVertices[k] - A
angl = (atan2 B.y B.x)
polyVertices[k].z = angl
)
--sort using angle --> z value
qsort polyVertices ut_compareAngle
Search WWH ::




Custom Search