Ejemplo n.º 1
0
        public virtual SceneQueryResult getLastResults()
        {
            SceneQueryResult ret = new SceneQueryResult(OgrePINVOKE.RegionSceneQuery_getLastResults(swigCPtr), false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// private method for selection object that creates a box from the SelectionRectangle, stop variable is passed in
        /// </summary>
        /// <param name="first">Vector2</param>
        /// <param name="second">Vector2</param>
        private void PerformSelectionWithSelectionBox(Math.Vector2 first, Math.Vector2 second)
        {
            Log("MouseSelector: " + this._name + " performing selection.");

            float left = first.x, right = second.x, top = first.y, bottom = second.y;

            if (left > right)
            {
                Utility.Swap(ref left, ref right);
            }

            if (top > bottom)
            {
                Utility.Swap(ref top, ref bottom);
            }

            if ((right - left) * (bottom - top) < 0.0001)
            {
                return;
            }

            Ray topLeft     = this._Camera.GetCameraToViewportRay(left, top);
            Ray topRight    = this._Camera.GetCameraToViewportRay(right, top);
            Ray bottomLeft  = this._Camera.GetCameraToViewportRay(left, bottom);
            Ray bottomRight = this._Camera.GetCameraToViewportRay(right, bottom);

            var vol = new PlaneBoundedVolume();

            vol.planes.Add(new Math.Plane(topLeft.GetPoint(3), topRight.GetPoint(3), bottomRight.GetPoint(3)));
            // front plane
            vol.planes.Add(new Math.Plane(topLeft.Origin, topLeft.GetPoint(100), topRight.GetPoint(100))); // top plane
            vol.planes.Add(new Math.Plane(topLeft.Origin, bottomLeft.GetPoint(100), topLeft.GetPoint(100)));
            // left plane
            vol.planes.Add(new Math.Plane(bottomLeft.Origin, bottomRight.GetPoint(100), bottomLeft.GetPoint(100)));
            // bottom plane
            vol.planes.Add(new Math.Plane(topRight.Origin, topRight.GetPoint(100), bottomRight.GetPoint(100)));
            // right plane

            var volList = new PlaneBoundedVolumeList();

            volList.Add(vol);

            PlaneBoundedVolumeListSceneQuery volQuery;

            volQuery         = Root.Instance.SceneManager.CreatePlaneBoundedVolumeQuery(new PlaneBoundedVolumeList());
            volQuery.Volumes = volList;
            SceneQueryResult result = volQuery.Execute();

            foreach (MovableObject obj in result.objects)
            {
                SelectObject(obj);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Casts the plane selection and selects all objects inside the SelectionRectangle.
        /// Hitted objects sends to the GameObjectManager (OnLeftClick).
        /// </summary>
        /// <param name="first">The firts corner.</param>
        /// <param name="second">The second corner.</param>
        private void PerformSelection(Vector2 first, Vector2 second)
        {
            float left = first.x, right = second.x,
                  top = first.y, bottom = second.y;

            if (left > right)
            {
                Swap(ref left, ref right);
            }
            if (top > bottom)
            {
                Swap(ref top, ref bottom);
            }

            if ((right - left) * (bottom - top) < 0.0001)
            {
                return;
            }

            Camera c           = Game.SceneManager.GetCamera("myCam");
            Ray    topLeft     = c.GetCameraToViewportRay(left, top);
            Ray    topRight    = c.GetCameraToViewportRay(right, top);
            Ray    bottomLeft  = c.GetCameraToViewportRay(left, bottom);
            Ray    bottomRight = c.GetCameraToViewportRay(right, bottom);

            PlaneBoundedVolume vol = new PlaneBoundedVolume();

            vol.planes.Add(new Plane(topLeft.GetPoint(3), topRight.GetPoint(3), bottomRight.GetPoint(3)));                // Front plane
            vol.planes.Add(new Plane(topLeft.Origin, topLeft.GetPoint(100), topRight.GetPoint(100)));                     // Top plane
            vol.planes.Add(new Plane(topLeft.Origin, bottomLeft.GetPoint(100), topLeft.GetPoint(100)));                   // Left plane
            vol.planes.Add(new Plane(bottomLeft.Origin, bottomRight.GetPoint(100), bottomLeft.GetPoint(100)));            // Bottom plane
            vol.planes.Add(new Plane(topRight.Origin, topRight.GetPoint(100), bottomRight.GetPoint(100)));                // Right plane

            PlaneBoundedVolumeList volList = new PlaneBoundedVolumeList();

            volList.Add(vol);
            PlaneBoundedVolumeListSceneQuery volQuery = Game.SceneManager.CreatePlaneBoundedVolumeQuery(volList);
            SceneQueryResult result = volQuery.Execute();

            List <MovableObject> list = new List <MovableObject>(result.movables);

            GameObjectManager.GetInstance().OnLeftClick(list);

            Game.SceneManager.DestroyQuery(volQuery);
        }
Ejemplo n.º 4
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SceneQueryResult obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }