Ejemplo n.º 1
0
 public void AddTorch(List <ushort> myelements, List <VertexPositionTexture> myvertices, int x, int y, int z, TorchType type)
 {
 }
Ejemplo n.º 2
0
        public void AddTorch(List <ushort> myelements, List <VertexPositionTexture> myvertices, int x, int y, int z, TorchType type)
        {
            Color curcolor    = Color.White;
            float torchsizexy = 0.16f;
            float topx        = 1f / 2f - torchsizexy / 2f;
            float topy        = 1f / 2f - torchsizexy / 2f;
            float bottomx     = 1f / 2f - torchsizexy / 2f;
            float bottomy     = 1f / 2f - torchsizexy / 2f;

            topx    += x;
            topy    += y;
            bottomx += x;
            bottomy += y;

            if (type == TorchType.Front)
            {
                bottomx = x - torchsizexy;
            }
            if (type == TorchType.Back)
            {
                bottomx = x + 1;
            }
            if (type == TorchType.Left)
            {
                bottomy = y - torchsizexy;
            }
            if (type == TorchType.Right)
            {
                bottomy = y + 1;
            }

            Vector3 top00 = new Vector3(topx, z + 0.9f, topy);
            Vector3 top01 = new Vector3(topx, z + 0.9f, topy + torchsizexy);
            Vector3 top10 = new Vector3(topx + torchsizexy, z + 0.9f, topy);
            Vector3 top11 = new Vector3(topx + torchsizexy, z + 0.9f, topy + torchsizexy);

            if (type == TorchType.Left)
            {
                top01 += new Vector3(0, -0.1f, 0);
                top11 += new Vector3(0, -0.1f, 0);
            }

            if (type == TorchType.Right)
            {
                top10 += new Vector3(0, -0.1f, 0);
                top00 += new Vector3(0, -0.1f, 0);
            }

            if (type == TorchType.Front)
            {
                top10 += new Vector3(0, -0.1f, 0);
                top11 += new Vector3(0, -0.1f, 0);
            }

            if (type == TorchType.Back)
            {
                top01 += new Vector3(0, -0.1f, 0);
                top00 += new Vector3(0, -0.1f, 0);
            }

            Vector3 bottom00 = new Vector3(bottomx, z + 0, bottomy);
            Vector3 bottom01 = new Vector3(bottomx, z + 0, bottomy + torchsizexy);
            Vector3 bottom10 = new Vector3(bottomx + torchsizexy, z + 0, bottomy);
            Vector3 bottom11 = new Vector3(bottomx + torchsizexy, z + 0, bottomy + torchsizexy);

            //top
            {
                int        sidetexture = TopTexture;
                RectangleF texrec      = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked);
                short      lastelement = (short)myvertices.Count;
                myvertices.Add(new VertexPositionTexture(top00.X, top00.Y, top00.Z, texrec.Left, texrec.Top, curcolor));
                myvertices.Add(new VertexPositionTexture(top01.X, top01.Y, top01.Z, texrec.Left, texrec.Bottom, curcolor));
                myvertices.Add(new VertexPositionTexture(top10.X, top10.Y, top10.Z, texrec.Right, texrec.Top, curcolor));
                myvertices.Add(new VertexPositionTexture(top11.X, top11.Y, top11.Z, texrec.Right, texrec.Bottom, curcolor));
                myelements.Add((ushort)(lastelement + 0));
                myelements.Add((ushort)(lastelement + 1));
                myelements.Add((ushort)(lastelement + 2));
                myelements.Add((ushort)(lastelement + 1));
                myelements.Add((ushort)(lastelement + 3));
                myelements.Add((ushort)(lastelement + 2));
            }

            //bottom - same as top, but z is 1 less.
            {
                int        sidetexture = SideTexture;
                RectangleF texrec      = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked);
                short      lastelement = (short)myvertices.Count;
                myvertices.Add(new VertexPositionTexture(bottom00.X, bottom00.Y, bottom00.Z, texrec.Left, texrec.Top, curcolor));
                myvertices.Add(new VertexPositionTexture(bottom01.X, bottom01.Y, bottom01.Z, texrec.Left, texrec.Bottom, curcolor));
                myvertices.Add(new VertexPositionTexture(bottom10.X, bottom10.Y, bottom10.Z, texrec.Right, texrec.Top, curcolor));
                myvertices.Add(new VertexPositionTexture(bottom11.X, bottom11.Y, bottom11.Z, texrec.Right, texrec.Bottom, curcolor));
                myelements.Add((ushort)(lastelement + 1));
                myelements.Add((ushort)(lastelement + 0));
                myelements.Add((ushort)(lastelement + 2));
                myelements.Add((ushort)(lastelement + 3));
                myelements.Add((ushort)(lastelement + 1));
                myelements.Add((ushort)(lastelement + 2));
            }

            //front
            {
                int        sidetexture = SideTexture;
                RectangleF texrec      = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked);
                short      lastelement = (short)myvertices.Count;
                myvertices.Add(new VertexPositionTexture(bottom00.X, bottom00.Y, bottom00.Z, texrec.Left, texrec.Bottom, curcolor));
                myvertices.Add(new VertexPositionTexture(bottom01.X, bottom01.Y, bottom01.Z, texrec.Right, texrec.Bottom, curcolor));
                myvertices.Add(new VertexPositionTexture(top00.X, top00.Y, top00.Z, texrec.Left, texrec.Top, curcolor));
                myvertices.Add(new VertexPositionTexture(top01.X, top01.Y, top01.Z, texrec.Right, texrec.Top, curcolor));
                myelements.Add((ushort)(lastelement + 0));
                myelements.Add((ushort)(lastelement + 1));
                myelements.Add((ushort)(lastelement + 2));
                myelements.Add((ushort)(lastelement + 1));
                myelements.Add((ushort)(lastelement + 3));
                myelements.Add((ushort)(lastelement + 2));
            }

            //back - same as front, but x is 1 greater.
            {
                int        sidetexture = SideTexture;
                RectangleF texrec      = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked);
                short      lastelement = (short)myvertices.Count;
                myvertices.Add(new VertexPositionTexture(bottom10.X, bottom10.Y, bottom10.Z, texrec.Right, texrec.Bottom, curcolor));
                myvertices.Add(new VertexPositionTexture(bottom11.X, bottom11.Y, bottom11.Z, texrec.Left, texrec.Bottom, curcolor));
                myvertices.Add(new VertexPositionTexture(top10.X, top10.Y, top10.Z, texrec.Right, texrec.Top, curcolor));
                myvertices.Add(new VertexPositionTexture(top11.X, top11.Y, top11.Z, texrec.Left, texrec.Top, curcolor));
                myelements.Add((ushort)(lastelement + 1));
                myelements.Add((ushort)(lastelement + 0));
                myelements.Add((ushort)(lastelement + 2));
                myelements.Add((ushort)(lastelement + 3));
                myelements.Add((ushort)(lastelement + 1));
                myelements.Add((ushort)(lastelement + 2));
            }

            {
                int        sidetexture = SideTexture;
                RectangleF texrec      = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked);
                short      lastelement = (short)myvertices.Count;
                myvertices.Add(new VertexPositionTexture(bottom00.X, bottom00.Y, bottom00.Z, texrec.Right, texrec.Bottom, curcolor));
                myvertices.Add(new VertexPositionTexture(top00.X, top00.Y, top00.Z, texrec.Right, texrec.Top, curcolor));
                myvertices.Add(new VertexPositionTexture(bottom10.X, bottom10.Y, bottom10.Z, texrec.Left, texrec.Bottom, curcolor));
                myvertices.Add(new VertexPositionTexture(top10.X, top10.Y, top10.Z, texrec.Left, texrec.Top, curcolor));
                myelements.Add((ushort)(lastelement + 0));
                myelements.Add((ushort)(lastelement + 1));
                myelements.Add((ushort)(lastelement + 2));
                myelements.Add((ushort)(lastelement + 1));
                myelements.Add((ushort)(lastelement + 3));
                myelements.Add((ushort)(lastelement + 2));
            }

            //right - same as left, but y is 1 greater.
            {
                int        sidetexture = SideTexture;
                RectangleF texrec      = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked);
                short      lastelement = (short)myvertices.Count;
                myvertices.Add(new VertexPositionTexture(bottom01.X, bottom01.Y, bottom01.Z, texrec.Left, texrec.Bottom, curcolor));
                myvertices.Add(new VertexPositionTexture(top01.X, top01.Y, top01.Z, texrec.Left, texrec.Top, curcolor));
                myvertices.Add(new VertexPositionTexture(bottom11.X, bottom11.Y, bottom11.Z, texrec.Right, texrec.Bottom, curcolor));
                myvertices.Add(new VertexPositionTexture(top11.X, top11.Y, top11.Z, texrec.Right, texrec.Top, curcolor));
                myelements.Add((ushort)(lastelement + 1));
                myelements.Add((ushort)(lastelement + 0));
                myelements.Add((ushort)(lastelement + 2));
                myelements.Add((ushort)(lastelement + 3));
                myelements.Add((ushort)(lastelement + 1));
                myelements.Add((ushort)(lastelement + 2));
            }
        }
