Esempio n. 1
0
bool nv::computeCircularBoundaryMap(HalfEdge::Mesh * mesh)
{
    HalfEdge::Vertex * vertex = findBoundaryVertex(mesh);

    if (vertex == NULL)
    {
        return false;
    }

    // Compute boundary length.
    float boundaryLength = 0.0f;

    HalfEdge::Edge * const firstEdge = vertex->edge();
    HalfEdge::Edge * edge = firstEdge;
    do {
        boundaryLength += edge->length();
        edge = edge->next();
    } while (edge != firstEdge);

    float length = 0.0f;

    edge = firstEdge;
    do {
        float angle = length * 2.0f * PI / boundaryLength;
        edge->vertex()->tex.set(cos(angle), sin(angle));

		length += edge->length();
        edge = edge->next();
    } while (edge != firstEdge);

    return true;
}