Ejemplo n.º 1
0
        public override void OnMouseMove(MouseEventArgs mouseEvent)
        {
            mouseOver = false;
            // find the ray for this control
            // check what face it hits
            // mark that face to draw a highlight
            base.OnMouseMove(mouseEvent);

            // rotate the view
            if (MouseDownOnWidget)
            {
                trackballTumbleWidgetExtended.DoRotateAroundOrigin(mouseEvent.Position);
            }
            else if (world != null &&
                     cubeTraceData != null)               // Make sure we don't use the trace data before it is ready
            {
                Ray           ray  = world.GetRayForLocalBounds(mouseEvent.Position);
                IntersectInfo info = cubeTraceData.GetClosestIntersection(ray);

                if (info != null)
                {
                    mouseOver = true;

                    DrawMouseHover(GetHitData(info.HitPosition));
                }
                else
                {
                    ResetTextures();
                }
            }
        }
Ejemplo n.º 2
0
        public override void OnMouseMove(MouseEventArgs mouseEvent)
        {
            mouseOver = false;
            // find the ray for this control
            // check what face it hits
            // mark that face to draw a highlight
            base.OnMouseMove(mouseEvent);

            // rotate the view
            if (MouseDownOnWidget)
            {
                var        movePosition             = mouseEvent.Position;
                Quaternion activeRotationQuaternion = TrackBallController.GetRotationForMove(new Vector2(Width / 2, Height / 2), Width, lastMovePosition, movePosition, false);

                if (activeRotationQuaternion != Quaternion.Identity)
                {
                    lastMovePosition = movePosition;
                    object3DControlLayer.World.RotationMatrix = object3DControlLayer.World.RotationMatrix * Matrix4X4.CreateRotation(activeRotationQuaternion);
                    object3DControlLayer.Invalidate();
                }
            }
            else if (world != null &&
                     cubeTraceData != null)               // Make sure we don't use the trace data before it is ready
            {
                Ray           ray  = world.GetRayForLocalBounds(mouseEvent.Position);
                IntersectInfo info = cubeTraceData.GetClosestIntersection(ray);

                if (info != null)
                {
                    mouseOver = true;

                    DrawMouseHover(GetHitData(info.HitPosition));
                }
                else
                {
                    ResetTextures();
                }
            }
        }
Ejemplo n.º 3
0
        private bool FindInteractionVolumeHit(Ray ray, out int interactionVolumeHitIndex, out IntersectInfo info)
        {
            interactionVolumeHitIndex = -1;
            if (interactionVolumes.Count == 0 || interactionVolumes[0].CollisionVolume == null)
            {
                info = null;
                return(false);
            }

            List <ITraceable> uiTraceables = new List <ITraceable>();

            foreach (InteractionVolume interactionVolume in interactionVolumes)
            {
                if (interactionVolume.CollisionVolume != null)
                {
                    var traceData = interactionVolume.CollisionVolume;
                    uiTraceables.Add(new Transform(traceData, interactionVolume.TotalTransform));
                }
            }

            ITraceable allUiObjects = BoundingVolumeHierarchy.CreateNewHierachy(uiTraceables);

            info = allUiObjects.GetClosestIntersection(ray);
            if (info != null)
            {
                for (int i = 0; i < interactionVolumes.Count; i++)
                {
                    List <IBvhItem> insideBounds = new List <IBvhItem>();
                    if (interactionVolumes[i].CollisionVolume != null)
                    {
                        interactionVolumes[i].CollisionVolume.GetContained(insideBounds, info.ClosestHitObject.GetAxisAlignedBoundingBox());
                        if (insideBounds.Contains(info.ClosestHitObject))
                        {
                            interactionVolumeHitIndex = i;
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }