Beispiel #1
0
 public void CargarTexturas(bool daylight)
 {
     if (daylight)
     {
         this.left = new Textura(@"../../Imagenes/Texturas/Skybox/mpa23lf.bmp", false);
         this.front = new Textura(@"../../Imagenes/Texturas/Skybox/mpa23ft.bmp", false);
         this.right = new Textura(@"../../Imagenes/Texturas/Skybox/mpa23rt.bmp", false);
         this.back = new Textura(@"../../Imagenes/Texturas/Skybox/mpa23bk.bmp", false);
         this.up = new Textura(@"../../Imagenes/Texturas/Skybox/mpa23up.bmp", false);
         this.down = new Textura(@"../../Imagenes/Texturas/Skybox/mpa23dn.bmp", false);
     }
     else
     {
         this.left = new Textura(@"../../Imagenes/Texturas/Skybox/night_mpa23lf.bmp", false);
         this.front = new Textura(@"../../Imagenes/Texturas/Skybox/night_mpa23ft.bmp", false);
         this.right = new Textura(@"../../Imagenes/Texturas/Skybox/night_mpa23rt.bmp", false);
         this.back = new Textura(@"../../Imagenes/Texturas/Skybox/night_mpa23bk.bmp", false);
         this.up = new Textura(@"../../Imagenes/Texturas/Skybox/night_mpa23up.bmp", false);
         this.down = new Textura(@"../../Imagenes/Texturas/Skybox/night_mpa23dn.bmp", false);
     }
 }
Beispiel #2
0
 public void CargarTexturas(bool daylight)
 {
     if (daylight)
     {
         this.left  = new Textura(@"../../Imagenes/Texturas/Skybox/mpa23lf.bmp", false);
         this.front = new Textura(@"../../Imagenes/Texturas/Skybox/mpa23ft.bmp", false);
         this.right = new Textura(@"../../Imagenes/Texturas/Skybox/mpa23rt.bmp", false);
         this.back  = new Textura(@"../../Imagenes/Texturas/Skybox/mpa23bk.bmp", false);
         this.up    = new Textura(@"../../Imagenes/Texturas/Skybox/mpa23up.bmp", false);
         this.down  = new Textura(@"../../Imagenes/Texturas/Skybox/mpa23dn.bmp", false);
     }
     else
     {
         this.left  = new Textura(@"../../Imagenes/Texturas/Skybox/night_mpa23lf.bmp", false);
         this.front = new Textura(@"../../Imagenes/Texturas/Skybox/night_mpa23ft.bmp", false);
         this.right = new Textura(@"../../Imagenes/Texturas/Skybox/night_mpa23rt.bmp", false);
         this.back  = new Textura(@"../../Imagenes/Texturas/Skybox/night_mpa23bk.bmp", false);
         this.up    = new Textura(@"../../Imagenes/Texturas/Skybox/night_mpa23up.bmp", false);
         this.down  = new Textura(@"../../Imagenes/Texturas/Skybox/night_mpa23dn.bmp", false);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Carga la textura a ser aplicada sobre la superficie.
 /// </summary>
 /// <param name="fileName">Path al archivo imagen a ser utilizado para la textura</param>
 /// <param name="uAspectRatio">Relación de aspecto para la coordenada U</param>
 /// <param name="vAspectRatio">Relación de aspecto para la coordenada V</param>
 public virtual void LoadTextures(string fileName, double uAspectRatio, double vAspectRatio)
 {
     this.UTextureAspectRatio = uAspectRatio;
     this.VTextureAspectRatio = vAspectRatio;
     this.texture             = new Textura(fileName, true);
 }
Beispiel #4
0
        private void DibujarTronco()
        {
            if (texturaTronco == null)
                texturaTronco = new Textura(@"../../Imagenes/Texturas/Arbol/tronco_1.bmp", false);

            Gl.glEnable(Gl.GL_TEXTURE_2D);

            float[] colorBrown = new float[4] { 124.0f / 255.0f, 87.0f / 255.0f, 59.0f / 255.0f, .15f };
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT_AND_DIFFUSE, colorBrown);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, new float[] { 0f, 0f, 0f, 1.0f });

            texturaTronco.Activate();
            Glu.gluQuadricDrawStyle(quadraticCylinder, Glu.GLU_FILL);
            Glu.gluQuadricNormals(quadraticCylinder, Glu.GLU_SMOOTH);
            Glu.gluQuadricTexture(quadraticCylinder, Gl.GL_TRUE);
            Glu.gluCylinder(quadraticCylinder, this.radioBaseTronco, this.radioBaseTronco, this.longitudTronco, CANTIDAD_CARAS, 1);

            Gl.glDisable(Gl.GL_TEXTURE_2D);
        }
