Exemplo n.º 1
0
    // ! THIS IS THE HEAVY WORK THAT THIS DESIGN HAS TO WORK WITH !
    public static void SpitMesh(Chunk chunk)
    {
        PrimVUT[,,] vuts = chunk.Vuts;
        byte[,,] blocks  = chunk.Blocks;
        VUT totalVUT = chunk.MainVUT;

        totalVUT.Clear();
        for (int i = 0; i < Chunk.Width; i++)
        {
            for (int j = 0; j < Chunk.Height; j++)
            {
                for (int k = 0; k < Chunk.Width; k++)
                {
                    if (blocks[i, j, k] != 0)
                    {
                        totalVUT.vertices.AddRange(vuts[i, j, k].vertices);
                        totalVUT.uvs.AddRange(vuts[i, j, k].uvs);
                        foreach (int tri in vuts[i, j, k].triangles)
                        {
                            totalVUT.triangles.Add(tri + (totalVUT.vertices.Count - vuts[i, j, k].vertices.Length));
                        }
                    }
                }
            }
        }
        finishedWork.Enqueue(chunk);
    }
Exemplo n.º 2
0
    public void SetMesh(VUT vut)
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();
        vut.ToMesh(MyMesh);
        mCollider.sharedMesh = MyMesh;
        mRenderer.enabled    = true;
        //UnityEngine.Debug.Log("C " + this.Name + " " + sw.ElapsedMilliseconds / 1000f);
    }
Exemplo n.º 3
0
 // Use this for initialization
 void Awake()
 {
     Blocks    = new byte[Width, Height, Width];
     Vuts      = new PrimVUT[Width, Height, Width];
     MainVUT   = new VUT(new List <Vector3>(), new List <Vector2>(), new List <int>());
     mFilter   = GetComponent <MeshFilter>();
     mRenderer = GetComponent <MeshRenderer>();
     mCollider = GetComponent <MeshCollider>();
     MyMesh    = mFilter.mesh;
     //MyMesh.MarkDynamic();
     enabled = false;
 }