当前位置: 首页>>代码示例>>C#>>正文


C# MeshData.AddQuadTriangles方法代码示例

本文整理汇总了C#中MeshData.AddQuadTriangles方法的典型用法代码示例。如果您正苦于以下问题:C# MeshData.AddQuadTriangles方法的具体用法?C# MeshData.AddQuadTriangles怎么用?C# MeshData.AddQuadTriangles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MeshData的用法示例。


在下文中一共展示了MeshData.AddQuadTriangles方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CrossMeshRenderer

    public static void CrossMeshRenderer(Chunk chunk, BlockPos pos, MeshData meshData, TextureCollection texture, Block block)
    {
        float halfBlock = (Config.Env.BlockSize / 2) + Config.Env.BlockFacePadding;
        float colliderOffest = 0.05f * Config.Env.BlockSize;
        float blockHeight = halfBlock * 2 * (block.data2 / 255f);

        float offsetX = (halfBlock * 2 * ((byte)(block.data3 & 0x0F) / 32f)) - (halfBlock/2);
        float offsetZ = (halfBlock * 2 * ((byte)((block.data3 & 0xF0) >> 4) / 32f)) - (halfBlock/2);

        //Converting the position to a vector adjusts it based on block size and gives us real world coordinates for x, y and z
        Vector3 vPos = pos;
        Vector3 vPosCollider = pos;
        vPos += new Vector3(offsetX, 0, offsetZ);

        float blockLight = ( (block.data1/255f) * Config.Env.BlockLightStrength) + (0.8f*Config.Env.AOStrength);

        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
        meshData.AddQuadTriangles();
        BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
        meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);

        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
        meshData.AddQuadTriangles();
        BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
        meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);

        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
        meshData.AddQuadTriangles();
        BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
        meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);

        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
        meshData.AddQuadTriangles();
        BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
        meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);

        meshData.AddVertex(new Vector3(vPosCollider.x - halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z + halfBlock), collisionMesh: true);
        meshData.AddVertex(new Vector3(vPosCollider.x + halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z + halfBlock), collisionMesh: true);
        meshData.AddVertex(new Vector3(vPosCollider.x + halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z - halfBlock), collisionMesh: true);
        meshData.AddVertex(new Vector3(vPosCollider.x - halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z - halfBlock), collisionMesh: true);
        meshData.AddQuadTriangles(collisionMesh:true);
    }
开发者ID:li5414,项目名称:Voxelmetric,代码行数:54,代码来源:MeshBuilder.cs

示例2: Vector3

    protected virtual MeshData FaceDataDown
        (Chunk chunk, int x, int y, int z, MeshData meshData)
    {
        meshData.AddVertex(new Vector3(x - 0.5f, y - 0.5f, z - 0.5f));
        meshData.AddVertex(new Vector3(x + 0.5f, y - 0.5f, z - 0.5f));
        meshData.AddVertex(new Vector3(x + 0.5f, y - 0.5f, z + 0.5f));
        meshData.AddVertex(new Vector3(x - 0.5f, y - 0.5f, z + 0.5f));

        meshData.AddQuadTriangles();
        meshData.uv.AddRange(FaceUVs(Direction.down));
        return meshData;
    }
开发者ID:HimariO,项目名称:Corrosion_NtustUnityProjecta,代码行数:12,代码来源:Block.cs

示例3: AddQuadToMeshData

    static void AddQuadToMeshData(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, bool useCollisionMesh)
    {
        //Adding a tiny overlap between block meshes may solve floating point imprecision
        //errors causing pixel size gaps between blocks when looking closely
        float halfBlock = (Config.Env.BlockSize / 2) + Config.Env.BlockFacePadding;

        //Converting the position to a vector adjusts it based on block size and gives us real world coordinates for x, y and z
        Vector3 vPos = pos;

        switch (direction)
        {
            case Direction.up:
                meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y + halfBlock, vPos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y + halfBlock, vPos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y + halfBlock, vPos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y + halfBlock, vPos.z - halfBlock), useCollisionMesh);
                break;
            case Direction.down:
                meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock), useCollisionMesh);
                break;
            case Direction.north:
                meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y + halfBlock, vPos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y + halfBlock, vPos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock), useCollisionMesh);
                break;
            case Direction.east:
                meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y + halfBlock, vPos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y + halfBlock, vPos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock), useCollisionMesh);
                break;
            case Direction.south:
                meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y + halfBlock, vPos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y + halfBlock, vPos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock), useCollisionMesh);
                break;
            case Direction.west:
                meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y + halfBlock, vPos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y + halfBlock, vPos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock), useCollisionMesh);
                break;
            default:
                Debug.LogError("Direction not recognized");
                break;
        }

        meshData.AddQuadTriangles(useCollisionMesh);
    }
