Exemple #1
0
    public PolySet Inset(PolySet polys, float interpolation)
    {
        PolySet    stitchedPolys = StitchPolys(polys);
        List <int> verts         = polys.GetUniqueVertices();

        //Calculate the average center of all the vertices
        //in these Polygons.

        Vector3 center = Vector3.zero;

        foreach (int vert in verts)
        {
            center += m_Vertices[vert];
        }
        center /= verts.Count;

        // Pull each vertex towards the center, then correct
        // it's height so that it's as far from the center of
        // the planet as it was before.

        foreach (int vert in verts)
        {
            Vector3 v      = m_Vertices[vert];
            float   height = v.magnitude;
            v = Vector3.Lerp(v, center, interpolation);
            v = v.normalized * height;
            m_Vertices[vert] = v;
        }

        return(stitchedPolys);
    }
Exemple #2
0
    public PolySet Extrude(PolySet polys, float height)
    {
        PolySet    stitchedPolys = StitchPolys(polys);
        List <int> verts         = polys.GetUniqueVertices();

        foreach (int vert in verts)
        {
            Vector3 v = m_Vertices[vert];
            v = v.normalized * (v.magnitude + height);
            m_Vertices[vert] = v;
        }
        return(stitchedPolys);
    }
Exemple #3
0
    // public PolySet Inset(PolySet polys, float interpolation)
    // {
    //     PolySet stitchedPolys = StitchPolys(polys);
    //     List<int> verts = polys.GetUniqueVertices();
    //     //Calculate the average center of all the vertices
    //     //in these Polygons.
    //     Vector3 center = Vector3.zero;
    //     foreach (int vert in verts)
    //         center += m_Vertices[vert];
    //     center /= verts.Count;
    //     // Pull each vertex towards the center, then correct
    //     // it's height so that it's as far from the center of
    //     // the planet as it was before.
    //     foreach (int vert in verts)
    //     {
    //         Vector3 v = m_Vertices[vert];
    //         float height = v.magnitude;
    //         v = Vector3.Lerp(v, center, interpolation);
    //         v = v.normalized * height;
    //         m_Vertices[vert] = v;
    //     }
    //     return stitchedPolys;
    // }

    public PolySet Extrude(PolySet polys, float height)
    {
        PolySet    stitchedPolys = StitchPolys(polys);
        List <int> verts         = polys.GetUniqueVertices();

        // Take each vertex in this list of polys, and push it
        // away from the center of the Planet by the height
        // parameter.
        foreach (int vert in verts)
        {
            Vector3 v = m_Vertices[vert];
            v = v.normalized * (v.magnitude + height);
            m_Vertices[vert] = v;
        }
        return(stitchedPolys);
    }
Exemple #4
0
    private static PolySet Extrude(ICollection <Polygon> polygons, IList <Vector3> vertices, PolySet polys, float height)
    {
        PolySet     stitchedPolys = StitchPolys(polygons, vertices, polys, out EdgeSet _);
        IList <int> verts         = PolySet.GetUniqueVertices(polys);

        // Take each vertex in this list of polys, and push it
        // away from the center of the Planet by the height
        // parameter.

        foreach (int vert in verts)
        {
            Vector3 v = vertices[vert];
            v = v.normalized * (v.magnitude + height);
            vertices[vert] = v;
        }

        return(stitchedPolys);
    }
Exemple #5
0
    public PolySet Inset(PolySet polys, float interpolation)
    {
        PolySet    stitchedPolys = StitchPolys(polys);
        List <int> verts         = polys.GetUniqueVertices();

        Vector3 center = Vector3.zero;

        foreach (int vert in verts)
        {
            center += m_Vertices[vert];
        }
        center /= verts.Count;

        foreach (int vert in verts)
        {
            Vector3 v      = m_Vertices[vert];
            float   height = v.magnitude;
            v = Vector3.Lerp(v, center, interpolation);
            v = v.normalized * height;
            m_Vertices[vert] = v;
        }
        return(stitchedPolys);
    }