Пример #1
0
        /// <summary>
        /// <para>Projects a position in 3D space into draw target pixel coordinates</para>
        /// <para>Returns false if the projected point is behind the camera</para>
        /// </summary>
        /// <param name="position">3D world space position to project into draw target coordinates</param>
        /// <param name="coordinate">draw target coordinates of the projected position</param>
        /// <returns>True if the projected position is in front of the camera</returns>
        /// <param name="target">Draw Target space to project the point onto</param>
        public bool ProjectToTarget(ref Vector3 position, out Vector2 coordinate, Graphics.DrawTarget target)
        {
            if (target == null)
            {
                throw new ArgumentNullException();
            }

            Vector2 size = target.Size;

            bool result = Camera3D.ProjectToCoordinate(this, ref position, out coordinate, ref size);

            coordinate.X = size.X * (coordinate.X * 0.5f + 0.5f);
            coordinate.Y = size.Y * (coordinate.Y * 0.5f + 0.5f);

            return(result);
        }
Пример #2
0
        /// <summary>
        /// <para>Projects a position in 3D space into [-1,+1] projected coordinates</para>
        /// <para>[-1,+1] Coordinates are equivalent of the size of a DrawTarget, where (-1,-1) is bottom left, (1,1) is top right and (0,0) is centered</para>
        /// <para>Returns false if the projected point is behind the camera</para>
        /// </summary>
        /// <param name="position">3D world space position to project into [-1,+1] projected coordinates</param>
        /// <param name="coordinate">[-1,+1] coordinates of the projected position</param>
        /// <returns>True if the projected position is in front of the camera</returns>
        public bool ProjectToCoordinate(ref Vector3 position, out Vector2 coordinate)
        {
            Vector2 size = Vector2.One;

            return(Camera3D.ProjectToCoordinate(this, ref position, out coordinate, ref size));
        }