开发者ID:li5414,项目名称:Voxelmetric,代码行数:54,代码来源:BlockBuilder.cs

示例4: MakeFenceFace

    static void MakeFenceFace(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, bool useCollisionMesh, Vector3 ModelSize, Vector3 ConnMeshSizeX, Vector3 ConnMeshSizeY, Vector3 ConnMeshSizeZ, Direction[] Dir)
    {
        //Adding a tiny overlap between block meshes may solve floating point imprecision
        //errors causing pixel size gaps between blocks when looking closely
        float halfBlockX = 0;
        float halfBlockY = 0;
        float halfBlockZ = 0;

        //Converting the position to a vector adjusts it based on block size and gives us real world coordinates for x, y and z
        foreach (Direction localDir in Dir)
        {
            Vector3 vPos = new Vector3();
            if (localDir == Direction.north)
            {
                vPos = new Vector3(pos.x, pos.y, pos.z + ModelSize.z);
                halfBlockX = (ConnMeshSizeZ.x / 2) + Config.Env.BlockFacePadding;
                halfBlockY = (ConnMeshSizeZ.y / 2) + Config.Env.BlockFacePadding;
                halfBlockZ = (ConnMeshSizeZ.z / 2) + Config.Env.BlockFacePadding;
            }
            else if (localDir == Direction.south)
            {
                vPos = new Vector3(pos.x, pos.y, pos.z - ModelSize.z);
                halfBlockX = (ConnMeshSizeZ.x / 2) + Config.Env.BlockFacePadding;
                halfBlockY = (ConnMeshSizeZ.y / 2) + Config.Env.BlockFacePadding;
                halfBlockZ = (ConnMeshSizeZ.z / 2) + Config.Env.BlockFacePadding;
            }
            else if (localDir == Direction.east)
            {
                vPos = new Vector3(pos.x + ModelSize.x, pos.y, pos.z);
                halfBlockX = (ConnMeshSizeX.x / 2) + Config.Env.BlockFacePadding;
                halfBlockY = (ConnMeshSizeX.y / 2) + Config.Env.BlockFacePadding;
                halfBlockZ = (ConnMeshSizeX.z / 2) + Config.Env.BlockFacePadding;
            }
            else if (localDir == Direction.west)
            {
                vPos = new Vector3(pos.x - ModelSize.x, pos.y, pos.z);
                halfBlockX = (ConnMeshSizeX.x / 2) + Config.Env.BlockFacePadding;
                halfBlockY = (ConnMeshSizeX.y / 2) + Config.Env.BlockFacePadding;
                halfBlockZ = (ConnMeshSizeX.z / 2) + Config.Env.BlockFacePadding;
            }
            else if (localDir == Direction.up)
            {
                vPos = new Vector3(pos.x, pos.y + ModelSize.y, pos.z);
                halfBlockX = (ConnMeshSizeY.x / 2) + Config.Env.BlockFacePadding;
                halfBlockY = (ConnMeshSizeY.y / 2) + Config.Env.BlockFacePadding;
                halfBlockZ = (ConnMeshSizeY.z / 2) + Config.Env.BlockFacePadding;
            }
            else if (localDir == Direction.down)
            {
                vPos = new Vector3(pos.x, pos.y - ModelSize.y, pos.z);
                halfBlockX = (ConnMeshSizeY.x / 2) + Config.Env.BlockFacePadding;
                halfBlockY = (ConnMeshSizeY.y / 2) + Config.Env.BlockFacePadding;
                halfBlockZ = (ConnMeshSizeY.z / 2) + Config.Env.BlockFacePadding;
            }
            switch (direction)
            {
                case Direction.up:
                    meshData.AddVertex(new Vector3(vPos.x - halfBlockX, vPos.y + halfBlockY, vPos.z + halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x + halfBlockX, vPos.y + halfBlockY, vPos.z + halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x + halfBlockX, vPos.y + halfBlockY, vPos.z - halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x - halfBlockX, vPos.y + halfBlockY, vPos.z - halfBlockZ), useCollisionMesh);
                    break;
                case Direction.down:
                    meshData.AddVertex(new Vector3(vPos.x - halfBlockX, vPos.y - halfBlockY, vPos.z - halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x + halfBlockX, vPos.y - halfBlockY, vPos.z - halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x + halfBlockX, vPos.y - halfBlockY, vPos.z + halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x - halfBlockX, vPos.y - halfBlockY, vPos.z + halfBlockZ), useCollisionMesh);
                    break;
                case Direction.north:
                    meshData.AddVertex(new Vector3(vPos.x + halfBlockX, vPos.y - halfBlockY, vPos.z + halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x + halfBlockX, vPos.y + halfBlockY, vPos.z + halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x - halfBlockX, vPos.y + halfBlockY, vPos.z + halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x - halfBlockX, vPos.y - halfBlockY, vPos.z + halfBlockZ), useCollisionMesh);
                    break;
                case Direction.east:
                    meshData.AddVertex(new Vector3(vPos.x + halfBlockX, vPos.y - halfBlockY, vPos.z - halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x + halfBlockX, vPos.y + halfBlockY, vPos.z - halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x + halfBlockX, vPos.y + halfBlockY, vPos.z + halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x + halfBlockX, vPos.y - halfBlockY, vPos.z + halfBlockZ), useCollisionMesh);
                    break;
                case Direction.south:
                    meshData.AddVertex(new Vector3(vPos.x - halfBlockX, vPos.y - halfBlockY, vPos.z - halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x - halfBlockX, vPos.y + halfBlockY, vPos.z - halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x + halfBlockX, vPos.y + halfBlockY, vPos.z - halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x + halfBlockX, vPos.y - halfBlockY, vPos.z - halfBlockZ), useCollisionMesh);
                    break;
                case Direction.west:
                    meshData.AddVertex(new Vector3(vPos.x - halfBlockX, vPos.y - halfBlockY, vPos.z + halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x - halfBlockX, vPos.y + halfBlockY, vPos.z + halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x - halfBlockX, vPos.y + halfBlockY, vPos.z - halfBlockZ), useCollisionMesh);
                    meshData.AddVertex(new Vector3(vPos.x - halfBlockX, vPos.y - halfBlockY, vPos.z - halfBlockZ), useCollisionMesh);
                    break;
                default:
                    Debug.LogError("Direction not recognized");
                    break;

            }

            meshData.AddQuadTriangles(useCollisionMesh);
        }
//.........这里部分代码省略.........
开发者ID:FaizanDurrani,项目名称:Voxelmetric-ConnectedMeshes,代码行数:101,代码来源:ConnectedBuilder.cs

示例5: Vector3

    protected virtual MeshData FaceDataUp
		(Chunk chunk, int x, int y, int z, MeshData meshData, int CycleNumber)
    {
        meshData.AddVertex(new Vector3(x - 0.5f, y + 0.5f, z + 0.5f));
        meshData.AddVertex(new Vector3(x + 0.5f, y + 0.5f, z + 0.5f));
        meshData.AddVertex(new Vector3(x + 0.5f, y + 0.5f, z - 0.5f));
        meshData.AddVertex(new Vector3(x - 0.5f, y + 0.5f, z - 0.5f));

        meshData.AddQuadTriangles();
        meshData.uv.AddRange(FaceUVs(Direction.up));
        return meshData;
    }
开发者ID:Deus0,项目名称:Zeltex,代码行数:12,代码来源:BlockBase.cs

示例6: AddQuadToMeshData

    static void AddQuadToMeshData(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction,bool useCollisionMesh)
    {
        //Adding a tiny overlap between block meshes may solve floating point imprecision
        //errors causing pixel size gaps between blocks when looking closely
        float halfBlock = 0.5005f;

        switch (direction)
        {
            case Direction.up:
                meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y + halfBlock, pos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y + halfBlock, pos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y + halfBlock, pos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y + halfBlock, pos.z - halfBlock), useCollisionMesh);
                break;
            case Direction.down:
                meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock, pos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock, pos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock, pos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock, pos.z + halfBlock), useCollisionMesh);
                break;
            case Direction.north:
                meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock, pos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y + halfBlock, pos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y + halfBlock, pos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock, pos.z + halfBlock), useCollisionMesh);
                break;
            case Direction.east:
                meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock, pos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y + halfBlock, pos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y + halfBlock, pos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock, pos.z + halfBlock), useCollisionMesh);
                break;
            case Direction.south:
                meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock, pos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y + halfBlock, pos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y + halfBlock, pos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock, pos.z - halfBlock), useCollisionMesh);
                break;
            case Direction.west:
                meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock, pos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y + halfBlock, pos.z + halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y + halfBlock, pos.z - halfBlock), useCollisionMesh);
                meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock, pos.z - halfBlock), useCollisionMesh);
                break;
            default:
                Debug.LogError("Direction not recognized");
                break;
        }

        meshData.AddQuadTriangles(useCollisionMesh);
    }
