glc_settargetmover.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "glc_settargetmover.h"
00024 #include "glc_viewport.h"
00025 #include "glc_openglexception.h"
00026
00027
00028 GLC_SetTargetMover::GLC_SetTargetMover(GLC_Viewport* pViewport, const QList<GLC_RepMover*>& repsList)
00029 : GLC_Mover(pViewport, repsList)
00030 {
00031
00032
00033 }
00034
00035
00036 GLC_SetTargetMover::GLC_SetTargetMover(const GLC_SetTargetMover& mover)
00037 : GLC_Mover(mover)
00038 {
00039
00040
00041 }
00042
00043 GLC_SetTargetMover::~GLC_SetTargetMover()
00044 {
00045
00046 }
00047
00049
00051
00052
00053 GLC_Mover* GLC_SetTargetMover::clone() const
00054 {
00055 return new GLC_SetTargetMover(*this);
00056 }
00057
00059
00061
00062
00063 void GLC_SetTargetMover::init(const GLC_UserInput& userInput)
00064 {
00065
00066 GLfloat Depth;
00067
00068 glReadPixels(userInput.x(), m_pViewport->viewVSize() - userInput.y() , 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &Depth);
00069
00070
00071 if (!qFuzzyCompare(Depth, 1.0f))
00072 {
00073 const GLC_Point3d target(m_pViewport->unProject(userInput.x(), userInput.y()));
00074 m_pViewport->cameraHandle()->setTargetCam(target);
00075 }
00076 else
00077 {
00078
00079 const GLC_Point3d curPos(m_pViewport->mapPosMouse(userInput.x(), userInput.y()));
00080 const GLC_Point3d prevPos(m_pViewport->mapPosMouse(m_pViewport->viewHSize() / 2, m_pViewport->viewVSize() / 2));
00081 const GLC_Vector3d VectPan(curPos - prevPos);
00082
00083 m_pViewport->cameraHandle()->pan(VectPan);
00084 }
00085 }