Skip to content

Commit

Permalink
Code clean y fix PlaySound3D #48
Browse files Browse the repository at this point in the history
  • Loading branch information
rejurime committed Jul 30, 2016
1 parent f4b42fa commit 1cef658
Show file tree
Hide file tree
Showing 50 changed files with 396 additions and 356 deletions.
12 changes: 7 additions & 5 deletions TGC.Core/Camara/TgcFpsCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public class TgcFpsCamera : TgcCamera
private Vector3 positionEye;
private float updownRot = -FastMath.PI / 10.0f;

private TgcD3dInput Input { get; set; }

public TgcFpsCamera(TgcD3dInput input)
{
Input = input;
Expand All @@ -46,7 +44,7 @@ public TgcFpsCamera(TgcD3dInput input)
}

/// <summary>
/// Crea una camara con una posicion y una direccion IMPORTANTE!!!! la direccion debe estar normalizada.
/// Crea una camara con una posicion y una direccion IMPORTANTE!!!! la direccion debe estar normalizada.
/// </summary>
/// <param name="positionEye"></param>
/// <param name="directionView"></param>
Expand All @@ -62,18 +60,22 @@ public TgcFpsCamera(Vector3 positionEye, TgcD3dInput input) : this(input)
this.positionEye = positionEye;
}

public TgcFpsCamera(Vector3 positionEye, float moveSpeed, float jumpSpeed, TgcD3dInput input) : this(positionEye, input)
public TgcFpsCamera(Vector3 positionEye, float moveSpeed, float jumpSpeed, TgcD3dInput input)
: this(positionEye, input)
{
MovementSpeed = moveSpeed;
JumpSpeed = jumpSpeed;
}

public TgcFpsCamera(Vector3 positionEye, float moveSpeed, float jumpSpeed, float rotationSpeed, TgcD3dInput input)
public TgcFpsCamera(Vector3 positionEye, float moveSpeed, float jumpSpeed, float rotationSpeed,
TgcD3dInput input)
: this(positionEye, moveSpeed, jumpSpeed, input)
{
RotationSpeed = rotationSpeed;
}

private TgcD3dInput Input { get; }

