예제 #1
0
        public override RaycastColliderHit Raycast(Ray ray)
        {
            _sphere.Center = Vector3.Zero;
            _sphere.Radius = Radius;

            var modelSpaceRay = GetModelSpaceRay(ray);
            var hit           = _sphere.Raycast(modelSpaceRay);

            if (hit != null)
            {
                var raycastHit = new RaycastColliderHit();
                raycastHit.Collider = this;
                raycastHit.Point    = Vector3.Transform(hit.Point, Transform.ModelMatrix);
                raycastHit.Distance = Vector3.Distance(ray.Origin, raycastHit.Point);
                return(raycastHit);
            }
            return(null);
        }
예제 #2
0
        public override RaycastColliderHit Raycast(Ray ray)
        {
            _box.Center = Offset;
            _box.Size   = Size;

            var modelSpaceRay = GetModelSpaceRay(ray);

            var hit = _box.Raycast(modelSpaceRay);

            if (hit != null)
            {
                var raycastHit = new RaycastColliderHit();
                raycastHit.Collider = this;
                raycastHit.Point    = Vector3.Transform(hit.Point, Transform.ModelMatrix);
                raycastHit.Distance = Vector3.Distance(ray.Origin, raycastHit.Point);
                return(raycastHit);
            }
            return(null);
        }
예제 #3
0
        public override RaycastColliderHit Raycast(Ray ray)
        {
            _cylinder.Base   = Offset;
            _cylinder.Radius = Radius;
            _cylinder.Height = Height;

            var modelSpaceRay = GetModelSpaceRay(ray);

            var hit = _cylinder.Raycast(modelSpaceRay);

            if (hit != null)
            {
                var raycastHit = new RaycastColliderHit();
                raycastHit.Collider = this;
                raycastHit.Point    = Vector3.Transform(hit.Point, Transform.ModelMatrix);
                raycastHit.Distance = Vector3.Distance(ray.Origin, raycastHit.Point);
                return(raycastHit);
            }
            return(null);
        }