void Camera::moveSideward(float length) { vec4 posVec = vec4(length, 0.0f, 0.0f, 0.0f) * this->getViewRotateXY(); posX += posVec.x; posY += posVec.y; posZ += posVec.z; recalcView(); }
void mouse (int32_t button, int32_t state, int32_t x, int32_t y) { switch (button) { case GLUT_LEFT_BUTTON: rightMouse=0; switch (state) { case GLUT_DOWN: selectZoomX = x; selectZoomY = y; break; case GLUT_UP: selectZoomW = x; selectZoomH = y; mousePosX = 0; mousePosY = 0; recalcZoom(); break; } break; case GLUT_RIGHT_BUTTON: rightMouse=1; switch (state) { case GLUT_DOWN: selectMoveX = x; selectMoveY = y; break; case GLUT_UP: selectMoveW = x; selectMoveH = y; mousePosX = 0; mousePosY = 0; recalcView(); break; } break; } }
void Camera::setPos(float x, float y, float z) { this->posX = x; this->posY = y; this->posZ = z; recalcView(); }
void Camera::setPosZ(float z) { this->posZ = z; recalcView(); }
void Camera::setPosY(float y) { this->posY = y; recalcView(); }
void Camera::setPosX(float x) { this->posX = x; recalcView(); }
float Camera::setTheta(float theta) { m_theta = theta; recalcView(); return m_theta; }
float Camera::setPhi(float phi) { m_phi = glm::clamp(phi, (float)-M_PI_2, (float)M_PI_2); recalcView(); return m_phi; }