Exemplo n.º 1
0
        private void panel1_MouseUp(object sender, MouseEventArgs e)
        {
            if (mDragObject != null)
            {
                IEditorNode hPicture = (IEditorNode)mDragObject;
                //hPicture.Highlight(PictureNode.eHighlightOptions.Highlight_None);
                mDragObject = null;
            }

            if (mIsDraggingPanel)
            {
                panel1.Cursor    = oldcursor;
                mIsDraggingPanel = false;

                // unproject the screen point into world space
                // find the cursor position on this application
                Point screenPoint = PointToClient(new Point(Cursor.Position.X - panel1.Location.X, Cursor.Position.Y - panel1.Location.Y));
                // converts it to vec3
                GlmNet.vec3 scrPt = Utilities.PointToVec3(screenPoint);

                GlmNet.vec3 movement = previousScrPt - scrPt;
                movement *= 0.1f;

                Camera.Instance().StrifeCamera(movement);

                //System.Console.WriteLine(" Cursor    : " + scrPt.ToString());
                //System.Console.WriteLine(" Delta     : " + movement.ToString());
                //System.Console.WriteLine(" Camera    : " + mCamera.GetCameraPosition().ToString());

                // refresh matrices...
                //refreshMatrices();
                _mustRender = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the Real and the Display locations of an image.
        /// </summary>
        /// <param name="i">An image of type PictureNode</param>
        /// <param name="RealTopLeft">returns the top left world location of this object</param>
        /// <param name="RealBottomRight">returns the bottom right world location of this object</param>
        /// <param name="DisplayTopLeft">returns the top left location for display</param>
        /// <param name="DisplayBottomRight">returns the bottom right location for display</param>
        static public void GetProjectedPoint(
            IEditorNode i,
            ref Point DisplayTopLeft,
            ref Point DisplayBottomRight)
        {
            vec3 topLeft           = new vec3(i.RealLocation.X, i.RealLocation.Y, 0);
            vec3 bottomRight       = new vec3(i.RealLocation.X + i.RealSize.Width, i.RealLocation.Y + i.RealSize.Height, 0);
            vec3 screenTopLeft     = new vec3();
            vec3 screenBottomRight = new vec3();

            // generates a new vertex
            screenTopLeft = glm.project(
                topLeft,
                i.GetModel(),
                Camera.Instance().GetProjectionView(),
                Camera.Instance().GetViewport());


            screenBottomRight = glm.project(
                bottomRight,
                i.GetModel(),
                Camera.Instance().GetProjectionView(),
                Camera.Instance().GetViewport());

            // finds the world location of this object based on the
            //Camera.Instance().WorldToPixel(topLeft, bottomRight, ref screenTopLeft, ref screenBottomRight);

            DisplayTopLeft     = new Point((int)screenTopLeft.x, (int)screenTopLeft.y);
            DisplayBottomRight = new Point((int)screenBottomRight.x, (int)screenBottomRight.y);
        }
Exemplo n.º 3
0
 private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
 {
     if (mDragObject == null)
     {
         mDragObject = (IEditorNode)sender;
         //hPicture.Highlight(PictureNode.eHighlightOptions.Highlight_Border);
     }
 }
Exemplo n.º 4
0
        internal static Point ScreenToWorld(Point screenPoint, IEditorNode i)
        {
            // converts it to vec3
            GlmNet.vec3 scrPt = Utilities.PointToVec3(screenPoint);

            // project from screen to world location this point, according to the current
            // projection_view matrix.
            GlmNet.vec3 unprojectedPoint1 = GlmNet.glm.unProject(
                scrPt,
                i.GetModel(),
                Camera.Instance().GetProjectionView(),
                Camera.Instance().GetViewport());

            // converts to point
            return(new Point((int)unprojectedPoint1.x, (int)unprojectedPoint1.y));
        }