GLC_Matrix4x4 GLC_PullManipulator::doManipulate(const GLC_Point3d& newPoint, const GLC_Vector3d& projectionDirection)
{
	// Project the given point on the sliding plane with the given direction
	GLC_Point3d projectedPoint;
	GLC_Line3d projectionLine(newPoint, projectionDirection);
	glc::lineIntersectPlane(projectionLine, GLC_AbstractManipulator::m_SliddingPlane, &projectedPoint);

	// Project the point on the pulling direction
	projectedPoint= glc::project(projectedPoint, GLC_Line3d(GLC_AbstractManipulator::previousPosition(), m_PullDirection));

	// Compute the translation matrix
	GLC_Matrix4x4 translationMatrix(projectedPoint - GLC_AbstractManipulator::m_PreviousPosition);

	// Update previous position to this position
	GLC_AbstractManipulator::m_PreviousPosition= projectedPoint;
	return translationMatrix;
}
Esempio n. 2
0
GLC_AbstractManipulator* GLC_CuttingPlane::rotationNavigator(int index)
{
	index= index - 2;
	Q_ASSERT((index > -1) && (index < 3));

	const GLC_Matrix4x4 rotationMatrix(m_CompMatrix.rotationMatrix());
	GLC_Vector3d axis;
	if (index == 0)
	{
		axis= rotationMatrix * glc::X_AXIS;
	}
	else if (index == 1)
	{
		axis= rotationMatrix * glc::Y_AXIS;
	}
	else
	{
		axis= rotationMatrix * glc::Z_AXIS;
	}
	GLC_AbstractManipulator* pManipulator= new GLC_RotationManipulator(GLC_3DWidget::widgetManagerHandle()->viewport(), GLC_Line3d(m_CurrentNavigatorPosition, axis));

	return pManipulator;
}