Пример #1
0
        /// <summary>
        ///     Se llama cada vez que hay que refrescar la pantalla.
        ///     Escribir aquí todo el código referido al renderizado.
        /// </summary>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.SetRenderTarget(RenderTarget);
            GraphicsDevice.Clear(Color.CornflowerBlue);

            SphereModel.Draw(LavaSphereWorld, Camera.View, Camera.Projection, LavaTexture);
            SphereModel.Draw(WaterSphereWorld, Camera.View, Camera.Projection, WaterTexture);
            SphereModel.Draw(RockSphereWorld, Camera.View, Camera.Projection, RockTexture);
            FloorQuad.Draw(FloorWorld, Camera.View, Camera.Projection, FloorTexture);

            DrawRobot();

            if (LightingEnabled)
            {
                LightCube.Draw(Matrix.CreateTranslation(LightOnePosition), Camera.View, Camera.Projection, Color.Red);
                LightCube.Draw(Matrix.CreateTranslation(LightTwoPosition), Camera.View, Camera.Projection, Color.Blue);
            }

            GraphicsDevice.SetRenderTarget(null);
            GraphicsDevice.Clear(Color.Black);

            Effect.CurrentTechnique = Effect.Techniques["PostProcessing"];
            Effect.Parameters["ModelTexture"].SetValue(RenderTarget);
            FullScreenQuad.Draw(Effect);



            base.Draw(gameTime);
        }
Пример #2
0
        /// <summary>
        ///     Libero los recursos que se cargaron en el juego.
        /// </summary>
        protected override void UnloadContent()
        {
            // Libero los recursos.
            Content.Unload();

            FloorQuad.Dispose();
            SphereModel.Dispose();
            FullScreenQuad.Dispose();

            if (LightingEnabled)
            {
                LightCube.Dispose();
            }
            base.UnloadContent();
        }
        /// <summary>
        /// Instruct the robot to pick up his LightCube.
        /// <para>While picking up the cube, Vector will use path planning.</para><para>Note that actions that use the wheels cannot be performed at the same time, otherwise you may see a TRACKS_LOCKED error.</para>
        /// </summary>
        /// <remarks>Requires behavior control; see <see cref="ControlComponent.RequestControl(int)"/>.</remarks>
        /// <param name="lightCube">The light cube.</param>
        /// <param name="usePreDockPose">Whether or not to try to immediately pick up an object or first position the robot next to the object.</param>
        /// <param name="numRetries">Number of times to reattempt action in case of a failure.</param>
        /// <returns>A task that represents the asynchronous operation; the task result contains the result from the robot.</returns>
        /// <exception cref="System.ArgumentException">Light cube object must be provided. - lightCube</exception>
        public async Task <ActionResult> PickupObject(LightCube lightCube, bool usePreDockPose = true, int numRetries = 0)
        {
            if (lightCube == null)
            {
                throw new ArgumentException("Light cube object must be provided.", nameof(lightCube));
            }

            var response = await RunAction((client, cancellationToken, idTag) => client.PickupObjectAsync(new PickupObjectRequest()
            {
                IdTag          = idTag,
                UsePreDockPose = usePreDockPose,
                ObjectId       = lightCube.ObjectId,
                NumRetries     = numRetries
            }, cancellationToken: cancellationToken)).ConfigureAwait(false);

            return(new ActionResult(response.Status.Code, response.Result.Code));
        }
        /// <summary>
        /// Tells Vector to dock with a light cube, optionally using a given approach angle and distance.
        /// <para>While docking with the cube, Vector will use path planning.</para>
        /// </summary>
        /// <remarks>Requires behavior control; see <see cref="ControlComponent.RequestControl(int)"/>.</remarks>
        /// <param name="lightCube">The light cube.</param>
        /// <param name="approachAngle">The approach angle in radians.</param>
        /// <param name="alignment">Which part of the robot to align with the object.</param>
        /// <param name="distanceFromMarker">The distance from marker in mm (0 to dock).</param>
        /// <param name="numRetries">Number of times to re-attempt action in case of a failure.</param>
        /// <returns>A task that represents the asynchronous operation; the task result contains the result from the robot.</returns>
        public async Task <ActionResult> DockWithCube(LightCube lightCube, float?approachAngle = null, AlignmentType alignment = AlignmentType.LiftPlate, float distanceFromMarker = 0f, int numRetries = 0)
        {
            var response = await RunAction((client, cancellationToken, idTag) => client.DockWithCubeAsync(new DockWithCubeRequest()
            {
                IdTag                = idTag,
                AlignmentType        = (ExternalInterface.AlignmentType)alignment,
                MotionProf           = MotionProfile.ToPathMotionProfile(),
                ObjectId             = lightCube.ObjectId,
                ApproachAngleRad     = approachAngle ?? 0,
                UseApproachAngle     = approachAngle.HasValue,
                UsePreDockPose       = approachAngle.HasValue,
                DistanceFromMarkerMm = distanceFromMarker,
                NumRetries           = numRetries
            }, cancellationToken: cancellationToken)).ConfigureAwait(false);

            return(new ActionResult(response.Status.Code, response.Result.Code));
        }