bool GLC_TurnTableMover::move(const GLC_UserInput& userInput)
{
	GLC_Camera* pCamera= GLC_Mover::m_pViewport->cameraHandle();
	// Turn table rotation
	const double rotSpeed= 2.3;
	const double width= static_cast<double> ( GLC_Mover::m_pViewport->viewVSize() );
	const double height= static_cast<double> ( GLC_Mover::m_pViewport->viewHSize() );

	const double alpha = -((static_cast<double>(userInput.x()) - GLC_Mover::m_PreviousVector.x()) / width) * rotSpeed;
	const double beta = ((static_cast<double>(userInput.y()) - GLC_Mover::m_PreviousVector.y()) / height) * rotSpeed;

	// Rotation around the screen vertical axis
	pCamera->rotateAroundTarget(pCamera->defaultUpVector(), alpha * m_Sign);

	// Rotation around the screen horizontal axis
	GLC_Vector3d incidentVector= -pCamera->forward();
	GLC_Vector3d rightVector= incidentVector ^ pCamera->upVector();
	if (!rightVector.isNull())
	{
		pCamera->rotateAroundTarget(rightVector, beta);
	}

	m_PreviousVector.setVect(static_cast<double>(userInput.x()), static_cast<double>(userInput.y()), 0.0);

	return true;
}
Exemple #2
0
// Move the camera
bool GLC_TsrMover::move(const GLC_UserInput& userInput)
{
    const GLC_Vector3d VectCur(m_pViewport->mapPosMouse(static_cast<double>(userInput.x()), static_cast<double>(userInput.y())));
    const GLC_Vector3d VectPan= VectCur - m_PreviousVector;	// moving Vector

    GLC_Camera* pCamera= m_pViewport->cameraHandle();

    // Pan the camera
    pCamera->pan(-VectPan);

    // Zoom
    //m_pViewport->reframeFromDeltaCover(userInput.scaleFactor());
    zoom(userInput.scaleFactor());

    // Rotation
    if (!qFuzzyCompare(userInput.rotationAngle(), 0.0))
    {
        GLC_Point3d unProjectedPoint= userInput.unprojectedPoint();

        pCamera->rotateAround(pCamera->forward(), userInput.rotationAngle(), unProjectedPoint);
    }

    m_PreviousVector= VectCur;
    return true;
}
// Initialized the mover
void GLC_SetTargetMover::init(const GLC_UserInput& userInput)
{
	// Z Buffer component of selected point between 0 and 1
	GLfloat Depth;
	// read selected point
	glReadPixels(userInput.x(), m_pViewport->viewVSize() - userInput.y() , 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &Depth);

	// Test if there is geometry under picking point
	if (!qFuzzyCompare(Depth, 1.0f))
	{	// Geometry find -> Update camera's target position
		const GLC_Point3d target(m_pViewport->unProject(userInput.x(), userInput.y()));
		m_pViewport->cameraHandle()->setTargetCam(target);
	}
	else
	{	// Geometry not find -> panning

		const GLC_Point3d curPos(m_pViewport->mapPosMouse(userInput.x(), userInput.y()));
		const GLC_Point3d prevPos(m_pViewport->mapPosMouse(m_pViewport->viewHSize() / 2, m_pViewport->viewVSize() / 2));
		const GLC_Vector3d VectPan(curPos - prevPos);	// panning vector
		// pan camera
		m_pViewport->cameraHandle()->pan(VectPan);
	}
}
// Initialized the mover
void GLC_TurnTableMover::init(const GLC_UserInput& userInput)
{
	GLC_Mover::m_PreviousVector.setVect(static_cast<double>(userInput.x()), static_cast<double>(userInput.y()),0.0);
	GLC_Camera* pCamera= GLC_Mover::m_pViewport->cameraHandle();
	// Calculate angle sign
	m_Sign= pCamera->defaultUpVector() * pCamera->upVector();
	if (m_Sign == 0)
	{
		m_Sign= 1;
	}
	else
	{
		m_Sign= m_Sign / fabs(m_Sign);
	}

	pCamera->setUpCam(pCamera->defaultUpVector() * m_Sign);
}
Exemple #5
0
// Initialized the mover
void GLC_TsrMover::init(const GLC_UserInput& userInput)
{
    m_PreviousVector= m_pViewport->mapPosMouse(static_cast<double>(userInput.x()), static_cast<double>(userInput.y()));
}