Пример #1
0
        private void FindHoverAxis()
        {
            var ray = Scene.MainCamera.Unproject(Scene.Control.ScreenMousePosition);

            ray = Ray.Transform(ray, Transform.InvertedModelMatrix);

            var hit = _xyzPlane.Raycast(ray);

            if (hit != null)
            {
                var point = hit.Point;
                if (point.X > 0 && point.Y > 0 && point.Z > 0)
                {
                    _hoverAxis = Axis.XYZ;
                    return;
                }
            }

            if (CheckAxis(Axis.X, ray))
            {
                return;
            }
            if (CheckAxis(Axis.Y, ray))
            {
                return;
            }
            if (CheckAxis(Axis.Z, ray))
            {
                return;
            }

            if (CheckTwoAxisPlane(Axis.XY, ray))
            {
                return;
            }
            if (CheckTwoAxisPlane(Axis.XZ, ray))
            {
                return;
            }
            if (CheckTwoAxisPlane(Axis.YZ, ray))
            {
                return;
            }

            _hoverAxis = Axis.None;
        }
Пример #2
0
        private RaycastHit RaycastAxisPlane(Ray ray, Plane plane)
        {
            var hit = plane.Raycast(ray);

            if (hit == null)
            {
                return(null);
            }

            var distanceToCenter = hit.Point.Length;

            if (distanceToCenter > Radius - MinDistance && distanceToCenter < Radius + MinDistance)
            {
                return(hit);
            }
            else
            {
                return(null);
            }
        }