Пример #1
0
 /// <summary>
 /// This is a cinematic styled fixed camera it uses way points to traverse thru the world.
 /// </summary>
 public WaypointCamera(GraphicsDevice device, SpriteBatch spriteBatch, Texture2D dot, Vector3 pos, Vector3 target, Vector3 up, float nearClipPlane, float farClipPlane, float fieldOfView, bool perspective, bool inverseProjection)
 {
     DrawHelpers.Initialize(device, spriteBatch, dot);
     wayPointCurvature = new CurveMyImbalancedSpline();
     TransformCamera(pos, target, up);
     SetProjection(device, nearClipPlane, farClipPlane, fieldOfView, perspective, inverseProjection);
 }
Пример #2
0
        public void DrawCurveThruWayPointsWithSpriteBatch(GameTime gameTime)
        {
            if (wayPointCurvature != null)
            {
                // current 2d camera position and forward on the orthographic xy plane.
                var camPosition               = _camera.Translation;
                var camForward                = _camera.Forward;
                var drawnCamDepthAdjustment   = new Vector2(camPosition.Z / 4, camPosition.Z);
                var drawnCamTargetPos         = new Vector2(_targetLookAtPos.X, _targetLookAtPos.Y);
                var drawnCamPos               = new Vector2(camPosition.X, camPosition.Y);
                var drawnCamIteratedPos       = new Vector2(drawnCamPos.X, drawnCamPos.Y);
                var drawnCamForawrdRay        = new Vector2(camForward.X, camForward.Y) * 25;
                var drawnCamIteratedOffsetPos = drawnCamIteratedPos + drawnCamDepthAdjustment;
                var drawCamCrossHairLeft      = new Vector2(-15, 0) + drawnCamIteratedOffsetPos;
                var drawCamCrossHairRight     = new Vector2(0 + 15, 0) + drawnCamIteratedOffsetPos;
                var drawCamCrossHairUp        = new Vector2(0, 0 - 15) + drawnCamIteratedOffsetPos;
                var drawCamCrossHairDown      = new Vector2(0, 15) + drawnCamIteratedOffsetPos;

                // draw curved segmented output.
                var curveLineSegments = wayPointCurvature.GetCurveLineSegments;
                for (int i = 0; i < curveLineSegments.Count; i++)
                {
                    var segment = curveLineSegments[i];
                    if (i % 2 == 0)
                    {
                        DrawHelpers.DrawBasicLine(new Vector2(segment.Start.X, segment.Start.Y), new Vector2(segment.End.X, segment.End.Y), 1, Color.Black);
                    }
                    else
                    {
                        DrawHelpers.DrawBasicLine(new Vector2(segment.Start.X, segment.Start.Y), new Vector2(segment.End.X, segment.End.Y), 1, Color.Blue);
                    }
                }

                // Draw forward camera direction
                DrawHelpers.DrawBasicLine(drawnCamPos, drawnCamForawrdRay + drawnCamPos, 1, Color.Yellow);
                // Draw camera crosshairs forward to target.
                DrawHelpers.DrawBasicLine(drawnCamTargetPos, drawnCamIteratedOffsetPos, 1, Color.Yellow);
                // Draw a line from camera crosshairs to current position on way point curve.
                DrawHelpers.DrawBasicLine(drawnCamIteratedPos, drawnCamIteratedOffsetPos, 1, Color.White);
                // Draw cross hair for camera position
                DrawHelpers.DrawBasicLine(drawCamCrossHairLeft, drawCamCrossHairRight, 1, Color.Blue);
                DrawHelpers.DrawBasicLine(drawCamCrossHairUp, drawCamCrossHairDown, 1, Color.Blue);
                // Draw current 2d waypoint positions on the orthographic xy plane.
                foreach (var p in wayPointReference)
                {
                    DrawHelpers.DrawBasicPoint(new Vector2(p.X, p.Y), Color.White);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Tells the camera to execute a visualization of the waypoint camera path.
        /// </summary>
        /// <param name="scale">Scale of visualization</param>
        /// <param name="offset">positional offset on screen</param>
        /// <param name="PlaneOption">change of the signifigant input offsets to , xyz  0 = xy0, 1 =x0y, 2 = 0yz</param>
        /// <param name="gameTime"></param>
        public void DrawCurveThruWayPointsWithSpriteBatch(float scale, Vector3 offset, int PlaneOption, GameTime gameTime)
        {
            if (wayPointCurvature != null)
            {
                Vector2 offset2d = Get2dVectorAxisElements(offset, PlaneOption);
                // current 2d camera position and forward on the orthographic xy plane.
                var camTargetPos = Get2dVectorAxisElements(_targetLookAtPos, PlaneOption);
                var camPosition  = Get3dTwistedVectorAxisElements(_cameraWorld.Translation, PlaneOption);
                var camForward   = Get3dTwistedVectorAxisElements(_cameraWorld.Forward, PlaneOption);
                //
                var     drawnCam2dHeightAdjustment = new Vector2(0, camPosition.Z * -.5f) * scale;
                var     drawnCamTargetPos = camTargetPos * scale + offset2d;
                var     drawnCamForwardRay = new Vector2(camForward.X, camForward.Y) * 15;
                var     drawnCamIteratedPos = new Vector2(camPosition.X, camPosition.Y) * scale + offset2d;
                var     drawnCamIteratedOffsetPos = drawnCamIteratedPos + drawnCam2dHeightAdjustment * scale;
                var     drawCamForwardRayEndPoint = drawnCamIteratedPos + drawnCamForwardRay;
                Vector2 drawCrossHairLeft, drawCrossHairRight, drawCrossHairUp, drawCrossHairDown;
                GetIndividualCrossHairVectors(drawnCamIteratedOffsetPos, 7, out drawCrossHairLeft, out drawCrossHairRight, out drawCrossHairUp, out drawCrossHairDown);

                // Draw cross hair for camera position
                DrawHelpers.DrawBasicLine(drawCrossHairLeft, drawCrossHairRight, 1, Color.White);
                DrawHelpers.DrawBasicLine(drawCrossHairUp, drawCrossHairDown, 1, Color.White);

                // Draw a line from camera from current position on way point curve to offset position.
                if (drawnCam2dHeightAdjustment.Y < 0)
                {
                    DrawHelpers.DrawBasicLine(drawnCamIteratedPos, drawnCamIteratedOffsetPos, 1, Color.LightGreen);
                }
                else
                {
                    DrawHelpers.DrawBasicLine(drawnCamIteratedPos, drawnCamIteratedOffsetPos, 1, Color.Red);
                }

                // Draw forward camera direction
                DrawHelpers.DrawBasicLine(drawnCamIteratedPos, drawCamForwardRayEndPoint, 1, Color.Beige);
                // Draw camera crosshairs forward to target.
                DrawHelpers.DrawBasicLine(drawnCamIteratedOffsetPos, drawCamForwardRayEndPoint, 1, Color.Yellow);

                // draw curved segmented output.
                var curveLineSegments = wayPointCurvature.GetCurveLineSegments;
                for (int i = 0; i < curveLineSegments.Count; i++)
                {
                    var segment = curveLineSegments[i];
                    var start   = Get2dVectorAxisElements(segment.Start, PlaneOption) * scale + offset2d;
                    var end     = Get2dVectorAxisElements(segment.End, PlaneOption) * scale + offset2d;

                    if (i % 2 == 0)
                    {
                        DrawHelpers.DrawBasicLine(start, end, 1, Color.Black);
                    }
                    else
                    {
                        DrawHelpers.DrawBasicLine(start, end, 1, Color.Blue);
                    }
                }

                // Draw current 2d waypoint positions on the orthographic xy plane.
                foreach (var p in wayPointReference)
                {
                    var waypointPos = Get2dVectorAxisElements(p, PlaneOption) * scale + offset2d;
                    GetIndividualCrossHairVectors(waypointPos, 4, out drawCrossHairLeft, out drawCrossHairRight, out drawCrossHairUp, out drawCrossHairDown);
                    DrawHelpers.DrawBasicLine(drawCrossHairLeft, drawCrossHairRight, 1, Color.DarkGray);
                    DrawHelpers.DrawBasicLine(drawCrossHairUp, drawCrossHairDown, 1, Color.DarkGray);
                }
            }
        }
 public static void DrawCrossHair(Vector2 position, float radius, Color color)
 {
     DrawHelpers.DrawBasicLine(new Vector2(-radius, 0) + position, new Vector2(0 + radius, 0) + position, 1, color);
     DrawHelpers.DrawBasicLine(new Vector2(0, 0 - radius) + position, new Vector2(0, radius) + position, 1, color);
 }