//---------------------------------------------------------------------------- // 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( (float) GetFrameLineWidth()) ; glBegin( GL_LINES) ; // asse X+ glColor3f( 1, 0, 0) ; glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ; glVertex3f( float( ptOrig.x + dLen), float( ptOrig.y), float( ptOrig.z)) ; // asse Y+ glColor3f( 0, 1, 0) ; glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ; glVertex3f( float( ptOrig.x), float( ptOrig.y + dLen), float( ptOrig.z)) ; // asse Z+ glColor3f( 0, 0, 1) ; glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ; glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z + dLen)) ; glEnd() ; // ripristino spessore linee glLineWidth( (float) GetLineWidth()) ; // ripristino lo stack delle matrici glPopMatrix() ; return true ; }