Beispiel #1
0
        public Terreno2(GraphicsDevice device, Texture2D imagemMapaAlturas, Texture2D texturaPlano, float tamanhoPlano, Texture2D textura)
        {
            texturaTerreno   = textura;
            tamanhoMapa      = (imagemMapaAlturas.Height * imagemMapaAlturas.Width);
            this.texturaMapa = imagemMapaAlturas;
            effect           = new BasicEffect(device);
            worldMatrix      = Matrix.Identity;
            float aspectRatio = (float)device.Viewport.Width / device.Viewport.Height;

            effect.View               = Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 10.0f), Vector3.Zero, Vector3.Up);//para onde aponta a camara
            effect.Projection         = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 0.01f, 1000.0f);
            effect.LightingEnabled    = false;
            effect.VertexColorEnabled = true;
            effect.Texture            = texturaTerreno;
            effect.TextureEnabled     = true;

            lerMapaAlturas(imagemMapaAlturas);
            createGeometry(device);

            vertexBuffer = new VertexBuffer(device, typeof(VertexPositionColorTexture), vertices.Length, BufferUsage.None);
            vertexBuffer.SetData <VertexPositionColorTexture>(vertices);

            indexBuffer = new IndexBuffer(device, typeof(short), indice.Length, BufferUsage.None);
            indexBuffer.SetData <short>(indice);

            vertexBuffer2 = new VertexBuffer(device, typeof(VertexPositionColorTexture), verticesPrimeiroLado.Length, BufferUsage.None);
            vertexBuffer2.SetData <VertexPositionColorTexture>(verticesPrimeiroLado);

            indexBuffer2 = new IndexBuffer(device, typeof(short), indicesSegundoLado.Length, BufferUsage.None);
            indexBuffer2.SetData <short>(indicesPrimeiroLado);

            vertexBuffer3 = new VertexBuffer(device, typeof(VertexPositionColorTexture), verticesSegundoLado.Length, BufferUsage.None);
            vertexBuffer3.SetData <VertexPositionColorTexture>(verticesSegundoLado);

            indexBuffer3 = new IndexBuffer(device, typeof(short), indicesSegundoLado.Length, BufferUsage.None);
            indexBuffer3.SetData <short>(indicesSegundoLado);



            this.plano = new Plano(device, texturaPlano, tamanhoPlano);
        }
Beispiel #2
0
        public Terreno2(GraphicsDevice device,Texture2D imagemMapaAlturas,Texture2D texturaPlano,float tamanhoPlano,Texture2D textura)
        {
            texturaTerreno = textura;
            tamanhoMapa = (imagemMapaAlturas.Height * imagemMapaAlturas.Width);
            this.texturaMapa = imagemMapaAlturas;
            effect = new BasicEffect(device);
            worldMatrix = Matrix.Identity;
            float aspectRatio = (float)device.Viewport.Width / device.Viewport.Height;

            effect.View = Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 10.0f), Vector3.Zero, Vector3.Up);//para onde aponta a camara
            effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 0.01f, 1000.0f);
            effect.LightingEnabled = false;
            effect.VertexColorEnabled = true;
            effect.Texture = texturaTerreno;
            effect.TextureEnabled = true;

            lerMapaAlturas(imagemMapaAlturas);
            createGeometry(device);

            vertexBuffer = new VertexBuffer(device, typeof(VertexPositionColorTexture), vertices.Length, BufferUsage.None);
            vertexBuffer.SetData<VertexPositionColorTexture>(vertices);

            indexBuffer = new IndexBuffer(device, typeof(short), indice.Length, BufferUsage.None);
            indexBuffer.SetData<short>(indice);

            vertexBuffer2 = new VertexBuffer(device, typeof(VertexPositionColorTexture), verticesPrimeiroLado.Length, BufferUsage.None);
            vertexBuffer2.SetData<VertexPositionColorTexture>(verticesPrimeiroLado);

            indexBuffer2 = new IndexBuffer(device, typeof(short), indicesSegundoLado.Length, BufferUsage.None);
            indexBuffer2.SetData<short>(indicesPrimeiroLado);

            vertexBuffer3 = new VertexBuffer(device, typeof(VertexPositionColorTexture), verticesSegundoLado.Length, BufferUsage.None);
            vertexBuffer3.SetData<VertexPositionColorTexture>(verticesSegundoLado);

            indexBuffer3 = new IndexBuffer(device, typeof(short), indicesSegundoLado.Length, BufferUsage.None);
            indexBuffer3.SetData<short>(indicesSegundoLado);

            this.plano = new Plano(device, texturaPlano, tamanhoPlano);
        }