Ejemplo n.º 3
0
    public void AddTorch(GameData d_Data, Game d_TerainRenderer, ModelData m, int x, int y, int z, TorchType type)
    {
        float one         = 1;
        int   curcolor    = Game.ColorFromArgb(255, 255, 255, 255);
        float torchsizexy = one * 16 / 100;
        float topx        = one / 2 - torchsizexy / 2;
        float topy        = one / 2 - torchsizexy / 2;
        float bottomx     = one / 2 - torchsizexy / 2;
        float bottomy     = one / 2 - torchsizexy / 2;

        topx    += x;
        topy    += y;
        bottomx += x;
        bottomy += y;

        if (type == TorchType.Front)
        {
            bottomx = x - torchsizexy;
        }
        if (type == TorchType.Back)
        {
            bottomx = x + 1;
        }
        if (type == TorchType.Left)
        {
            bottomy = y - torchsizexy;
        }
        if (type == TorchType.Right)
        {
            bottomy = y + 1;
        }

        Vector3Ref top00 = Vector3Ref.Create(topx, z + (one * 9 / 10), topy);
        Vector3Ref top01 = Vector3Ref.Create(topx, z + (one * 9 / 10), topy + torchsizexy);
        Vector3Ref top10 = Vector3Ref.Create(topx + torchsizexy, z + (one * 9 / 10), topy);
        Vector3Ref top11 = Vector3Ref.Create(topx + torchsizexy, z + (one * 9 / 10), topy + torchsizexy);

        if (type == TorchType.Left)
        {
            top01.Y += -(one * 1 / 10);
            top11.Y += -(one * 1 / 10);
        }

        if (type == TorchType.Right)
        {
            top10.Y += -(one * 1 / 10);
            top00.Y += -(one * 1 / 10);
        }

        if (type == TorchType.Front)
        {
            top10.Y += -(one * 1 / 10);
            top11.Y += -(one * 1 / 10);
        }

        if (type == TorchType.Back)
        {
            top01.Y += -(one * 1 / 10);
            top00.Y += -(one * 1 / 10);
        }

        Vector3Ref bottom00 = Vector3Ref.Create(bottomx, z + 0, bottomy);
        Vector3Ref bottom01 = Vector3Ref.Create(bottomx, z + 0, bottomy + torchsizexy);
        Vector3Ref bottom10 = Vector3Ref.Create(bottomx + torchsizexy, z + 0, bottomy);
        Vector3Ref bottom11 = Vector3Ref.Create(bottomx + torchsizexy, z + 0, bottomy + torchsizexy);

        //top
        {
            int      sidetexture = TopTexture;
            RectFRef texrec      = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked());
            int      lastelement = m.GetVerticesCount();
            AddVertex(m, top00.X, top00.Y, top00.Z, texrec.Left(), texrec.Top(), curcolor);
            AddVertex(m, top01.X, top01.Y, top01.Z, texrec.Left(), texrec.Bottom(), curcolor);
            AddVertex(m, top10.X, top10.Y, top10.Z, texrec.Right(), texrec.Top(), curcolor);
            AddVertex(m, top11.X, top11.Y, top11.Z, texrec.Right(), texrec.Bottom(), curcolor);
            m.indices[m.indicesCount++] = (lastelement + 0);
            m.indices[m.indicesCount++] = (lastelement + 1);
            m.indices[m.indicesCount++] = (lastelement + 2);
            m.indices[m.indicesCount++] = (lastelement + 1);
            m.indices[m.indicesCount++] = (lastelement + 3);
            m.indices[m.indicesCount++] = (lastelement + 2);
        }

        //bottom - same as top, but z is 1 less.
        {
            int      sidetexture = SideTexture;
            RectFRef texrec      = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked());
            int      lastelement = m.GetVerticesCount();
            AddVertex(m, bottom00.X, bottom00.Y, bottom00.Z, texrec.Left(), texrec.Top(), curcolor);
            AddVertex(m, bottom01.X, bottom01.Y, bottom01.Z, texrec.Left(), texrec.Bottom(), curcolor);
            AddVertex(m, bottom10.X, bottom10.Y, bottom10.Z, texrec.Right(), texrec.Top(), curcolor);
            AddVertex(m, bottom11.X, bottom11.Y, bottom11.Z, texrec.Right(), texrec.Bottom(), curcolor);
            m.indices[m.indicesCount++] = (lastelement + 1);
            m.indices[m.indicesCount++] = (lastelement + 0);
            m.indices[m.indicesCount++] = (lastelement + 2);
            m.indices[m.indicesCount++] = (lastelement + 3);
            m.indices[m.indicesCount++] = (lastelement + 1);
            m.indices[m.indicesCount++] = (lastelement + 2);
        }

        //front
        {
            int      sidetexture = SideTexture;
            RectFRef texrec      = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked());
            int      lastelement = m.GetVerticesCount();
            AddVertex(m, bottom00.X, bottom00.Y, bottom00.Z, texrec.Left(), texrec.Bottom(), curcolor);
            AddVertex(m, bottom01.X, bottom01.Y, bottom01.Z, texrec.Right(), texrec.Bottom(), curcolor);
            AddVertex(m, top00.X, top00.Y, top00.Z, texrec.Left(), texrec.Top(), curcolor);
            AddVertex(m, top01.X, top01.Y, top01.Z, texrec.Right(), texrec.Top(), curcolor);
            m.indices[m.indicesCount++] = (lastelement + 0);
            m.indices[m.indicesCount++] = (lastelement + 1);
            m.indices[m.indicesCount++] = (lastelement + 2);
            m.indices[m.indicesCount++] = (lastelement + 1);
            m.indices[m.indicesCount++] = (lastelement + 3);
            m.indices[m.indicesCount++] = (lastelement + 2);
        }

        //back - same as front, but x is 1 greater.
        {
            int      sidetexture = SideTexture;
            RectFRef texrec      = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked());
            int      lastelement = m.GetVerticesCount();
            AddVertex(m, bottom10.X, bottom10.Y, bottom10.Z, texrec.Right(), texrec.Bottom(), curcolor);
            AddVertex(m, bottom11.X, bottom11.Y, bottom11.Z, texrec.Left(), texrec.Bottom(), curcolor);
            AddVertex(m, top10.X, top10.Y, top10.Z, texrec.Right(), texrec.Top(), curcolor);
            AddVertex(m, top11.X, top11.Y, top11.Z, texrec.Left(), texrec.Top(), curcolor);
            m.indices[m.indicesCount++] = (lastelement + 1);
            m.indices[m.indicesCount++] = (lastelement + 0);
            m.indices[m.indicesCount++] = (lastelement + 2);
            m.indices[m.indicesCount++] = (lastelement + 3);
            m.indices[m.indicesCount++] = (lastelement + 1);
            m.indices[m.indicesCount++] = (lastelement + 2);
        }

        {
            int      sidetexture = SideTexture;
            RectFRef texrec      = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked());
            int      lastelement = m.GetVerticesCount();
            AddVertex(m, bottom00.X, bottom00.Y, bottom00.Z, texrec.Right(), texrec.Bottom(), curcolor);
            AddVertex(m, top00.X, top00.Y, top00.Z, texrec.Right(), texrec.Top(), curcolor);
            AddVertex(m, bottom10.X, bottom10.Y, bottom10.Z, texrec.Left(), texrec.Bottom(), curcolor);
            AddVertex(m, top10.X, top10.Y, top10.Z, texrec.Left(), texrec.Top(), curcolor);
            m.indices[m.indicesCount++] = (lastelement + 0);
            m.indices[m.indicesCount++] = (lastelement + 1);
            m.indices[m.indicesCount++] = (lastelement + 2);
            m.indices[m.indicesCount++] = (lastelement + 1);
            m.indices[m.indicesCount++] = (lastelement + 3);
            m.indices[m.indicesCount++] = (lastelement + 2);
        }

        //right - same as left, but y is 1 greater.
        {
            int      sidetexture = SideTexture;
            RectFRef texrec      = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked());
            int      lastelement = m.GetVerticesCount();
            AddVertex(m, bottom01.X, bottom01.Y, bottom01.Z, texrec.Left(), texrec.Bottom(), curcolor);
            AddVertex(m, top01.X, top01.Y, top01.Z, texrec.Left(), texrec.Top(), curcolor);
            AddVertex(m, bottom11.X, bottom11.Y, bottom11.Z, texrec.Right(), texrec.Bottom(), curcolor);
            AddVertex(m, top11.X, top11.Y, top11.Z, texrec.Right(), texrec.Top(), curcolor);
            m.indices[m.indicesCount++] = (lastelement + 1);
            m.indices[m.indicesCount++] = (lastelement + 0);
            m.indices[m.indicesCount++] = (lastelement + 2);
            m.indices[m.indicesCount++] = (lastelement + 3);
            m.indices[m.indicesCount++] = (lastelement + 1);
            m.indices[m.indicesCount++] = (lastelement + 2);
        }
    }