开发者ID:holmstrom,项目名称:Voxelmetric,代码行数:51,代码来源:BlockBuilder.cs

示例7: FaceData

    protected virtual MeshData FaceData(Chunk chunk, Vector3 corner, Vector3 v1, Vector3 v2, Direction direction, MeshData meshData)
    {
        meshData.AddVertex (corner + v1);
        meshData.AddVertex (corner + v1 + v2);
        meshData.AddVertex (corner + v2);
        meshData.AddVertex (corner);

        meshData.AddQuadTriangles ();

        meshData.uv.AddRange(FaceUVs(direction));

        return meshData;
    }
开发者ID:neilsustc,项目名称:myMinecraft-unity3d,代码行数:13,代码来源:Block.cs

示例8: FaceDataWest

    protected virtual MeshData FaceDataWest(Chunk chunk, int x, int y, int z, MeshData meshData)
    {
        meshData.AddVertex (new Vector3(x - verticeOffset, y - verticeOffset, z + verticeOffset));
        meshData.AddVertex (new Vector3(x - verticeOffset, y + verticeOffset, z + verticeOffset));
        meshData.AddVertex (new Vector3(x - verticeOffset, y + verticeOffset, z - verticeOffset));
        meshData.AddVertex (new Vector3(x - verticeOffset, y - verticeOffset, z - verticeOffset));

        meshData.AddQuadTriangles();

        meshData.uv.AddRange (FaceUVs(Direction.west));

        return meshData;
    }
