示例#1
0
        public Material GetRunTimeRendererData(QuadStatus quadStatus)
        {
            switch (quadStatus)
            {
            case QuadStatus.Front:
                return(blockData.frontTex);

            case QuadStatus.Back:
                return(blockData.backTex);

            case QuadStatus.Top:
                return(blockData.topTex);

            case QuadStatus.Bottom:
                return(blockData.bottomTex);

            case QuadStatus.Right:
                return(blockData.rightTex);

            case QuadStatus.Left:
                return(blockData.leftTex);

            default:
                Debug.LogError("Runtime-Error Excepiton Type");
                return(null);
            }
        }
示例#2
0
        private void DrawQuad(int height, int x, int y, QuadStatus quadStatus)
        {
            var blockID  = runtimeWorldData[height, x, y];
            var blockMap = blockMaps[blockID];

            var pivot = new Vector3(x, height, y);

            var runtimeData = runtimeSharedRendererData.Find(val => val.matName == blockMap.GetRunTimeRendererData(quadStatus).name);

            var verIndex = runtimeData.vertices.Count;

            runtimeData.rendererCaches.Add(new RendererCache()
            {
                pos          = new Vector3(x, height, y),
                verticeIndex = verIndex
            });

            switch (quadStatus)
            {
            case QuadStatus.Top:
                runtimeData.vertices.Add(pivot + new Vector3(0, 1, 1) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(1, 1, 1) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(0, 1, 0) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(1, 1, 0) + mapData.startPos);

                runtimeData.triangles.Add(verIndex);
                runtimeData.triangles.Add(verIndex + 1);
                runtimeData.triangles.Add(verIndex + 2);
                runtimeData.triangles.Add(verIndex + 2);
                runtimeData.triangles.Add(verIndex + 1);
                runtimeData.triangles.Add(verIndex + 3);

                break;

            case QuadStatus.Bottom:
                runtimeData.vertices.Add(pivot + new Vector3(0, 0, 1) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(1, 0, 1) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(0, 0, 0) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(1, 0, 0) + mapData.startPos);

                runtimeData.triangles.Add(verIndex);
                runtimeData.triangles.Add(verIndex + 2);
                runtimeData.triangles.Add(verIndex + 1);
                runtimeData.triangles.Add(verIndex + 1);
                runtimeData.triangles.Add(verIndex + 2);
                runtimeData.triangles.Add(verIndex + 3);
                break;

            case QuadStatus.Right:
                runtimeData.vertices.Add(pivot + new Vector3(1, 1, 0) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(1, 1, 1) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(1, 0, 0) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(1, 0, 1) + mapData.startPos);

                runtimeData.triangles.Add(verIndex);
                runtimeData.triangles.Add(verIndex + 1);
                runtimeData.triangles.Add(verIndex + 2);
                runtimeData.triangles.Add(verIndex + 2);
                runtimeData.triangles.Add(verIndex + 1);
                runtimeData.triangles.Add(verIndex + 3);
                break;

            case QuadStatus.Left:
                runtimeData.vertices.Add(pivot + new Vector3(0, 1, 0) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(0, 1, 1) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(0, 0, 0) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(0, 0, 1) + mapData.startPos);

                runtimeData.triangles.Add(verIndex);
                runtimeData.triangles.Add(verIndex + 2);
                runtimeData.triangles.Add(verIndex + 1);
                runtimeData.triangles.Add(verIndex + 1);
                runtimeData.triangles.Add(verIndex + 2);
                runtimeData.triangles.Add(verIndex + 3);
                break;

            case QuadStatus.Front:
                runtimeData.vertices.Add(pivot + new Vector3(0, 1, 1) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(1, 1, 1) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(0, 0, 1) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(1, 0, 1) + mapData.startPos);

                runtimeData.triangles.Add(verIndex);
                runtimeData.triangles.Add(verIndex + 2);
                runtimeData.triangles.Add(verIndex + 1);
                runtimeData.triangles.Add(verIndex + 1);
                runtimeData.triangles.Add(verIndex + 2);
                runtimeData.triangles.Add(verIndex + 3);
                break;

            case QuadStatus.Back:
                runtimeData.vertices.Add(pivot + new Vector3(0, 1, 0) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(1, 1, 0) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(0, 0, 0) + mapData.startPos);
                runtimeData.vertices.Add(pivot + new Vector3(1, 0, 0) + mapData.startPos);

                runtimeData.triangles.Add(verIndex);
                runtimeData.triangles.Add(verIndex + 1);
                runtimeData.triangles.Add(verIndex + 2);
                runtimeData.triangles.Add(verIndex + 2);
                runtimeData.triangles.Add(verIndex + 1);
                runtimeData.triangles.Add(verIndex + 3);

                break;
            }

            runtimeData.uvs.Add(new Vector2(0, 1));
            runtimeData.uvs.Add(new Vector2(1, 1));
            runtimeData.uvs.Add(new Vector2(0, 0));
            runtimeData.uvs.Add(new Vector2(1, 0));
        }