Exemplo n.º 1
0
        public void Setup(ChunkMeshCluster chunkMeshCluster, RendererType rendererType)
        {
            SetRendererType(rendererType);
            if (rendererType == RendererType.Water)
            {
                // Water rendering requires that we overlap the meshes less, because of the transparency
                blockMeshHalfSize = 0.5f + 0.00001f;
            }
            else
            {
                // The fractional part seals the mesh and prevents flickering
                blockMeshHalfSize = 0.5f + 0.0005f;
            }

            if (chunkMeshCluster != null && chunkMeshCluster.chunk != null)
            {
                Vector3 position;
                position.x         = chunkMeshCluster.chunk.WorldPosition().x *Chunk.SIZE - 0.5f;
                position.y         = chunkMeshCluster.chunk.WorldPosition().y *Chunk.SIZE - 0.5f;
                position.z         = chunkMeshCluster.chunk.WorldPosition().z *Chunk.SIZE - 0.5f;
                transform.position = position;
            }
            associatedChunkMeshCluster = chunkMeshCluster;
            SetName();
        }
Exemplo n.º 2
0
        // Use this for initialization
        void Awake()
        {
            associatedChunkMeshCluster = null;
            generateMeshWorkFunction   = new BatchProcessor.WorkFunction(GenerateMeshThread);
            meshGenerationState        = MeshGenerationState.Waiting;

            verticesList  = new List <Vector3>();
            uvList        = new List <Vector2>();
            trianglesList = new List <int>();
            normalsList   = new List <Vector3>();
            colorList     = new List <Color32>();

            rendererType = RendererType.Solid;

            // Load up our mesh double buffering
            activeMesh          = 0;
            meshes              = new Mesh[2];
            rendererGameObjects = new GameObject[2];
            int index = 0;

            foreach (Transform child in transform)
            {
                rendererGameObjects[index] = child.gameObject;
                rendererGameObjects[index].SetActive(false);
                meshes[index] = child.gameObject.GetComponent <MeshFilter>().mesh;
                meshes[index].Clear();
                index++;
            }
        }