开发者ID:strauzen,项目名称:Voxels,代码行数:13,代码来源:Block.cs

示例9: FaceDataSouth

    protected virtual MeshData FaceDataSouth(Chunk chunk, int x, int y, int z, MeshData meshData)
    {
        meshData.useRenderDataForCol = true;

        meshData.AddVertex (new Vector3(x - verticeOffset, y - verticeOffset, z - verticeOffset));
        meshData.AddVertex (new Vector3(x - verticeOffset, y + verticeOffset, z - verticeOffset));
        meshData.AddVertex (new Vector3(x + verticeOffset, y + verticeOffset, z - verticeOffset));
        meshData.AddVertex (new Vector3(x + verticeOffset, y - verticeOffset, z - verticeOffset));

        meshData.AddQuadTriangles();

        meshData.uv.AddRange (FaceUVs(Direction.south));

        return meshData;
    }
开发者ID:strauzen,项目名称:Voxels,代码行数:15,代码来源:Block.cs

示例10: FaceDataWest

    protected virtual MeshData FaceDataWest(ChunkGenerator chunk, int x, int y, int z, MeshData meshData)
    {
        meshData.AddVertex(new Vector3(x - 0.5f, y - 0.5f, z + 0.5f));
        meshData.AddVertex(new Vector3(x - 0.5f, y + 0.5f, z + 0.5f));
        meshData.AddVertex(new Vector3(x - 0.5f, y + 0.5f, z - 0.5f));
        meshData.AddVertex(new Vector3(x - 0.5f, y - 0.5f, z - 0.5f));

        meshData.AddQuadTriangles();
        meshData.uv.AddRange(FaceUVs(Direction.west));
        return meshData;
    }
开发者ID:BKahuna,项目名称:MinecraftCloneInUnity,代码行数:11,代码来源:BlockData.cs

