Game Development Reference
In-Depth Information
--include each vertex one at time and do triangulation
for p in vertices do
(
--setup the edge buffer
edges = #()
--for all the triangles currently in the triangulated mesh, do the check
for j = delunayTriangles.count to 1 by -1 do
(
t = delunayTriangles[j]
circumCircle = [0,0,0] --contains a circle using xy for the center and z for the radius
--check if point p is inside the circumcircle of the current triangle
inside = ut_isInsideCircumcircle p t circumCircle
if(inside == true) then --store the edges and delete the triangle from the triangulation
(
tedg = tedge t.p1 t.p2
append edges tedg
tedg = tedge t.p2 t.p3
append edges tedg
tedg = tedge t.p3 t.p1
append edges tedg
deleteItem delunayTriangles j
)
)
--tag multiple edges to prevent their use when creating triangles
for j=1 to edges.count do
(
e1 = edges[j]
for k = j+1 to edges.count do
(
e2 = edges[k]
if(e1.p1 == e2.p2 and e1.p2 == e2.p1) then
(
e1.p1 = [-1,-1]
e1.p2 = [-1,-1]
e2.p1 = [-1,-1]
e2.p2 = [-1,-1]
)
)
)
--form new triangles using the remaining edges and current vertex
for j=1 to edges.count do
(
ee = edges[j]
if (ee.p1 == [-1,-1] or ee.p2 == [-1,-1]) then
continue
Search WWH ::




Custom Search