// Initialize projection matrix void Camera2::SetProjection(float fov, unsigned int width, unsigned int height, float near, float far) { this->m_fFOV = fov; this->m_fNearClippingPlane = near; this->m_fFarClippingPlane = far; UpdateProjection(); }
Matrix4 Camera::GetProjection() const { if (projectionDirty_) UpdateProjection(); return flipVertical_ ? flipMatrix * projection_ : projection_; }
Frustum Camera::GetSplitFrustum(float nearClip, float farClip) const { if (projectionDirty_) UpdateProjection(); nearClip = Max(nearClip, projNearClip_); farClip = Min(farClip, projFarClip_); if (farClip < nearClip) farClip = nearClip; Frustum ret; if (customProjection_) { // DefineSplit() needs to project the near & far distances, so can not use a combined view-projection matrix. // Transform to world space afterward instead ret.DefineSplit(projection_, nearClip, farClip); ret.Transform(GetEffectiveWorldTransform()); } else { if (!orthographic_) ret.Define(fov_, aspectRatio_, zoom_, nearClip, farClip, GetEffectiveWorldTransform()); else ret.DefineOrtho(orthoSize_, aspectRatio_, zoom_, nearClip, farClip, GetEffectiveWorldTransform()); } return ret; }
float Camera::GetFarClip() const { if (projectionDirty_) UpdateProjection(); return projFarClip_; }
const Frustum& Camera::GetFrustum() const { // Use projection_ instead of GetProjection() so that Y-flip has no effect. Update first if necessary if (projectionDirty_) UpdateProjection(); if (frustumDirty_) { if (customProjection_) frustum_.Define(projection_ * GetView()); else { // If not using a custom projection, prefer calculating frustum from projection parameters instead of matrix // for better accuracy if (!orthographic_) frustum_.Define(fov_, aspectRatio_, zoom_, GetNearClip(), GetFarClip(), GetEffectiveWorldTransform()); else frustum_.DefineOrtho(orthoSize_, aspectRatio_, zoom_, GetNearClip(), GetFarClip(), GetEffectiveWorldTransform()); } frustumDirty_ = false; } return frustum_; }
void GlueMapWindow::QuickRedraw() { UpdateScreenAngle(); UpdateProjection(); UpdateMapScale(); UpdateScreenBounds(); #ifndef ENABLE_OPENGL /* update the Projection */ ++ui_generation; /* quickly stretch the existing buffer into the window */ scale_buffer = 2; #endif Invalidate(); #ifndef ENABLE_OPENGL /* we suppose that the operation will need a full redraw later, so trigger that now */ draw_thread->TriggerRedraw(); #endif }
size_t SceneManager::Render( tRendererType *renderer ) { size_t _n = 0; #else void SceneManager::Render( tRendererType *renderer ) { #endif assert( renderer ); MathLib::Rectanglef rcViewport; rcViewport.min_vert = m_rcViewport.min_vert / m_fScale; rcViewport.max_vert = m_rcViewport.max_vert / m_fScale; renderer->SetViewport( &m_vp ); UpdateProjection(); UpdateRenderables( renderer ); for( SceneLayerPtrVector::iterator it = m_vLayers.begin() ; it != m_vLayers.end() ; ++it ) { SceneLayer *pLayer = *it; assert( pLayer ); RenderablePtrListType &custom_renderables = pLayer->lstCustomRenderables; for( RenderablePtrListType::iterator it0 = custom_renderables.begin() ; it0 != custom_renderables.end() ; ++it0 ) { RenderablePtrListNode &node = *it0; assert(node.renderable); if( !node.bounds || MathLib::intersect( *node.bounds , rcViewport ) ) renderer->Draw( node.renderable ); #ifdef DEBUG ++_n; #endif } SpriteRenderGroupContainer &container = pLayer->lstRenderables; for( SpriteRenderGroupContainer::iterator it0 = container.begin() ; it0 != container.end() ; ++it0 ) { SpriteRenderGroup *obj = it0->second; assert(obj); if( obj->GetElementsCount() > 0 ) { obj->SetupViewport(&m_vp); renderer->Draw( obj ); } #ifdef DEBUG ++_n; #endif } } renderer->_DoRenderScene(); renderer->SetViewport( NULL ); ClearRenderables(); #ifdef DEBUG return _n; #endif }
void Camera::Init() { UpdateProjection(); if(!GetGame()->scene->mainCamera) { GetGame()->scene->mainCamera = this; } }
bool RasterMap::LoadCache(FILE *file) { bool success = raster_tile_cache.LoadCache(file); if (success) UpdateProjection(); return success; }
void GlueMapWindow::PanTo(const GeoPoint &location) { follow_mode = FOLLOW_PAN; visible_projection.SetGeoLocation(location); UpdateProjection(); FullRedraw(); }
Camera::Camera(void) : Position(0.0f, 0.0f, 0.0f) { Pitch = 0.0f; Yaw = 0.0f; fov = 0.52; zNear = 0.1f; zFar = 1000.0f; aspectRatio = 1.33333; UpdateProjection(); }
void Camera::Update() const { if (isDirty_) { isDirty_ = false; UpdateProjection(); UpdateViewProjection(); signalUpdated_->Run(); } }
/** * Perspective viewing volume constructor. * * @param distNear Near plane [optional] * @param distFar Far plane [optional] * @param aspect Aspect ratio [optional] * @param fov Field of view [optional] */ PerspectiveViewingVolume::PerspectiveViewingVolume(const float distNear, const float distFar, const float aspect, const float fov) : fov(fov) , aspect(aspect) , distNear(distNear) , distFar(distFar) { UpdateProjection(); }
void SampledTaskPoint::UpdateOZ(const FlatProjection &projection, const OZBoundary &_boundary) { search_max = search_min = nominal_points.front(); boundary_points.clear(); for (const SearchPoint sp : _boundary) boundary_points.push_back(sp); UpdateProjection(projection); }
void SampledTaskPoint::UpdateOZ(const TaskProjection &projection) { search_max = search_reference; search_min = search_reference; boundary_points.clear(); for (const SearchPoint sp : GetBoundary()) boundary_points.push_back(sp); UpdateProjection(projection); }
void GlueMapWindow::FullRedraw() { UpdateDisplayMode(); UpdateScreenAngle(); UpdateProjection(); UpdateMapScale(); #ifdef ENABLE_OPENGL invalidate(); #else draw_thread->TriggerRedraw(); #endif }
void SetParams(float fov, float width, float height, float nearClip, float farClip) { m_FOV = fov; m_viewport.Set(width, height); m_near = nearClip; m_far = farClip; m_vViewport.x = 0; m_vViewport.y = 0; m_vViewport.z = m_viewport.x; m_vViewport.w = m_viewport.y; UpdateProjection(); }
void GlueMapWindow::TogglePan() { switch (follow_mode) { case FOLLOW_SELF: follow_mode = FOLLOW_PAN; break; case FOLLOW_PAN: follow_mode = FOLLOW_SELF; break; } UpdateProjection(); FullRedraw(); }
bool Camera::Update() { aspect = (float)Window::width / (float)Window::height; if (Camera::current == this) { ImGui::Begin("Main Camera Settings"); ImGui::Checkbox("Orthographic", &orthographic); if (orthographic) { ImGui::DragFloat("Orthographic Size", &orthographicSize); ImGui::DragFloat("Near Clip Plane", (float*)&orthoNear); ImGui::DragFloat("Far Clip Plane", (float*)&orthoFar); } else { ImGui::DragFloat("Field Of View", &fieldOfView); ImGui::DragFloat("Near Clip Plane", (float*)&perspNear); ImGui::DragFloat("Far Clip Plane", (float*)&perspFar); } ImGui::ColorEdit4("Background Color", (float*)&backgroundColor); ImGui::DragFloat("Mouse Sensitivity", &mouseSensitivity, 0.1f); ImGui::DragFloat3("Velocity", (float*)&velocity); ImGui::End(); } if (this->transform && this->transform->isSelected) { Inspector(); } if (initializedOldStuff) { oldProjectionMatrix = projectionMatrix; oldViewMatrix = viewMatrix; } else { oldProjectionMatrix = projectionMatrix + mat4(1); oldViewMatrix = viewMatrix + mat4(1); oldOrthographic = orthographic; initializedOldStuff = true; } UpdateProjection(); if(Camera::current != this) RenderFrustum(); return true; }
void Camera::Serialize(Properties* prop) { Component::Serialize(prop); prop->Value("fov", &fov); prop->Value("aspectRatio", &aspectRatio); prop->Value("viewRange", &viewRange); prop->Value("aperture", &aperture); prop->Value("focalLength", &focalLength); prop->Value("focalDepth", &focalDepth); prop->Value("useDof", &useDof); short mode = 0; prop->Value("mode", &mode); if(prop->mode == Properties::Mode::Input) this->mode = (Mode)mode; // prop->Value("mode", &mode); // mode = (Mode)prop->Get<short>("mode"); UpdateProjection(); }
Frustum Camera::GetViewSpaceFrustum() const { if (projectionDirty_) UpdateProjection(); Frustum ret; if (customProjection_) ret.Define(projection_); else { if (!orthographic_) ret.Define(fov_, aspectRatio_, zoom_, GetNearClip(), GetFarClip()); else ret.DefineOrtho(orthoSize_, aspectRatio_, zoom_, GetNearClip(), GetFarClip()); } return ret; }
int KungFuPOC::SetUp() { UpdateProjection(); int code = 0; code = InitMaterial(); if (code) return code; code = InitJointMeshes(); if (code) return code; code = InitPainting(); if (code) return code; code = InitPaintLogic(); if (code) return code; code = kinectController.InitSensor(); if (code) return code; code = kinectController.InitStream(NUI_INITIALIZE_FLAG_USES_COLOR | NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_SKELETON); if (code) return code; colorDisplay = new KinectColorDisplay(device, deviceContext, &kinectController); colorDisplay->SetWidth(0.6f); colorDisplay->SetHeight(0.6f); colorDisplay->SetX(-0.9f); colorDisplay->SetY(-0.9f); code = colorDisplay->Init(); if (code) return code; depthDisplay = new KinectDepthDisplay(device, deviceContext, &kinectController); depthDisplay->SetWidth(0.6f); depthDisplay->SetHeight(0.6f); depthDisplay->SetX(-0.2f); depthDisplay->SetY(-0.9f); code = depthDisplay->Init(); if (code) return code; return 0; }
void SampledTaskPoint::UpdateOZ(const TaskProjection &projection) { search_max = search_reference; search_min = search_reference; boundary_points.clear(); if (boundary_scored) { const OZBoundary boundary = GetBoundary(); for (auto i = boundary.begin(), end = boundary.end(); i != end; ++i) { SearchPoint sp(*i); boundary_points.push_back(sp); } boundary_points.PruneInterior(); } else { boundary_points.push_back(search_reference); } UpdateProjection(projection); }
void GlueMapWindow::SetPan(bool enable) { switch (follow_mode) { case FOLLOW_SELF: if (!enable) return; follow_mode = FOLLOW_PAN; break; case FOLLOW_PAN: if (enable) return; follow_mode = FOLLOW_SELF; break; } UpdateProjection(); FullRedraw(); }
Frustum Camera::GetViewSpaceSplitFrustum(float nearClip, float farClip) const { if (projectionDirty_) UpdateProjection(); nearClip = Max(nearClip, projNearClip_); farClip = Min(farClip, projFarClip_); if (farClip < nearClip) farClip = nearClip; Frustum ret; if (customProjection_) ret.DefineSplit(projection_, nearClip, farClip); else { if (!orthographic_) ret.Define(fov_, aspectRatio_, zoom_, nearClip, farClip); else ret.DefineOrtho(orthoSize_, aspectRatio_, zoom_, nearClip, farClip); } return ret; }
GLCamera::GLCamera(float _fovy, int _width,int _height, float _nearZ, float _farZ) { //m_ViewPort.MinDepth = 0.0f; //m_ViewPort.MaxDepth = 1.0f; m_width = _width; m_height = _height; m_aspectRatio = (float)m_width / (float)m_height; m_FOVy = _fovy;//2 * glm::atan(glm::tan(0.5f * _fovy) * m_aspectRatio); m_nearZ = _nearZ; m_farZ = _farZ; m_position = glm::vec3(0, 0, 0); m_forward = glm::vec3(0, 0, -1); m_right = glm::vec3(1, 0, 0); m_up = glm::vec3(0, 1, 0); UpdateView(); UpdateProjection(); SetForward(glm::vec3(0,0,-1)); }
void eel::PerspectiveCamera::SetLens(FLOAT fovAngle, FLOAT aspect, FLOAT nearZ, FLOAT farZ) { UpdateProjection(XMMatrixPerspectiveFovLH(fovAngle, aspect, nearZ, farZ)); }
void eel::OrthographicCamera::SetLens(FLOAT width, FLOAT height, FLOAT nearZ, FLOAT farZ) { UpdateProjection(XMMatrixOrthographicLH(width, height, nearZ, farZ)); }
FirstPersonCamera::FirstPersonCamera() : PerspectiveCamera() { SetRotation(XMFLOAT2(0.0f, 0.0f), 0.0f); UpdateProjection(); }
FirstPersonCamera::FirstPersonCamera(float nearClip, float farClip, float fov, float aspect) : PerspectiveCamera(nearClip, farClip, fov, aspect) { SetRotation(XMFLOAT2(0.0f, 0.0f), 0.0f); UpdateProjection(); }