示例#1
0
    public override void CreateMesh(NeighboursField Neighbours)
    {
        m_Vertices.Clear();
        m_Indices.Clear();
        m_UVs.Clear();
        m_BlockType = BlockType.STONE;
        if (!Utils.IsBitSet(Neighbours, (int)NeighboursField.Front))
        {
            RenderFront(224);
        }
        if (!Utils.IsBitSet(Neighbours, (int)NeighboursField.Back))
        {
            RenderBack(224);
        }
        if (!Utils.IsBitSet(Neighbours, (int)NeighboursField.Left))
        {
            RenderLeft(224);
        }
        if (!Utils.IsBitSet(Neighbours, (int)NeighboursField.Right))
        {
            RenderRight(224);
        }
        if (!Utils.IsBitSet(Neighbours, (int)NeighboursField.Top))
        {
            RenderTop(224);
        }
        if (!Utils.IsBitSet(Neighbours, (int)NeighboursField.Bottom))
        {
            RenderBottom(224);
        }

        GenerateMesh();
    }
示例#2
0
    private static NeighboursField GetNeighbours(int x, int y, int z)
    {
        NeighboursField Field = 0;

        if (x > 0 && x < m_WorldArray.GetLength(0))
        {
            if (m_WorldArray[x - 1, y, z].GetBlockType() != BlockType.AIR)
            {
                Field = (NeighboursField)Utils.SetBit(Field, (int)NeighboursField.Left);
            }
        }
        if (x >= 0 && x < m_WorldArray.GetLength(0) - 1)
        {
            if (m_WorldArray[x + 1, y, z].GetBlockType() != BlockType.AIR)
            {
                Field = (NeighboursField)Utils.SetBit(Field, (int)NeighboursField.Right);
            }
        }
        if (y > 0 && y < m_WorldArray.GetLength(1))
        {
            if (m_WorldArray[x, y - 1, z].GetBlockType() != BlockType.AIR)
            {
                Field = (NeighboursField)Utils.SetBit(Field, (int)NeighboursField.Bottom);
            }
        }
        if (y >= 0 && y < m_WorldArray.GetLength(1) - 1)
        {
            if (m_WorldArray[x, y + 1, z].GetBlockType() != BlockType.AIR)
            {
                Field = (NeighboursField)Utils.SetBit(Field, (int)NeighboursField.Top);
            }
        }
        if (z > 0 && z < m_WorldArray.GetLength(2))
        {
            if (m_WorldArray[x, y, z - 1].GetBlockType() != BlockType.AIR)
            {
                Field = (NeighboursField)Utils.SetBit(Field, (int)NeighboursField.Back);
            }
        }
        if (z >= 0 && z < m_WorldArray.GetLength(2) - 1)
        {
            if (m_WorldArray[x, y, z + 1].GetBlockType() != BlockType.AIR)
            {
                Field = (NeighboursField)Utils.SetBit(Field, (int)NeighboursField.Front);
            }
        }

        return(Field);
    }
示例#3
0
    public override void CreateMesh(NeighboursField Neighbours)
    {
        m_Vertices.Clear();
        m_Indices.Clear();
        m_UVs.Clear();
        m_BlockType = BlockType.DOORBOTTOM;

        RenderFront(244);
        RenderBack(244);
        RenderLeft(145);
        RenderRight(145);
        RenderBottom(244);

        GenerateMesh();
    }
示例#4
0
 abstract public void CreateMesh(NeighboursField Neighbours);
