Integrating the functioning camera and rectangle renderer.

This commit is contained in:
Harrison Deng 2019-02-25 21:40:07 -06:00
parent 99e4530407
commit 653a7de562
4 changed files with 54 additions and 26 deletions

Binary file not shown.

View File

@ -49,6 +49,11 @@
The graphics device used
</summary>
</member>
<member name="P:RecrownedAthenaeum.Camera.Camera3D.BasicEffect">
<summary>
The basic effect that contains the transformations.
</summary>
</member>
<member name="M:RecrownedAthenaeum.Camera.Camera3D.#ctor(Microsoft.Xna.Framework.Graphics.GraphicsDevice)">
<summary>
Constructs 3D camera with an orthographic projection matrix with dimensions of graphics devices viewport. All changes to matrices should have apply called after changes.
@ -60,10 +65,11 @@
Applies the changes to the fields and properties of the camera.
</summary>
</member>
<member name="M:RecrownedAthenaeum.Camera.Camera3D.Center">
<member name="M:RecrownedAthenaeum.Camera.Camera3D.MoveCamera(Microsoft.Xna.Framework.Vector3)">
<summary>
Centers the camera to middle of width and height of game window.
Moves camera by the given amount.
</summary>
<param name="move">A <see cref="T:Microsoft.Xna.Framework.Vector3"/> that contains how much in each direction to move.</param>
</member>
<member name="T:RecrownedAthenaeum.Camera.Camera2D">
<summary>
@ -75,12 +81,23 @@
The 2D position.
</summary>
</member>
<member name="P:RecrownedAthenaeum.Camera.Camera2D.CenterPosition">
<summary>
Places camera in the center given the corner position.
</summary>
</member>
<member name="M:RecrownedAthenaeum.Camera.Camera2D.#ctor(Microsoft.Xna.Framework.Graphics.GraphicsDevice)">
<summary>
A 2D camera from the generic <see cref="T:RecrownedAthenaeum.Camera.Camera3D"/>.
</summary>
<param name="graphicsDevice">The graphics device to use if not using the one in <see cref="T:RecrownedAthenaeum.Configuration"/>.</param>
</member>
<member name="M:RecrownedAthenaeum.Camera.Camera2D.Apply">
<summary>
Applies for 2D.
Sets where the camera is looking for the view matrix to the position of the camera.
</summary>
</member>
<member name="M:RecrownedAthenaeum.Camera.Camera2D.LinearInterpolationToPosition(System.Single,Microsoft.Xna.Framework.Vector2,System.Single)">
<summary>
Lerps to the given position.
@ -89,6 +106,13 @@
<param name="targetPosition">The target position to lerp to.</param>
<param name="delta">Time between this frame and the previous frame.</param>
</member>
<member name="M:RecrownedAthenaeum.Camera.Camera2D.MoveCamera(Microsoft.Xna.Framework.Vector2)">
<summary>
Moves the camera.
Apply needs to be called.
</summary>
<param name="move">Magnitude of how much to move per axis.</param>
</member>
<member name="T:RecrownedAthenaeum.ContentSystem.ContentManagerController">
<summary>
Wrapper for the content manager that helps with controlling it by adding automated multithreaded content loading.
@ -742,24 +766,36 @@
The <see cref="T:RecrownedAthenaeum.Render.PrimitiveBatch"/> used. Needs to be disposed.
</summary>
</member>
<member name="M:RecrownedAthenaeum.Render.RectangleRenderer.#ctor(RecrownedAthenaeum.Render.PrimitiveBatch)">
<member name="M:RecrownedAthenaeum.Render.RectangleRenderer.#ctor(RecrownedAthenaeum.Camera.Camera2D,Microsoft.Xna.Framework.Graphics.GraphicsDevice)">
<summary>
Creates a rectangle renderer with the given <see cref="T:RecrownedAthenaeum.Render.PrimitiveBatch"/>.
</summary>
<param name="primitiveBatch"></param>
<param name="camera">Camera to use for <see cref="T:RecrownedAthenaeum.Render.PrimitiveBatch"/>. Default will use <see cref="T:RecrownedAthenaeum.Configuration"/>.</param>
<param name="graphicsDevice">Graphics device to use. Default will use <see cref="T:RecrownedAthenaeum.Configuration"/>.</param>
</member>
<member name="M:RecrownedAthenaeum.Render.RectangleRenderer.Dispose">
<summary>
Disposes the rectangle renderer.
</summary>
</member>
<member name="M:RecrownedAthenaeum.Render.RectangleRenderer.Dispose(System.Boolean)">
<summary>
Overridable for dispose.
</summary>
<param name="disposing">True when its a player calling the dispose.</param>
</member>
<member name="M:RecrownedAthenaeum.Render.RectangleRenderer.Begin(System.Boolean)">
<summary>
Begins the render batch.
Begins a batch for rectangles.
</summary>
<param name="filled">Whether or not to fill the rectangle.</param>
<param name="filled">Whether or not this batch should be filled rectangles.</param>
</member>
<member name="M:RecrownedAthenaeum.Render.RectangleRenderer.End">
<summary>
Ends the batch.
</summary>
</member>
<member name="M:RecrownedAthenaeum.Render.RectangleRenderer.DrawRectangle(System.Int32,System.Int32,System.Int32,System.Int32,Microsoft.Xna.Framework.Color,System.Double)">
<member name="M:RecrownedAthenaeum.Render.RectangleRenderer.Draw(System.Int32,System.Int32,System.Int32,System.Int32,Microsoft.Xna.Framework.Color,System.Single)">
<summary>
Draws a basic rectangle given bottom left and top right.
</summary>
@ -775,9 +811,9 @@
A batch used to draw primitive shapes by batching together vertices.
</summary>
</member>
<member name="P:RecrownedAthenaeum.Render.PrimitiveBatch.MaxVertices">
<member name="F:RecrownedAthenaeum.Render.PrimitiveBatch.primitiveCount">
<summary>
The maximum vertices expected. The further off this expectancy is from the true value, the less efficient.
Amount of primitives.
</summary>
</member>
<member name="M:RecrownedAthenaeum.Render.PrimitiveBatch.#ctor(RecrownedAthenaeum.Camera.Camera2D,Microsoft.Xna.Framework.Graphics.GraphicsDevice,System.Int32)">
@ -809,6 +845,7 @@
<member name="M:RecrownedAthenaeum.Render.PrimitiveBatch.Flush">
<summary>
Flushes the batch. Automatically called if required if using <see cref="F:Microsoft.Xna.Framework.Graphics.PrimitiveType.LineList"/> or <see cref="F:Microsoft.Xna.Framework.Graphics.PrimitiveType.TriangleList"/>. Otherwise, manual flushing is required.
<see cref="F:RecrownedAthenaeum.Render.PrimitiveBatch.primitiveCount"/> is used if not zero. Is reset to zero every flush.
</summary>
</member>
<member name="M:RecrownedAthenaeum.Render.PrimitiveBatch.Dispose">

