13.07.2015 Views

Manual de Apoio 2010

Manual de Apoio 2010

Manual de Apoio 2010

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Desenhar um Torus Ver<strong>de</strong>gl. glColor4f (0 , 1f, 0, .5f);drawWorld (gl );// Desenhar um Torus Vermelho com Blendinggl. glPushMatrix ();gl. glTranslatef (.1f, 0, .3f);gl. glEnable ( GL2 . GL_BLEND );gl. glBlendFunc ( GL2 . GL_SRC_ALPHA , GL2 . GL_ONE_MINUS_SRC_ALPHA );gl. glColor4f (1f, 0, 0,drawWorld (gl );.5f);gl. glDisable ( GL2 . GL_BLEND );gl. glPopMatrix ();gl. glColor4f (0.60f, .40f, .10f, .5f);GlUtil . drawGround ( FloorSize , 1f);gl. glPopMatrix ();O resultado do código em cima será o da Figura 6.2.Figura 6.2: Exemplo <strong>de</strong> BlendingModificando ligeiramente o código anterior, po<strong>de</strong>mos obter a sensação <strong>de</strong> reflexão:gl. glPushMatrix ();// Desenhar a luz Invertida ( mirror Y)gl. glLightfv ( GL2 . GL_LIGHT0 , GL2 . GL_POSITION , fLightPos . mirrorY (). toArray () , 0);// Desenhar a reflexao do Torusgl. glPushMatrix ();// Ao utiliza y=-1 estamos a inverter a imagemgl. glScalef (1f, -1f, 1f);gl. glFrontFace ( GL2 . GL_CW ); // Estamos InvertidosdrawWorld (gl );gl. glFrontFace ( GL2 . GL_CCW ); // Reporgl. glPopMatrix ();// Desenhar o Nosso chao , mas agora transparentegl. glDisable ( GL2 . GL_LIGHTING );gl. glEnable ( GL2 . GL_BLEND );gl. glBlendFunc ( GL2 . GL_SRC_ALPHA , GL2 . GL_ONE_MINUS_SRC_ALPHA );gl. glColor4f (.5f, .5f, .5f, .5f);GlUtil . drawGround ( FloorSize , 1f);60

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

Saved successfully!

Ooh no, something went wrong!