//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : SceneGlobFrame.cpp Data : 02.12.14 Versione : 1.5l1 // Contenuto : Implementazione gestione e disegno terna di riferimento globale. // // // // Modifiche : 02.12.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "Scene.h" #include "EGrUtils.h" using namespace std ; //---------------------------------------------------------------------------- bool Scene::SetGlobFrameShow( bool bShow) { m_bShowGlobFrame = bShow ; return true ; } //---------------------------------------------------------------------------- bool Scene::DrawGlobFrame( void) { // se non devo disegnare, esco subito if ( ! m_bShowGlobFrame) return true ; // recupero la matrice viewport GLint Viewport[ 4] ; glGetIntegerv( GL_VIEWPORT, Viewport) ; // imposto il riferimento glPushMatrix() ; // origine del riferimento globale const double DIST_BORDER = 30 ; const double POS_Z = 0.5 ; Point3d ptOrig ; UnProject( Point3d( DIST_BORDER, Viewport[3] - DIST_BORDER, POS_Z), ptOrig) ; // lunghezza degli assi const double LEN_AX = DIST_BORDER - 2 ; double dLen = LEN_AX * ( 2 * m_dHalfWidth) / Viewport[2] ; // disegno degli assi glLineWidth( 2) ; glBegin( GL_LINES) ; // asse X+ glColor3f( RED.GetRed(), RED.GetGreen(), RED.GetBlue()) ; glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ; glVertex3f( float( ptOrig.x + dLen), float( ptOrig.y), float( ptOrig.z)) ; // asse Y+ glColor3f( LIME.GetRed(), LIME.GetGreen(), LIME.GetBlue()) ; glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ; glVertex3f( float( ptOrig.x), float( ptOrig.y + dLen), float( ptOrig.z)) ; // asse Z+ glColor3f( BLUE.GetRed(), BLUE.GetGreen(), BLUE.GetBlue()) ; glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ; glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z + dLen)) ; glEnd() ; glLineWidth( 1) ; // ripristino lo stack delle matrici glPopMatrix() ; return true ; }