Пример #1
0
        protected override void LoadSecciones()
        {
            Seccion seccion = new Seccion();
            seccion.Vertices.Add(new Punto(-this.Width / 2, -this.Height / 2, this.Altura));
            seccion.Vertices.Add(new Punto(this.Width / 2, -this.Height / 2, this.Altura));
            this.secciones.Add(seccion);

            seccion = new Seccion();
            seccion.Vertices.Add(new Punto(-this.Width / 2, this.Height / 2, this.Altura));
            seccion.Vertices.Add(new Punto(this.Width / 2, this.Height / 2, this.Altura));
            this.secciones.Add(seccion);
        }
Пример #2
0
        protected override Punto CalculateNormalForPunto(int posVertexActual, Punto verticeActual, int posSeccionActual, Seccion seccionActual)
        {
            Punto puntoNorte = null;
            Punto puntoSur = null;
            Punto puntoEste = null;
            Punto puntoOeste = null;
            if (posSeccionActual + 1 < (this.Width * this.VertexRatio) - 1) puntoNorte = this.secciones[posSeccionActual + 1].Vertices[posVertexActual];
            if (posSeccionActual - 1 > 0) puntoSur = this.secciones[posSeccionActual - 1].Vertices[posVertexActual];
            if (posVertexActual + 1 < (this.Height * this.VertexRatio) - 1) puntoEste = this.secciones[posSeccionActual].Vertices[posVertexActual + 1];
            if (posVertexActual - 1 > 0) puntoOeste = this.secciones[posSeccionActual].Vertices[posVertexActual - 1];

            return Punto.CalcularNormal(this.secciones[posSeccionActual].Vertices[posVertexActual], puntoNorte, puntoEste, puntoSur, puntoOeste, true);
        }
Пример #3
0
        protected override void LoadSecciones()
        {
            Seccion seccion = new Seccion();

            seccion.Vertices.Add(new Punto(-this.Width / 2, -this.Height / 2, this.Altura));
            seccion.Vertices.Add(new Punto(this.Width / 2, -this.Height / 2, this.Altura));
            this.secciones.Add(seccion);

            seccion = new Seccion();
            seccion.Vertices.Add(new Punto(-this.Width / 2, this.Height / 2, this.Altura));
            seccion.Vertices.Add(new Punto(this.Width / 2, this.Height / 2, this.Altura));
            this.secciones.Add(seccion);
        }
Пример #4
0
        protected override void LoadSecciones()
        {
            Bitmap mapa = new Bitmap(@"../../Imagenes/Bitmap.bmp");

            for (double i = 0; i < (this.Width * this.VertexRatio); i++)
            {
                Seccion seccion = new Seccion();

                for (double j = 0; j < (this.Height * this.VertexRatio); j++)
                {
                    double altura = (mapa.GetPixel(this.GetXBitmapCoord(i, mapa), this.GetYBitmapCoord(j, mapa)).B) * (this.AlturaMaxima / 255d);
                    seccion.Vertices.Add(new Punto((i / this.VertexRatio) - (this.Width / 2), (j / this.VertexRatio) - (this.Height / 2), altura));
                }

                secciones.Add(seccion);
            }
        }
Пример #5
0
        /// <summary>
        /// Calcula las coordenadas de textura creando el buffer de coordenadas de textura
        /// para la superficie.
        /// </summary>
        protected virtual void BuildTextureCoordBuffer()
        {
            double         u, v = 0;
            double         distU = 0, distV = 0;
            IList <double> textCoord = new List <double>();

            for (int i = 0; i < secciones.Count; i++)
            {
                Seccion seccion = secciones[i];

                if (i != 0)
                {
                    Punto verticeAnt    = secciones[i - 1].Vertices[secciones[i - 1].Vertices.Count / 2];
                    Punto verticeActual = seccion.Vertices[seccion.Vertices.Count / 2];
                    distV = (verticeActual - verticeAnt).Modulo();
                    v    += distV * VTextureAspectRatio;
                }

                u = 0;
                for (int j = 0; j < seccion.Vertices.Count; j++)
                {
                    if (j != 0)
                    {
                        Punto verticeAnt    = seccion.Vertices[j - 1];
                        Punto verticeActual = seccion.Vertices[j];
                        distU = (verticeActual - verticeAnt).Modulo();
                        u    += distU * UTextureAspectRatio;
                    }

                    textCoord.Add(v);
                    textCoord.Add(u);
                }
            }

            this.textures = textCoord.ToArray <double>();
        }
Пример #6
0
        protected virtual Punto CalculateNormalForPunto(int posVertexActual, Punto verticeActual, int posSeccionActual, Seccion seccionActual)
        {
            Punto normalSeccion = (seccionActual.Vertices[1] - seccionActual.Vertices[0]) * (seccionActual.Vertices[2] - seccionActual.Vertices[1]);

            if (posVertexActual == 0)
            {
                return((seccionActual.Vertices[posVertexActual + 1] - seccionActual.Vertices[posVertexActual]) * normalSeccion);
            }
            else if (posVertexActual == (seccionActual.Vertices.Count - 1))
            {
                return((seccionActual.Vertices[posVertexActual] - seccionActual.Vertices[posVertexActual - 1]) * normalSeccion);
            }
            else
            {
                return((seccionActual.Vertices[posVertexActual + 1] - seccionActual.Vertices[posVertexActual - 1]) * normalSeccion);
            }
        }
Пример #7
0
 protected override Punto CalculateNormalForPunto(int posVertexActual, Punto verticeActual, int posSeccionActual, Seccion seccionActual)
 {
     return(new Punto(0, 0, 1));
 }
Пример #8
0
 protected override Punto CalculateNormalForPunto(int posVertexActual, Punto verticeActual, int posSeccionActual, Seccion seccionActual)
 {
     return new Punto(0, 0, 1);
 }
Пример #9
0
        protected virtual Punto CalculateNormalForPunto(int posVertexActual, Punto verticeActual, int posSeccionActual, Seccion seccionActual)
        {
            Punto normalSeccion = (seccionActual.Vertices[1] - seccionActual.Vertices[0]) * (seccionActual.Vertices[2] - seccionActual.Vertices[1]);

            if (posVertexActual == 0)
            {
                return (seccionActual.Vertices[posVertexActual + 1] - seccionActual.Vertices[posVertexActual]) * normalSeccion;
            }
            else if (posVertexActual == (seccionActual.Vertices.Count - 1))
            {
                return (seccionActual.Vertices[posVertexActual] - seccionActual.Vertices[posVertexActual - 1]) * normalSeccion;
            }
            else
            {
                return (seccionActual.Vertices[posVertexActual + 1] - seccionActual.Vertices[posVertexActual - 1]) * normalSeccion;
            }
        }