View File

@ -10,8 +10,7 @@ namespace RhythmBullet.Audio.Visualizer
internal class HorizontalVisualizer : UIModule, IDisposable
{
bool disposed;
private PrimitiveBatch primitiveBatch;
private RectangleRenderer renderer;
private RectangleRenderer rectangleRenderer;
private const int BAR_COUNT = 70;
private const int SMOOTH_RANGE = 3;
private readonly int binsPerBar;
@ -29,8 +28,7 @@ namespace RhythmBullet.Audio.Visualizer
binsPerBar = tsp.GetCurrentSpectrum().Length / BAR_COUNT;
barValue = new int[BAR_COUNT];
primitiveBatch = new PrimitiveBatch(camera2D);
renderer = new RectangleRenderer(primitiveBatch);
rectangleRenderer = new RectangleRenderer();
}
public override void Update(GameTime gameTime)
@ -44,18 +42,19 @@ namespace RhythmBullet.Audio.Visualizer
public override void Draw(SpriteBatch batch)
{
if (disposed) throw new ObjectDisposedException(this.Name);
rectangleRenderer.Begin(true);
for (int i = 0; i < BAR_COUNT; i++)
{
bar.X = (i * (bar.Width + spaceBetweenBars)) + bounds.X;
bar.Y = bounds.Y;
renderer.Begin(true);
bar.Height = barValue[i];
renderer.DrawRectangle(bar.X, bar.Y, bar.Width, bar.Height, color);
rectangleRenderer.Draw(bar.X, bar.Y, bar.Width, bar.Height, color);
bar.Height = -barValue[BAR_COUNT - i - 1];
renderer.DrawRectangle(bar.X, bar.Y, bar.Width, bar.Height, color);
rectangleRenderer.Draw(bar.X, bar.Y, bar.Width, bar.Height, color);
}
rectangleRenderer.End();
base.Draw(batch);
}
@ -112,7 +111,7 @@ namespace RhythmBullet.Audio.Visualizer
{
if (disposing && !disposed)
{
primitiveBatch.Dispose();
rectangleRenderer.Dispose();
}
disposed = true;
}

View File

@ -16,10 +16,9 @@ namespace RhythmBullet.Screens.MainMenu
TextButton playButton;
TextButton quitButton;
PrimitiveBatch primitiveBatch = new PrimitiveBatch();
internal MainPage() : base(0, 0)
{
Debugging = true;
}
protected override void Initialize(ContentManagerController assets, ISkin skin)
@ -39,9 +38,6 @@ namespace RhythmBullet.Screens.MainMenu
public override void ApplySize(int width, int height)
{
title.Scale = (width - 40) / title.Texture.Width;
title.CenterOrigin();
title.bounds.X = (int)(width / 2f);
title.bounds.Y = (int)(height / 2f);
base.ApplySize(width, height);
}
@ -49,10 +45,6 @@ namespace RhythmBullet.Screens.MainMenu
public override void Draw(SpriteBatch batch)
{
base.Draw(batch);
primitiveBatch.Begin(PrimitiveType.LineList);
primitiveBatch.AddVertex(new Vector2(20, 20), Color.Red);
primitiveBatch.AddVertex(new Vector2(50, 60), Color.Red);
primitiveBatch.End();
}
}
}