Esempio n. 1
0
        public void Update(WSceneView view)
        {
            UpdateSelectionGizmo(view);

            // If we have a gizmo and we're transforming it, don't check for selection change.
            if (TransformGizmo != null && TransformGizmo.IsTransforming)
            {
                return;
            }
            if (WInput.GetMouseButtonDown(0) && !WInput.GetMouseButton(1))
            {
                FRay mouseRay   = view.ProjectScreenToWorld(WInput.MousePosition);
                var  addedActor = Raycast(mouseRay);

                // Check the behaviour of this click to determine appropriate selection modification behaviour.
                // Click w/o Modifiers = Clear Selection, add result to selection
                // Click /w Ctrl = Toggle Selection State
                // Click /w Shift = Add to Selection
                bool ctrlPressed  = WInput.GetKey(Key.LeftCtrl) || WInput.GetKey(Key.RightCtrl);
                bool shiftPressed = WInput.GetKey(Key.LeftShift) || WInput.GetKey(Key.RightShift);

                if (!ctrlPressed & !shiftPressed)
                {
                    EditorSelection.ClearSelection();
                    if (addedActor != null)
                    {
                        EditorSelection.AddToSelection(addedActor);
                    }
                }
                else if (addedActor != null && (ctrlPressed && !shiftPressed))
                {
                    if (addedActor.IsSelected)
                    {
                        EditorSelection.RemoveFromSelection(addedActor);
                    }
                    else
                    {
                        EditorSelection.AddToSelection(addedActor);
                    }
                }
                else if (addedActor != null && shiftPressed)
                {
                    if (!EditorSelection.SelectedObjects.Contains(addedActor))
                    {
                        EditorSelection.AddToSelection(addedActor);
                    }
                }

                UpdateGizmoTransform();
            }

            // Add our gizmo to the renderer this frame.
            ((IRenderable)TransformGizmo).AddToRenderer(view);
        }
Esempio n. 2
0
    private void updateTouch()
    {
        if (WInput.HasInput() == false)
        {
            return;
        }

        WHumanInput input = WInput.GetInput();

        if (input.phase == TouchPhase.Stationary)
        {
            Ray        ray     = Camera.mainCamera.ScreenPointToRay(input.position);
            RaycastHit hitInfo = new RaycastHit();

            if (Physics.Raycast(ray, out hitInfo))
            {
                generationMinionWithPosition(hitInfo.point);
            }
        }
        else if (input.phase == TouchPhase.Began)
        {
            Ray        ray     = Camera.mainCamera.ScreenPointToRay(input.position);
            RaycastHit hitInfo = new RaycastHit();

            if (Physics.Raycast(ray, out hitInfo))
            {
                _startRayPosition = hitInfo.point;
            }
            else
            {
                _startRayPosition = Vector3.zero;
            }
        }
        else if (_startRayPosition != Vector3.zero && input.phase == TouchPhase.Moved)
        {
            Ray        ray     = Camera.mainCamera.ScreenPointToRay(input.position);
            RaycastHit hitInfo = new RaycastHit();

            if (Physics.Raycast(ray, out hitInfo))
            {
                Vector3 newPosition = hitInfo.point;

                Vector3 touchDeltaPosition = newPosition - _startRayPosition;
                touchDeltaPosition.y = 0;

                Camera.mainCamera.transform.position -= touchDeltaPosition;

                Debug.Log("camera(" + Camera.mainCamera.transform.position + ") start(" + _startRayPosition + ") new(" + newPosition + ") deltaPosition (" + touchDeltaPosition + ")");
            }
        }
    }
        private void DoApplicationTick()
        {
            // Poll the mouse at a high resolution
            System.Drawing.Point mousePos = m_glControl.PointToClient(System.Windows.Forms.Cursor.Position);

            mousePos.X = WMath.Clamp(mousePos.X, 0, m_glControl.Width);
            mousePos.Y = WMath.Clamp(mousePos.Y, 0, m_glControl.Height);
            WInput.SetMousePosition(new Vector2(mousePos.X, mousePos.Y));

            ProcessTick();
            WInput.Internal_UpdateInputState();

            m_glControl.SwapBuffers();
        }
