/////////////////////////////////////////////////////////////////////////////// // draw bottom window (3rd person view) /////////////////////////////////////////////////////////////////////////////// void ModelGL::drawSub2() { // set bottom viewport setViewportSub(0, 0, windowWidth, windowHeight/2, 1, 100); // clear buffer glClearColor(bgColor[0], bgColor[1], bgColor[2], bgColor[3]); // background color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glPushMatrix(); // First, transform the camera (viewing matrix) from world space to eye space glTranslatef(0, 0, -cameraDistance); glRotatef(cameraAngleX, 1, 0, 0); // pitch glRotatef(cameraAngleY, 0, 1, 0); // heading // draw grid drawGrid(10, 1); // draw balls drawSpheres(); // draw the camera glPushMatrix(); glTranslatef(0, 0, 7); drawCamera(); drawFrustum(projectionLeft, projectionRight, projectionBottom, projectionTop, projectionNear, projectionFar); glPopMatrix(); glPopMatrix(); }
void renderFunction() { float grey = 241.0; glClearColor(grey/255.0, grey/255.0, grey/255.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); glOrtho(-20.0, areaWidth+25.0, -20.0, areaHeight+25.0, -1.0, 1.0); drawAxes(); drawCamera(simCamera.position(), 1.0, 0.0, 0.0); drawCamera(filter.position(), 0.0, 0.0, 1.0); printf("\n"); drawLandmarks(); glutSwapBuffers(); glFlush(); }
void RGBID_SLAM::CameraView::updateCamera(const Eigen::Affine3d &new_pose) { bool not_first_pose_flag = removeCamera(); camera_pose_ = new_pose.cast<float>(); { drawCamera(camera_pose_, 1.0, 0.0, 0.0); } //drawMotionUncertainty(cov_mat_, camera_pose_, 1.0, 1.0, 1.0) ; }
void display(void) { float aspect = 1.0f * graphicsWinWidth / graphicsWinHeight; glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, aspect, 0.01f, 10.f); gluLookAt(0.9, 0.8, 0.8, 0, 0, 0, 0, 1, 0); glRotated(xAngle,1,0,0); glRotated(yAngle,0,1,0); drawXYZAxes(); drawBoard(CHESS_ROW_DX/1000.0f, CHESS_ROW_NUM, CHESS_COL_NUM); drawCamera(transGL, rotGL); glutSwapBuffers(); }
/////////////////////////////////////////////////////////////////////////////// // draw bottom window (3rd person view) /////////////////////////////////////////////////////////////////////////////// void ModelGL::drawSub2() { // set bottom viewport setViewportSub(0, 0, windowWidth, windowHeight/2, NEAR_PLANE, FAR_PLANE); // clear buffer glClearColor(bgColor[0], bgColor[1], bgColor[2], bgColor[3]); // background color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glPushMatrix(); // First, transform the camera (viewing matrix) from world space to eye space glTranslatef(0, 0, -cameraDistance); glRotatef(cameraAngleX, 1, 0, 0); // pitch glRotatef(cameraAngleY, 0, 1, 0); // heading // draw grid drawGrid(10, 1); // draw a teapot glPushMatrix(); glTranslatef(modelPosition[0], modelPosition[1], modelPosition[2]); glRotatef(modelAngle[0], 1, 0, 0); glRotatef(modelAngle[1], 0, 1, 0); glRotatef(modelAngle[2], 0, 0, 1); drawAxis(4); drawTeapot(); glPopMatrix(); // draw the camera glPushMatrix(); glTranslatef(cameraPosition[0], cameraPosition[1], cameraPosition[2]); glRotatef(cameraAngle[0], 1, 0, 0); glRotatef(cameraAngle[1], 0, 1, 0); glRotatef(cameraAngle[2], 0, 0, 1); drawCamera(); drawFrustum(FOV_Y, 1, 1, 10); glPopMatrix(); glPopMatrix(); }
void OpenGLTransformation::drawSub2() { glViewport(windowWidth / 2, 0, windowWidth / 2, windowHeight); glScissor(windowWidth / 2, 0, windowWidth / 2, windowHeight); glClearColor(0.f, 0.f, 0.f, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); MatStack.matrixMode(tgt::MatrixStack::PROJECTION); MatStack.pushMatrix(); MatStack.loadMatrix(cameraRight->getProjectionMatrix(glm::ivec2(windowWidth * 0.5f, windowHeight))); MatStack.matrixMode(tgt::MatrixStack::MODELVIEW); MatStack.pushMatrix(); MatStack.loadMatrix(cameraRight->getViewMatrix()); // always draw the grid at the origin (before any modeling transform) drawGrid(10, 1); drawAxis(4); glm::mat4 cubeModel = glm::translate(glm::vec3(-0.5f)); MatStack.pushMatrix(); MatStack.loadMatrix(cameraRight->getViewMatrix() * cubeModel); drawCube(); MatStack.popMatrix(); // draw the camera glm::mat4 camModel = glm::translate(camera->getPosition()) * glm::inverse(camera->getRotateMatrix()); MatStack.pushMatrix(); MatStack.loadMatrix(cameraRight->getViewMatrix() * camModel); drawCamera(); drawFrustum(camera->getFovy(), camera->getRatio(), camera->getNearDist(), camera->getFarDist()); MatStack.popMatrix(); MatStack.matrixMode(tgt::MatrixStack::PROJECTION); MatStack.popMatrix(); MatStack.matrixMode(tgt::MatrixStack::MODELVIEW); MatStack.popMatrix(); }
void CCY457OpenGLView::RenderScene () { glLoadIdentity(); glTranslatef(m_xPos, m_yPos, m_zPos); glRotatef(m_xAngle, 1.0f,0.0f,0.0f); glRotatef(m_yAngle, 0.0f,1.0f,0.0f); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //ground if(m_ground){ glBegin(GL_QUADS); glColor4f(0.2f,0.2f,0.2f,1.0f); glVertex3f( 500.0f, -CUBELINE*10,-500.0f); glVertex3f(-500.0f, -CUBELINE*10,-500.0f); glVertex3f(-500.0f, -CUBELINE*10, 500.0f); glVertex3f( 500.0f, -CUBELINE*10, 500.0f); glEnd(); } //table if(m_table){ glDepthMask(GL_FALSE); glBegin(GL_QUADS); glColor4f(1.0f,1.0f,1.0f,0.5f); glVertex3f( CUBELINE*4, -0.01f,-CUBELINE*4); glVertex3f(-CUBELINE*4, -0.01f,-CUBELINE*4); glVertex3f(-CUBELINE*4, -0.01f, CUBELINE*4); glVertex3f( CUBELINE*4, -0.01f, CUBELINE*4); glEnd(); glDepthMask(GL_TRUE); } //cube if(m_cube){ glColor4f(0.8f,0.8f,0.8f,1.0f); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,m_Texture[1]); //Front Face glBegin(GL_POLYGON); glTexCoord2f(0,0); glVertex3f(0.0f, 0.0f,CUBELINE); glTexCoord2f(1,0); glVertex3f(CUBELINE, 0.0f,CUBELINE); glTexCoord2f(1,1); glVertex3f(CUBELINE, CUBELINE,CUBELINE); glTexCoord2f(0,1); glVertex3f(0.0f, CUBELINE,CUBELINE); glEnd(); glBindTexture(GL_TEXTURE_2D,m_Texture[3]); //Back Face glBegin(GL_POLYGON); glTexCoord2f(1,0); glVertex3f(0.0f, 0.0f,0.0f); glTexCoord2f(1,1); glVertex3f(0.0f, CUBELINE,0.0f); glTexCoord2f(0,1); glVertex3f(CUBELINE, CUBELINE,0.0f); glTexCoord2f(0,0); glVertex3f(CUBELINE, 0.0f,0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D,m_Texture[2]); //Left Face glBegin(GL_POLYGON); glTexCoord2f(1,0); glVertex3f(0.0f, 0.0f, CUBELINE); glTexCoord2f(1,1); glVertex3f(0.0f, CUBELINE, CUBELINE); glTexCoord2f(0,1); glVertex3f(0.0f, CUBELINE, 0.0f); glTexCoord2f(0,0); glVertex3f(0.0f, 0.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D,m_Texture[4]); //Right Face glBegin(GL_POLYGON); glTexCoord2f(0,0); glVertex3f(CUBELINE, 0.0f, CUBELINE); glTexCoord2f(1,0); glVertex3f(CUBELINE, 0.0f, 0.0f); glTexCoord2f(1,1); glVertex3f(CUBELINE, CUBELINE, 0.0f); glTexCoord2f(0,1); glVertex3f(CUBELINE, CUBELINE, CUBELINE); glEnd(); glBindTexture(GL_TEXTURE_2D,m_Texture[5]); //Top Face glBegin(GL_POLYGON); glTexCoord2f(0,0); glVertex3f(0.0f, CUBELINE, CUBELINE); glTexCoord2f(1,0); glVertex3f(CUBELINE, CUBELINE, CUBELINE); glTexCoord2f(1,1); glVertex3f(CUBELINE, CUBELINE, 0.0f); glTexCoord2f(0,1); glVertex3f(0.0f, CUBELINE, 0.0f); glEnd(); //Bottom Face glBindTexture(GL_TEXTURE_2D,m_Texture[0]); glBegin(GL_POLYGON); glTexCoord2f(0,0); glVertex3f(0.0f, 0.0f, CUBELINE); glTexCoord2f(1,0); glVertex3f(CUBELINE, 0.0f, CUBELINE); glTexCoord2f(1,1); glVertex3f(CUBELINE, 0.0f, 0.0f); glTexCoord2f(0,1); glVertex3f(0.0f, 0.0f, 0.0f); glEnd(); glDisable(GL_TEXTURE_2D); } //axia if(m_axia){ float i; glColor4f(1.0f,0.0f,0.0f,1.0f); glBegin(GL_LINES); glVertex3f(0.0f,0.0f,0.0f); glVertex3f(100.0f,0.0f,0.0f); glEnd(); for(i=0;i<500;i++){ glBegin(GL_LINES); glVertex3f(i/10,0.0f,0.0f); glVertex3f(i/10,0.0f,0.05f); glEnd(); } glColor4f(0.0f,1.0f,0.0f,1.0f); glBegin(GL_LINES); glVertex3f(0.0f,0.0f,0.0f); glVertex3f(0.0f,100.0f,0.0f); glEnd(); for(i=0;i<500;i++){ glBegin(GL_LINES); glVertex3f(0.0f,i/10,0.0f); glVertex3f(0.0f,i/10,0.05f); glEnd(); } glColor4f(0.0f,0.0f,1.0f,1.0f); glBegin(GL_LINES); glVertex3f(0.0f,0.0f,0.0f); glVertex3f(0.0f,0.0f,100.0f); glEnd(); for(i=0;i<500;i++){ glBegin(GL_LINES); glVertex3f(0.0f,0.0f,i/10); glVertex3f(0.05f,0.0f,i/10); glEnd(); } } //camera if(m_camera){ glDepthMask(GL_FALSE); int j; for(j=0;j<m_cameraCount;j++){ drawCamera(m_cameraData+j); } glDepthMask(GL_TRUE); } }
void DebuggingView::draw() { if (!valid()) { glShadeModel( GL_SMOOTH ); glEnable( GL_DEPTH_TEST ); glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); glEnable( GL_LIGHT1 ); glEnable( GL_NORMALIZE ); } glViewport( 0, 0, w(), h() ); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(30.0,-float(w())/float(h()),1.0,100.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_camera->applyViewingTransform(); // Need to apply an extra transform so that our camera 'approximately' // lines up with the scene camera, initially, and to correct for our // definition of "up." { Vec3d uAxis = raytracer->getScene().getCamera().getU(); Vec3d vAxis = raytracer->getScene().getCamera().getV(); Vec3d wAxis = uAxis ^ vAxis; uAxis = wAxis ^ vAxis; uAxis.normalize(); vAxis.normalize(); wAxis.normalize(); GLdouble rotMat[16]; rotMat[0] = uAxis[0]; rotMat[1] = vAxis[0]; rotMat[2] = wAxis[0]; rotMat[3] = 0.0; rotMat[4] = uAxis[1]; rotMat[5] = vAxis[1]; rotMat[6] = wAxis[1]; rotMat[7] = 0.0; rotMat[8] = uAxis[2]; rotMat[9] = vAxis[2]; rotMat[10] = wAxis[2]; rotMat[11] = 0.0; rotMat[12] = 0.0; rotMat[13] = 0.0; rotMat[14] = 0.0; rotMat[15] = 1.0; glMultMatrixd( rotMat ); } if( m_showAxes ) drawAxes(); if( raytracer == 0 || !raytracer->sceneLoaded() ) return; if( m_showLights ) drawLights(); if( m_showGeometry ) { lightScene(); drawScene(); } drawRays(); if( m_showCamera ) drawCamera(); }
void Scene::paintGL() { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( 0, RESOLUTION_WIDTH, 0, RESOLUTION_HEIGHT, 1, 1000 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); // Inicio: Gráfico de cámara glEnable( GL_TEXTURE_2D ); glColor3f( 1, 1, 1 ); glBindTexture( GL_TEXTURE_2D, textures->at( 0 )->id ); glBegin( GL_QUADS ); glTexCoord2f( 0, 0 ); glVertex3f( 0, RESOLUTION_HEIGHT, -999 ); glTexCoord2f( 1, 0 ); glVertex3f( RESOLUTION_WIDTH, RESOLUTION_HEIGHT, -999 ); glTexCoord2f( 1, 1 ); glVertex3f( RESOLUTION_WIDTH, 0, -999 ); glTexCoord2f( 0, 1 ); glVertex3f( 0, 0, -999 ); glEnd(); glDisable( GL_TEXTURE_2D ); // Fin: Gráfico de cámara glMatrixMode( GL_PROJECTION ); double projectionMatrix[16]; cv::Size2i sceneSize( RESOLUTION_WIDTH, RESOLUTION_HEIGHT ); cv::Size2i openGlSize( RESOLUTION_WIDTH, RESOLUTION_HEIGHT ); cameraParameters->glGetProjectionMatrix( sceneSize, openGlSize, projectionMatrix, 0.05, 10 ); glLoadMatrixd( projectionMatrix ); glMatrixMode( GL_MODELVIEW ); double modelview_matrix[16]; // Inicio: Gráfico en marcadores bool musicDetected = false; ThreeDWriter textoParaCredencial(80, "Arial", -0.04f, 0.045f, -0.001f, 0.3f, 0.02f, 0.0001f); QString comando_sql; QString textoParaMostrar; QVector<QStringList> vDatos; for( int i = 0 ; i < detectedMarkers.size() ; i++ ) { detectedMarkers.operator []( i ).glGetModelViewMatrix( modelview_matrix ); glLoadMatrixd( modelview_matrix ); glTranslatef( xTranslationOption, yTranslationOption, zTranslationOption ); if( rotateOption ) { emit message( "Rotando" ); zRotationOption += rotationVelocityOption; } glRotatef( xRotationOption, 1, 0, 0 ); glRotatef( yRotationOption, 0, 1, 0 ); glRotatef( zRotationOption, 0, 0, 1 ); /* ||**************************************************************************************************************|| || || || MÉTODOS LISTOS PARA USAR EN MARCADORES: || || || || DrawSheet - DrawBox - DrawCamera - DrawCameraBox - DrawModel - DrawVideo - DrawWebImage - ListenWebMusic || || Siempre agregar "+ scaleOption" al parámetro percentage para que la escala pueda ser modificada || || || || *************************************************************************************************************|| || || || RECORDAR: Ajustar la escala que se envía como parámetro ( percentage ). || || IMPORTANTE: Para que los modelos se vean bien, las imagenes y el sonido, agregar antes de usar: || || || || DrawBox: glRotatef( -90, 0, 1, 0 ); || || DrawCamera: glRotatef( 90, 0, 1, 0 ); || || DrawCameraBox: glRotatef( 90, 0, 1, 0 ); || || DrawSheet: glRotatef( 90, 0, 1, 0 ); || || DrawWebImage: glRotatef( 180, 0, 0, 1 ); glRotatef( -90, 0, 1, 0 ); || || DrawVideo: glRotatef( 90, 0, 1, 0 ); glRotatef( 180, 0, 0, 1 ); || || ListenWebMusic: glRotatef( 180, 0, 0, 1 ); drawWebImage(); || || musicDetected = true; webMusicPlayer->setVolume( detectedMarkers.at( i ).getArea() / 1000 ); || || || || House: glRotatef( -90, 0, 1, 0 ); || || IPhone: glTranslatef( 0.032, 0, -0.025 ); glRotatef( 90, 1, 0, 0 ); || || Man: glTranslatef( 0, 0, -0.012 ); glRotatef( -90, 1, 0, 0 ); glRotatef( 90, 0, 0, 1 ); || || Oil: glRotatef( 90, 1, 0, 0 ); || || Wagen: glRotatef( 90, 1, 0, 0 ); glRotatef( 90, 0, 0, 1 ); || || Woman: glRotatef( 90, 1, 0, 0 ); glRotatef( 90, 0, 0, 1 ); || || || || *************************************************************************************************************|| */ switch( detectedMarkers.at( i ).id ) { case 0: { glRotatef( 270, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); drawCamera( 130 + scaleOption ); emit message( "Dibujando Cámara" ); break; } case 1: { glRotatef( 90, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); drawCameraBox( 130 + scaleOption ); emit message( "Dibujando Cubo de la Cámara" ); break; } case 2: { glRotatef( 90+180, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); drawWebImage( 150 + scaleOption ); break; } case 3: { glRotatef( -90, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); drawWebMusicImage( 150 + scaleOption ); musicDetected = true; int volume = detectedMarkers.at( i ).getArea() / 150; if( volume > 100 ) volume = 100; webMusicPlayer->setVolume( volume ); emit message( "Volumen audio: " + QString::number( volume ) ); listenWebMusic(); break; } case 4: { glRotatef( 90, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); drawBox( "Danger.jpg", 100 + scaleOption ); emit message( "Dibujando la Famosa Caja Danger" ); break; } case 5: { glRotatef( 180, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); glTranslatef( -0.03, 0.05, 0); drawModel( "IPhone.3ds", 70 + scaleOption ); emit message( "Dibujando Modelo 3d: IPhone" ); break;} case 6: { glTranslatef( 0, 0.02, 0 ); glRotatef( -90, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); glRotatef( 90+180, 1, 0, 0 ); drawModel( "Man.3ds", 3 + scaleOption ); emit message( "Dibujando Modelo 3d: Man" ); break; } case 7: { glRotatef( 90, 0, 1, 0 ); glRotatef( 90, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); drawModel( "Oil.3ds", 150 + scaleOption ); emit message( "Dibujando Modelo 3d: Oil" ); break; } case 8: { glRotatef( 270, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); int volume = detectedMarkers.at( i ).getArea() / 150; if( volume > 100 ) volume = 100; emit message( "Volumen video: " + QString::number( volume ) ); drawVideo( "trailer-RF7.mp4", volume, 200 + 2*scaleOption ); break; } case 9: { glRotatef( 90, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); drawBox( "Ubp.png", 150 + scaleOption ); emit message( "Dibujando Cubo de la UBP" ); break; } case 10: { if ( ! seguirRostroOption) actualizaServoSiCorresponde(detectedMarkers.at( i ).getCenter().x, 50); glBegin(GL_LINES); glColor3f (1, 0, 0); glVertex3f( 0, 0, 0); glVertex3f( 0, 100, 0); glColor3f (0, 0, 1); glVertex3f( 0, 0, 0); glVertex3f( -100, 0, 0); glEnd(); emit message( "Control de Servo" ); break; } case 11: { glRotatef( 270, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); int volume = detectedMarkers.at( i ).getArea() / 150; if( volume > 100 ) volume = 100; emit message( "Volumen video: " + QString::number( volume ) ); drawVideo( "stic.mp4", volume, 200 + 2*scaleOption ); break; } case 12: { glRotatef( 270, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); int volume = detectedMarkers.at( i ).getArea() / 150; if( volume > 100 ) volume = 100; emit message( "Volumen video: " + QString::number( volume ) ); drawVideo( "trailer-relato.mp4", volume, 200 + 2*scaleOption ); break; } case 13: comando_sql = "SELECT sorteo FROM invitados WHERE apellido = 'House'"; vDatos = adminDB.ejecutarComandoSelect(comando_sql); for (int i=0 ; i<vDatos.size() ; i++) { textoParaMostrar = vDatos.at(i).at(0); } glRotatef( 90, 1, 0, 0 ); glRotatef( 270, 0, 1, 0 ); glTranslatef( 0, 0, 0.005 ); drawSheet( "drhouse.jpg", 130 + scaleOption ); glLoadMatrixd( modelview_matrix ); // Cargamos la matriz inicial glRotatef( 90, 0, 0, 1 ); glRotated(180, 0, 0, 5); textoParaCredencial.writeText(textoParaMostrar); break; case 14: comando_sql = "SELECT sorteo FROM invitados WHERE apellido = 'Messi'"; vDatos = adminDB.ejecutarComandoSelect(comando_sql); for (int i=0 ; i<vDatos.size() ; i++) { textoParaMostrar = vDatos.at(i).at(0); } glRotatef( 90, 1, 0, 0 ); glRotatef( 270, 0, 1, 0 ); glTranslatef( 0, 0, 0.005 ); drawSheet( "messi.png", 130 + scaleOption ); glLoadMatrixd( modelview_matrix ); // Cargamos la matriz inicial glRotatef( 90, 0, 0, 1 ); glRotated(180, 0, 0, 5); textoParaCredencial.writeText(textoParaMostrar); break; case 17: { glRotatef( -90, 0, 0, 1 ); glRotatef( 90, 1, 0, 0 ); drawModel( "House.3ds", 40 + scaleOption ); emit message( "Dibujando Modelo 3d: Casa" ); break; } case 15: { glRotatef( 90, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); drawBox( "caja.bmp", 100 + scaleOption ); emit message( "Dibujando Cubo de la UBP" ); break; } case 16: { glRotatef( 90, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); drawBox( "caja.bmp", 100 + scaleOption ); emit message( "Dibujando Cubo de la UBP" ); break; } case 18: { glRotatef( 90, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); drawBox( "caja.bmp", 100 + scaleOption ); emit message( "Dibujando Cubo de la UBP" ); break; } case 19: { glRotatef( 90, 1, 0, 0 ); glRotatef( 90, 0, 1, 0 ); drawBox( "caja.bmp", 100 + scaleOption ); emit message( "Dibujando Cubo de la UBP" ); break; } default: { break; } } } if( musicDetected ) musicActive = true; else if( musicActive ) { emit message( "<div style=\"color:red;\">Marcador no detectado, la música se pausará</div>" ); webMusicPlayer->setVolume( webMusicPlayer->volume() - 1 ); if( webMusicPlayer->volume() <= 0 ) { emit message( "Musica pausada" ); webMusicPlayer->pause(); musicActive = false; } } // La siguiente linea se ejecuta siempre. Habria que ingeniarsela de otra forma para bajar el volumen decreaseVideosVolume(); // Fin: Gráfico en marcadores glFlush(); }
void GLScenePane::drawCameras() { //draw camera trajectory for (int i = 0; i < m_pSLAM->numCams; i++) { const CamPoseItem* cam = m_pSLAM->slam[i].m_camPos.first(); while (cam->f < m_pSLAM->m_lastFrmBundle) cam = cam->next; //glColor3f(CAMERA_COLORS[3 * i], CAMERA_COLORS[3 * i + 1], CAMERA_COLORS[3 * i + 2]); glLineWidth(2.0f); glColor3f(0.5f, 0.5f, 0.5f); glBegin(GL_LINE_STRIP); while (cam) { // drawCamCenter(cam, PT_COLOR + 3 * i); //if (cam->f >= m_pSLAM->curFrame - 200) { double org[3]; getCamCenter(cam, org); glVertex3d(org[0], org[1], org[2]); } cam = cam->next; } glEnd(); glPointSize(2.0); glBegin(GL_LINE_STRIP); cam = m_pSLAM->slam[i].m_camPos.first(); while (cam) { // drawCamCenter(cam, PT_COLOR + 3 * i); //if (cam->f >= m_pSLAM->curFrame - 200) { double org[3]; getCamCenter(cam, org); glVertex3d(org[0], org[1], org[2]); } cam = cam->next; } glEnd(); cam = m_pSLAM->slam[i].m_camPos.first(); glColor3f(0.5f, 0.5f, 0.5f); glLineWidth(2.0f); glBegin(GL_LINE_STRIP); while (cam && cam->f <= m_pSLAM->m_lastFrmBundle) { // drawCamCenter(cam, PT_COLOR + 3 * i); if (cam->f >= m_pSLAM->m_firstFrmBundle) { double org[3]; getCamCenter(cam, org); glVertex3d(org[0], org[1], org[2]); } cam = cam->next; } glEnd(); drawCamera(m_pSLAM->slam[i].videoReader->_w, m_pSLAM->slam[i].videoReader->_h, m_pSLAM->slam[i].K.data, m_pSLAM->slam[i].m_camPos.current(), m_camSize, CAMERA_COLORS + 3 * i, 100); } //draw key camera poses for (int i = 0; i < m_pSLAM->numCams; i++) { for (size_t n = 0; n < m_pSLAM->slam[i].m_selfKeyPose.size(); ++n) { const KeyPose* keyPose = m_pSLAM->slam[i].m_selfKeyPose[n]; drawCameraPose(keyPose->cam, m_camSize, CAMERA_COLORS + 3 * i, 4); } const KeyPose* keyPose = m_pSLAM->slam[i].m_keyPose.first(); int n = 0; while (keyPose) { drawCameraPose(keyPose->cam, m_camSize * 0.5, CAMERA_COLORS + 3 * i); n++; keyPose = keyPose->next; } } }
void myDisplay(void) { int range; middleX= windowWidth/2; middleY= windowHeight/2; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* draw shaded view in perspective as seen from the camera */ /* in top right quadrant */ glViewport(middleX, middleY, windowWidth/2, windowHeight/2); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(cameraAngle, aspectRatio, 0.1, 100.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(lookFrom[0], lookFrom[1], lookFrom[2], lookAt[0], lookAt[1], lookAt[2], lookUp[0], lookUp[1], lookUp[2]); drawModel(0); /* draw the orthographic views */ if(aspectRatio < 1.0) range= GRID_SIZE; else range= GRID_SIZE*aspectRatio+1; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-GRID_SIZE*aspectRatio, GRID_SIZE*aspectRatio, -GRID_SIZE, GRID_SIZE, -GRID_SIZE*aspectRatio, GRID_SIZE*aspectRatio); glMatrixMode(GL_MODELVIEW); /* draw xy ortho view in top left quadrant */ glLoadIdentity(); gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0); glViewport(0, middleY, windowWidth/2, windowHeight/2); drawGrid(XY, range); drawModel(1); drawCamera(lookFrom, lookAt, lookUp, cameraAngle, aspectRatio); /* draw xz ortho view in bottom left quadrant */ glLoadIdentity(); gluLookAt(0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0); glViewport(0, 0, windowWidth/2, windowHeight/2); drawGrid(XZ, range); drawModel(1); drawCamera(lookFrom, lookAt, lookUp, cameraAngle, aspectRatio); /* draw yz ortho view in bottom right quadrant */ glLoadIdentity(); gluLookAt(0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0); glViewport(middleX, 0, windowWidth/2, windowHeight/2); drawGrid(YZ, range); drawModel(1); drawCamera(lookFrom, lookAt, lookUp, cameraAngle, aspectRatio); /* draw subwindow borders */ glViewport(0, 0, windowWidth, windowHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0, windowWidth, 0.0, windowHeight); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor3f(1.0, 1.0, 1.0); glBegin(GL_LINES); glVertex2i(0, middleY); glVertex2i(windowWidth, middleY); glVertex2i(middleX, 0); glVertex2i(middleX, windowHeight); glEnd(); glutSwapBuffers(); }
void GLWidget::paintGL() { int i; QList<Point3D> points; QImage image; //Set backgroung glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); rotateCamera(); drawGround( 10.0f, 1.0f, 0); //Using stack of matrix glPushMatrix(); //Draw all objects glEnable(GL_TEXTURE_2D); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //colors of glObject are replaced by texture. other - GL_REPLACE - combination glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); float refl; int shine; //need to draw pictures then objects //Drawing images for( i = 0; i < Scene::Instance().stub_objects().size(); i++) { //checking type of object - lense or picture LensObjectStub* n = dynamic_cast<LensObjectStub*>(Scene::Instance().stub_objects()[i]); if (!(n)) { shine = 10; refl = 0.5; //textures PictureObjectStub* picobj = (PictureObjectStub*)Scene::Instance().stub_objects()[i]; image = convertToGLFormat(picobj->image()); glTexImage2D(GL_TEXTURE_2D, 0, 3, (GLsizei)image.width(), (GLsizei)image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.bits()); if (Scene::Instance().stub_objects()[i]->selected()) { glColor4f( 0.1, 0.1, 1.0, 1.0); } else { glColor4f( 1.0, 1.0, 1.0, 1.0); } float specref[] = { refl, refl, refl}; glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, specref); glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, shine); //0..128 - reflection points = Scene::Instance().stub_objects()[i]->getPoints(); //qDebug() << points; //Drawing pictures glBegin( GL_QUADS); //Draw normals for lighting TODO //glNormal3f( x, y ,z); glTexCoord2f(0, 1); glVertex3f( points[0].x, points[0].y, points[0].z); glTexCoord2f(1, 1); glVertex3f( points[1].x, points[1].y, points[1].z); glTexCoord2f(1, 0); glVertex3f( points[2].x, points[2].y, points[2].z); glTexCoord2f(0, 0); glVertex3f( points[3].x, points[3].y, points[3].z); glEnd(); } } //Drawing lenses for( i = 0; i < Scene::Instance().stub_objects().size(); i++) { //checking type of object - lense or picture LensObjectStub* n = dynamic_cast<LensObjectStub*>(Scene::Instance().stub_objects()[i]); if (n) { shine = 128; refl = 1.0; glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); image = convertToGLFormat(n->heightMap1()); glTexImage2D(GL_TEXTURE_2D, 0, 3, (GLsizei)image.width(), (GLsizei)image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.bits()); if (Scene::Instance().stub_objects()[i]->selected()) { glColor4f( 0.1, 0.1, 1.0, 0.5); } else { glColor4f( 1.0, 1.0, 1.0, 0.5); } float specref[] = { refl, refl, refl}; glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, specref); glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, shine); //0..128 - reflection points = Scene::Instance().stub_objects()[i]->getPoints(); //qDebug() << points; //Drawing pictures glBegin( GL_QUADS); //Draw normals for lighting TODO //glNormal3f( x, y ,z); glTexCoord2f(0, 1); glVertex3f( points[0].x, points[0].y, points[0].z); glTexCoord2f(1, 1); glVertex3f( points[1].x, points[1].y, points[1].z); glTexCoord2f(1, 0); glVertex3f( points[2].x, points[2].y, points[2].z); glTexCoord2f(0, 0); glVertex3f( points[3].x, points[3].y, points[3].z); glEnd(); //draw back with diff texture glCullFace(GL_BACK); image = convertToGLFormat(n->heightMap2()); glTexImage2D(GL_TEXTURE_2D, 0, 3, (GLsizei)image.width(), (GLsizei)image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.bits()); glBegin( GL_QUADS); //Draw again wi other texture glTexCoord2f(0, 1); glVertex3f( points[0].x, points[0].y, points[0].z); glTexCoord2f(1, 1); glVertex3f( points[1].x, points[1].y, points[1].z); glTexCoord2f(1, 0); glVertex3f( points[2].x, points[2].y, points[2].z); glTexCoord2f(0, 0); glVertex3f( points[3].x, points[3].y, points[3].z); glEnd(); glCullFace(GL_FRONT_AND_BACK); glDisable(GL_CULL_FACE); } } /*glPushMatrix(); glBegin(GL_LINES); glVertex3f(8, -9, 5); glVertex3f(0, 0, 0); glEnd(); glPopMatrix();*/ glPopMatrix(); drawCamera(); //clear drawing command stack swapBuffers(); }