Finished the BasicEffect Sample which tests all possible feature combinations of the Effect.

This commit is contained in:
SND\AstrorEnales_cp 2012-10-13 09:09:27 +00:00 committed by Konstantin Koch
parent bff87410e9
commit 085fb42ba6
33 changed files with 760 additions and 274 deletions

View File

@ -9,7 +9,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Audio
{
#if !WINDOWSMETRO //TODO: search replacement for Win8
[SerializableAttribute]
[Serializable]
#endif
[PercentageComplete(99)]
[Developer("AstrorEnales")]

View File

@ -49,13 +49,10 @@ namespace ANX.Framework.Audio
#region Equality
public override bool Equals(object obj)
{
if (obj is RendererDetail)
return this == (RendererDetail)obj;
return false;
return obj is RendererDetail && this == (RendererDetail)obj;
}
public static bool operator ==(RendererDetail lhs, RendererDetail rhs)
public static bool operator ==(RendererDetail lhs, RendererDetail rhs)
{
return lhs.friendlyName.Equals(rhs.friendlyName) &&
lhs.rendererId.Equals(rhs.rendererId);

View File

@ -1,4 +1,5 @@
using System;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -6,6 +7,9 @@ using System;
namespace ANX.Framework
{
[PercentageComplete(100)]
[Developer("???")]
[TestState(TestStateAttribute.TestState.InProgress)]
public class CurveKey : IEquatable<CurveKey>, IComparable<CurveKey>
{
#region Public

View File

@ -9,7 +9,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.InProgress)]
[TestState(TestStateAttribute.TestState.Tested)]
[Developer("AstrorEnales")]
public class BasicEffect : Effect, IEffectMatrices, IEffectLights, IEffectFog
{

View File

@ -28,19 +28,16 @@ namespace ANX.Framework.Input
public GamePadThumbSticks (Vector2 leftThumbstick, Vector2 rightThumbstick)
{
this.left = Vector2.Clamp(leftThumbstick, -Vector2.One, Vector2.One);
this.right = Vector2.Clamp(rightThumbstick, -Vector2.One, Vector2.One);
left = Vector2.Clamp(leftThumbstick, -Vector2.One, Vector2.One);
right = Vector2.Clamp(rightThumbstick, -Vector2.One, Vector2.One);
}
public override bool Equals(object obj)
{
if (obj != null && obj.GetType() == typeof(GamePadThumbSticks))
return this == (GamePadThumbSticks)obj;
return false;
return obj is GamePadThumbSticks && this == (GamePadThumbSticks)obj;
}
public static bool operator ==(GamePadThumbSticks lhs, GamePadThumbSticks rhs)
public static bool operator ==(GamePadThumbSticks lhs, GamePadThumbSticks rhs)
{
return lhs.left == rhs.left && lhs.right == rhs.right;
}
@ -52,7 +49,7 @@ namespace ANX.Framework.Input
public override int GetHashCode()
{
return this.left.GetHashCode() ^ this.right.GetHashCode();
return left.GetHashCode() ^ right.GetHashCode();
}
public override string ToString()

View File

@ -33,13 +33,10 @@ namespace ANX.Framework.Input
public override bool Equals(object obj)
{
if (obj != null && obj.GetType() == typeof(GamePadTriggers))
return this == (GamePadTriggers)obj;
return false;
return obj is GamePadTriggers && this == (GamePadTriggers)obj;
}
public static bool operator ==(GamePadTriggers lhs, GamePadTriggers rhs)
public static bool operator ==(GamePadTriggers lhs, GamePadTriggers rhs)
{
return lhs.Left == rhs.Left && lhs.Right == rhs.Right;
}

View File

@ -13,18 +13,15 @@ namespace ANX.Framework.Input
public struct KeyboardState
{
#region Private
private KeyState[] keyState;
private readonly KeyState[] keyState;
#endregion
public KeyState this[Keys key]
{
get
{
return keyState[(int)key];
}
}
public KeyState this[Keys key]
{
get { return keyState[(int)key]; }
}
public KeyboardState(params Keys[] keys)
public KeyboardState(params Keys[] keys)
{
keyState = new KeyState[255];
for (int i = 0; i < keys.Length; i++)
@ -48,13 +45,10 @@ namespace ANX.Framework.Input
public override bool Equals(object obj)
{
if (obj != null && obj.GetType() == typeof(KeyboardState))
return this == (KeyboardState)obj;
return false;
return obj is KeyboardState && this == (KeyboardState)obj;
}
public static bool operator ==(KeyboardState lhs, KeyboardState rhs)
public static bool operator ==(KeyboardState lhs, KeyboardState rhs)
{
if (lhs.keyState.Length != rhs.keyState.Length)
return false;

View File

@ -1,5 +1,4 @@
using System.IO;
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.PlatformSystem;
using ANX.Framework.NonXNA.Development;

View File

@ -1,4 +1,5 @@
using System;
using ANX.Framework;
using ANX.Framework.Content;
using ANX.Framework.Graphics;
@ -9,10 +10,56 @@ using ANX.Framework.Graphics;
namespace BasicEffectSample
{
public abstract class BaseScene
{
{
protected BasicEffect effect;
protected VertexBuffer vertices;
protected IndexBuffer indices;
public abstract string Name { get; }
public abstract void Initialize(ContentManager content, GraphicsDevice graphicsDevice);
public abstract void Draw(GraphicsDevice graphicsDevice);
protected void EnableLightingMode(LightingMode mode)
{
effect.LightingEnabled = true;
if (mode == LightingMode.VertexLighting)
{
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = false;
}
else if (mode == LightingMode.OneLight)
{
effect.DirectionalLight0.Enabled = true;
effect.DirectionalLight1.Enabled = false;
effect.DirectionalLight2.Enabled = false;
effect.PreferPerPixelLighting = false;
}
else if (mode == LightingMode.PixelLighting)
{
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = true;
}
}
protected void ToggleFog(bool enabled)
{
if (enabled)
{
effect.FogStart = 1f;
effect.FogEnd = 15f;
effect.FogColor = Color.Gray.ToVector3();
}
effect.FogEnabled = enabled;
}
protected void SetCameraMatrices()
{
effect.World = Camera.World;
effect.View = Camera.View;
effect.Projection = Camera.Projection;
}
}
}

View File

@ -81,20 +81,29 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BaseScene.cs" />
<Compile Include="LightingMode.cs" />
<Compile Include="Scenes\DiffuseFogScene.cs" />
<Compile Include="Camera.cs" />
<Compile Include="Scenes\DiffuseNoFogScene.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Game1.cs" />
<Compile Include="Scenes\VertexLightingDiffuseNoFogScene.cs" />
<Compile Include="Scenes\VertexLightingDiffuseFogScene.cs" />
<Compile Include="Scenes\LitVertexColorTextureFogScene.cs" />
<Compile Include="Scenes\LitVertexColorTextureNoFogScene.cs" />
<Compile Include="Scenes\LitTextureFogScene.cs" />
<Compile Include="Scenes\LitTextureNoFogScene.cs" />
<Compile Include="Scenes\LitVertexColorFogScene.cs" />
<Compile Include="Scenes\LitVertexColorNoFogScene.cs" />
<Compile Include="Scenes\LitDiffuseNoFogScene.cs" />
<Compile Include="Scenes\LitDiffuseFogScene.cs" />
<Compile Include="Scenes\VertexColorTextureNoFogScene.cs" />
<Compile Include="Scenes\VertexColorTextureFogScene.cs" />
<Compile Include="Scenes\TextureNoFogScene.cs" />
<Compile Include="Scenes\TextureFogScene.cs" />
<Compile Include="Scenes\VertexColorNoFogScene.cs" />
<Compile Include="Scenes\VertexColorFogScene.cs" />
<Compile Include="VertexTypes\VertexPositionNormalColorTexture.cs" />
<Compile Include="VertexTypes\VertexPositionNormalColor.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Game.ico" />

View File

@ -79,20 +79,29 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BaseScene.cs" />
<Compile Include="LightingMode.cs" />
<Compile Include="Scenes\DiffuseFogScene.cs" />
<Compile Include="Camera.cs" />
<Compile Include="Scenes\DiffuseNoFogScene.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Game1.cs" />
<Compile Include="Scenes\VertexLightingDiffuseNoFogScene.cs" />
<Compile Include="Scenes\VertexLightingDiffuseFogScene.cs" />
<Compile Include="Scenes\LitVertexColorTextureFogScene.cs" />
<Compile Include="Scenes\LitVertexColorTextureNoFogScene.cs" />
<Compile Include="Scenes\LitTextureFogScene.cs" />
<Compile Include="Scenes\LitTextureNoFogScene.cs" />
<Compile Include="Scenes\LitVertexColorFogScene.cs" />
<Compile Include="Scenes\LitVertexColorNoFogScene.cs" />
<Compile Include="Scenes\LitDiffuseNoFogScene.cs" />
<Compile Include="Scenes\LitDiffuseFogScene.cs" />
<Compile Include="Scenes\VertexColorTextureNoFogScene.cs" />
<Compile Include="Scenes\VertexColorTextureFogScene.cs" />
<Compile Include="Scenes\TextureNoFogScene.cs" />
<Compile Include="Scenes\TextureFogScene.cs" />
<Compile Include="Scenes\VertexColorNoFogScene.cs" />
<Compile Include="Scenes\VertexColorFogScene.cs" />
<Compile Include="VertexTypes\VertexPositionNormalColorTexture.cs" />
<Compile Include="VertexTypes\VertexPositionNormalColor.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Game.ico" />

View File

@ -79,20 +79,29 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BaseScene.cs" />
<Compile Include="LightingMode.cs" />
<Compile Include="Scenes\DiffuseFogScene.cs" />
<Compile Include="Camera.cs" />
<Compile Include="Scenes\DiffuseNoFogScene.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Game1.cs" />
<Compile Include="Scenes\VertexLightingDiffuseNoFogScene.cs" />
<Compile Include="Scenes\VertexLightingDiffuseFogScene.cs" />
<Compile Include="Scenes\LitVertexColorTextureFogScene.cs" />
<Compile Include="Scenes\LitVertexColorTextureNoFogScene.cs" />
<Compile Include="Scenes\LitTextureFogScene.cs" />
<Compile Include="Scenes\LitTextureNoFogScene.cs" />
<Compile Include="Scenes\LitVertexColorFogScene.cs" />
<Compile Include="Scenes\LitVertexColorNoFogScene.cs" />
<Compile Include="Scenes\LitDiffuseNoFogScene.cs" />
<Compile Include="Scenes\LitDiffuseFogScene.cs" />
<Compile Include="Scenes\VertexColorTextureNoFogScene.cs" />
<Compile Include="Scenes\VertexColorTextureFogScene.cs" />
<Compile Include="Scenes\TextureNoFogScene.cs" />
<Compile Include="Scenes\TextureFogScene.cs" />
<Compile Include="Scenes\VertexColorNoFogScene.cs" />
<Compile Include="Scenes\VertexColorFogScene.cs" />
<Compile Include="VertexTypes\VertexPositionNormalColorTexture.cs" />
<Compile Include="VertexTypes\VertexPositionNormalColor.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Game.ico" />

View File

@ -56,20 +56,29 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BaseScene.cs" />
<Compile Include="LightingMode.cs" />
<Compile Include="Scenes\DiffuseFogScene.cs" />
<Compile Include="Camera.cs" />
<Compile Include="Scenes\DiffuseNoFogScene.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Game1.cs" />
<Compile Include="Scenes\VertexLightingDiffuseNoFogScene.cs" />
<Compile Include="Scenes\VertexLightingDiffuseFogScene.cs" />
<Compile Include="Scenes\LitVertexColorTextureFogScene.cs" />
<Compile Include="Scenes\LitVertexColorTextureNoFogScene.cs" />
<Compile Include="Scenes\LitTextureFogScene.cs" />
<Compile Include="Scenes\LitTextureNoFogScene.cs" />
<Compile Include="Scenes\LitVertexColorFogScene.cs" />
<Compile Include="Scenes\LitVertexColorNoFogScene.cs" />
<Compile Include="Scenes\LitDiffuseNoFogScene.cs" />
<Compile Include="Scenes\LitDiffuseFogScene.cs" />
<Compile Include="Scenes\VertexColorTextureNoFogScene.cs" />
<Compile Include="Scenes\VertexColorTextureFogScene.cs" />
<Compile Include="Scenes\TextureNoFogScene.cs" />
<Compile Include="Scenes\TextureFogScene.cs" />
<Compile Include="Scenes\VertexColorNoFogScene.cs" />
<Compile Include="Scenes\VertexColorFogScene.cs" />
<Compile Include="VertexTypes\VertexPositionNormalColorTexture.cs" />
<Compile Include="VertexTypes\VertexPositionNormalColor.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Game.ico" />

View File

@ -18,7 +18,7 @@ namespace BasicEffectSample
KeyboardState lastState;
BaseScene[] allScenes =
private readonly BaseScene[] allScenes =
{
// Basic
new DiffuseNoFogScene(),
@ -31,37 +31,37 @@ namespace BasicEffectSample
new VertexColorTextureFogScene(),
// Vertex Lighting
new VertexLightingDiffuseNoFogScene(),
new VertexLightingDiffuseFogScene(),
//new VertexLightingVertexColorNoFogScene(),
//new VertexLightingVertexColorFogScene(),
//new VertexLightingTextureNoFogScene(),
//new VertexLightingTextureFogScene(),
//new VertexLightingVertexColorTextureNoFogScene(),
//new VertexLightingVertexColorTextureFogScene(),
new LitDiffuseNoFogScene(LightingMode.VertexLighting),
new LitDiffuseFogScene(LightingMode.VertexLighting),
new LitVertexColorNoFogScene(LightingMode.VertexLighting),
new LitVertexColorFogScene(LightingMode.VertexLighting),
new LitTextureNoFogScene(LightingMode.VertexLighting),
new LitTextureFogScene(LightingMode.VertexLighting),
new LitVertexColorTextureNoFogScene(LightingMode.VertexLighting),
new LitVertexColorTextureFogScene(LightingMode.VertexLighting),
// One Light
//new OneLightNoFogScene(),
//new OneLightFogScene(),
//new OneLightVertexColorNoFogScene(),
//new OneLightVertexColorFogScene(),
//new OneLightTextureNoFogScene(),
//new OneLightTextureFogScene(),
//new OneLightVertexColorTextureNoFogScene(),
//new OneLightVertexColorTextureFogScene(),
new LitDiffuseNoFogScene(LightingMode.OneLight),
new LitDiffuseFogScene(LightingMode.OneLight),
new LitVertexColorNoFogScene(LightingMode.OneLight),
new LitVertexColorFogScene(LightingMode.OneLight),
new LitTextureNoFogScene(LightingMode.OneLight),
new LitTextureFogScene(LightingMode.OneLight),
new LitVertexColorTextureNoFogScene(LightingMode.OneLight),
new LitVertexColorTextureFogScene(LightingMode.OneLight),
// Pixel Lighting
//new PixelLightingNoFogScene(),
//new PixelLightingFogScene(),
//new PixelLightingVertexColorNoFogScene(),
//new PixelLightingVertexColorFogScene(),
//new PixelLightingTextureNoFogScene(),
//new PixelLightingTextureFogScene(),
//new PixelLightingVertexColorTextureNoFogScene(),
//new PixelLightingVertexColorTextureFogScene(),
new LitDiffuseNoFogScene(LightingMode.PixelLighting),
new LitDiffuseFogScene(LightingMode.PixelLighting),
new LitVertexColorNoFogScene(LightingMode.PixelLighting),
new LitVertexColorFogScene(LightingMode.PixelLighting),
new LitTextureNoFogScene(LightingMode.PixelLighting),
new LitTextureFogScene(LightingMode.PixelLighting),
new LitVertexColorTextureNoFogScene(LightingMode.PixelLighting),
new LitVertexColorTextureFogScene(LightingMode.PixelLighting),
};
int currentSceneIndex = 0;
int currentSceneIndex;
public Game1()
{

View File

@ -0,0 +1,15 @@
using System;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace BasicEffectSample
{
public enum LightingMode
{
VertexLighting,
OneLight,
PixelLighting
}
}

View File

@ -11,17 +11,10 @@ namespace BasicEffectSample.Scenes
{
public class DiffuseFogScene : BaseScene
{
public override string Name
{
get
{
return "DiffuseColor with Fog";
}
}
private BasicEffect effect;
private VertexBuffer vertices;
private IndexBuffer indices;
public override string Name
{
get { return "DiffuseColor with Fog"; }
}
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
@ -30,7 +23,7 @@ namespace BasicEffectSample.Scenes
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0));
vertices = new VertexBuffer(graphicsDevice, declaration, 4, BufferUsage.WriteOnly);
vertices.SetData<Vector3>(new Vector3[]
vertices.SetData(new[]
{
new Vector3(-5f, 0f, -5f),
new Vector3(-5f, 0f, 5f),
@ -39,21 +32,16 @@ namespace BasicEffectSample.Scenes
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 6, BufferUsage.WriteOnly);
indices.SetData<ushort>(new ushort[] { 0, 2, 1, 0, 3, 2 });
indices.SetData(new ushort[] { 0, 2, 1, 0, 3, 2 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
effect.FogStart = 1f;
effect.FogEnd = 15f;
effect.FogColor = Color.Gray.ToVector3();
effect.World = Camera.World;
effect.View = Camera.View;
effect.Projection = Camera.Projection;
{
ToggleFog(true);
SetCameraMatrices();
effect.DiffuseColor = Color.Red.ToVector3();
effect.EmissiveColor = Color.Black.ToVector3();
effect.LightingEnabled = false;
effect.FogEnabled = true;
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;

View File

@ -11,26 +11,19 @@ namespace BasicEffectSample.Scenes
{
public class DiffuseNoFogScene : BaseScene
{
public override string Name
{
get
{
return "DiffuseColor";
}
}
private BasicEffect effect;
private VertexBuffer vertices;
private IndexBuffer indices;
public override string Name
{
get { return "DiffuseColor"; }
}
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
effect = new BasicEffect(graphicsDevice);
var declaration = new VertexDeclaration(12,
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0));
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0));
vertices = new VertexBuffer(graphicsDevice, declaration, 4, BufferUsage.WriteOnly);
vertices.SetData<Vector3>(new Vector3[]
vertices.SetData(new[]
{
new Vector3(-5f, 0f, -5f),
new Vector3(-5f, 0f, 5f),
@ -39,18 +32,16 @@ namespace BasicEffectSample.Scenes
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 6, BufferUsage.WriteOnly);
indices.SetData<ushort>(new ushort[] { 0, 2, 1, 0, 3, 2 });
indices.SetData(new ushort[] { 0, 2, 1, 0, 3, 2 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
effect.World = Camera.World;
effect.View = Camera.View;
effect.Projection = Camera.Projection;
{
SetCameraMatrices();
effect.DiffuseColor = Color.Red.ToVector3();
effect.EmissiveColor = Color.Black.ToVector3();
effect.LightingEnabled = false;
effect.FogEnabled = false;
effect.LightingEnabled = false;
ToggleFog(false);
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;

View File

@ -9,25 +9,25 @@ using ANX.Framework;
namespace BasicEffectSample.Scenes
{
public class VertexLightingDiffuseNoFogScene : BaseScene
public class LitDiffuseFogScene : BaseScene
{
public override string Name
{
get
{
return "VertexLighting with DiffuseColor";
}
}
public override string Name
{
get { return mode + "VertexLighting with DiffuseColor and Fog"; }
}
private BasicEffect effect;
private VertexBuffer vertices;
private IndexBuffer indices;
private readonly LightingMode mode;
public LitDiffuseFogScene(LightingMode setMode)
{
mode = setMode;
}
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
effect = new BasicEffect(graphicsDevice);
var elements = new VertexElement[]
var elements = new[]
{
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
@ -35,7 +35,7 @@ namespace BasicEffectSample.Scenes
var declaration = new VertexDeclaration(24, elements);
vertices = new VertexBuffer(graphicsDevice, declaration, 6, BufferUsage.WriteOnly);
vertices.SetData<Vector3>(new Vector3[]
vertices.SetData(new[]
{
new Vector3(0f, 0f, -5f), new Vector3(-1f, 0f, 0f),
new Vector3(0f, 0f, 5f), new Vector3(-1f, 0f, 0f),
@ -46,23 +46,19 @@ namespace BasicEffectSample.Scenes
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 12, BufferUsage.WriteOnly);
indices.SetData<ushort>(new ushort[] { 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3 });
indices.SetData(new ushort[] { 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
effect.World = Camera.World;
effect.View = Camera.View;
effect.Projection = Camera.Projection;
{
ToggleFog(true);
SetCameraMatrices();
effect.DiffuseColor = Color.LightGreen.ToVector3();
effect.EmissiveColor = Color.Black.ToVector3();
effect.LightingEnabled = true;
effect.PreferPerPixelLighting = false;
effect.FogEnabled = false;
effect.EnableDefaultLighting();
EnableLightingMode(mode);
effect.CurrentTechnique.Passes[0].Apply();
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;
graphicsDevice.SetVertexBuffer(vertices);

View File

@ -9,25 +9,25 @@ using ANX.Framework;
namespace BasicEffectSample.Scenes
{
public class VertexLightingDiffuseFogScene : BaseScene
public class LitDiffuseNoFogScene : BaseScene
{
public override string Name
{
get
{
return "VertexLighting with DiffuseColor and Fog";
}
}
public override string Name
{
get { return mode + " with DiffuseColor"; }
}
private BasicEffect effect;
private VertexBuffer vertices;
private IndexBuffer indices;
private readonly LightingMode mode;
public LitDiffuseNoFogScene(LightingMode setMode)
{
mode = setMode;
}
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
effect = new BasicEffect(graphicsDevice);
var elements = new VertexElement[]
var elements = new[]
{
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
@ -35,7 +35,7 @@ namespace BasicEffectSample.Scenes
var declaration = new VertexDeclaration(24, elements);
vertices = new VertexBuffer(graphicsDevice, declaration, 6, BufferUsage.WriteOnly);
vertices.SetData<Vector3>(new Vector3[]
vertices.SetData(new[]
{
new Vector3(0f, 0f, -5f), new Vector3(-1f, 0f, 0f),
new Vector3(0f, 0f, 5f), new Vector3(-1f, 0f, 0f),
@ -46,24 +46,17 @@ namespace BasicEffectSample.Scenes
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 12, BufferUsage.WriteOnly);
indices.SetData<ushort>(new ushort[] { 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3 });
indices.SetData(new ushort[] { 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
effect.FogStart = 1f;
effect.FogEnd = 15f;
effect.FogColor = Color.Gray.ToVector3();
effect.World = Camera.World;
effect.View = Camera.View;
effect.Projection = Camera.Projection;
{
SetCameraMatrices();
effect.DiffuseColor = Color.LightGreen.ToVector3();
effect.EmissiveColor = Color.Black.ToVector3();
effect.LightingEnabled = true;
effect.PreferPerPixelLighting = false;
effect.FogEnabled = true;
effect.EmissiveColor = Color.Black.ToVector3();
ToggleFog(false);
effect.EnableDefaultLighting();
EnableLightingMode(mode);
effect.CurrentTechnique.Passes[0].Apply();

View File

@ -0,0 +1,67 @@
using System;
using ANX.Framework.Graphics;
using ANX.Framework.Content;
using ANX.Framework;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace BasicEffectSample.Scenes
{
public class LitTextureFogScene : BaseScene
{
public override string Name
{
get { return mode + " with Texture and Fog"; }
}
private Texture2D texture;
private readonly LightingMode mode;
public LitTextureFogScene(LightingMode setMode)
{
mode = setMode;
}
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
texture = content.Load<Texture2D>("Textures/stone_tile");
effect = new BasicEffect(graphicsDevice);
vertices = new VertexBuffer(graphicsDevice, VertexPositionNormalTexture.VertexDeclaration, 6, BufferUsage.WriteOnly);
float textureFactor = 1f / 7f;
vertices.SetData(new[]
{
new VertexPositionNormalTexture(new Vector3(0f, 0f, -5f), new Vector3(-1f, 0f, 0f), new Vector2(0, 0)),
new VertexPositionNormalTexture(new Vector3(0f, 0f, 5f), new Vector3(-1f, 0f, 0f), new Vector2(0, 1)),
new VertexPositionNormalTexture(new Vector3(0f, 2f, -5f), Vector3.Normalize(new Vector3(-1f, 1f, 0f)), new Vector2(textureFactor * 2f, 0)),
new VertexPositionNormalTexture(new Vector3(0f, 2f, 5f), Vector3.Normalize(new Vector3(-1f, 1f, 0f)), new Vector2(textureFactor * 2f, 1)),
new VertexPositionNormalTexture(new Vector3(5f, 2f, -5f), new Vector3(0f, 1f, 0f), new Vector2(1, 0)),
new VertexPositionNormalTexture(new Vector3(5f, 2f, 5f), new Vector3(0f, 1f, 0f), new Vector2(1, 1))
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 12, BufferUsage.WriteOnly);
indices.SetData(new ushort[] { 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
ToggleFog(true);
SetCameraMatrices();
effect.DiffuseColor = Color.White.ToVector3();
effect.EmissiveColor = Color.Black.ToVector3();
effect.TextureEnabled = true;
effect.VertexColorEnabled = false;
effect.Texture = texture;
EnableLightingMode(mode);
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;
graphicsDevice.SetVertexBuffer(vertices);
graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 6, 0, 4);
}
}
}

View File

@ -0,0 +1,67 @@
using System;
using ANX.Framework.Graphics;
using ANX.Framework.Content;
using ANX.Framework;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace BasicEffectSample.Scenes
{
public class LitTextureNoFogScene : BaseScene
{
public override string Name
{
get { return mode + " with Texture"; }
}
private Texture2D texture;
private readonly LightingMode mode;
public LitTextureNoFogScene(LightingMode setMode)
{
mode = setMode;
}
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
texture = content.Load<Texture2D>("Textures/stone_tile");
effect = new BasicEffect(graphicsDevice);
vertices = new VertexBuffer(graphicsDevice, VertexPositionNormalTexture.VertexDeclaration, 6, BufferUsage.WriteOnly);
float textureFactor = 1f / 7f;
vertices.SetData(new[]
{
new VertexPositionNormalTexture(new Vector3(0f, 0f, -5f), new Vector3(-1f, 0f, 0f), new Vector2(0, 0)),
new VertexPositionNormalTexture(new Vector3(0f, 0f, 5f), new Vector3(-1f, 0f, 0f), new Vector2(0, 1)),
new VertexPositionNormalTexture(new Vector3(0f, 2f, -5f), Vector3.Normalize(new Vector3(-1f, 1f, 0f)), new Vector2(textureFactor * 2f, 0)),
new VertexPositionNormalTexture(new Vector3(0f, 2f, 5f), Vector3.Normalize(new Vector3(-1f, 1f, 0f)), new Vector2(textureFactor * 2f, 1)),
new VertexPositionNormalTexture(new Vector3(5f, 2f, -5f), new Vector3(0f, 1f, 0f), new Vector2(1, 0)),
new VertexPositionNormalTexture(new Vector3(5f, 2f, 5f), new Vector3(0f, 1f, 0f), new Vector2(1, 1))
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 12, BufferUsage.WriteOnly);
indices.SetData(new ushort[] { 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
SetCameraMatrices();
effect.DiffuseColor = Color.White.ToVector3();
effect.EmissiveColor = Color.Black.ToVector3();
effect.VertexColorEnabled = false;
effect.TextureEnabled = true;
effect.Texture = texture;
ToggleFog(false);
EnableLightingMode(mode);
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;
graphicsDevice.SetVertexBuffer(vertices);
graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 6, 0, 4);
}
}
}

View File

@ -0,0 +1,64 @@
using System;
using ANX.Framework.Graphics;
using ANX.Framework.Content;
using ANX.Framework;
using BasicEffectSample.VertexTypes;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace BasicEffectSample.Scenes
{
public class LitVertexColorFogScene : BaseScene
{
public override string Name
{
get { return mode + "with VertexColor and Fog"; }
}
private readonly LightingMode mode;
public LitVertexColorFogScene(LightingMode setMode)
{
mode = setMode;
}
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
effect = new BasicEffect(graphicsDevice);
vertices = new VertexBuffer(graphicsDevice, VertexPositionNormalColor.VertexDeclaration, 6, BufferUsage.WriteOnly);
vertices.SetData(new[]
{
new VertexPositionNormalColor(new Vector3(0f, 0f, -5f), new Vector3(-1f, 0f, 0f), Color.OrangeRed),
new VertexPositionNormalColor(new Vector3(0f, 0f, 5f), new Vector3(-1f, 0f, 0f), Color.LightGreen),
new VertexPositionNormalColor(new Vector3(0f, 2f, -5f), Vector3.Normalize(new Vector3(-1f, 1f, 0f)), Color.OrangeRed),
new VertexPositionNormalColor(new Vector3(0f, 2f, 5f), Vector3.Normalize(new Vector3(-1f, 1f, 0f)), Color.LightGreen),
new VertexPositionNormalColor(new Vector3(5f, 2f, -5f), new Vector3(0f, 1f, 0f), Color.OrangeRed),
new VertexPositionNormalColor(new Vector3(5f, 2f, 5f), new Vector3(0f, 1f, 0f), Color.LightGreen)
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 12, BufferUsage.WriteOnly);
indices.SetData(new ushort[] { 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
ToggleFog(true);
SetCameraMatrices();
effect.DiffuseColor = Color.White.ToVector3();
effect.EmissiveColor = Color.Black.ToVector3();
effect.VertexColorEnabled = true;
effect.TextureEnabled = false;
EnableLightingMode(mode);
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;
graphicsDevice.SetVertexBuffer(vertices);
graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 6, 0, 4);
}
}
}

View File

@ -0,0 +1,64 @@
using System;
using ANX.Framework.Graphics;
using ANX.Framework.Content;
using ANX.Framework;
using BasicEffectSample.VertexTypes;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace BasicEffectSample.Scenes
{
public class LitVertexColorNoFogScene : BaseScene
{
public override string Name
{
get { return mode + " with VertexColor"; }
}
private readonly LightingMode mode;
public LitVertexColorNoFogScene(LightingMode setMode)
{
mode = setMode;
}
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
effect = new BasicEffect(graphicsDevice);
vertices = new VertexBuffer(graphicsDevice, VertexPositionNormalColor.VertexDeclaration, 6, BufferUsage.WriteOnly);
vertices.SetData(new[]
{
new VertexPositionNormalColor(new Vector3(0f, 0f, -5f), new Vector3(-1f, 0f, 0f), Color.OrangeRed),
new VertexPositionNormalColor(new Vector3(0f, 0f, 5f), new Vector3(-1f, 0f, 0f), Color.LightGreen),
new VertexPositionNormalColor(new Vector3(0f, 2f, -5f), Vector3.Normalize(new Vector3(-1f, 1f, 0f)), Color.OrangeRed),
new VertexPositionNormalColor(new Vector3(0f, 2f, 5f), Vector3.Normalize(new Vector3(-1f, 1f, 0f)), Color.LightGreen),
new VertexPositionNormalColor(new Vector3(5f, 2f, -5f), new Vector3(0f, 1f, 0f), Color.OrangeRed),
new VertexPositionNormalColor(new Vector3(5f, 2f, 5f), new Vector3(0f, 1f, 0f), Color.LightGreen)
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 12, BufferUsage.WriteOnly);
indices.SetData(new ushort[] { 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
SetCameraMatrices();
effect.DiffuseColor = Color.White.ToVector3();
effect.EmissiveColor = Color.Black.ToVector3();
effect.VertexColorEnabled = true;
effect.TextureEnabled = false;
ToggleFog(false);
EnableLightingMode(mode);
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;
graphicsDevice.SetVertexBuffer(vertices);
graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 6, 0, 4);
}
}
}

View File

@ -0,0 +1,68 @@
using System;
using ANX.Framework.Graphics;
using ANX.Framework.Content;
using ANX.Framework;
using BasicEffectSample.VertexTypes;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace BasicEffectSample.Scenes
{
public class LitVertexColorTextureFogScene : BaseScene
{
public override string Name
{
get { return mode + " with VertexColor, Texture and Fog"; }
}
private Texture2D texture;
private readonly LightingMode mode;
public LitVertexColorTextureFogScene(LightingMode setMode)
{
mode = setMode;
}
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
texture = content.Load<Texture2D>("Textures/stone_tile");
effect = new BasicEffect(graphicsDevice);
vertices = new VertexBuffer(graphicsDevice, VertexPositionNormalColorTexture.VertexDeclaration, 6, BufferUsage.WriteOnly);
float textureFactor = 1f / 7f;
vertices.SetData(new[]
{
new VertexPositionNormalColorTexture(new Vector3(0f, 0f, -5f), new Vector3(-1f, 0f, 0f), Color.OrangeRed, new Vector2(0, 0)),
new VertexPositionNormalColorTexture(new Vector3(0f, 0f, 5f), new Vector3(-1f, 0f, 0f), Color.LightGreen, new Vector2(0, 1)),
new VertexPositionNormalColorTexture(new Vector3(0f, 2f, -5f), Vector3.Normalize(new Vector3(-1f, 1f, 0f)), Color.OrangeRed, new Vector2(textureFactor * 2f, 0)),
new VertexPositionNormalColorTexture(new Vector3(0f, 2f, 5f), Vector3.Normalize(new Vector3(-1f, 1f, 0f)), Color.LightGreen, new Vector2(textureFactor * 2f, 1)),
new VertexPositionNormalColorTexture(new Vector3(5f, 2f, -5f), new Vector3(0f, 1f, 0f), Color.OrangeRed, new Vector2(1, 0)),
new VertexPositionNormalColorTexture(new Vector3(5f, 2f, 5f), new Vector3(0f, 1f, 0f), Color.LightGreen, new Vector2(1, 1))
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 12, BufferUsage.WriteOnly);
indices.SetData(new ushort[] { 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
ToggleFog(true);
SetCameraMatrices();
effect.DiffuseColor = Color.White.ToVector3();
effect.EmissiveColor = Color.Black.ToVector3();
effect.VertexColorEnabled = true;
effect.TextureEnabled = true;
effect.Texture = texture;
EnableLightingMode(mode);
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;
graphicsDevice.SetVertexBuffer(vertices);
graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 6, 0, 4);
}
}
}

View File

@ -0,0 +1,68 @@
using System;
using ANX.Framework.Graphics;
using ANX.Framework.Content;
using ANX.Framework;
using BasicEffectSample.VertexTypes;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace BasicEffectSample.Scenes
{
public class LitVertexColorTextureNoFogScene : BaseScene
{
public override string Name
{
get { return mode + " with VertexColor and Texture"; }
}
private Texture2D texture;
private readonly LightingMode mode;
public LitVertexColorTextureNoFogScene(LightingMode setMode)
{
mode = setMode;
}
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
texture = content.Load<Texture2D>("Textures/stone_tile");
effect = new BasicEffect(graphicsDevice);
vertices = new VertexBuffer(graphicsDevice, VertexPositionNormalColorTexture.VertexDeclaration, 6, BufferUsage.WriteOnly);
float textureFactor = 1f / 7f;
vertices.SetData(new[]
{
new VertexPositionNormalColorTexture(new Vector3(0f, 0f, -5f), new Vector3(-1f, 0f, 0f), Color.OrangeRed, new Vector2(0, 0)),
new VertexPositionNormalColorTexture(new Vector3(0f, 0f, 5f), new Vector3(-1f, 0f, 0f), Color.LightGreen, new Vector2(0, 1)),
new VertexPositionNormalColorTexture(new Vector3(0f, 2f, -5f), Vector3.Normalize(new Vector3(-1f, 1f, 0f)), Color.OrangeRed, new Vector2(textureFactor * 2f, 0)),
new VertexPositionNormalColorTexture(new Vector3(0f, 2f, 5f), Vector3.Normalize(new Vector3(-1f, 1f, 0f)), Color.LightGreen, new Vector2(textureFactor * 2f, 1)),
new VertexPositionNormalColorTexture(new Vector3(5f, 2f, -5f), new Vector3(0f, 1f, 0f), Color.OrangeRed, new Vector2(1, 0)),
new VertexPositionNormalColorTexture(new Vector3(5f, 2f, 5f), new Vector3(0f, 1f, 0f), Color.LightGreen, new Vector2(1, 1))
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 12, BufferUsage.WriteOnly);
indices.SetData(new ushort[] { 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
SetCameraMatrices();
effect.DiffuseColor = Color.White.ToVector3();
effect.EmissiveColor = Color.Black.ToVector3();
effect.VertexColorEnabled = true;
effect.TextureEnabled = true;
effect.Texture = texture;
ToggleFog(false);
EnableLightingMode(mode);
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;
graphicsDevice.SetVertexBuffer(vertices);
graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 6, 0, 4);
}
}
}

View File

@ -11,17 +11,11 @@ namespace BasicEffectSample.Scenes
{
public class TextureFogScene : BaseScene
{
public override string Name
{
get
{
return "Texture with Fog";
}
}
public override string Name
{
get { return "Texture with Fog"; }
}
private BasicEffect effect;
private VertexBuffer vertices;
private IndexBuffer indices;
private Texture2D texture;
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
@ -30,7 +24,7 @@ namespace BasicEffectSample.Scenes
effect = new BasicEffect(graphicsDevice);
vertices = new VertexBuffer(graphicsDevice, VertexPositionTexture.VertexDeclaration, 4, BufferUsage.WriteOnly);
vertices.SetData<VertexPositionTexture>(new[]
vertices.SetData(new[]
{
new VertexPositionTexture(new Vector3(-5f, 0f, -5f), new Vector2(0, 0)),
new VertexPositionTexture(new Vector3(-5f, 0f, 5f), new Vector2(0, 1)),
@ -39,24 +33,19 @@ namespace BasicEffectSample.Scenes
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 6, BufferUsage.WriteOnly);
indices.SetData<ushort>(new ushort[] { 0, 2, 1, 0, 3, 2 });
indices.SetData(new ushort[] { 0, 2, 1, 0, 3, 2 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
effect.FogStart = 1f;
effect.FogEnd = 15f;
effect.FogColor = Color.Gray.ToVector3();
effect.World = Camera.World;
effect.View = Camera.View;
effect.Projection = Camera.Projection;
ToggleFog(true);
SetCameraMatrices();
effect.DiffuseColor = Color.White.ToVector3();
effect.EmissiveColor = Color.Black.ToVector3();
effect.LightingEnabled = false;
effect.VertexColorEnabled = false;
effect.TextureEnabled = true;
effect.Texture = texture;
effect.FogEnabled = true;
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;

View File

@ -11,17 +11,11 @@ namespace BasicEffectSample.Scenes
{
public class TextureNoFogScene : BaseScene
{
public override string Name
{
get
{
return "Texture";
}
}
public override string Name
{
get { return "Texture"; }
}
private BasicEffect effect;
private VertexBuffer vertices;
private IndexBuffer indices;
private Texture2D texture;
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
@ -30,7 +24,7 @@ namespace BasicEffectSample.Scenes
effect = new BasicEffect(graphicsDevice);
vertices = new VertexBuffer(graphicsDevice, VertexPositionTexture.VertexDeclaration, 4, BufferUsage.WriteOnly);
vertices.SetData<VertexPositionTexture>(new[]
vertices.SetData(new[]
{
new VertexPositionTexture(new Vector3(-5f, 0f, -5f), new Vector2(0, 0)),
new VertexPositionTexture(new Vector3(-5f, 0f, 5f), new Vector2(0, 1)),
@ -39,21 +33,21 @@ namespace BasicEffectSample.Scenes
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 6, BufferUsage.WriteOnly);
indices.SetData<ushort>(new ushort[] { 0, 2, 1, 0, 3, 2 });
indices.SetData(new ushort[] { 0, 2, 1, 0, 3, 2 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
effect.World = Camera.World;
effect.View = Camera.View;
effect.Projection = Camera.Projection;
{
SetCameraMatrices();
effect.DiffuseColor = Color.White.ToVector3();
effect.EmissiveColor = Color.Black.ToVector3();
effect.LightingEnabled = false;
effect.VertexColorEnabled = false;
effect.TextureEnabled = true;
effect.FogEnabled = false;
effect.Texture = texture;
ToggleFog(false);
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;

View File

@ -11,24 +11,17 @@ namespace BasicEffectSample.Scenes
{
public class VertexColorFogScene : BaseScene
{
public override string Name
{
get
{
return "VertexColor with Fog";
}
}
private BasicEffect effect;
private VertexBuffer vertices;
private IndexBuffer indices;
public override string Name
{
get { return "VertexColor with Fog"; }
}
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
effect = new BasicEffect(graphicsDevice);
vertices = new VertexBuffer(graphicsDevice, VertexPositionColor.VertexDeclaration, 4, BufferUsage.WriteOnly);
vertices.SetData<VertexPositionColor>(new[]
vertices.SetData(new[]
{
new VertexPositionColor(new Vector3(-5f, 0f, -5f), Color.Red),
new VertexPositionColor(new Vector3(-5f, 0f, 5f), Color.Green),
@ -37,21 +30,16 @@ namespace BasicEffectSample.Scenes
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 6, BufferUsage.WriteOnly);
indices.SetData<ushort>(new ushort[] { 0, 2, 1, 0, 3, 2 });
indices.SetData(new ushort[] { 0, 2, 1, 0, 3, 2 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
effect.FogStart = 1f;
effect.FogEnd = 15f;
effect.FogColor = Color.Gray.ToVector3();
effect.World = Camera.World;
effect.View = Camera.View;
effect.Projection = Camera.Projection;
{
ToggleFog(true);
SetCameraMatrices();
effect.EmissiveColor = Color.Black.ToVector3();
effect.VertexColorEnabled = true;
effect.LightingEnabled = false;
effect.FogEnabled = true;
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;

View File

@ -11,24 +11,17 @@ namespace BasicEffectSample.Scenes
{
public class VertexColorNoFogScene : BaseScene
{
public override string Name
{
get
{
return "VertexColor";
}
}
private BasicEffect effect;
private VertexBuffer vertices;
private IndexBuffer indices;
public override string Name
{
get { return "VertexColor"; }
}
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
effect = new BasicEffect(graphicsDevice);
vertices = new VertexBuffer(graphicsDevice, VertexPositionColor.VertexDeclaration, 4, BufferUsage.WriteOnly);
vertices.SetData<VertexPositionColor>(new[]
vertices.SetData(new[]
{
new VertexPositionColor(new Vector3(-5f, 0f, -5f), Color.Red),
new VertexPositionColor(new Vector3(-5f, 0f, 5f), Color.Green),
@ -41,14 +34,12 @@ namespace BasicEffectSample.Scenes
}
public override void Draw(GraphicsDevice graphicsDevice)
{
effect.World = Camera.World;
effect.View = Camera.View;
effect.Projection = Camera.Projection;
{
SetCameraMatrices();
effect.VertexColorEnabled = true;
effect.LightingEnabled = false;
effect.EmissiveColor = Color.Black.ToVector3();
effect.FogEnabled = false;
effect.EmissiveColor = Color.Black.ToVector3();
ToggleFog(false);
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;

View File

@ -11,17 +11,11 @@ namespace BasicEffectSample.Scenes
{
public class VertexColorTextureFogScene : BaseScene
{
public override string Name
{
get
{
return "VertexColor with Texture and Fog";
}
}
public override string Name
{
get { return "VertexColor with Texture and Fog"; }
}
private BasicEffect effect;
private VertexBuffer vertices;
private IndexBuffer indices;
private Texture2D texture;
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
@ -30,7 +24,7 @@ namespace BasicEffectSample.Scenes
effect = new BasicEffect(graphicsDevice);
vertices = new VertexBuffer(graphicsDevice, VertexPositionColorTexture.VertexDeclaration, 4, BufferUsage.WriteOnly);
vertices.SetData<VertexPositionColorTexture>(new[]
vertices.SetData(new[]
{
new VertexPositionColorTexture(new Vector3(-5f, 0f, -5f), Color.Red, new Vector2(0, 0)),
new VertexPositionColorTexture(new Vector3(-5f, 0f, 5f), Color.Green, new Vector2(0, 1)),
@ -39,23 +33,18 @@ namespace BasicEffectSample.Scenes
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 6, BufferUsage.WriteOnly);
indices.SetData<ushort>(new ushort[] { 0, 2, 1, 0, 3, 2 });
indices.SetData(new ushort[] { 0, 2, 1, 0, 3, 2 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
effect.FogStart = 1f;
effect.FogEnd = 15f;
effect.FogColor = Color.Gray.ToVector3();
effect.World = Camera.World;
effect.View = Camera.View;
effect.Projection = Camera.Projection;
{
ToggleFog(true);
SetCameraMatrices();
effect.VertexColorEnabled = true;
effect.EmissiveColor = Color.Black.ToVector3();
effect.LightingEnabled = false;
effect.TextureEnabled = true;
effect.Texture = texture;
effect.FogEnabled = true;
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;

View File

@ -11,18 +11,12 @@ namespace BasicEffectSample.Scenes
{
public class VertexColorTextureNoFogScene : BaseScene
{
public override string Name
{
get
{
return "VertexColor with Texture";
}
}
public override string Name
{
get { return "VertexColor with Texture"; }
}
private BasicEffect effect;
private VertexBuffer vertices;
private IndexBuffer indices;
private Texture2D texture;
private Texture2D texture;
public override void Initialize(ContentManager content, GraphicsDevice graphicsDevice)
{
@ -30,7 +24,7 @@ namespace BasicEffectSample.Scenes
effect = new BasicEffect(graphicsDevice);
vertices = new VertexBuffer(graphicsDevice, VertexPositionColorTexture.VertexDeclaration, 4, BufferUsage.WriteOnly);
vertices.SetData<VertexPositionColorTexture>(new[]
vertices.SetData(new[]
{
new VertexPositionColorTexture(new Vector3(-5f, 0f, -5f), Color.Red, new Vector2(0, 0)),
new VertexPositionColorTexture(new Vector3(-5f, 0f, 5f), Color.Green, new Vector2(0, 1)),
@ -39,20 +33,18 @@ namespace BasicEffectSample.Scenes
});
indices = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 6, BufferUsage.WriteOnly);
indices.SetData<ushort>(new ushort[] { 0, 2, 1, 0, 3, 2 });
indices.SetData(new ushort[] { 0, 2, 1, 0, 3, 2 });
}
public override void Draw(GraphicsDevice graphicsDevice)
{
effect.World = Camera.World;
effect.View = Camera.View;
effect.Projection = Camera.Projection;
{
SetCameraMatrices();
effect.VertexColorEnabled = true;
effect.LightingEnabled = false;
effect.EmissiveColor = Color.Black.ToVector3();
effect.TextureEnabled = true;
effect.Texture = texture;
effect.FogEnabled = false;
effect.Texture = texture;
ToggleFog(false);
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.Indices = indices;

View File

@ -0,0 +1,44 @@
using System;
using ANX.Framework;
using ANX.Framework.Graphics;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace BasicEffectSample.VertexTypes
{
public struct VertexPositionNormalColor : IVertexType
{
public Vector3 Position;
public Vector3 Normal;
public Color Color;
public static readonly VertexDeclaration VertexDeclaration;
VertexDeclaration IVertexType.VertexDeclaration
{
get { return VertexDeclaration; }
}
public VertexPositionNormalColor(Vector3 position, Vector3 normal, Color color)
{
Position = position;
Normal = normal;
Color = color;
}
static VertexPositionNormalColor()
{
VertexElement[] elements =
{
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
new VertexElement(24, VertexElementFormat.Color, VertexElementUsage.Color, 0)
};
VertexDeclaration = new VertexDeclaration(28, elements);
VertexDeclaration.Name = "VertexPositionNormalColor.VertexDeclaration";
}
}
}

View File

@ -0,0 +1,47 @@
using System;
using ANX.Framework;
using ANX.Framework.Graphics;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace BasicEffectSample.VertexTypes
{
public struct VertexPositionNormalColorTexture : IVertexType
{
public Vector3 Position;
public Vector3 Normal;
public Color Color;
public Vector2 TextureCoordinate;
public static readonly VertexDeclaration VertexDeclaration;
VertexDeclaration IVertexType.VertexDeclaration
{
get { return VertexDeclaration; }
}
public VertexPositionNormalColorTexture(Vector3 position, Vector3 normal, Color color, Vector2 texcoord)
{
Position = position;
Normal = normal;
Color = color;
TextureCoordinate = texcoord;
}
static VertexPositionNormalColorTexture()
{
VertexElement[] elements =
{
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
new VertexElement(24, VertexElementFormat.Color, VertexElementUsage.Color, 0),
new VertexElement(28, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
};
VertexDeclaration = new VertexDeclaration(36, elements);
VertexDeclaration.Name = "VertexPositionNormalColorTexture.VertexDeclaration";
}
}
}