11.07.2015 Views

Download document (10.35 MB) - Escuela Superior de Informática ...

Download document (10.35 MB) - Escuela Superior de Informática ...

Download document (10.35 MB) - Escuela Superior de Informática ...

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.

150 Capítulo D. Código fuente113 DestinoY = punto3D->y;114 DestinoZ = punto3D->z;115116 EjeX = DestinoX - OrigenX;117 EjeY = DestinoY - OrigenY;118 EjeZ = DestinoZ - OrigenZ;119120 /* Altura <strong>de</strong>l cilindro a dibujar */121 Altura = (float) sqrt(EjeX*EjeX + EjeY*EjeY + EjeZ*EjeZ);122123 glMatrixMo<strong>de</strong>(GL_MODELVIEW);124 glPushMatrix();125126 qobj = gluNewQuadric ();127 gluQuadricDrawStyle (qobj, GLU_FILL);128129 /* Primero trasladamos para que el origen <strong>de</strong> las coor<strong>de</strong>nadas <strong>de</strong>l mundo130 coincidan con el punto origen <strong>de</strong>l cilindro */131 glTranslatef(OrigenX, OrigenY, OrigenZ);132133 /* Angulo entre los vectores <strong>de</strong>l eje <strong>de</strong>seado <strong>de</strong>l cilindro y el eje Z */134 Angulo = acos((EjeX*EjeObjetivoX + EjeY*EjeObjetivoY135 + EjeZ*EjeObjetivoZ)/Altura)*360/(2*MI_PI);136137 /* Calculamos el eje <strong>de</strong> rotacion */138 EjeRotX = EjeObjetivoY*EjeZ - EjeY*EjeObjetivoZ;139 EjeRotY = EjeObjetivoZ*EjeX - EjeZ*EjeObjetivoX;140 EjeRotZ = EjeObjetivoX*EjeY - EjeX*EjeObjetivoY;141142 glRotatef(Angulo,EjeRotX,EjeRotY,EjeRotZ); /* Y rotamos. :) */143144 /* Si es una marca perdida, no la dibujamos */145 if ((OrigenX < 999998.) && (DestinoX < 999998.)) {146147 /* Dibujamos el cilindro */148 glDisable(GL_LIGHTING);149 gluQuadricDrawStyle (qobj, GLU_FILL);150 gluCylin<strong>de</strong>r(qobj,radio,radio,Altura,5,5);151 glEnable(GL_LIGHTING);152153 /* Dibujamos las "tapas" */154 gluDisk(qobj,0,radio,10,10);155 glTranslatef(0,0,Altura);156 gluDisk(qobj,0,radio,10,10);157 }158 }159160 glPopMatrix();161 }162163 /*****************************************************************164 * Funcion: dibujaMarcas165 * Descripcion: Dibuja la marca especificada en pantalla.166 * Entradas: marca --> Numero <strong>de</strong> la marca a pintar167 * tamano --> Radio <strong>de</strong> la esfera a dibujar168 * frame --> Frame actual169 * Salidas: Ninguna.170 ****************************************************************/171 void dibujaMarcas(int marca, double tamano, int frame)172 {

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

Saved successfully!

Ooh no, something went wrong!