Cygnus, you actually created a 2 sided triangle.
try replacing
with
Now I might have the vertex orders incorrect, making the square half visible on one side and half visible on the other. I can never seem to remember wether the order should be clockwise or counterclockwise.
try replacing
tri1=addtriangle(surface,v1,v2,v3) tri2=addtriangle(surface,v1,v3,v2)
with
tri1=AddTriangle(surface,v1,v2,v3) tri2=AddTriangle(surface,v2,v4,v3)
Now I might have the vertex orders incorrect, making the square half visible on one side and half visible on the other. I can never seem to remember wether the order should be clockwise or counterclockwise.