Esempio n. 4
0
        public void Update(WSceneView view)
        {
            if (WInput.GetMouseButton(0) && !WInput.GetMouseButton(1))
            {
                FRay mouseRay   = view.ProjectScreenToWorld(WInput.MousePosition);
                var  addedActor = Raycast(mouseRay);

                // Check the behaviour of this click to determine appropriate selection modification behaviour.
                // Click w/o Modifiers = Clear Selection, add result to selection
                // Click /w Ctrl = Toggle Selection State
                // Click /w Shift = Add to Selection
                bool ctrlPressed  = WInput.GetKey(Key.LeftCtrl) || WInput.GetKey(Key.RightCtrl);
                bool shiftPressed = WInput.GetKey(Key.LeftShift) || WInput.GetKey(Key.RightShift);

                if (ctrlPressed && !WInput.GetMouseButtonDown(0))
                {
                    return;
                }

                if (!ctrlPressed & !shiftPressed)
                {
                    ClearSelection();
                    if (addedActor != null)
                    {
                        AddTriangleToSelection(addedActor);
                    }
                }
                else if (addedActor != null && (ctrlPressed && !shiftPressed))
                {
                    if (addedActor.IsSelected)
                    {
                        RemoveTriangleFromSelection(addedActor);
                    }
                    else
                    {
                        AddTriangleToSelection(addedActor);
                    }
                }
                else if (addedActor != null && shiftPressed)
                {
                    if (!EditorSelection.SelectedObjects.Contains(addedActor))
                    {
                        AddTriangleToSelection(addedActor);
                    }
                }
            }
        }
Esempio n. 5
0
        public WResult PerformCapture(int hWnd, int x1, int y1, int x2, int y2)
        {
            WInput objInput = ComFactory.Instance.NewWInput();  // set capture options
            int    wOptions = 0;

            // set the get paragraph flag
            wOptions |= (int)W_CAPTURE_OPTIONS.wCaptureOptionsGetParagraph;
            // set the highlight word flag
            wOptions |= (int)W_CAPTURE_OPTIONS.wCaptureOptionsHighlightWords;
            // set the getContext flag
            wOptions |= (int)W_CAPTURE_OPTIONS.wCaptureOptionsGetContext;
            //set capture parameters
            objInput.Hwnd    = hWnd;
            objInput.StartX  = x1;
            objInput.StartY  = y1;
            objInput.EndX    = x2;
            objInput.EndY    = y2;
            objInput.Options = wOptions;


            // set the number of context words
            objInput.ContextWordsLeft  = 1;
            objInput.ContextWordsRight = 1;
            // declare the string which will get the results
            string strResult;

            WResult objResult;

            objResult = m_wCapture.Capture(objInput);

            // get the text from the capture
            strResult = objResult.Text;


            //use OCR if native method fails
            if (strResult == string.Empty)
            {
                wOptions        |= (int)W_CAPTURE_OPTIONS.wCaptureOptionsGetTessOCRText;
                objInput.Options = wOptions;
                objResult        = m_wCapture.Capture(objInput);
                strResult        = objResult.Text;
            }

            return(objResult);
        }
        private void RenderFrame()
        {
            m_frameBuffer.Bind();
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
            GL.Viewport(0, 0, m_frameBuffer.Width, m_frameBuffer.Height);

            float deltaTime = m_dtStopwatch.ElapsedMilliseconds / 1000f;

            m_dtStopwatch.Restart();
            m_renderCamera.Tick(deltaTime);
            m_lineBatcher.Tick(deltaTime);
            m_skeletonLineBatcher.Tick(deltaTime);

            deltaTime           = WMath.Clamp(deltaTime, 0, 0.25f); // quarter second max because debugging
            m_timeSinceStartup += deltaTime;

            if (m_modelRenderOptions.AnimateLight)
            {
                // Rotate our light
                float angleInRad = m_timeSinceStartup % WMath.DegreesToRadians(360f);
                m_mainLight.Position = new Vector4(CalculateLightPosition(angleInRad), 0);
            }

            if (m_modelRenderOptions.ShowGrid)
            {
                DrawFixedGrid();
            }

            if (m_modelRenderOptions.DepthPrePass)
            {
                foreach (var j3d in m_loadedModels)
                {
                    // Render a depth-only pre pass. We need to tell it to render translucent and opaque objects so that
                    // they both write in to the depth buffer (it's a specific pre-pass so they should)
                    j3d.Render(m_renderCamera.ViewMatrix, m_renderCamera.ProjectionMatrix, Matrix4.Identity, true, true, true);
                }
            }

            foreach (var j3d in m_loadedModels)
            {
                j3d.Tick(deltaTime);
            }

            foreach (var j3d in m_loadedModels)
            {
                j3d.SetHardwareLight(0, m_mainLight);
                j3d.Render(m_renderCamera.ViewMatrix, m_renderCamera.ProjectionMatrix, Matrix4.Identity, true, false);
            }
            foreach (var j3d in m_loadedModels)
            {
                // Do a second render pass after all objects to render translucent ones.
                j3d.Render(m_renderCamera.ViewMatrix, m_renderCamera.ProjectionMatrix, Matrix4.Identity, false, true);
            }

            if (m_modelRenderOptions.ShowPivot)
            {
                m_lineBatcher.DrawLine(Vector3.Zero, new Vector3(50, 0, 0), WLinearColor.Red, 0, 0);
                m_lineBatcher.DrawLine(Vector3.Zero, new Vector3(0, 50, 0), WLinearColor.Green, 0, 0);
                m_lineBatcher.DrawLine(Vector3.Zero, new Vector3(0, 0, 50), WLinearColor.Blue, 0, 0);
            }

            if (m_modelRenderOptions.ShowBoundingBox)
            {
                foreach (var j3d in m_loadedModels)
                {
                    j3d.DrawBoundsForShapes(true, false, m_lineBatcher);
                }
            }

            if (m_modelRenderOptions.ShowBoundingSphere)
            {
                foreach (var j3d in m_loadedModels)
                {
                    j3d.DrawBoundsForShapes(false, true, m_lineBatcher);
                }
            }

            if (m_modelRenderOptions.ShowBoneBoundingBox)
            {
                foreach (var j3d in m_loadedModels)
                {
                    j3d.DrawBoundsForJoints(true, false, m_lineBatcher);
                }
            }

            if (m_modelRenderOptions.ShowBoneBoundingSphere)
            {
                foreach (var j3d in m_loadedModels)
                {
                    j3d.DrawBoundsForJoints(false, true, m_lineBatcher);
                }
            }

            if (m_modelRenderOptions.ShowBones)
            {
                foreach (var j3d in m_loadedModels)
                {
                    j3d.DrawBones(m_skeletonLineBatcher);
                }
            }

            // Debug Rendering
            if (WInput.GetKey(Key.I))
            {
                GL.Disable(EnableCap.CullFace);
                GL.Enable(EnableCap.Blend);
                GL.BlendFunc(BlendingFactorSrc.DstAlpha, BlendingFactorDest.Zero);

                m_alphaVisualizationShader.Bind();
                m_screenQuad.Draw();
            }

            // Blit the framebuffer to the backbuffer so it shows up on screen.
            m_lineBatcher.Render(m_renderCamera.ViewMatrix, m_renderCamera.ProjectionMatrix);
            m_skeletonLineBatcher.Render(m_renderCamera.ViewMatrix, m_renderCamera.ProjectionMatrix, true);
            m_frameBuffer.BlitToBackbuffer(m_viewportWidth, m_viewportHeight);
        }
