Beispiel #1
0
        public WSceneView()
        {
            m_opaqueRenderList      = new List <IRenderable>();
            m_transparentRenderList = new List <IRenderable>();
            m_renderablesInFrustum  = new List <IRenderable>();

            m_viewportRect      = new FRect(0, 0, 1f, 1f);
            m_viewCamera        = new WCamera();
            m_orientationWidget = new WViewportOrientationWidget();
        }
Beispiel #2
0
        /// <summary>
        /// Returns the position of the viewport in screenspace pixel coordinates.
        /// </summary>
        public FRect GetViewportDimensions()
        {
            FRect newRect = new FRect();

            newRect.X      = m_viewportRect.X * m_viewWidth;
            newRect.Y      = m_viewportRect.Y * m_viewHeight;
            newRect.Width  = m_viewportRect.Width * m_viewWidth;
            newRect.Height = m_viewportRect.Height * m_viewHeight;

            return(newRect);
        }
Beispiel #3
0
        public FRay ProjectScreenToWorld(Vector2 mousePosition)
        {
            FRect viewportDimensions = GetViewportDimensions();

            mousePosition.X -= viewportDimensions.X;
            mousePosition.Y -= viewportDimensions.Y;

            Vector3 mouseViewportA = new Vector3(mousePosition.X / viewportDimensions.Width, mousePosition.Y / viewportDimensions.Height, 0f);
            Vector3 mouseViewportB = new Vector3(mousePosition.X / viewportDimensions.Width, mousePosition.Y / viewportDimensions.Height, 1f);

            Vector4 nearUnproj = FFrustum.UnProject(m_viewCamera.ProjectionMatrix, m_viewCamera.ViewMatrix, mouseViewportA);
            Vector4 farUnproj  = FFrustum.UnProject(m_viewCamera.ProjectionMatrix, m_viewCamera.ViewMatrix, mouseViewportB);

            Vector3 dir = farUnproj.Xyz - nearUnproj.Xyz;

            dir.Normalize();

            return(new FRay(nearUnproj.Xyz, dir));
        }
Beispiel #4
0
        private void UpdateSceneViews()
        {
            // If they've clicked, check which view is in focus.
            if (WInput.GetMouseButtonDown(0) || WInput.GetMouseButtonDown(1) || WInput.GetMouseButtonDown(2))
            {
                WSceneView focusedScene = GetFocusedSceneView();
                foreach (var scene in m_sceneViews)
                {
                    scene.IsFocused = false;
                    FRect viewport = scene.GetViewportDimensions();
                    if (viewport.Contains(WInput.MousePosition.X, WInput.MousePosition.Y))
                    {
                        focusedScene = scene;
                    }
                }

                focusedScene.IsFocused = true;
            }
        }
Beispiel #5
0
 internal void SetViewRect(FRect rect)
 {
     m_viewportRect = rect;
 }