Skip to content

Commit

Permalink
Se unificaron un poco los metodos y propiedades en las geometrias #71
Browse files Browse the repository at this point in the history
  • Loading branch information
rejurime committed Aug 23, 2017
1 parent 736fe29 commit cefcb00
Show file tree
Hide file tree
Showing 37 changed files with 321 additions and 430 deletions.
16 changes: 6 additions & 10 deletions TGC.Core/Geometry/TGCSphere.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class TGCSphere : IRenderObject, ITransformObject
private int triangleCount;
private int levelOfDetail;
private float radius;
private Color color;
private TGCVector3 translation;
private TgcBoundingSphere boundingSphere;
private TGCVector2 uvOffset;
Expand Down Expand Up @@ -109,10 +108,7 @@ public virtual TGCVector3 Scale
/// <summary>
/// Color de los vértices de la esfera
/// </summary>
public Color Color
{
get { return color; }
}
public Color Color { get; set; }

/// <summary>
/// Textura de la esfera
Expand Down Expand Up @@ -274,9 +270,9 @@ public virtual void setColor(Color color)

Technique = TgcShaders.T_POSITION_COLORED;

if (this.color != color) mustUpdate = true;
if (this.Color != color) mustUpdate = true;

this.color = color;
this.Color = color;
}

/// <summary>
Expand Down Expand Up @@ -344,7 +340,7 @@ protected void configure(float radius, Color color, TgcTexture texture, TGCVecto
translation = center;
Rotation = TGCVector3.Empty;
Enabled = true;
scale = TGCVector3.One;
Scale = TGCVector3.One;
AlphaBlend = false;
uvOffset = TGCVector2.Zero;

Expand Down Expand Up @@ -394,7 +390,7 @@ public virtual void updateValues()
var polos = new int[2];
var p = 0;

var c = color.ToArgb();
var c = Color.ToArgb();

var twoPi = FastMath.TWO_PI;

Expand Down Expand Up @@ -818,7 +814,7 @@ protected virtual void updateBoundingVolume()
/// <returns>Sphere clonado</returns>
public virtual TGCSphere clone()
{
var cloneSphere = new TGCSphere(radius, color, translation);
var cloneSphere = new TGCSphere(radius, Color, translation);

if (Texture != null) cloneSphere.setTexture(Texture.Clone());

Expand Down
94 changes: 41 additions & 53 deletions TGC.Core/Geometry/TgcArrow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ public class TgcArrow

private Color bodyColor;

protected Effect effect;

private Color headColor;

protected string technique;

public TgcArrow()
{
vertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionColored), 54, D3DDevice.Instance.Device,
Expand All @@ -34,11 +30,11 @@ public TgcArrow()
Enabled = true;
bodyColor = Color.Blue;
headColor = Color.LightBlue;
AlphaBlendEnable = false;
AlphaBlend = false;

//Shader
effect = TgcShaders.Instance.VariosShader;
technique = TgcShaders.T_POSITION_COLORED;
Effect = TgcShaders.Instance.VariosShader;
Technique = TgcShaders.T_POSITION_COLORED;
}

/// <summary>
Expand Down Expand Up @@ -93,63 +89,20 @@ public TGCVector3 Position
/// <summary>
/// Shader del mesh
/// </summary>
public Effect Effect
{
get { return effect; }
set { effect = value; }
}
public Effect Effect { get; set; }

/// <summary>
/// Technique que se va a utilizar en el effect.
/// Cada vez que se llama a Render() se carga este Technique (pisando lo que el shader ya tenia seteado)
/// </summary>
public string Technique
{
get { return technique; }
set { technique = value; }
}
public string Technique { get; set; }

/// <summary>
/// Habilita el renderizado con AlphaBlending para los modelos
/// con textura o colores por vértice de canal Alpha.
/// Por default está deshabilitado.
/// </summary>
public bool AlphaBlendEnable { get; set; }

/// <summary>
/// Renderizar la flecha
/// </summary>
public void Render()
{
if (!Enabled)
return;

TexturesManager.Instance.clear(0);
TexturesManager.Instance.clear(1);

TgcShaders.Instance.setShaderMatrixIdentity(effect);
D3DDevice.Instance.Device.VertexDeclaration = TgcShaders.Instance.VdecPositionColored;
effect.Technique = technique;
D3DDevice.Instance.Device.SetStreamSource(0, vertexBuffer, 0);

//Render con shader
effect.Begin(0);
effect.BeginPass(0);
D3DDevice.Instance.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, 18);
effect.EndPass();
effect.End();
}

/// <summary>
/// Liberar recursos de la flecha
/// </summary>
public void Dispose()
{
if (vertexBuffer != null && !vertexBuffer.Disposed)
{
vertexBuffer.Dispose();
}
}
public bool AlphaBlend { get; set; }

/// <summary>
/// Actualizar parámetros de la flecha en base a los valores configurados
Expand Down Expand Up @@ -264,6 +217,41 @@ public void updateValues()
vertexBuffer.SetData(vertices, 0, LockFlags.None);
}

/// <summary>
/// Renderizar la flecha
/// </summary>
public void Render()
{
if (!Enabled)
return;

TexturesManager.Instance.clear(0);
TexturesManager.Instance.clear(1);

TgcShaders.Instance.setShaderMatrixIdentity(Effect);
D3DDevice.Instance.Device.VertexDeclaration = TgcShaders.Instance.VdecPositionColored;
Effect.Technique = Technique;
D3DDevice.Instance.Device.SetStreamSource(0, vertexBuffer, 0);

//Render con shader
Effect.Begin(0);
Effect.BeginPass(0);
D3DDevice.Instance.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, 18);
Effect.EndPass();
Effect.End();
}

/// <summary>
/// Liberar recursos de la flecha
/// </summary>
public void Dispose()
{
if (vertexBuffer != null && !vertexBuffer.Disposed)
{
vertexBuffer.Dispose();
}
}

#region Creacion

/// <summary>
Expand Down
Loading

0 comments on commit cefcb00

Please sign in to comment.