示例#5
0
    private NeighboursField GetNeighbours(int x, int y, int z)
    {
        NeighboursField Field = 0;

        try
        {
            if (x > 0 && x < m_HouseArray.GetLength(0))
            {
                if (m_HouseArray[x - 1, y, z].GetBlockType() != BlockType.AIR &&
                    m_HouseArray[x - 1, y, z].GetBlockType() != BlockType.DOORBOTTOM &&
                    m_HouseArray[x - 1, y, z].GetBlockType() != BlockType.DOORTOP)
                {
                    Field = (NeighboursField)Utils.SetBit(Field, (int)NeighboursField.Left);
                }
            }
            if (x >= 0 && x < m_HouseArray.GetLength(0) - 1)
            {
                if (m_HouseArray[x + 1, y, z].GetBlockType() != BlockType.AIR &&
                    m_HouseArray[x + 1, y, z].GetBlockType() != BlockType.DOORBOTTOM &&
                    m_HouseArray[x + 1, y, z].GetBlockType() != BlockType.DOORTOP)
                {
                    Field = (NeighboursField)Utils.SetBit(Field, (int)NeighboursField.Right);
                }
            }
            if (y > 0 && y < m_HouseArray.GetLength(1))
            {
                if (m_HouseArray[x, y - 1, z].GetBlockType() != BlockType.AIR &&
                    m_HouseArray[x, y - 1, z].GetBlockType() != BlockType.DOORBOTTOM &&
                    m_HouseArray[x, y - 1, z].GetBlockType() != BlockType.DOORTOP)
                {
                    Field = (NeighboursField)Utils.SetBit(Field, (int)NeighboursField.Bottom);
                }
            }
            if (y >= 0 && y < m_HouseArray.GetLength(1) - 1)
            {
                if (m_HouseArray[x, y + 1, z].GetBlockType() != BlockType.AIR &&
                    m_HouseArray[x, y + 1, z].GetBlockType() != BlockType.DOORBOTTOM &&
                    m_HouseArray[x, y + 1, z].GetBlockType() != BlockType.DOORTOP)
                {
                    Field = (NeighboursField)Utils.SetBit(Field, (int)NeighboursField.Top);
                }
            }
            if (z > 0 && z < m_HouseArray.GetLength(2))
            {
                if (m_HouseArray[x, y, z - 1].GetBlockType() != BlockType.AIR &&
                    m_HouseArray[x, y, z - 1].GetBlockType() != BlockType.DOORBOTTOM &&
                    m_HouseArray[x, y, z - 1].GetBlockType() != BlockType.DOORTOP)
                {
                    Field = (NeighboursField)Utils.SetBit(Field, (int)NeighboursField.Back);
                }
            }
            if (z >= 0 && z < m_HouseArray.GetLength(2) - 1)
            {
                if (m_HouseArray[x, y, z + 1].GetBlockType() != BlockType.AIR &&
                    m_HouseArray[x, y, z + 1].GetBlockType() != BlockType.DOORBOTTOM &&
                    m_HouseArray[x, y, z + 1].GetBlockType() != BlockType.DOORTOP)
                {
                    Field = (NeighboursField)Utils.SetBit(Field, (int)NeighboursField.Front);
                }
            }
        }
        catch
        {
            Debug.Log(x);
            Debug.Log(y);
            Debug.Log(z);
            Debug.Log(m_HouseArray.GetLength(0));
            Debug.Log(m_HouseArray.GetLength(1));
            Debug.Log(m_HouseArray.GetLength(2));
        }

        return(Field);
    }
示例#6
0
    public override void CreateMesh(NeighboursField Neighbours)
    {
        m_Vertices.Clear();
        m_Indices.Clear();
        m_UVs.Clear();
        m_BlockType = BlockType.GRASS;
        if (!Utils.IsBitSet(Neighbours, (int)NeighboursField.Bottom))
        {
            RenderBottom(242);
        }
        if (!Utils.IsBitSet(Neighbours, (int)NeighboursField.Top))
        {
            RenderTop(178);
            top = true;
        }
        if (!Utils.IsBitSet(Neighbours, (int)NeighboursField.Front))
        {
            if (top)
            {
                RenderFront(180);
            }
            else
            {
                RenderFront(242);
            }
        }
        if (!Utils.IsBitSet(Neighbours, (int)NeighboursField.Back))
        {
            if (top)
            {
                RenderBack(180);
            }
            else
            {
                RenderBack(242);
            }
        }
        if (!Utils.IsBitSet(Neighbours, (int)NeighboursField.Left))
        {
            if (top)
            {
                RenderLeft(180);
            }
            else
            {
                RenderLeft(242);
            }
        }
        if (!Utils.IsBitSet(Neighbours, (int)NeighboursField.Right))
        {
            if (top)
            {
                RenderRight(180);
            }
            else
            {
                RenderRight(242);
            }
        }

        GenerateMesh();
    }
示例#7
0
 public override void CreateMesh(NeighboursField Neighbours)
 {
 }