1. Laboratorio de Computación Gráfica
Facultad de
Ingeniería
Práctica 9 / CP
Ortiz Gómez Cristian
cris.org@gmx.com
Teoría: Grupo 4
Texturizado 2
2. Texturizado 2
Objetivo
• El alumno utilizará el mapeo de texturas para cubrir elementos diversos.
Cuestionario previo
1. Investigue la manera de construir matemáticamente las siguientes primitivas geométricas, es decir, obtener los
vértices que formarán a la figura y sus reglas de unión (no utilizar funciones de GLUT):
1
Texturizado2
a) Prisma: Debe recibir
como parámetros la
longitud (eje X), la
altura (eje Y) y la
profundidad (eje Z).
void MyPrism(GLfloat lenght, GLfloat height, Glfloat depth) {
glBegin(GL_POLYGON); // Bottom
glVertex3f(-lenght/2, -height/2, depth/2);
glVertex3f(-lenght/2, -height/2, -depth/2);
glVertex3f( lenght/2, -height/2, -depth/2);
glVertex3f( lenght/2, -height/2, depth/2);
glEnd();
glBegin(GL_POLYGON); // Front
glVertex3f(-lenght/2, -height/2, depth/2);
glVertex3f( lenght/2, -height/2, depth/2);
glVertex3f( lenght/2, height/2, depth/2);
glVertex3f(-lenght/2, height/2, depth/2);
glEnd();
glBegin(GL_POLYGON); // Right
glVertex3f(lenght/2, -height/2, depth/2);
glVertex3f(lenght/2, -height/2, -depth/2);
glVertex3f(lenght/2, height/2, -depth/2);
glVertex3f(lenght/2, height/2, depth/2);
glEnd();
glBegin(GL_POLYGON); // Back
glVertex3f(-lenght/2, -height/2, -depth/2);
glVertex3f(-lenght/2, height/2, -depth/2);
glVertex3f( lenght/2, height/2, -depth/2);
glVertex3f( lenght/2, -height/2, -depth/2);
glEnd();
glBegin(GL_POLYGON); // Left
glVertex3f(-lenght/2, -height/2, depth/2);
glVertex3f(-lenght/2, height/2, depth/2);
glVertex3f(-lenght/2, height/2, -depth/2);
glVertex3f(-lenght/2, -height/2, -depth/2);
glEnd();
glBegin(GL_POLYGON); // Top
glVertex3f(-lenght/2, height/2, depth/2);
glVertex3f( lenght/2, height/2, depth/2);
glVertex3f( lenght/2, height/2, -depth/2);
glVertex3f(-lenght/2, height/2, -depth/2);
glEnd();
}
Prisma
3. 2
Texturizado2
b) Cono: Debe recibir como parámetros la altura (eje Y), radio y la resolución de su circunferencia final.
c) Cilindro: Debe recibir como parámetros la altura (eje Y), radio de las circunferencias y su resolución.
void MyCone(GLfloat height, GLfloat radius, Glfloat resolution) {
GLdouble theta, ntheta;
glBegin(GL_POLYGON); // Base
for(GLint i = 0; i < resolution; i++) {
theta = (2 * PI * i / resolution);
ntheta = (2 * PI * (i + 1) / resolution);
glBegin(GL_POLYGON); // Faces
glVertex3f(radius * cos(theta), 0, radius * sin(theta));
glVertex3f(0, height, 0);
glVertex3f(radius * cos(ntheta), 0, radius * sin(ntheta));
glEnd();
glVertex3f(radius * cos(theta), 0, radius * sin(theta));
}
glEnd();
}
Cono
void MyCylinder(GLfloat height, GLfloat radius, GLfloat resolution) {
GLdouble theta, ntheta, cos_t, sin_t, cos_nt, sin_nt;
glBegin(GL_POLYGON); // Bottom
for(GLint i = 0; i < resolution; i++) {
theta = (2 * PI * i / resolution);
ntheta = (2 * PI * (i + 1) / resolution);
cos_t = cos(theta); sin_t = sin(theta);
cos_nt = cos(ntheta); sin_nt = sin(ntheta);
glBegin(GL_POLYGON); // Faces
glVertex3f(radius * cos_t, 0, radius * sin_t);
glVertex3f(radius * cos_t, height, radius * sin_t);
glVertex3f(radius * cos_nt, height, radius * sin_nt);
glVertex3f(radius * cos_nt, 0, radius * sin_nt);
glEnd();
glVertex3f(radius * cos_t, 0, radius * sin_t);
}
glEnd();
glBegin(GL_POLYGON); // Top
for(GLint i = 0; i < resolution; i++) {
theta = (2 * PI * i / resolution);
glVertex3f(radius * cos(theta), height, radius * sin(theta));
}
glEnd();
}
Cilindro
4. 3
Texturizado2
2. Indique la diferencia entre un objeto transparente y un objeto translúcido.
2. La palabra transparente se usa en todos los casos donde la difusión no está involucrada. Un objeto que tiene la
propiedad de transmitir luz sin dispersión apreciable para que los cuerpos que se encuentran más allá se vean
claramente es transparente. Incluso si la lente es deficiente y hace que las imágenes no se enfoquen correctamente,
siempre que el problema se deba a aberraciones. La palabra translúcido se aplica cuando hay una difusión
significativa de la luz hasta el punto donde el objeto se ve "nublado" o "helado" y nunca se puede formar una imagen
nítida.
Conclusiones
• Para formar un prisma rectangular debemos especificar la longitud, altura y profundidad para poder calcular sus
dimensiones.
• Podemos aproximar la forma de un cono utilizando una pirámide de “n” caras, o también se puede aproximar la
forma de un cilindro utilizando un prisma de “n” caras .
• Los objetos transparentes permiten que la luz pase a través de ellos y podemos ver a través de estos objetos
claramente
• El objeto translúcido permite que la luz pase a través de ellos parcialmente.
Bibliografía
Shalini Govil-Pai (2004)
Principles of Computer Graphics
(pp. 95-100) Sunnyvale, CA, U.S.A., ed. Springer
What is the difference between the words transparent and translucent?
Copyright, 2018, Stack Exchange
https://physics.stackexchange.com/questions/93310/what-is-the-difference-between-the-words-transparent-and-translucent