void Camera::rotate(float angle, const Vector3& axis) { Matrix44 R; R.setRotation(angle,axis); Vector3 new_front = R * (center - eye); center = eye + new_front; updateViewMatrix(); }
void Camera::setAxes(const Vec3& right, const Vec3& up, const Vec3& front) { m_right = right; m_up = up; m_front = front; updateViewMatrix(); updateViewProjectionMatrix(); updateFrustumPlanesAndPoints(); }
// updates only if needed const Mat44& Camera::getViewMatrix() { if (mMatrixUpdateFlags) { updateViewMatrix(); } return mViewMatrix; }
void Camera::Lookat(Mesh* mesh) { unsigned int mid_index = mesh->vertex_number_/2; EigenVector3 lookat = mesh->vec_current_position_.block_vector(mid_index); m_lookat = glm::vec3(lookat[0], lookat[1], lookat[2]); updateViewMatrix(); }
void Camera::lookAt(const Vector3& eye, const Vector3& center, const Vector3& up) { this->eye = eye; this->center = center; this->up = up; updateViewMatrix(); }
void Camera::onLateUpdate() { if (dImpl->dirty) { updateViewMatrix(); dImpl->dirty = false; } }
void ShadowManager::addShadowLight(Light *const light) { light->addObserver(this, Light::MOVE); shadowDatas[light] = new ShadowData(light, nbShadowMaps); createShadowMaps(light); updateViewMatrix(light); }
void CCAMERA::ResetXYpos() { m_parametersChanged = true; m_camera_pos.x = 0.0f; m_camera_pos.y = 0.0f; updateViewMatrix(); updateFrustum(); }
void Camera::MouseChangeLookat(float coe, float dx, float dy) { glm::vec3 vdir(m_lookat - m_position); glm::vec3 u(glm::normalize(glm::cross(vdir, m_up))); glm::vec3 v(glm::normalize(glm::cross(u, vdir))); m_lookat += coe * (dy * v - dx * u); updateViewMatrix(); }
void CCAMERA::ZoomReset() { m_zoom = 1.0f; m_camera_pos.z = m_camera_pos_init.z; updateViewMatrix(); rebuildProjection(); }
const Matrix4& Camera::getViewMatrix() { if (m_isMatViewDirty) { updateViewMatrix(); m_isMatViewDirty = false; } return m_matView; }
CWBOOL cwOrthoCamera::init() { if (!cwCamera::init()) return CWFALSE; m_nPos = cwVector3D(0.0f, 0.0f, -10.0f); updateViewMatrix(); return CWTRUE; }
void ShadowManager::onResize(int width, int height) { sceneWidth = width; sceneHeight = height; for(std::map<const Light *, ShadowData *>::const_iterator it = shadowDatas.begin(); it!=shadowDatas.end(); ++it) { updateViewMatrix(it->first); } }
/** * @brief Resets trackball to initial position and orientation */ void reset (void) { quaternion = Eigen::Quaternion<float>::Identity(); zoom = 1.0; translationVector << 0.0, 0.0, 0.0; rotating = false; translating = false; Camera::reset(); updateViewMatrix(); }
/** * Set the position at which the camera is looking and update its rendering matrices accordingly * @author Serge Radinovich * @param _pTarget New target of the camera */ void Camera::lookAt(const D3DXVECTOR3* _pTarget) { m_lookPos = *_pTarget; D3DXVECTOR3 _look = m_lookPos - m_transform.translation; D3DXVec3Normalize(&_look, &_look); Transform::setForward(&m_transform, &_look); updateViewMatrix(); }
void updateEditorCamera(void) { camera_struct* c=&editorCamera; c->viewPosition=c->position; updateViewMatrix(c); updateFrustum(c); fixMatrix(c->transformationMatrix); }
/** * @brief Resets camera to initial position and orientation */ void reset (void) override { start_mouse_pos = Eigen::Vector2f::Zero(); rotation_matrix = Eigen::Matrix3f::Identity(); default_translation = Eigen::Vector3f (0.0, 0.0, -2.0); translation_vector = default_translation; rotation_X_axis = 0.0; rotation_Y_axis = 0.0; rotation_Z_axis = 0.0; updateViewMatrix(); }
void Camera::set() { updateViewMatrix(); updateProjectionMatrix(); glMatrixMode( GL_MODELVIEW ); glLoadMatrixf( view_matrix.m ); glMatrixMode( GL_PROJECTION ); glLoadMatrixf( projection_matrix.m ); glMatrixMode( GL_MODELVIEW ); }
Camera::Camera(vec3 pos, float horiAngle, float vertAngle, float aspectRatio, float fovy, float viewDistance) : position(pos) { this->verticalAngle = vertAngle; this->horizontalAngle = horiAngle; this->aspect = aspectRatio; this->fovy = fovy; this->viewDistance = viewDistance; updateViewMatrix(); updateProjectionMatrix(); }
void Camera::move(const D3DXVECTOR3 &direction, const D3DXVECTOR3 &amount) { // Moves the camera by the specified amount of world units in the specified // direction in world space. m_eye.x += direction.x * amount.x; m_eye.y += direction.y * amount.y; m_eye.z += direction.z * amount.z; updateViewMatrix(false); }
void DeferredRendererOld::refresh() { if(shader_->isModified()) updateShader(); mesh_.refresh(); sceneBox_.refresh(); camera_->update(); quadRender_.refresh(); updateViewMatrix(); }
/////////////////////////////////////////////////////////////////////////////// // set the camera position and rotation /////////////////////////////////////////////////////////////////////////////// void ModelGL::setViewMatrix(float x, float y, float z, float pitch, float heading, float roll) { cameraPosition[0] = x; cameraPosition[1] = y; cameraPosition[2] = z; cameraAngle[0] = pitch; cameraAngle[1] = heading; cameraAngle[2] = roll; updateViewMatrix(); }
void rotate(const glm::vec2& delta) { // create orientation vectors auto lookat = orientation * Vectors::UNIT_NEG_Z; auto forward = glm::normalize(vec3(lookat.x, 0, lookat.z)); auto side = glm::cross(Vectors::UP, forward); // rotate camera with quaternions created from axis and angle orientation = glm::angleAxis(delta.x, Vectors::UP) * orientation; orientation = glm::angleAxis(-delta.y, side) * orientation; updateViewMatrix(); }
CWVOID cwCamera::lookAt(const cwVector3D& pos, const cwVector3D& target, const cwVector3D& up) { m_nLook = target - pos; m_nLook.normalize(); m_nRight = up.cross(m_nLook); m_nRight.normalize(); m_nUp = m_nLook.cross(m_nRight); m_nPos = pos; updateViewMatrix(); }
void PlotGl::mouseMoveEvent(QMouseEvent *pEvt) { bool bUpdateView = 0; if(m_bMouseRotateActive) { t_real_gl dNewX = t_real_gl(pEvt->POS_F().x()); t_real_gl dNewY = t_real_gl(pEvt->POS_F().y()); m_dMouseRot[0] += dNewX - m_dMouseBegin[0]; m_dMouseRot[1] += dNewY - m_dMouseBegin[1]; m_dMouseBegin[0] = dNewX; m_dMouseBegin[1] = dNewY; bUpdateView = 1; } if(m_bMouseScaleActive) { t_real_gl dNewY = t_real_gl(pEvt->POS_F().y()); m_dMouseScale *= 1.-(dNewY - m_dMouseScaleBegin)/t_real_gl(height()) * 2.; m_dMouseScaleBegin = dNewY; bUpdateView = 1; } if(bUpdateView) updateViewMatrix(); m_dMouseX = 2.*pEvt->POS_F().x()/t_real_gl(m_iW) - 1.; m_dMouseY = -(2.*pEvt->POS_F().y()/t_real_gl(m_iH) - 1.); bool bHasSelected = 0; if(m_bEnabled.load()) { mouseSelectObj(m_dMouseX, m_dMouseY); for(PlotObjGl& obj : m_vecObjs) { if(obj.bSelected) { m_sigHover(&obj); bHasSelected = 1; break; } } } if(!bHasSelected) m_sigHover(nullptr); }
Camera::Camera(GLFWwindow *window) { m_window = window; getWindowDimensions(); centerMouse(); initVars(); setCenter(glm::vec3(0, 0, 5)); setLookAt(glm::vec3(0, 0, 4)); setUp(glm::vec3(0, 1, 0)); setRight(glm::vec3(1, 0, 0)); updateViewMatrix(); }
xtCamera::xtCamera(void) { //this->matrixView.identity(); for ( int i=0; i<3; ++i ) { this->cameraPosition[i] = 0.0; } this->cameraAngle[0] = CAMERA_ANGLE_X; this->cameraAngle[1] = CAMERA_ANGLE_Y; this->cameraAngle[2] = 0.0f; updateViewMatrix(); }
CWVOID cwCamera::roll(CWFLOAT fRadian) { cwMatrix4X4 matRot; matRot.setRotation(m_nLook, fRadian); m_nUp *= matRot; m_nRight *= matRot; m_nUp.normalize(); m_nRight.normalize(); updateViewMatrix(); }
void ShadowManager::notify(Observable *observable, int notificationType) { if(dynamic_cast<LightManager *>(observable)) { Light *light = lightManager->getLastUpdatedLight(); switch(notificationType) { case LightManager::ADD_LIGHT: { light->addObserver(this, Light::PRODUCE_SHADOW); if(light->isProduceShadow()) { addShadowLight(light); } break; } case LightManager::REMOVE_LIGHT: { light->removeObserver(this, Light::PRODUCE_SHADOW); if(light->isProduceShadow()) { removeShadowLight(light); } break; } } }else if(Light *light = dynamic_cast<Light *>(observable)) { switch(notificationType) { case Light::MOVE: { updateViewMatrix(light); break; } case Light::PRODUCE_SHADOW: { if(light->isProduceShadow()) { addShadowLight(light); }else { removeShadowLight(light); } break; } } } }
void Camera::orbit( const Vector3& center, float angle, const Vector3& axis ) { Matrix44 R; R.setRotation(angle,axis); Matrix44 T; T.setTranslation( center.x, center.y, center.z ); Matrix44 M = T * R; T.setTranslation( -center.x, -center.y, -center.z ); M = M * T; this->center = M * this->center; this->eye = M * this->eye; updateViewMatrix(); }