public bool LockCam
{
get { return lockCam; }
Expand Down
6 changes: 4 additions & 2 deletions TGC.Core/Camara/TgcRotationalCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class TgcRotationalCamera : TgcCamera
public static float DEFAULT_CAMERA_DISTANCE = 10f;
public static float DEFAULT_ROTATION_SPEED = 100f;
public static Vector3 DEFAULT_DOWN = new Vector3(0f, -1f, 0f);
private TgcD3dInput Input { get; set; }

/// <summary>
/// Crea camara con valores por defecto.
Expand Down Expand Up @@ -54,7 +53,8 @@ public TgcRotationalCamera(Vector3 position, Vector3 target, TgcD3dInput input)
/// <param name="cameraDistance"></param>
/// <param name="zoomFactor"></param>
/// <param name="rotationSpeed"></param>
public TgcRotationalCamera(Vector3 cameraCenter, float cameraDistance, float zoomFactor, float rotationSpeed, TgcD3dInput input)
public TgcRotationalCamera(Vector3 cameraCenter, float cameraDistance, float zoomFactor, float rotationSpeed,
TgcD3dInput input)
: this(input)
{
CameraCenter = cameraCenter;
Expand Down Expand Up @@ -84,6 +84,8 @@ public TgcRotationalCamera(Vector3 cameraCenter, float cameraDistance, TgcD3dInp
{
}

private TgcD3dInput Input { get; }

/// <summary>
/// Actualiza los valores de la camara.
/// </summary>
Expand Down
10 changes: 5 additions & 5 deletions TGC.Core/Example/TgcExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected void UpdateSounds3D()
}

/// <summary>
/// Limpia la pantalla y inicia la escena 3D
/// Limpia la pantalla y inicia la escena 3D
/// </summary>
protected void BeginRenderScene()
{
Expand All @@ -198,7 +198,7 @@ protected void BeginRenderScene()
}

/// <summary>
/// Inicia la escena 3D
/// Inicia la escena 3D
/// </summary>
public void BeginScene()
{
Expand Down Expand Up @@ -236,7 +236,7 @@ protected void RenderFPS()
}

/// <summary>
/// Finaliza y presenta (se debe hacer al final del render) la escena 3D
/// Finaliza y presenta (se debe hacer al final del render) la escena 3D
/// </summary>
protected void EndRenderScene()
{
Expand All @@ -245,7 +245,7 @@ protected void EndRenderScene()
}

/// <summary>
/// Finaliza una escena que se inicio con un BeginScene()
/// Finaliza una escena que se inicio con un BeginScene()
/// </summary>
private static void EndScene()
{
Expand Down Expand Up @@ -278,4 +278,4 @@ public virtual void ResetDefaultConfig()
ElapsedTime = -1;
}
}
}
}
4 changes: 2 additions & 2 deletions TGC.Core/Geometry/TgcPickingRay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ namespace TGC.Core.Geometry
/// </summary>
public class TgcPickingRay
{
private TgcD3dInput Input { get; set; }

public TgcPickingRay(TgcD3dInput input)
{
Input = input;
Ray = new TgcRay();
}

private TgcD3dInput Input { get; }

/// <summary>
/// Ray que representa la accion de Picking
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion TGC.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
// associated with an assembly.

[assembly: AssemblyTitle("TGC.Core")]
[assembly: AssemblyDescription("Libreria de renderizado 3D académico utilizado para realizar los trabajos prácticos de la asignatura electiva Técnicas de Gráficos por Computadora (TGC) en la carrera de Ingeniería en Sistemas de Información. Universidad Tecnológica Nacional, Facultad Regional Buenos Aires (UTN-FRBA).")]
[assembly:
AssemblyDescription(
"Libreria de renderizado 3D académico utilizado para realizar los trabajos prácticos de la asignatura electiva Técnicas de Gráficos por Computadora (TGC) en la carrera de Ingeniería en Sistemas de Información. Universidad Tecnológica Nacional, Facultad Regional Buenos Aires (UTN-FRBA)."
)]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("TGC - UTN.BA")]
[assembly: AssemblyProduct("TGC.Core")]
Expand Down
2 changes: 1 addition & 1 deletion TGC.Core/SceneLoader/TgcMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public TgcMesh(string name, TgcMesh parentInstance, Vector3 translation, Vector3
initData(parentInstance.d3dMesh, name, parentInstance.renderType);
//Si no se hace clone luego no pueden cambiar las texturas.
diffuseMaps = new TgcTexture[parentInstance.diffuseMaps.Length];
for (int i = 0; i < diffuseMaps.Length; i++)
for (var i = 0; i < diffuseMaps.Length; i++)
{
diffuseMaps[i] = parentInstance.diffuseMaps[i].Clone();
}
Expand Down
29 changes: 15 additions & 14 deletions TGC.Core/Text/TgcText2D.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.DirectX.Direct3D;
using System;
using System.Drawing;
using Microsoft.DirectX.Direct3D;
using TGC.Core.Direct3D;
using Font = Microsoft.DirectX.Direct3D.Font;
using Font = System.Drawing.Font;

namespace TGC.Core.Text
{
Expand All @@ -18,13 +18,12 @@ public enum TextAlign
CENTER
}

private TextAlign align;

//font default.
public static readonly System.Drawing.Font VERDANA_10 = new System.Drawing.Font("Verdana", 10, FontStyle.Regular, GraphicsUnit.Pixel);
public static readonly Font VERDANA_10 = new Font("Verdana", 10, FontStyle.Regular, GraphicsUnit.Pixel);

private TextAlign align;

private Rectangle rectangle;
private Sprite TextSprite { get; set; }

public TgcText2D()
{
Expand All @@ -37,10 +36,12 @@ public TgcText2D()
rectangle = new Rectangle(0, 0, D3DDevice.Instance.Width, D3DDevice.Instance.Height);
}

private Sprite TextSprite { get; }

/// <summary>
/// Fuente de Direct3D para la letra del texto
/// </summary>
public Font D3dFont { get; private set; }
public Microsoft.DirectX.Direct3D.Font D3dFont { get; private set; }

/// <summary>
/// Color del texto
Expand Down Expand Up @@ -85,6 +86,11 @@ public TextAlign Align
set { changeTextAlign(value); }
}

public void Dispose()
{
D3dFont.Dispose();
}

public void render()
{
TextSprite.Begin(SpriteFlags.AlphaBlend);
Expand All @@ -96,11 +102,11 @@ public void render()
/// Cambia la fuente del texto
/// </summary>
/// <param name="font">Fuente del sistema</param>
public void changeFont(System.Drawing.Font font)
public void changeFont(Font font)
{
if (D3dFont != null && !D3dFont.Disposed)
D3dFont.Dispose();
D3dFont = new Font(D3DDevice.Instance.Device, font);
D3dFont = new Microsoft.DirectX.Direct3D.Font(D3DDevice.Instance.Device, font);
}

/// <summary>
Expand Down Expand Up @@ -141,10 +147,5 @@ public void drawText(string text, int x, int y, Color color)
D3dFont.DrawText(TextSprite, text, x, y, color);
TextSprite.End();
}

public void Dispose()
{
D3dFont.Dispose();
}
}
}
2 changes: 1 addition & 1 deletion TGC.Examples/Animation/KeyFrameAnimation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Drawing;
using Microsoft.DirectX;
using System.Drawing;
using TGC.Core.Camara;
using TGC.Core.KeyFrameLoader;
using TGC.Core.UserControls;
Expand Down
2 changes: 1 addition & 1 deletion TGC.Examples/Animation/SkeletalAnimation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Drawing;
using Microsoft.DirectX;
using System.Drawing;
using TGC.Core.Camara;
using TGC.Core.Geometry;
using TGC.Core.SkeletalAnimation;
Expand Down
2 changes: 1 addition & 1 deletion TGC.Examples/Engine2D/Spaceship/Asteroide.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.DirectX;
using System;
using System.Collections.Generic;
using System.Drawing;
using Microsoft.DirectX;
using TGC.Examples.Engine2D.Spaceship.Core;

