glc_pullmanipulator.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
00025
00026 #include "glc_pullmanipulator.h"
00027 #include "../maths/glc_line3d.h"
00028 #include "../maths/glc_geomtools.h"
00029 #include "../viewport/glc_viewport.h"
00030
00031 #include <QtGlobal>
00032
00033 GLC_PullManipulator::GLC_PullManipulator(GLC_Viewport* pViewport, const GLC_Vector3d& pullDirection)
00034 : GLC_AbstractManipulator(pViewport)
00035 , m_PullDirection(pullDirection)
00036 {
00037
00038 }
00039
00040 GLC_PullManipulator::GLC_PullManipulator(const GLC_PullManipulator& pullManipulator)
00041 : GLC_AbstractManipulator(pullManipulator)
00042 , m_PullDirection(pullManipulator.m_PullDirection)
00043 {
00044
00045 }
00046
00047 GLC_PullManipulator::~GLC_PullManipulator()
00048 {
00049
00050 }
00051
00052 GLC_AbstractManipulator* GLC_PullManipulator::clone() const
00053 {
00054 return new GLC_PullManipulator(*this);
00055 }
00056
00057 void GLC_PullManipulator::setPullingDirection(const GLC_Vector3d& pullingDirection)
00058 {
00059 Q_ASSERT(!GLC_AbstractManipulator::isInManipulateState());
00060 m_PullDirection= pullingDirection;
00061 }
00062
00063 GLC_Matrix4x4 GLC_PullManipulator::doManipulate(const GLC_Point3d& newPoint, const GLC_Vector3d& projectionDirection)
00064 {
00065
00066 GLC_Point3d projectedPoint;
00067 GLC_Line3d projectionLine(newPoint, projectionDirection);
00068 glc::lineIntersectPlane(projectionLine, GLC_AbstractManipulator::m_SliddingPlane, &projectedPoint);
00069
00070
00071 GLC_Vector3d projNormal= (GLC_AbstractManipulator::m_pViewport->cameraHandle()->sideVector() ^ m_PullDirection).normalize();
00072 GLC_Plane projPlane(projNormal, GLC_AbstractManipulator::m_PreviousPosition);
00073
00074
00075 glc::lineIntersectPlane(projectionLine, projPlane, &projectedPoint);
00076
00077
00078 projectedPoint= glc::project(projectedPoint, GLC_Line3d(GLC_AbstractManipulator::previousPosition(), m_PullDirection));
00079
00080
00081 GLC_Matrix4x4 translationMatrix(projectedPoint - GLC_AbstractManipulator::m_PreviousPosition);
00082
00083
00084 GLC_AbstractManipulator::m_PreviousPosition= projectedPoint;
00085 return translationMatrix;
00086 }