Beispiel #5
0
        private void DibujarCopa()
        {
            Gl.glPushMatrix();
            Gl.glRotated(90.0f, 1, 0, 0);

            if (texturaCopa == null)
                texturaCopa = new Textura(@"../../Imagenes/Texturas/Arbol/copa.bmp", false);

            Gl.glEnable(Gl.GL_TEXTURE_2D);
            texturaCopa.Activate();

            float[] colorGray = new float[4] { .5f, .5f, .5f, .15f };
            float[] colorNone = new float[4] { 0.0f, 0.0f, 0.0f, 0.0f };

            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT_AND_DIFFUSE, colorGray);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, new float[] { 0f, 0f, 0f, 1.0f });

            Punto[] posicionesTextura = new Punto[]
            {
                new Punto ( 0,   0,  0 ),
                new Punto ( 1,   0, 0 ),
                new Punto ( 0,   1, 0 ),
                new Punto ( 1,   1, 0 )
            };

            for (int i = 0; i < matrizPuntosCopa.Length - 2; i++) // por columnas duplicadas
            {
                int cicloPosicionTextura = 0;
                Punto posicionTextura = null;

                Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
                for (int j = 0; j < matrizPuntosCopa[i].Length; j++)
                {
                    double ancho = (matrizPuntosCopa[i + 1][j] - matrizPuntosCopa[i][j]).Modulo();
                    double alto = 1.0f;
                    if (j < matrizPuntosCopa[i].Length-1)
                    {
                        alto = (matrizPuntosCopa[i][j + 1] - matrizPuntosCopa[i][j]).Modulo();
                    }

                    double anchoSobreAlto = ancho / alto;

                    posicionTextura = posicionesTextura[cicloPosicionTextura];
                    cicloPosicionTextura = (cicloPosicionTextura + 1) % posicionesTextura.Length;

                    Gl.glNormal3d(matrizPuntosCopa[i][j].NormalX, matrizPuntosCopa[i][j].NormalY, matrizPuntosCopa[i][j].NormalZ);
                    Gl.glVertex3d(matrizPuntosCopa[i][j].X, matrizPuntosCopa[i][j].Y, matrizPuntosCopa[i][j].Z);

                    Gl.glTexCoord2d(posicionTextura.X, posicionTextura.Y);

                    posicionTextura = posicionesTextura[cicloPosicionTextura];
                    cicloPosicionTextura = (cicloPosicionTextura + 1) % posicionesTextura.Length;

                    Gl.glNormal3d(matrizPuntosCopa[i + 1][j].NormalX, matrizPuntosCopa[i + 1][j].NormalY, matrizPuntosCopa[i + 1][j].NormalZ);
                    Gl.glVertex3d(matrizPuntosCopa[i + 1][j].X, matrizPuntosCopa[i + 1][j].Y, matrizPuntosCopa[i + 1][j].Z);
                    Gl.glTexCoord2d(posicionTextura.X, posicionTextura.Y);
                }
                Gl.glEnd();
            }
            Gl.glDisable(Gl.GL_TEXTURE_2D);

            if (DIBUJAR_NORMALES)
            {
                Gl.glDisable(Gl.GL_LIGHTING);
                for (int i = 0; i < matrizPuntosCopa.Length - 2; i++) // por columnas duplicadas
                {
                    for (int j = 0; j < matrizPuntosCopa[i].Length; j++)
                    {
                        Gl.glBegin(Gl.GL_LINES);
                        Gl.glColor3d(1, 0, 0);
                        Gl.glVertex3d(matrizPuntosCopa[i][j].X, matrizPuntosCopa[i][j].Y, matrizPuntosCopa[i][j].Z);
                        Gl.glColor3d(.2, 0, 0);
                        Gl.glVertex3d(matrizPuntosCopa[i][j].NormalX, matrizPuntosCopa[i][j].NormalY, matrizPuntosCopa[i][j].NormalZ);
                        Gl.glEnd();

                    }
                }
                Gl.glEnable(Gl.GL_LIGHTING);
            }
            Gl.glPopMatrix();
        }
 /// <summary>
 /// Carga la textura a ser aplicada sobre la superficie.
 /// </summary>
 /// <param name="fileName">Path al archivo imagen a ser utilizado para la textura</param>
 /// <param name="uAspectRatio">Relación de aspecto para la coordenada U</param>
 /// <param name="vAspectRatio">Relación de aspecto para la coordenada V</param>
 public virtual void LoadTextures(string fileName, double uAspectRatio, double vAspectRatio)
 {
     this.UTextureAspectRatio = uAspectRatio;
     this.VTextureAspectRatio = vAspectRatio;
     this.texture = new Textura(fileName, true);
 }