コード例 #1
0
ファイル: Camera.cpp プロジェクト: tiagoddinis/GParticles
void Camera::processMouseMovement()
{
	//// accumulate this frame offset to target offset
	//targetOffsetX += mouseX - lastMouseX;
	//targetOffsetY += mouseY - lastMouseY;

	//std::cout << ">> TargetOffsetX: " << targetOffsetX << std::endl;

	//GLfloat xoffset = glm::clamp(targetOffsetX, -offsetLimit, offsetLimit);
	//GLfloat yoffset = glm::clamp(targetOffsetY, -offsetLimit, offsetLimit);

	//std::cout << ">> Xoffset: " << xoffset << std::endl;

	//targetOffsetX -= xoffset;
	//targetOffsetY -= yoffset;

	//targetOffsetX += mouseX - lastMouseX;
	//targetOffsetY += mouseY - lastMouseY;

	//std::cout << ">> TargetOffsetX: " << targetOffsetX << std::endl;

	//GLfloat xoffset = glm::clamp(targetOffsetX, -offsetLimit, offsetLimit);
	//GLfloat yoffset = glm::clamp(targetOffsetY, -offsetLimit, offsetLimit);

	yaw += (mouseX - lastMouseX) * mouseSensitivity;
	pitch += (lastMouseY - mouseY) * mouseSensitivity;

	// don't flip screen when pitch is out of bounds
	if (pitch > 89.0f)
		pitch = 89.0f;
	if (pitch < -89.0f)
		pitch = -89.0f;

	updateCameraVectors();
}
コード例 #2
0
ファイル: Camera.cpp プロジェクト: AlexBartov/Simulation
void Camera::rotateCam(float phi, float theta)
{
#ifdef DEBUG
    qWarning() << "Camera::rotateCam(float phi, float theta)";
#endif

    m_theta += theta;
    m_phi += phi;

    if(m_theta > 360.0 || m_theta < 360 )
    {
        m_theta = (int) m_theta % 360 + (m_theta - (m_theta / 1));
        if(m_theta > 269.0f)
        {
            m_theta = 269.0f;
        }
        if(m_theta < 91.0f)
        {
            m_theta = 91.0f;
        }
    }
    if(m_phi > 360.0 || m_phi < 360 )
    {
       m_phi = (int) m_phi % 360 + (m_phi - (m_phi / 1));
    }

    updateCameraVectors();
}
コード例 #3
0
ファイル: Camera.cpp プロジェクト: alexmar10s/ProjectMartens
void Camera::processMouseInput(double xPosition, double yPosition)
{
	if (mFirstMouse)
	{
		mPreviousXPosition = xPosition;
		mPreviousYPosition = yPosition;
		mFirstMouse = false;
	}

	GLfloat xOffset = xPosition - mPreviousXPosition;
	GLfloat yOffset = mPreviousYPosition - yPosition;
	mPreviousXPosition = xPosition;
	mPreviousYPosition = yPosition;

	xOffset *= mSensitivity;
	yOffset *= mSensitivity;

	mYaw += xOffset;
	mPitch += yOffset;

	if (mPitch > 89.0f)
		mPitch = 89.0f;
	if (mPitch < -89.0f)
		mPitch = -89.0f;

	updateCameraVectors();
}
コード例 #4
0
Camera::Camera(glm::vec3 position, glm::vec3 up, GLfloat yaw, GLfloat pitch)
    : cameraFront(glm::vec3(0.0f, 0.0f, -1.0f)), movementSpeed(SPEED), mouseSensitivitive(SENSITIVITIVE), fieldOfView(FIELD_OF_VIEW)
{
    this->cameraPosition = position;
    this->cameraUp = up;
    this->yaw = yaw;
    this->pitch = pitch;
    updateCameraVectors();
}
コード例 #5
0
ファイル: Camera.cpp プロジェクト: AlexBartov/Simulation
void Camera::setZoom(GLfloat zoom)
{
    if(zoom < 0.0f || zoom > 180.0f)
    {
        return;
    }
    m_zoom = zoom;
    updateCameraVectors();
}
コード例 #6
0
ファイル: Camera.cpp プロジェクト: Toffanim/SyntheseDemo
void Camera::addPitch( float value )
{
    pitch += value;
    if (pitch > 89.0f)
        pitch = 89.0f;
    if (pitch < -89.0f)
        pitch = -89.0f;
    updateCameraVectors();
}
コード例 #7
0
ファイル: Camera.cpp プロジェクト: AlexBartov/Simulation
// Constructor
Camera::Camera(GLfloat distance, glm::vec3 aim, glm::vec3 up) : m_zoom(ZOOM)
{
#ifdef DEBUG
    qWarning() << "Camera::Camera(glm::vec3 aim, glm::vec3 position, glm::vec3 up) : Zoom(ZOOM)";
#endif
    m_lightColor = glm::vec3(1.0f, 1.0f, 1.0f);
    m_theta = THETA;
    m_phi = PHI;
    m_distance = distance;
    m_aim = aim;
    m_worldup = up;
    updateCameraVectors();
}
コード例 #8
0
ファイル: Camera.cpp プロジェクト: alexmar10s/ProjectMartens
Camera::Camera()
{
	mPosition = glm::vec3(0.0f, 0.0f, 3.0f);
	mWorldUp = glm::vec3(0.0f, 1.0f, 0.0f);

	mPreviousXPosition= 800 / 2.0;
	mPreviousYPosition = 600 / 2.0;
	mYaw = -90.0f;
	mPitch = 0.0f;
	mMovementSpeed = 5.0f;
	mSensitivity = 0.05f;
	mFirstMouse = true;	

	updateCameraVectors();
}
コード例 #9
0
void Camera::processMouseMovement(GLfloat xOffset, GLfloat yOffset, bool constrainPitch)
{
    xOffset *= mouseSensitivitive;
    yOffset *= mouseSensitivitive;

    this->pitch += yOffset;
    this->yaw += xOffset;

    if (constrainPitch) {
        if (pitch > 89.0f)
            pitch = 89.0f;
        if (pitch < -89.0f)
            pitch = -89.0f;
    }

    updateCameraVectors();
}
コード例 #10
0
ファイル: camera.cpp プロジェクト: LonamiWebs/CubicSystem
Camera::Camera(
    glm::vec3 position,
    glm::vec3 up,
    GLfloat yaw,
    GLfloat pitch) :

    Front(glm::vec3(0.0f, 0.0f, -1.0f)),
    MovementSpeed(SPEED),
    MouseSensitivity(SENSITIVITY),
    Zoom(ZOOM)
{
    Position = position;
    WorldUp = up;
    Yaw = yaw;
    Pitch = pitch;

    updateCameraVectors();
}
コード例 #11
0
ファイル: camera.cpp プロジェクト: LonamiWebs/CubicSystem
void Camera::ProcessEyeMovement(GLfloat xoffset, GLfloat yoffset, GLboolean constrainPitch)
{
    if (xoffset == 0 && yoffset == 0)
        return;

    xoffset *= MouseSensitivity;
    yoffset *= MouseSensitivity;

    // If we don't constrain the yaw to only use values between 0-360
    // we would lose floating precission with very high values, hence
    // the movement would look like big "steps" instead a smooth one!
    Yaw = std::fmod((Yaw + xoffset), (GLfloat)360.0f);
    Pitch += yoffset;

    if (constrainPitch)
    {
        if (Pitch > 80.0f)
            Pitch = 80.0f;
        else if (Pitch < -89.0f)
            Pitch = -89.0f;
    }

    updateCameraVectors();
}
コード例 #12
0
ファイル: Camera.cpp プロジェクト: AlexBartov/Simulation
void Camera::setDistance(GLfloat distance)
{
    m_distance = distance;
    updateCameraVectors();
}
コード例 #13
0
ファイル: Camera.cpp プロジェクト: Toffanim/SyntheseDemo
//Camera class, pretty straightforward
Camera::Camera(glm::vec3 position, glm::vec3 up, GLfloat yaw , GLfloat pitch ) : position(position), up(up), yaw(yaw), pitch(pitch)
{
    front = glm::vec3(0.0f, 0.0f, -1.0f);
    zoom = 45.0f;
    updateCameraVectors();
}
コード例 #14
0
ファイル: Camera.cpp プロジェクト: Toffanim/SyntheseDemo
void Camera::addYaw(float value)
{
    yaw += value;
    updateCameraVectors();
}