/// <summary> /// Draws the circle by the specified center, radius and color. /// </summary> /// <param name="center">The center of the circle.</param> /// <param name="radius">The radius of the circle.</param> /// <param name="color">The color of the circle.</param> /// <param name="sceneBatch">The scene batch for drawing the circle.</param> public static void DrawCircle(Vector2 center, float radius, Color color, SceneBatch sceneBatch) { if (graphicsDevice == null) { throw new Exception("No graphics device"); } // set effect parameters circleEffect.Parameters["Thickness"].SetValue(2.5f / radius * sceneBatch.InversScale); circleEffect.Parameters["BaseColor"].SetValue(color.ToVector4()); circleEffect.Parameters["Center"].SetValue(new Vector3(center.X, center.Y, 0f)); circleEffect.Parameters["Radius"].SetValue(radius); circleEffect.Parameters["xProjection"].SetValue(sceneBatch.Projection); circleEffect.Parameters["xView"].SetValue(sceneBatch.View); circleEffect.Parameters["xWorld"].SetValue(sceneBatch.World); // set blend state BlendState temp = graphicsDevice.BlendState = BlendState.NonPremultiplied; // draw circle circleEffect.CurrentTechnique.Passes[0].Apply(); graphicsDevice.SetVertexBuffer(vertexBuffer); graphicsDevice.DrawUserIndexedPrimitives <QuadVertex>(PrimitiveType.TriangleList, vertices, 0, 4, indices, 0, 2); // set previous blend state graphicsDevice.BlendState = temp; }
/// <inheritdoc /> /// <summary> /// Draws the vertex circles. /// </summary> public override void Draw(SceneBatch sceneBatch) { base.Draw(sceneBatch); for (int i = 0; i < Path.Vertices.Count; ++i) { Color color = i == hoveredVertex ? Color.Yellow : i == Path.Vertices.Count - 1 ? Color.Blue : Color.Red; PlatformGameCreator.Editor.Xna.RenderCircle.DrawCircle(pathView.Path.Vertices[i], vertexRadius * sceneBatch.InversScale, color, sceneBatch); } }
/// <inheritdoc /> public override void DrawShapes(SceneBatch sceneBatch) { if (containsShapes && Actor.Physics.Type != PhysicsComponent.BodyPhysicsType.None) { Color color = ColorSettings.ForShape(SceneSelect); foreach (Shape shape in Shapes) { sceneBatch.Draw(shape, color, 0f); } } }
/// <inheritdoc /> /// <remarks> /// Before drawing the appearance of the actor is updated, if needed. /// Draws the actor and its bounding rectangle. /// </remarks> public override void Draw(SceneBatch sceneBatch) { if (updateAppearance) { UpdateAppearance(); updateAppearance = false; } if (Actor.DrawableAssetVisible && sceneDrawable != null) { sceneDrawable.Draw(sceneBatch, Position, Angle, ScaleFactor, Actor.Layer != null ? Actor.Layer.GraphicsEffect : SceneElementEffect.None); } sceneBatch.Draw(Rectangle, ColorSettings.ForBounds(SceneSelect), 0); }
/// <summary> /// Draws the animation (located by <paramref name="position"/> parameter, rotated by <paramref name="rotation"/> parameter and scaled by <paramref name="scale"/> parameter) by <paramref name="sceneBatch"/> parameter on the scene. /// </summary> /// <param name="sceneBatch">The scene batch for drawing the animation.</param> /// <param name="position">The position of the animation.</param> /// <param name="rotation">The rotation of the animation.</param> /// <param name="scale">The scale of the animation.</param> /// <param name="effect">Effect to apply to the animation.</param> public void Draw(SceneBatch sceneBatch, Vector2 position, float rotation, Vector2 scale, SceneElementEffect effect) { if (sceneBatch.GameTime != null) { elapsedTime += sceneBatch.GameTime.ElapsedGameTime.TotalMilliseconds; } if (elapsedTime >= Animation.Speed) { ++actualFrame; elapsedTime -= Animation.Speed; if (actualFrame >= Animation.Frames.Count) { actualFrame = 0; } } if (actualFrame < Animation.Frames.Count) { sceneBatch.DrawTexture(Animation.Frames[actualFrame].TextureXna, ref position, rotation, ref scale, Animation.Frames[actualFrame].Origin, effect); } }
/// <summary> /// Draws the texture (located by <paramref name="position"/> parameter, rotated by <paramref name="rotation"/> parameter and scaled by <paramref name="scale"/> parameter) by <paramref name="sceneBatch"/> parameter on the scene. /// </summary> /// <param name="sceneBatch">The scene batch for drawing the texture.</param> /// <param name="position">The position of the texture.</param> /// <param name="rotation">The rotation of the texture.</param> /// <param name="scale">The scale of the texture.</param> /// <param name="effect">Effect to apply to the texture.</param> public void Draw(SceneBatch sceneBatch, Vector2 position, float rotation, Vector2 scale, SceneElementEffect effect) { sceneBatch.DrawTexture(Texture.TextureXna, ref position, rotation, ref scale, Texture.Origin, effect); }
/// <inheritdoc /> /// <remarks> /// Nothing to draw. /// </remarks> public override void DrawShapes(SceneBatch sceneBatch) { }
/// <inheritdoc /> /// <remarks> /// Draws the path and its bounding rectangle. /// </remarks> public override void Draw(SceneBatch sceneBatch) { sceneBatch.Draw(Rectangle, ColorSettings.ForBounds(SceneSelect), 0f); sceneBatch.Draw(pathShape, ColorSettings.ForShape(SceneSelect), 0f); }