示例#1
0
        public DynamicMesh GetAllMesh(int x, int y, int z)
        {
            DynamicMesh TempMesh = new DynamicMesh();

            TempMesh.Add(m_LeftToRight.GetTransMesh(x, y, z));
            TempMesh.Add(m_FrontToBack.GetTransMesh(x, y, z));

            return(TempMesh);
        }
示例#2
0
    private static GameObject Combine(IList <EasyDecal> decals, DecalTextureAtlas atlas)
    {
        if (decals.Count > 0)
        {
            DynamicMesh mesh = new DynamicMesh(DecalBase.DecalRoot, RecreationMode.Always);

            GameObject   root     = new GameObject(string.Format("Combined Decals Root [{0}]", atlas.name));
            MeshFilter   filter   = root.AddComponent <MeshFilter>();
            MeshRenderer renderer = root.AddComponent <MeshRenderer>();

            foreach (EasyDecal decal in decals)
            {
                if (decal.Source == SourceMode.Atlas && decal.Projector != null)
                {
                    mesh.Add(decal.Projector.Mesh, decal.LocalToWorldMatrix, root.transform.worldToLocalMatrix);

                    decal.gameObject.SetActive(false);
                }
            }

            renderer.material = atlas.Material;
            filter.sharedMesh = mesh.ConvertToMesh(null);

            //root.transform.parent = DecalBase.DecalRoot.transform;
        }

        return(null);
    }
示例#3
0
        public DynamicMesh GetAllMesh(int x, int y, int z)
        {
            DynamicMesh TempMesh = new DynamicMesh();

            TempMesh.Add(GetUpMesh(x, y, z));
            TempMesh.Add(GetDownMesh(x, y, z));
            TempMesh.Add(GetLeftMesh(x, y, z));
            TempMesh.Add(GetRightMesh(x, y, z));
            TempMesh.Add(GetFrontMesh(x, y, z));
            TempMesh.Add(GetBackMesh(x, y, z));

            return(TempMesh);
        }
        //build mesh
        public void BuildMesh()
        {
            //lock (m_LockObj)
            {
                //Clear Current Mesh
                m_DynamicMesh.Clear();

                IBlock CurBlk, AdjBlk;

                int x, y, z;
                for (x = 0; x < m_World.Section_Width; x++)
                {
                    for (y = 0; y < m_World.Section_Height; y++)
                    {
                        for (z = 0; z < m_World.Section_Depth; z++)
                        {
                            //get block type
                            CurBlk = m_World.BlkPalette[m_Voxel[x, y, z]];

                            if (CurBlk == null)
                            {
                                continue;
                            }

                            //case: Block is not opaque
                            if (!CurBlk.IsOpaque)
                            {
                                m_DynamicMesh.Add(CurBlk.GetAllMesh(x, y, z));
                            }
                            else
                            {
                                //Check Up side
                                AdjBlk = GetBlock(x, y + 1, z);
                                if (AdjBlk == null || !AdjBlk.IsOpaque || !AdjBlk.IsDownMeshExist)
                                {
                                    m_DynamicMesh.Add(CurBlk.GetUpMesh(x, y, z));
                                }

                                //Check Down side
                                AdjBlk = GetBlock(x, y - 1, z);
                                if (AdjBlk == null || !AdjBlk.IsOpaque || !AdjBlk.IsUpMeshExist)
                                {
                                    m_DynamicMesh.Add(CurBlk.GetDownMesh(x, y, z));
                                }

                                //Check Left side
                                AdjBlk = GetBlock(x - 1, y, z);
                                if (AdjBlk == null || !AdjBlk.IsOpaque || !AdjBlk.IsRigthMeshExist)
                                {
                                    m_DynamicMesh.Add(CurBlk.GetLeftMesh(x, y, z));
                                }

                                //Check Right side
                                AdjBlk = GetBlock(x + 1, y, z);
                                if (AdjBlk == null || !AdjBlk.IsOpaque || !AdjBlk.IsLeftMeshExist)
                                {
                                    m_DynamicMesh.Add(CurBlk.GetRightMesh(x, y, z));
                                }

                                //Check Front side
                                AdjBlk = GetBlock(x, y, z + 1);
                                if (AdjBlk == null || !AdjBlk.IsOpaque || !AdjBlk.IsDownMeshExist)
                                {
                                    m_DynamicMesh.Add(CurBlk.GetFrontMesh(x, y, z));
                                }

                                //Check Back side
                                AdjBlk = GetBlock(x, y, z - 1);
                                if (AdjBlk == null || !AdjBlk.IsOpaque || !AdjBlk.IsDownMeshExist)
                                {
                                    m_DynamicMesh.Add(CurBlk.GetBackMesh(x, y, z));
                                }
                            }
                        } //z-loop
                    }     //y-loop
                }         //x-loop
                IsDirty = true;
            }
        }