示例11: FaceDataEast

    protected virtual MeshData FaceDataEast(Chunk chunk, int x, int y, int z, MeshData meshData)
    {
        meshData.vertices.Add(new Vector3(x + 0.5f, y - 0.5f, z - 0.5f));
        meshData.vertices.Add(new Vector3(x + 0.5f, y + 0.5f, z - 0.5f));
        meshData.vertices.Add(new Vector3(x + 0.5f, y + 0.5f, z + 0.5f));
        meshData.vertices.Add(new Vector3(x + 0.5f, y - 0.5f, z + 0.5f));

        meshData.AddQuadTriangles();
        return meshData;
    }
开发者ID:billy1234,项目名称:TerrainGenMaster,代码行数:10,代码来源:Block.cs

示例12: BlockData

	public override MeshData BlockData(int x, int y, int z, MeshData data, int submesh, Block[,,] blocks) {
		data.useRenderDataForCol = true;

		Vector3[] v = new Vector3[8];

		v[0] = new Vector3(-0.5f, -0.5f, -0.5f);
		v[1] = new Vector3(-0.5f, -0.5f, 0.5f);
		v[2] = new Vector3(-0.5f, -0.4f, -0.5f);
		v[3] = new Vector3(-0.5f, -0.4f, 0.5f);
		v[4] = new Vector3(0.5f, -0.5f, -0.5f);
		v[5] = new Vector3(0.5f, -0.5f, 0.5f);
		v[6] = new Vector3(0.5f, -0.4f, -0.5f);
		v[7] = new Vector3(0.5f, -0.4f, 0.5f);

		//Add floor verticies
		if (CheckSolid(blocks, x, y + 1, z, Direction.Down)) {
			data.AddVertex(v[3] + new Vector3(x, y, z), Vector3.up);
			data.AddVertex(v[7] + new Vector3(x, y, z), Vector3.up);
			data.AddVertex(v[6] + new Vector3(x, y, z), Vector3.up);
			data.AddVertex(v[2] + new Vector3(x, y, z), Vector3.up);
			data.AddQuadTriangles(submesh, false);
			data.AddUVs(FaceUVs(Direction.Up));
		}

		if (CheckSolid(blocks, x, y - 1, z, Direction.Up)) {
			data.AddVertex(v[0] + new Vector3(x, y, z), Vector3.down);
			data.AddVertex(v[4] + new Vector3(x, y, z), Vector3.down);
			data.AddVertex(v[5] + new Vector3(x, y, z), Vector3.down);
			data.AddVertex(v[1] + new Vector3(x, y, z), Vector3.down);
			data.AddQuadTriangles(submesh, false);
			data.AddUVs(FaceUVs(Direction.Down));
		}

		if (CheckSolid(blocks, x, y, z + 1, Direction.South)) {
			data.AddVertex(v[5] + new Vector3(x, y, z), Vector3.forward);
			data.AddVertex(v[7] + new Vector3(x, y, z), Vector3.forward);
			data.AddVertex(v[3] + new Vector3(x, y, z), Vector3.forward);
			data.AddVertex(v[1] + new Vector3(x, y, z), Vector3.forward);
			data.AddQuadTriangles(submesh, false);
			data.AddUVs(FaceUVs(Direction.North));
		}

		if (CheckSolid(blocks, x, y, z - 1, Direction.North)) {
			data.AddVertex(v[0] + new Vector3(x, y, z), Vector3.back);
			data.AddVertex(v[2] + new Vector3(x, y, z), Vector3.back);
			data.AddVertex(v[6] + new Vector3(x, y, z), Vector3.back);
			data.AddVertex(v[4] + new Vector3(x, y, z), Vector3.back);
			data.AddQuadTriangles(submesh, false);
			data.AddUVs(FaceUVs(Direction.South));
		}

		if (CheckSolid(blocks, x + 1, y, z, Direction.West)) {
			data.AddVertex(v[4] + new Vector3(x, y, z), Vector3.right);
			data.AddVertex(v[6] + new Vector3(x, y, z), Vector3.right);
			data.AddVertex(v[7] + new Vector3(x, y, z), Vector3.right);
			data.AddVertex(v[5] + new Vector3(x, y, z), Vector3.right);
			data.AddQuadTriangles(submesh, false);
			data.AddUVs(FaceUVs(Direction.East));
		}

		if (CheckSolid(blocks, x - 1, y, z, Direction.East)) {
			data.AddVertex(v[1] + new Vector3(x, y, z), Vector3.left);
			data.AddVertex(v[3] + new Vector3(x, y, z), Vector3.left);
			data.AddVertex(v[2] + new Vector3(x, y, z), Vector3.left);
			data.AddVertex(v[0] + new Vector3(x, y, z), Vector3.left);
			data.AddQuadTriangles(submesh, false);
			data.AddUVs(FaceUVs(Direction.West));
		}

		return data;
	}