Esempio n. 7
0
        private void UpdateSelectionGizmo(WSceneView view)
        {
            if (!TransformGizmo.Enabled && EditorSelection.SelectedObjects.Count > 0)
            {
                // Show the Transform Gizmo.
                TransformGizmo.Enabled = true;
                UpdateGizmoTransform();
                // m_transformGizmo.SetPosition(m_selectionList[0].Transform.Position);
                // m_transformGizmo.SetLocalRotation(m_selectionList[0].Transform.Rotation);
            }
            else if (TransformGizmo.Enabled && EditorSelection.SelectedObjects.Count == 0)
            {
                // Hide the Transform Gizmo.
                TransformGizmo.Enabled = false;
            }

            if (!TransformGizmo.Enabled)
            {
                return;
            }

            if (WInput.GetKeyDown(Key.Q) && !WInput.GetMouseButton(1))
            {
                TransformGizmo.SetMode(FTransformMode.None);
            }
            if (WInput.GetKeyDown(Key.W) && !WInput.GetMouseButton(1))
            {
                TransformGizmo.SetMode(FTransformMode.Translation);
            }
            if (WInput.GetKeyDown(Key.E) && !WInput.GetMouseButton(1))
            {
                TransformGizmo.SetMode(FTransformMode.Rotation);
            }
            if (WInput.GetKeyDown(Key.R) && !WInput.GetMouseButton(1))
            {
                TransformGizmo.SetMode(FTransformMode.Scale);
            }

            if (WInput.GetKeyDown(Key.OemOpenBrackets))
            {
                TransformGizmo.DecrementSize();
            }

            if (WInput.GetKeyDown(Key.OemCloseBrackets))
            {
                TransformGizmo.IncrementSize();
            }

            if (WInput.GetKeyDown(Key.OemTilde))
            {
                if (TransformGizmo.TransformSpace == FTransformSpace.World)
                {
                    TransformGizmo.SetTransformSpace(FTransformSpace.Local);
                }
                else
                {
                    TransformGizmo.SetTransformSpace(FTransformSpace.World);
                }

                UpdateGizmoTransform();
            }

            if (WInput.GetMouseButtonDown(0))
            {
                FRay mouseRay = view.ProjectScreenToWorld(WInput.MousePosition);
                if (TransformGizmo.CheckSelectedAxes(mouseRay))
                {
                    TransformGizmo.StartTransform();
                }
            }

            if (WInput.GetMouseButtonUp(0))
            {
                if (TransformGizmo.IsTransforming)
                {
                    // When we end let go of the gizmo, we want to make one last action which specifies that it is done,
                    // so that the next gizmo move doesn't merge with the previous.
                    WUndoCommand undoAction = CreateUndoActionForGizmo(true);
                    if (undoAction != null)
                    {
                        BroadcastUndoEventGenerated(undoAction);
                    }

                    TransformGizmo.EndTransform();
                }
            }

            if (TransformGizmo.IsTransforming)
            {
                FRay mouseRay = view.ProjectScreenToWorld(WInput.MousePosition);
                if (TransformGizmo.TransformFromInput(mouseRay, view))
                {
                    WUndoCommand undoAction = CreateUndoActionForGizmo(false);
                    if (undoAction != null)
                    {
                        BroadcastUndoEventGenerated(undoAction);
                    }
                }
            }

            TransformGizmo.UpdateForSceneView(view);
        }
