Ejemplo n.º 1
0
    private PartMeshInfo renderStair(Vector3Int currPos, int maxY, IHasBlocks blockOwner)
    {
        Vector2      blockEffect = BlockEffectMap.Instance.GetBlockEffect(currPos);
        PartMeshInfo meshInfo    = new PartMeshInfo();

        RenderRefMesh(BlockMeshes.FullStair, currPos, Rotation, GetTexturePos(), blockEffect, meshInfo);
        return(meshInfo);
    }
Ejemplo n.º 2
0
    PartMeshInfo GenerateMesh(Vector3Int thisBlockPos, int maxY, Vector2 texturePos)
    {
        PartMeshInfo meshInfo = new PartMeshInfo();

        if (thisBlockPos.y <= maxY)
        {
            Block.CubeTop(thisBlockPos, meshInfo, texturePos, BlockEffects.NoEffect);
            Block.CubeBot(thisBlockPos, meshInfo, texturePos, BlockEffects.NoEffect);
            Block.CubeEast(thisBlockPos, meshInfo, texturePos, BlockEffects.NoEffect);
            Block.CubeWest(thisBlockPos, meshInfo, texturePos, BlockEffects.NoEffect);
            Block.CubeNorth(thisBlockPos, meshInfo, texturePos, BlockEffects.NoEffect);
            Block.CubeSouth(thisBlockPos, meshInfo, texturePos, BlockEffects.NoEffect);
        }
        return(meshInfo);
    }
Ejemplo n.º 3
0
    public void RenderBlock(Vector2 texturePos)
    {
        if (mesh == null)
        {
            mesh = GetComponent <MeshFilter>().mesh;
        }

        PartMeshInfo meshinfo = GenerateMesh(Vector3Int.zero, ChunkMeshGenerator.MaxY.Value, texturePos);

        mesh.Clear();
        mesh.vertices  = meshinfo.Vertices.ToArray();
        mesh.uv        = meshinfo.BaseUuv.ToArray();
        mesh.uv2       = meshinfo.EffectUuv.ToArray();
        mesh.triangles = meshinfo.Triangles.ToArray();
        mesh.Optimize();
        mesh.RecalculateNormals();
    }