开发者ID:platformed,项目名称:Platformed-Game,代码行数:71,代码来源:FloorBlock.cs

示例13: buildFaceWest

 protected virtual MeshData buildFaceWest(Vector3 start, Vector3 end, MeshData meshData)
 {
     meshData.AddVertex (new Vector3(end.x, start.y, start.z));
     meshData.AddVertex (new Vector3(end.x, start.y, end.z));
     meshData.AddVertex (new Vector3(end.x, end.y, end.z));
     meshData.AddVertex (new Vector3(end.x, end.y, start.z));
     meshData.AddQuadTriangles();
     meshData.uv.AddRange (FlatUVs ());
     return meshData;
 }
开发者ID:TwoClunkers,项目名称:Clunk-Genesis,代码行数:10,代码来源:SelectedArea.cs

示例14: BlockData

	/// <summary>
	/// Adds the blocks to a meshdata 
	/// </summary>
	/// <param name="x">X position of the block</param>
	/// <param name="y">Y position of the block</param>
	/// <param name="z">Z position of the block</param>
	/// <param name="data">The meshdata to add to</param>
	/// <param name="submesh">The submesh to put the block on</param>
	/// <param name="ignoreChunk">If the solidity of the neighboring blocks should be checked</param>
	/// <returns>Meshdata with added block meshdata</returns>
	public virtual MeshData BlockData(int x, int y, int z, MeshData data, int submesh, Block[,,] blocks) {
		data.useRenderDataForCol = true;

		Vector3[] v = new Vector3[8];

		v[0] = new Vector3(-0.5f, -0.5f, -0.5f);
		v[1] = new Vector3(-0.5f, -0.5f, 0.5f);
		v[2] = new Vector3(-0.5f, 0.5f, -0.5f);
		v[3] = new Vector3(-0.5f, 0.5f, 0.5f);
		v[4] = new Vector3(0.5f, -0.5f, -0.5f);
		v[5] = new Vector3(0.5f, -0.5f, 0.5f);
		v[6] = new Vector3(0.5f, 0.5f, -0.5f);
		v[7] = new Vector3(0.5f, 0.5f, 0.5f);

		//Add cube verticies

		//Top
		if (!CheckSolid(blocks, x, y + 1, z, Direction.Down)) {
			byte[] ao = CalculateFaceAO(new bool[] {
				CheckSolid(blocks, x - 1, y + 1, z    , Direction.East),
				CheckSolid(blocks, x - 1, y + 1, z + 1, Direction.East),
				CheckSolid(blocks, x    , y + 1, z + 1, Direction.South),
				CheckSolid(blocks, x + 1, y + 1, z + 1, Direction.South),
				CheckSolid(blocks, x + 1, y + 1, z    , Direction.West),
				CheckSolid(blocks, x + 1, y + 1, z - 1, Direction.West),
				CheckSolid(blocks, x    , y + 1, z - 1, Direction.North),
				CheckSolid(blocks, x - 1, y + 1, z - 1, Direction.North)
			});
			data.AddVertex(v[3] + new Vector3(x, y, z), Vector3.up, CalculateVertexColor(ao[0]));
			data.AddVertex(v[7] + new Vector3(x, y, z), Vector3.up, CalculateVertexColor(ao[1]));
			data.AddVertex(v[6] + new Vector3(x, y, z), Vector3.up, CalculateVertexColor(ao[2]));
			data.AddVertex(v[2] + new Vector3(x, y, z), Vector3.up, CalculateVertexColor(ao[3]));
			data.AddQuadTriangles(submesh, FlipQuad(ao));
			data.AddUVs(FaceUVs(Direction.Up));
		}

		//Bottom
		if (!CheckSolid(blocks, x, y - 1, z, Direction.Up)) {
			byte[] ao = CalculateFaceAO(new bool[] {
				CheckSolid(blocks, x - 1, y - 1, z    , Direction.East),
				CheckSolid(blocks, x - 1, y - 1, z - 1, Direction.East),
				CheckSolid(blocks, x    , y - 1, z - 1, Direction.North),
				CheckSolid(blocks, x + 1, y - 1, z - 1, Direction.North),
				CheckSolid(blocks, x + 1, y - 1, z    , Direction.West),
				CheckSolid(blocks, x + 1, y - 1, z + 1, Direction.West),
				CheckSolid(blocks, x    , y - 1, z + 1, Direction.South),
				CheckSolid(blocks, x - 1, y - 1, z + 1, Direction.South)
			});
			data.AddVertex(v[0] + new Vector3(x, y, z), Vector3.down, CalculateVertexColor(ao[0]));
			data.AddVertex(v[4] + new Vector3(x, y, z), Vector3.down, CalculateVertexColor(ao[1]));
			data.AddVertex(v[5] + new Vector3(x, y, z), Vector3.down, CalculateVertexColor(ao[2]));
			data.AddVertex(v[1] + new Vector3(x, y, z), Vector3.down, CalculateVertexColor(ao[3]));
			data.AddQuadTriangles(submesh, FlipQuad(ao));
			data.AddUVs(FaceUVs(Direction.Down));
		}

		//North
		if (!CheckSolid(blocks, x, y, z + 1, Direction.South)) {
			byte[] ao = CalculateFaceAO(new bool[] {
				CheckSolid(blocks, x    , y - 1, z + 1, Direction.Up),
				CheckSolid(blocks, x + 1, y - 1, z + 1, Direction.Up),
				CheckSolid(blocks, x + 1, y    , z + 1, Direction.East),
				CheckSolid(blocks, x + 1, y + 1, z + 1, Direction.East),
				CheckSolid(blocks, x    , y + 1, z + 1, Direction.Down),
				CheckSolid(blocks, x - 1, y + 1, z + 1, Direction.Down),
				CheckSolid(blocks, x - 1, y    , z + 1, Direction.West),
				CheckSolid(blocks, x - 1, y - 1, z + 1, Direction.West)
			});
			data.AddVertex(v[5] + new Vector3(x, y, z), Vector3.forward, CalculateVertexColor(ao[0]));
			data.AddVertex(v[7] + new Vector3(x, y, z), Vector3.forward, CalculateVertexColor(ao[1]));
			data.AddVertex(v[3] + new Vector3(x, y, z), Vector3.forward, CalculateVertexColor(ao[2]));
			data.AddVertex(v[1] + new Vector3(x, y, z), Vector3.forward, CalculateVertexColor(ao[3]));
			data.AddQuadTriangles(submesh, FlipQuad(ao));
			data.AddUVs(FaceUVs(Direction.North));
		}

		//South
		if (!CheckSolid(blocks, x, y, z - 1, Direction.North)) {
			byte[] ao = CalculateFaceAO(new bool[] {
				CheckSolid(blocks, x    , y - 1, z - 1, Direction.Up),
				CheckSolid(blocks, x - 1, y - 1, z - 1, Direction.Up),
				CheckSolid(blocks, x - 1, y    , z - 1, Direction.East),
				CheckSolid(blocks, x - 1, y + 1, z - 1, Direction.East),
				CheckSolid(blocks, x    , y + 1, z - 1, Direction.Down),
				CheckSolid(blocks, x + 1, y + 1, z - 1, Direction.Down),
				CheckSolid(blocks, x + 1, y    , z - 1, Direction.West),
				CheckSolid(blocks, x + 1, y - 1, z - 1, Direction.West)
			});
			data.AddVertex(v[0] + new Vector3(x, y, z), Vector3.back, CalculateVertexColor(ao[0]));
			data.AddVertex(v[2] + new Vector3(x, y, z), Vector3.back, CalculateVertexColor(ao[1]));
//.........这里部分代码省略.........
开发者ID:platformed,项目名称:Platformed-Game,代码行数:101,代码来源:Block.cs


注:本文中的MeshData.AddQuadTriangles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。