Ejemplo n.º 1
0
 /// <summary>
 /// Clears all data in this mesh.
 /// </summary>
 public void Clear()
 {
     Vertices.Clear();
     Normals.Clear();
     UVs.Clear();
     Triangles.Clear();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Clear Mesh
 /// </summary>
 public void Clear()
 {
     Positions.Clear();
     Normals.Clear();
     UVs.Clear();
     Indices.Clear();
 }
Ejemplo n.º 3
0
 public void Clear()
 {
     Vertices.Clear();
     UVs.Clear();
     Indices.Clear();
     Normals.Clear();
     Colours.Clear();
 }
Ejemplo n.º 4
0
    public void Calculate(int index = 0)
    {
        Vertices.Clear();
        Triangles.Clear();
        UVs.Clear();

        var s = Size / 2f;

        Vector3[] p = new Vector3[] {
            new Vector3(-s, -s, -s) + Position,             // 0 0
            new Vector3(-s, s, -s) + Position,              // 1 1
            new Vector3(s, s, -s) + Position,               // 2 2
            new Vector3(s, -s, -s) + Position,              // 3 3

            new Vector3(-s, -s, s) + Position,              // 4 0
            new Vector3(-s, s, s) + Position,               // 5 1
            new Vector3(s, s, s) + Position,                // 6 2
            new Vector3(s, -s, s) + Position,               // 7 3
        };

        for (int i = 0; i < Faces.Length; i++)
        {
            if (Faces[i])
            {
                Triangles.AddRange(AddTriangles(index + Vertices.Count));
                UVs.AddRange(UVPacker.GetCubeUVs(i, CubeTypes[type]));

                switch (i)
                {
                case 0: Vertices.AddRange(new Vector3[] { p[0], p[1], p[2], p[3] }); break;

                case 1: Vertices.AddRange(new Vector3[] { p[3], p[2], p[6], p[7] }); break;

                case 2: Vertices.AddRange(new Vector3[] { p[7], p[6], p[5], p[4] }); break;

                case 3: Vertices.AddRange(new Vector3[] { p[4], p[5], p[1], p[0] }); break;

                case 4: Vertices.AddRange(new Vector3[] { p[1], p[5], p[6], p[2] }); break;

                case 5: Vertices.AddRange(new Vector3[] { p[4], p[0], p[3], p[7] }); break;

                default: break;
                }
            }
        }

        this.Calculated = true;
    }
Ejemplo n.º 5
0
        public void Optimise()
        {
            List <C2Vertex> points = new List <C2Vertex>();
            List <Vector3>  verts  = new List <Vector3>();
            List <Vector2>  uvs    = new List <Vector2>();

            for (int i = 0; i < Verts.Count; i++)
            {
                C2Vertex p = new C2Vertex(Verts[i], UVs[i]);

                //Console.WriteLine("Vert " + i);
                int newID = points.IndexOf(p);
                //int newID = verts.IndexOf(Verts[i]);

                if (newID == -1)
                {
                    //Console.WriteLine("Adding " + p.ToString());
                    points.Add(p);
                    verts.Add(Verts[i]);
                    uvs.Add(UVs[i]);
                    newID = verts.Count - 1;
                }

                for (int j = 0; j < Faces.Count; j++)
                {
                    Faces[j].ReplaceVertID(i, newID);
                }
            }

            //Console.WriteLine("Reduced Vert count from " + Verts.Count + " to " + verts.Count);
            //Console.WriteLine("Reduced UV count from " + UVs.Count + " to " + uvs.Count);

            Verts.Clear();
            for (int i = 0; i < verts.Count; i++)
            {
                Verts.Add(verts[i]);
            }
            UVs.Clear();
            for (int i = 0; i < uvs.Count; i++)
            {
                UVs.Add(uvs[i]);
            }
        }
Ejemplo n.º 6
0
        private void StartTubeSegment()
        {
            currentSegmentLength = 0;
            Verts.Clear();
            Tris.Clear();
            UVs.Clear();

            CurrentSegment = new GameObject();
            CurrentSegment.AddComponent <MeshFilter>();
            CurrentSegment.AddComponent <MeshRenderer>();

            Mesh = CurrentSegment.GetComponent <MeshFilter>().mesh;
            Mesh.MarkDynamic();
            CurrentSegment.GetComponent <Renderer>().material = Material;
            Mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;

            UpdateVertsAndUVs();
            Mesh.RecalculateNormals();
            LoopCount = 1;
        }