glc_repcrossmover.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  Version 2.0.0 Beta 1, packaged on April 2010.
00006 
00007  http://glc-lib.sourceforge.net
00008 
00009  GLC-lib is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU General Public License as published by
00011  the Free Software Foundation; either version 2 of the License, or
00012  (at your option) any later version.
00013 
00014  GLC-lib is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU General Public License for more details.
00018 
00019  You should have received a copy of the GNU General Public License
00020  along with GLC-lib; if not, write to the Free Software
00021  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023  *****************************************************************************/
00024 
00025 #include "glc_repcrossmover.h"
00026 #include "glc_viewport.h"
00027 
00028 // Default constructor
00029 GLC_RepCrossMover::GLC_RepCrossMover(GLC_Viewport* pViewport)
00030 : GLC_RepMover(pViewport)
00031 {
00032 
00033 }
00034 
00035 // Copy constructor
00036 GLC_RepCrossMover::GLC_RepCrossMover(const GLC_RepCrossMover& repMover)
00037 : GLC_RepMover(repMover)
00038 {
00039 
00040 }
00041 
00042 GLC_RepCrossMover::~GLC_RepCrossMover()
00043 {
00044 
00045 }
00046 
00048 // Get Functions
00050 
00051 // Return a clone of the repmover
00052 GLC_RepMover* GLC_RepCrossMover::clone() const
00053 {
00054         return new GLC_RepCrossMover(*this);
00055 }
00056 
00058 // OpenGL Functions
00060 
00061 // Virtual interface for OpenGL Geometry set up.
00062 void GLC_RepCrossMover::glDraw()
00063 {
00064         int nLgAxe;
00065         const int winHSize= m_pViewport->viewHSize();
00066         const int winVSize= m_pViewport->viewVSize();
00067         if (winHSize > winVSize)
00068         {
00069                 nLgAxe = static_cast<int>(static_cast<double>(winVSize) / 2.0);
00070         }
00071         else
00072         {
00073                 nLgAxe = static_cast<int>(static_cast<double>(winHSize) / 2.0);
00074         }
00075 
00076         // Compute the length of camera's field of view
00077         const double ChampsVision = 2 * (m_pViewport->cameraHandle()->distEyeTarget()) *  tan((m_pViewport->viewAngle() * glc::PI / 180.0) / 2.0);
00078 
00079         // the side of camera's square is mapped on Vertical length of window
00080         // Axis length in OpenGL unit = length(Pixel) * (dimend GL / dimens Pixel)
00081         const double dLgAxe= ((double)nLgAxe * ChampsVision / (double)winVSize) / 7;
00082         const double dDecAxe= dLgAxe / 3;
00083         glPushMatrix();
00084 
00085         glTranslated(m_pViewport->cameraHandle()->target().x(), m_pViewport->cameraHandle()->target().y(),
00086                         m_pViewport->cameraHandle()->target().z() );
00087 
00088         // Graphic properties
00089         glDisable(GL_TEXTURE_2D);
00090         glDisable(GL_LIGHTING);
00091         glColor4d(m_MainColor.redF(), m_MainColor.greenF(), m_MainColor.blueF(), m_MainColor.alphaF());
00092         glLineWidth(1.0);
00093 
00094         // Display camera's target lines
00095         glBegin(GL_LINES);
00096                 //X axis
00097                 glVertex3d(-dLgAxe, 0, 0);
00098                 glVertex3d(-dDecAxe, 0, 0);
00099                 glVertex3d(dDecAxe, 0, 0);
00100                 glVertex3d(dLgAxe, 0, 0);
00101 
00102                 //Y axis
00103                 glVertex3d(0, -dLgAxe, 0);
00104                 glVertex3d(0, -dDecAxe, 0);
00105                 glVertex3d(0, dDecAxe, 0);
00106                 glVertex3d(0, dLgAxe, 0);
00107 
00108                 //Z axis
00109                 glVertex3d(0, 0, -dLgAxe);
00110                 glVertex3d(0, 0, -dDecAxe);
00111                 glVertex3d(0, 0, dDecAxe);
00112                 glVertex3d(0, 0, dLgAxe);
00113 
00114         glEnd();
00115 
00116         glPopMatrix();
00117 
00118 }
00119 
00120 

SourceForge.net Logo

©2005 Laurent Ribon