Esempio n. 8
0
 private void GlControlHost_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
 {
     WInput.SetKeyboardState(e.Key, true);
 }
Esempio n. 9
0
 private void GlControlHost_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     WInput.SetMouseScrollDelta(e.Delta);
 }
Esempio n. 10
0
 private void GlControlHost_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     WInput.SetMouseState(WinFormToWPFMouseButton(e), true);
 }
Esempio n. 11
0
        public void Update(WSceneView view)
        {
            m_View = view;
            UpdateSelectionGizmo(view);

            // Add our gizmo to the renderer this frame.
            if (TransformGizmo != null)
            {
                ((IRenderable)TransformGizmo).AddToRenderer(view);
            }

            // If we have a gizmo and we're transforming it, don't check for selection change.
            if (TransformGizmo != null && TransformGizmo.IsTransforming)
            {
                return;
            }
            if (WInput.GetMouseButtonDown(0) && !WInput.GetMouseButton(1) && !m_bOverrideSceneCamera)
            {
                FRay           mouseRay = view.ProjectScreenToWorld(WInput.MousePosition);
                BindingVector3 addedVec = Raycast(mouseRay, view.ViewCamera);

                // Check the behaviour of this click to determine appropriate selection modification behaviour.
                // Click w/o Modifiers = Clear Selection, add result to selection
                // Click /w Ctrl = Toggle Selection State
                // Click /w Shift = Add to Selection
                bool ctrlPressed  = WInput.GetKey(Key.LeftCtrl) || WInput.GetKey(Key.RightCtrl);
                bool shiftPressed = WInput.GetKey(Key.LeftShift) || WInput.GetKey(Key.RightShift);

                // Replace the previous selection with the current selection, if it's valid.
                if (!ctrlPressed & !shiftPressed)
                {
                    EditorSelection.ClearSelection();

                    if (addedVec != null)
                    {
                        EditorSelection.AddToSelection(addedVec);
                    }
                }
                else if (addedVec != null && (ctrlPressed && !shiftPressed))
                {
                    if (EditorSelection.SelectedObjects.Contains(addedVec))
                    {
                        EditorSelection.RemoveFromSelection(addedVec);
                    }
                    else
                    {
                        EditorSelection.AddToSelection(addedVec);
                    }
                }
                else if (addedVec != null && shiftPressed)
                {
                    if (!EditorSelection.SelectedObjects.Contains(addedVec))
                    {
                        EditorSelection.AddToSelection(addedVec);
                    }
                }
            }
            if (m_CopyCameraRequest != null)
            {
                m_CopyCameraRequest.RequestingCut.CopySettingsFromCamera(view.ViewCamera, m_CopyCameraRequest.IsStart);
                m_CopyCameraRequest = null;
            }
            if (WInput.GetMouseButton(1) && m_bOverrideSceneCamera)
            {
                RestoreSceneCamera(view);
            }

            UpdateGizmoTransform();
        }