13.07.2015 Views

Manual de Apoio 2010

Manual de Apoio 2010

Manual de Apoio 2010

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

O valor utilizado no primeiro argumento das funções relacionadas com as texturas passa agora a serGL TEXTURE CUBE MAP. O mesmo valor é utilizado para activar o cube mapping:gl. glEnable ( GL2 . GL_TEXTURE_CUBE_MAP );No caso <strong>de</strong> GL TEXTURE CUBE MAP e GL TEXTURE 2D estarem activos simultâneamente, o cube map prevalece.De notar que a utilização do glTexParameter no cube map afecta as 6 texturas <strong>de</strong> uma só vez. Para todos osefeitos, os cube maps são tratados como texturas 3D, com coor<strong>de</strong>nadas s, t e r.9.5.2 Utilização dos Cube MapsA utilização mais comum para o cube map é a reflexão do ambiente. No exemplo CubeMap.java, a cena écapturada mudando o ponto <strong>de</strong> vista 6 vezes utilizando um field of view <strong>de</strong> 90 o .Para conseguir o efeito <strong>de</strong> reflexão com a composição das seis imagens, utilizamos:gl. glTexGeni ( GL2 .GL_S , GL2 . GL_TEXTURE_GEN_MODE , GL2 . GL_REFLECTION_MAP );gl. glTexGeni ( GL2 .GL_T , GL2 . GL_TEXTURE_GEN_MODE , GL2 . GL_REFLECTION_MAP );gl. glTexGeni ( GL2 .GL_R , GL2 . GL_TEXTURE_GEN_MODE , GL2 . GL_REFLECTION_MAP );Ao <strong>de</strong>senhar a nossa geometria (no exemplo um torus e uma sphere), <strong>de</strong>sactivamos temporáriamenteo GL TEXTURE 2D e activamos o GL TEXTURE CUBE MAP, activamos a geração das coor<strong>de</strong>nadas das texturas e<strong>de</strong>senhamos a geometria normalmente. Seguidamente restauramos o estado anterior reactivando o GL TEXTURE 2D:// Desactivar temporariamente TEXTURE_2Dgl. glDisable ( GL2 . GL_TEXTURE_2D );// Activar o Cube Mapgl. glEnable ( GL2 . GL_TEXTURE_CUBE_MAP );gl. glBindTexture ( GL2 . GL_TEXTURE_CUBE_MAP , textures . get ( CubeStartIn<strong>de</strong>x ));gl. glEnable ( GL2 . GL_TEXTURE_GEN_S );gl. glEnable ( GL2 . GL_TEXTURE_GEN_T );gl. glEnable ( GL2 . GL_TEXTURE_GEN_R );// Desenhar a Geometria que reflecte o cube mapgl. glTranslatef (0 , .5f, -.3f);glut . glutSolidSphere (.15 , 61 , 37);gl. glRotatef (( float ) Math . toDegrees ( torusRot ), 0, 1f, 0);glut . glutSolidTorus (.1f, .3f, 61 , 37);// Colocar tudo como estavagl. glDisable ( GL2 . GL_TEXTURE_GEN_S );gl. glDisable ( GL2 . GL_TEXTURE_GEN_T );gl. glDisable ( GL2 . GL_TEXTURE_GEN_R );gl. glDisable ( GL2 . GL_TEXTURE_CUBE_MAP );gl. glEnable ( GL2 . GL_TEXTURE_2D );O output do programa CubeMap.java po<strong>de</strong> ser analisado na Figura 9.8.98

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!