Ejemplo n.º 1
0
    // Regenerates the mesh from the ground up
    void Regenerate()
    {
        // Create a new GenMesh to begin building the mesh
        GenMesh mesh = new GenMesh();

        // and a petal, for good measure
        Vector3 s = editablePoints.Length > 0 ? editablePoints[0] : Vector3.zero, e = editablePoints.Length > 1 ? editablePoints[1] : Vector3.zero;

        mesh += new GenTube(Vector3.zero, s - Vector3.zero)
        {
            radius             = radius,
            widthCurve         = widthCurve,
            lengthCurve        = lengthCurve,
            upCurve            = upCurve,
            twistCurve         = twistCurve,
            numSegmentVertices = numSegments,
        };
        mesh += new GenSymmetrise(new GenPetal(s, e - s, 0.3f, petalCurve, 128), 8, s, Vector3.up);

        // Copy the GenMesh contents to the mesh
        mesh.CopyToUnityMesh(generatedMesh);

        // Transfer new mesh contents to filter
        generatedMesh.RecalculateNormals();
        GetComponent <MeshFilter>().sharedMesh = generatedMesh;
    }
Ejemplo n.º 2
0
 public GenSymmetrise(GenMesh source, int numberOfCopies, Vector3 rotationOrigin, Vector3 lineOfSymmetry)
 {
     this.rotationOrigin = rotationOrigin;
     this.lineOfSymmetry = lineOfSymmetry;
     this.numberOfCopies = numberOfCopies;
     this.sourceMesh     = source;
 }
Ejemplo n.º 3
0
    /// <summary>
    /// Appends a GenMesh to another
    /// </summary>
    public static GenMesh operator +(GenMesh left, GenMesh right)
    {
        GenMesh outputMesh = new GenMesh(left);

        left.Validate();
        right.Validate();
        outputMesh.AddElements(right.vertices.ToArray(), right.triangles.ToArray(), right.colors.ToArray());

        return(outputMesh);
    }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructs a deep clone of an exisitng GenMesh
 /// </summary>
 /// <param name="source">The exisitng GenMesh to clone into this one</param>
 public GenMesh(GenMesh source)
 {
     vertices  = new List <Vector3>(source.vertices);
     triangles = new List <int>(source.triangles);
     colors    = new List <Color32>(source.colors);
 }
Ejemplo n.º 5
0
 private void Start()
 {
     gm = new GenMesh();
     vv = gm.Init(10, 10);
     gm.UpdateMesh_Public(vv);
 }