public void Sprite_Constructor_Test() { var texture = new Texture(Device, Path.Combine(RenderSettings.MediaPath, "Test/fatship256.tga"), ""); var sprite = new Sprite(texture); Assert.AreEqual(texture, sprite.Texture); Assert.AreEqual(Color.White, sprite.Color); }
public TextureRenderTarget(Device device, Size size) { Texture = new Texture(device, "RenderTarget", size); TargetSurface = Texture.RawTexture.GetSurfaceLevel(0); DepthStencilSurface = D3D.Surface.CreateDepthStencil(device.RawDevice, (int)size.Width, (int)size.Height, D3D.Format.D16, D3D.MultisampleType.None, 0, false); Size = size; }
protected override object OnReadXml(XmlReader reader) { string textureName = reader["Source"]; if (String.IsNullOrWhiteSpace(textureName) == false) Texture = this.assetManager.Load(textureName) as Texture; SourceRect = Rectangle.Parse(reader["SourceRect"]); return null; }
public Font(string name, Texture texture, string dataFile) : this(name, texture) { using (var stream = File.OpenRead(dataFile)) { ReadWidthData(stream); } }
public void AnimateSprite_Animate_ByUpdate_Test() { var texture = new Texture(Device, TestHelpers.GetAssetFullPath("explosion_30_128.tga"), ""); int startFrame = 6; var sprite = new AnimateSprite(texture, new Range<int>(0, 29), startFrame, 6, 128, 128); sprite.Update(1.0f); Assert.AreEqual(startFrame + 1, sprite.CurrentFrame); }
public Sprite(Texture texture) { Texture = texture; Color = Color.White; Position = Vector2.Zero; Scale = new Vector2(1.0f, 1.0f); Rotation = new Radian(0.0f); SourceRect = new Rectangle(0, 0, Texture.Width, Texture.Height); }
public void Texture_FromToStream_Test() { var expected = CreateTexture("TextureName"); var stream = new MemoryStream(); expected.ToStream().CopyTo(stream); stream.Position = 0; var actual = new Texture(Device, stream, "TextureName"); Assert.AreEqual(expected.Width, actual.Width); }
public static Font Load(Device device, string fileName, string name, AssetManager assetManager) { using (var zip = new ZipArchive(fileName)) { string textureFile = Path.ChangeExtension(Path.GetFileName(fileName), ".tga"); Texture texture = new Texture(device, zip.Load(textureFile), name); string widthDataFile = Path.ChangeExtension(Path.GetFileName(fileName), ".dat"); return new Font(name, texture, zip.Load(widthDataFile)); } }
public void AnimateSprite_Render_Test() { var texture = new Texture(Device, TestHelpers.GetAssetFullPath("explosion_30_128.tga"), ""); var sprite = new AnimateSprite(texture, new Range<int>(0, 29), 0, 6, 128, 128); Device.RawDevice.BeginScene(); SpriteRenderer.RawSprite.Begin(D3D.SpriteFlags.AlphaBlend); Assert.IsTrue((sprite as ISprite).Render(SpriteRenderer)); SpriteRenderer.RawSprite.End(); Device.RawDevice.EndScene(); }
private Font(string name, Texture texture) { Name = name; Texture = texture; int numCharPerLine = 16; int charWidth = texture.Width / numCharPerLine; int charHeight = texture.Height / numCharPerLine; this.sprite = new AnimateSprite(texture, new Range<int>(0, 0), 0, numCharPerLine, charWidth, charHeight); }
public ParticleEmitter(Texture texture) { this.texture = texture; MaxSprite = 100; Length = 200; ColorRange = new Range<Color>(Color.Black, Color.White); Spread = 10; Velocity = 1.0f; Scale = 2.0f; this.timer.Start(); }
public void Font_Print_Test() { var texture = new Texture(Device, Path.Combine(RenderSettings.MediaPath, "Engine/system12.tga"), ""); string fontData = Path.Combine(RenderSettings.MediaPath, "Engine/system12.dat"); var font = new Font("system12", texture, fontData); Device.RawDevice.BeginScene(); SpriteRenderer.RawSprite.Begin(D3D.SpriteFlags.AlphaBlend); Assert.IsTrue(font.Print("text", Vector2.Zero, Color.White, SpriteRenderer)); SpriteRenderer.RawSprite.End(); Device.RawDevice.EndScene(); }
public void ParticleEmitter_Constructor_Test() { var texture = new Texture(Device, TestHelpers.GetAssetFullPath("particle16.tga"), ""); var emitter = new ParticleEmitter(texture); Assert.AreEqual(Vector2.Zero, emitter.Position); Assert.AreEqual(new Radian(0.0f), emitter.Direction); Assert.AreEqual(100, emitter.MaxSprite); Assert.AreEqual(200, emitter.Length); Assert.AreEqual(new Range<Color>(Color.Black, Color.White), emitter.ColorRange); Assert.AreEqual(10, emitter.Spread); Assert.AreEqual(1.0f, emitter.Velocity); Assert.AreEqual(2.0f, emitter.Scale); }
public void AnimateSprite_Constructor_Test() { var texture = new Texture(Device, TestHelpers.GetAssetFullPath("explosion_30_128.tga"), ""); int frameRangeMin = 0, frameRangeMax = 29; int startFrame = 6; int numColumn = 6; int frameWidth = 128, frameHeight = 128; var sprite = new AnimateSprite(texture, new Range<int>(frameRangeMin, frameRangeMax), startFrame, numColumn, frameWidth, frameHeight); Assert.AreEqual(texture, sprite.Texture); Assert.AreEqual(new Range<int>(frameRangeMin, frameRangeMax), sprite.FrameRange); Assert.AreEqual(startFrame, sprite.CurrentFrame); Assert.AreEqual(frameWidth, sprite.FrameWidth); Assert.AreEqual(frameHeight, sprite.FrameHeight); }
public void ParticleEmitter_Render_Test() { var texture = new Texture(Device, TestHelpers.GetAssetFullPath("particle16.tga"), ""); var emitter = new ParticleEmitter(texture); Device.RawDevice.BeginScene(); SpriteRenderer.RawSprite.Begin(D3D.SpriteFlags.AlphaBlend); Assert.IsTrue((emitter as ISprite).Render(SpriteRenderer)); SpriteRenderer.RawSprite.End(); Device.RawDevice.EndScene(); emitter.Update(1000.0f); Device.RawDevice.BeginScene(); SpriteRenderer.RawSprite.Begin(D3D.SpriteFlags.AlphaBlend); Assert.IsTrue((emitter as ISprite).Render(SpriteRenderer)); SpriteRenderer.RawSprite.End(); Device.RawDevice.EndScene(); }
private Sprite CreateSprite(string textureFile = "Test/fatship256.tga") { var texture = new Texture(Device, Path.Combine(RenderSettings.MediaPath, textureFile), ""); return new Sprite(texture); }
public SpriteMock(Device device) { this.texture = new Texture(device, SampleTexturePath, ""); }
public Font(string name, Texture texture, Stream widthStream) : this(name, texture) { ReadWidthData(widthStream); }