public static MeshData CreateMeshData(this TileVertices tileVertices)
    {
        MeshData meshData = new MeshData();

        meshData.AddMeshData(tileVertices.front.meshData);
        meshData.AddMeshData(tileVertices.back.meshData);

        meshData.AddMeshData(tileVertices.up.meshData);

        meshData.AddMeshData(tileVertices.right.meshData);

        meshData.AddMeshData(tileVertices.down.meshData);

        meshData.AddMeshData(tileVertices.left.meshData);

        return(meshData);
    }
示例#2
0
        void start()
        {
            GL.Rotate(90, 0, 1, 0);
            GL.Translate(10, -20, -55);

            // Creates height map
            heightMaps = noise.generateHeightIndexs();

            for (int x = 0; x < Math.Sqrt(areaOfMap); x++)
            {
                for (int z = 0; z < Math.Sqrt(areaOfMap); z++)
                {
                    vertices[verticesIndex] = new Vec3D(x * 2, heightMaps[verticesIndex], z * 2);
                    verticesIndex++;
                }
            }

            // Groups 4 vertices into one to render a tile on
            for (int vert = 0; vert < tileVertices.Length; vert++)
            {
                Vec3D[] verts = new Vec3D[verticesPerPlain];

                verts[0] = vertices[groupVertID];
                verts[1] = vertices[groupVertID + 1];

                if (vertices[groupVertID + (int)Math.Sqrt(areaOfMap)].x == vertices[groupVertID + (int)Math.Sqrt(areaOfMap) + 1].x)
                {
                    verts[2] = vertices[groupVertID + (int)Math.Sqrt(areaOfMap)];
                    verts[3] = vertices[groupVertID + (int)Math.Sqrt(areaOfMap) + 1];
                }

                groupVertID++;

                try {
                    tileVertices[vert] = new TileVertices(verts);
                    tiles[vert]        = new Tile(tileVertices[vert]);
                }catch (Exception exception) {}
            }

            window.RenderFrame += render;
            window.Resize      += resize;
            window.Load        += load;

            window.Run(1 / 60);
        }
示例#3
0
    public void Initialize()
    {
        SetBitMaskValue();

        tileVertices = new TileVertices(this);
    }