namespace TGC.Examples.Engine2D.Spaceship
Expand Down
10 changes: 5 additions & 5 deletions TGC.Examples/Engine2D/Spaceship/Core/AnimatedSprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class AnimatedSprite : CustomSprite
/// <param name="frameSize">tamaño de un tile de la animacion</param>
/// <param name="totalFrames">cantidad de frames que tiene la animacion</param>
/// <param name="frameRate">velocidad en cuadros por segundo</param>
public AnimatedSprite(string texturePath, Size frameSize, int totalFrames, float frameRate) : base()
public AnimatedSprite(string texturePath, Size frameSize, int totalFrames, float frameRate)
{
enabled = true;
currentFrame = 0;
Expand All @@ -44,11 +44,11 @@ public AnimatedSprite(string texturePath, Size frameSize, int totalFrames, float
playing = true;

//Sprite
this.Bitmap = new CustomBitmap(texturePath, D3DDevice.Instance.Device);
Bitmap = new CustomBitmap(texturePath, D3DDevice.Instance.Device);

//Calcular valores de frames de la textura
textureWidth = this.Bitmap.Width;
textureHeight = this.Bitmap.Height;
textureWidth = Bitmap.Width;
textureHeight = Bitmap.Height;
framesPerColumn = (int)textureWidth / frameSize.Width;
framesPerRow = (int)textureHeight / frameSize.Height;
var realTotalFrames = framesPerRow * framesPerColumn;
Expand Down Expand Up @@ -134,7 +134,7 @@ public void update(float elapsedTime)
srcRect.Width = frameSize.Width;
srcRect.X = frameSize.Height * (currentFrame % framesPerColumn);
srcRect.Height = frameSize.Height;
this.SrcRect = srcRect;
SrcRect = srcRect;
}
}
}
2 changes: 1 addition & 1 deletion TGC.Examples/Engine2D/Spaceship/Core/CustomBitmap.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.DirectX.Direct3D;
using System;
using System.Drawing;
using Microsoft.DirectX.Direct3D;

namespace TGC.Examples.Engine2D.Spaceship.Core
{
Expand Down
26 changes: 13 additions & 13 deletions TGC.Examples/Engine2D/Spaceship/Core/CustomSprite.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.DirectX;
using System;
using System.Drawing;
using Microsoft.DirectX;

namespace TGC.Examples.Engine2D.Spaceship.Core
{
Expand All @@ -11,6 +11,18 @@ public CustomSprite()
initialize();
}

#region Miembros de IDisposable

public void Dispose()
{
if (Bitmap != null)
{
Bitmap.Dispose();
}
}

#endregion Miembros de IDisposable

private void initialize()
{
//Set the identity matrix.
Expand Down Expand Up @@ -132,17 +144,5 @@ public Vector2 Scaling
}

#endregion Public members

#region Miembros de IDisposable

public void Dispose()
{
if (Bitmap != null)
{
Bitmap.Dispose();
}
}

#endregion Miembros de IDisposable
}
}
6 changes: 3 additions & 3 deletions TGC.Examples/Engine2D/Spaceship/Core/Drawer2D.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Drawing;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using System.Drawing;
using TGC.Core.Direct3D;

namespace TGC.Examples.Engine2D.Spaceship.Core
Expand All @@ -10,15 +10,15 @@ namespace TGC.Examples.Engine2D.Spaceship.Core
/// </summary>
public class Drawer2D
{
private readonly Microsoft.DirectX.Direct3D.Sprite DxSprite;
private readonly Sprite DxSprite;
private readonly Line line;

private readonly CustomVertex.PositionColoredTextured[] LineVertexData =
new CustomVertex.PositionColoredTextured[2];

public Drawer2D()
{
DxSprite = new Microsoft.DirectX.Direct3D.Sprite(D3DDevice.Instance.Device);
DxSprite = new Sprite(D3DDevice.Instance.Device);
line = new Line(D3DDevice.Instance.Device);
}

Expand Down
4 changes: 2 additions & 2 deletions TGC.Examples/Engine2D/Spaceship/GameManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Microsoft.DirectX;
using System;
using System.Collections.Generic;
using Microsoft.DirectX;
using TGC.Core.Direct3D;
using TGC.Core.Input;
using TGC.Core.UserControls;
Expand Down
2 changes: 1 addition & 1 deletion TGC.Examples/Engine2D/Spaceship/Misil.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Microsoft.DirectX;
using System;
using TGC.Examples.Engine2D.Spaceship.Core;

namespace TGC.Examples.Engine2D.Spaceship
Expand Down
4 changes: 2 additions & 2 deletions TGC.Examples/Engine2D/Spaceship/Spaceship.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.DirectX;
using Microsoft.DirectX.DirectInput;
using System;
using System.Collections.Generic;
using System.Drawing;
using Microsoft.DirectX;
using Microsoft.DirectX.DirectInput;
using TGC.Core.Input;
using TGC.Examples.Engine2D.Spaceship.Core;

Expand Down
Loading

0 comments on commit 1cef658

Please sign in to comment.