public void LightBloom() { var tc = new TestCore(); tc.Init(); var texture = Texture2D.Load(@"TestData/IO/AltseedPink.png"); Assert.NotNull(texture); Engine.AddNode(new SpriteNode() { Texture = texture, ZOrder = 1 }); Engine.AddNode(new PostEffectLightBloomNode { Threshold = 0.1f, ZOrder = 2 }); tc.LoopBody(c => { }, null); tc.End(); }
public void PartsTree() { var tc = new TestCore(); tc.Init(); var partstree = new PartsTree("TestData/PartsTreeSystem/Parts.nodes"); tc.Duration = 200; Altseed2.Node added = new Altseed2.Node(); tc.LoopBody( (_) => { added = partstree.InstantiateAndAddToEngine(); }, (_) => { foreach (var c in added.Children) { if (c is TransformNode tc) { tc.Position += new Vector2F(_ * 2f, _ * 2f); } } } ); tc.End(); }
public void MousePosition() { var tc = new TestCore(); tc.Init(); var font = Font.LoadDynamicFont("TestData/Font/mplus-1m-regular.ttf", 64); Assert.NotNull(font); var node = new TextNode(); node.Font = font; node.FontSize = 80; Engine.AddNode(node); tc.LoopBody(c => { var mp = Engine.Mouse.Position; node.Text = $"{mp.X},{mp.Y}"; } , null); tc.End(); }
public void StreamFile() { var tc = new TestCore(); tc.Init(); var file1 = Altseed2.StreamFile.CreateStrict("TestData/IO/test.txt"); const string path = "Serialization/StreamFile.bin"; file1.Read(3); Serialize(path, file1); Assert.True(System.IO.File.Exists(path)); var file2 = Deserialize <StreamFile>(path); using var stream = new FileStream("Serialization/StreamFile.txt", FileMode.Create); stream.Write(file2.TempBuffer, 0, file2.TempBufferSize); Assert.AreEqual(file1.Path, file2.Path); Assert.AreEqual(file1.IsInPackage, file2.IsInPackage); Assert.AreEqual(file1.CurrentPosition, file2.CurrentPosition); Assert.AreEqual(file1.TempBufferSize, file2.TempBufferSize); Assert.AreEqual(file1.Size, file2.Size); Assert.True(Enumerable.SequenceEqual(file1.TempBuffer, file2.TempBuffer)); tc.End(); }
public void RectangleCollider() { var tc = new TestCore(); tc.Init(); var collider1 = new RectangleCollider(); collider1.CenterPosition = new Vector2F(15f, 15f); collider1.Position = new Vector2F(30f, 30f); collider1.Rotation = MathHelper.DegreeToRadian(10.0f); collider1.Size = new Vector2F(20f, 20f); const string path = "Serialization/RectangleCollider.bin"; Serialize(path, collider1); var collider2 = Deserialize <RectangleCollider>(path); Assert.NotNull(collider2); Assert.AreEqual(collider1.CenterPosition, collider2.CenterPosition); Assert.AreEqual(collider1.Position, collider2.Position); Assert.AreEqual(collider1.Rotation, collider2.Rotation); Assert.AreEqual(collider1.Size, collider2.Size); tc.End(); }
public void MassSpriteNode() { var tc = new TestCore(new Configuration() { WaitVSync = false }); tc.Init(); var texture = Texture2D.Load(@"TestData/IO/AltseedPink256.png"); Assert.NotNull(texture); var ws = Engine.WindowSize; var size = 10; for (var x = 0; x < ws.X / size; x++) { for (var y = 0; y < ws.Y / size; y++) { var node = new SpriteNode(); node.Texture = texture; node.Src = new RectF(new Vector2F(128 * (x % 2), 128 * (y % 2)), new Vector2F(128, 128)); node.Scale = new Vector2F(1, 1) * size / 128f; node.Position = new Vector2F(x, y) * size; Engine.AddNode(node); } } tc.LoopBody(null, null); tc.End(); }
public void PolygonNode() { var tc = new TestCore(); tc.Init(); PolygonNode node = new PolygonNode() { Position = new Vector2F(250, 250) }; Engine.AddNode(node); Span <Vector2F> span = stackalloc Vector2F[] { new Vector2F(-100, -100), new Vector2F(100, -100), new Vector2F(100, 100), new Vector2F(-100, 100), }; node.SetVertexes(span, new Color(255, 0, 0)); foreach (var current in node.Buffers) { System.Diagnostics.Debug.WriteLine(current); } tc.LoopBody(c => { }, null); tc.End(); }
public void RenderedSprite() { var tc = new TestCore(); tc.Init(); var texture = Altseed2.Texture2D.LoadStrict(@"TestData/IO/AltseedPink.png"); Assert.NotNull(texture); var sprite1 = Altseed2.RenderedSprite.Create(); Assert.NotNull(sprite1); sprite1.Src = new RectF(100, 100, 200, 200); sprite1.Texture = texture; const string path = "Serialization/RenderedSprite.bin"; Serialize(path, sprite1); var sprite2 = Deserialize <RenderedSprite>(path); Assert.NotNull(sprite2); Assert.AreEqual(sprite1.Color, sprite2.Color); Assert.AreEqual(sprite1.Material, sprite2.Material); Assert.AreEqual(sprite1.AlphaBlend, sprite2.AlphaBlend); Assert.AreEqual(sprite1.Src, sprite2.Src); Assert.AreEqual((sprite1.Texture as Texture2D).Path, (sprite1.Texture as Texture2D).Path); Assert.AreEqual(sprite1.Texture.Size, sprite2.Texture.Size); Assert.AreEqual(sprite1.Transform, sprite2.Transform); tc.End(); }
public void RenderedCamera() { var tc = new TestCore(); tc.Init(); var texture = Altseed2.RenderTexture.Create(new Vector2I(100, 100), TextureFormat.R8G8B8A8_UNORM); Assert.NotNull(texture); var camera1 = Altseed2.RenderedCamera.Create(); Assert.NotNull(camera1); camera1.ViewMatrix = Matrix44F.GetTranslation2D(new Vector2F(10, 10)); camera1.TargetTexture = texture; const string path = "Serialization/RenderedCamera.bin"; Serialize(path, camera1); var camera2 = Deserialize <RenderedCamera>(path); Assert.NotNull(camera2); Assert.AreEqual(camera1.RenderPassParameter.ClearColor, camera2.RenderPassParameter.ClearColor); Assert.AreEqual(camera1.RenderPassParameter.IsColorCleared, camera2.RenderPassParameter.IsColorCleared); Assert.AreEqual(camera1.RenderPassParameter.IsDepthCleared, camera2.RenderPassParameter.IsDepthCleared); Assert.AreEqual(camera1.TargetTexture.Size, camera2.TargetTexture.Size); Assert.AreEqual(camera1.ViewMatrix, camera2.ViewMatrix); tc.End(); }
public void FloatArray() { var tc = new TestCore(); tc.Init(); var netArray1 = new float[] { 1, 2, 3, 4, 5 }; var array1 = Altseed2.FloatArray.Create(netArray1.AsSpan()); Assert.NotNull(array1); const string path = "Serialization/FloatArray.bin"; Serialize(path, array1); var array2 = Deserialize <FloatArray>(path); Assert.NotNull(array2); var netArray2 = array2.ToArray(); Assert.AreEqual(netArray1.Length, netArray2.Length); Assert.True(Enumerable.SequenceEqual(netArray1, netArray2)); tc.End(); }
public void Vector2FArray() { var tc = new TestCore(); tc.Init(); var netArray1 = new Vector2F[] { new Vector2F(10, 10), new Vector2F(20, 20), new Vector2F(30, 30) }; var array1 = Altseed2.Vector2FArray.Create(netArray1.AsSpan()); Assert.NotNull(array1); const string path = "Serialization/Vector2FArray.bin"; Serialize(path, array1); var array2 = Deserialize <Vector2FArray>(path); Assert.NotNull(array2); var netArray2 = array2.ToArray(); Assert.AreEqual(netArray1.Length, netArray2.Length); Assert.True(Enumerable.SequenceEqual(netArray1, netArray2)); tc.End(); }
public void Sound() { var tc = new TestCore(); tc.Init(); var sound1 = Altseed2.Sound.LoadStrict(@"TestData/Sound/se1.wav", true); Assert.NotNull(sound1); const string path = "Serialization/Sound.bin"; Serialize(path, sound1); Assert.True(System.IO.File.Exists(path)); var font2 = Deserialize <Altseed2.Sound>(path); Assert.NotNull(font2); Assert.AreEqual(sound1.Path, font2.Path); Assert.AreEqual(sound1.IsDecompressed, font2.IsDecompressed); Assert.AreEqual(sound1.IsLoopingMode, font2.IsLoopingMode); Assert.AreEqual(sound1.Length, font2.Length); Assert.AreEqual(sound1.LoopEndPoint, font2.LoopEndPoint); Assert.AreEqual(sound1.LoopStartingPoint, font2.LoopStartingPoint); tc.End(); }
public void RenderTexture() { var tc = new TestCore(); tc.Init(); var size = new Vector2I(100, 100); var texture1 = Altseed2.RenderTexture.Create(size, TextureFormat.R8G8B8A8_UNORM); Assert.NotNull(texture1); const string path = "Serialization/RenderTexture.bin"; Serialize(path, texture1); Assert.True(System.IO.File.Exists(path)); var texture2 = Deserialize <RenderTexture>(path); Assert.NotNull(texture2); Assert.AreEqual(texture1.Size, texture2.Size); Assert.AreEqual(texture1.FilterType, texture2.FilterType); Assert.AreEqual(texture1.Format, texture2.Format); Assert.AreEqual(texture1.WrapMode, texture2.WrapMode); tc.End(); }
public void GrayScale() { var tc = new TestCore(); tc.Init(); var texture = Texture2D.Load(@"TestData/IO/AltseedPink.png"); Assert.NotNull(texture); Engine.AddNode(new SpriteNode() { Texture = texture, ZOrder = 1 }); Engine.AddNode(new PostEffectGrayScaleNode() { ZOrder = 2 }); tc.LoopBody(c => { }, null); tc.End(); }
public void Keyboard() { var tc = new TestCore(); tc.Init(); var font = Font.LoadDynamicFont("TestData/Font/mplus-1m-regular.ttf", 64); Assert.NotNull(font); var node = new TextNode(); node.Font = font; node.FontSize = 80; Engine.AddNode(node); tc.LoopBody(c => { var sp = Engine.Keyboard.GetKeyState(Key.Space); node.Text = $"Spaceキー:{sp}"; } , null); tc.End(); }
public void CircleCollider() { var tc = new TestCore(); tc.Init(); var collider1 = new CircleCollider(); collider1.Position = new Vector2F(30f, 30f); collider1.Rotation = MathHelper.DegreeToRadian(10.0f); collider1.Radius = 30.0f; const string path = "Serialization/CircleCollider.bin"; Serialize(path, collider1); var collider2 = Deserialize <CircleCollider>(path); Assert.NotNull(collider2); Assert.AreEqual(collider1.Position, collider2.Position); Assert.AreEqual(collider1.Rotation, collider2.Rotation); Assert.AreEqual(collider1.Radius, collider2.Radius); tc.End(); }
public void StaticFont() { var tc = new TestCore(); tc.Init(); Assert.IsTrue(Font.GenerateFontFile("TestData/Font/mplus-1m-regular.ttf", "test.a2f", 100, "Hello, world! こんにちは")); var font = Font.LoadDynamicFont("TestData/Font/mplus-1m-regular.ttf", 100); var font2 = Font.LoadStaticFont("test.a2f"); Assert.NotNull(font); Assert.NotNull(font2); var imageFont = Font.CreateImageFont(font); imageFont.AddImageGlyph('〇', Texture2D.Load(@"TestData/IO/AltseedPink.png")); Engine.AddNode(new TextNode() { Font = font, Text = "Hello, world! こんにちは" }); Engine.AddNode(new TextNode() { Font = font2, Text = "Hello, world! こんにちは", Position = new Vector2F(0.0f, 100.0f), Color = new Color(0, 0, 255) }); tc.LoopBody(c => { }, null); tc.End(); }
public void PolygonCollider() { var tc = new TestCore(); tc.Init(); var collider1 = new PolygonCollider(); collider1.Position = new Vector2F(30f, 30f); collider1.Rotation = MathHelper.DegreeToRadian(10.0f); Span <Vector2F> array = stackalloc Vector2F[] { new Vector2F(10f, 10f), new Vector2F(20f, 20f), new Vector2F(30f, 30f), }; collider1.SetVertexes(array); const string path = "Serialization/PolygonCollider.bin"; Serialize(path, collider1); var collider2 = Deserialize <PolygonCollider>(path); Assert.NotNull(collider2); Assert.AreEqual(collider1.Position, collider2.Position); Assert.AreEqual(collider1.Rotation, collider2.Rotation); Assert.True(Enumerable.SequenceEqual(collider1.Vertexes, collider2.Vertexes)); tc.End(); }
public void PolygonNode_SetVertexesByVector2F() { var tc = new TestCore(new Configuration() { WaitVSync = false }); tc.Init(); var node = new PolygonNode(); Engine.AddNode(node); tc.LoopBody(c => { var sin = MathF.Sin(MathHelper.DegreeToRadian(c)) * 50; var cos = MathF.Cos(MathHelper.DegreeToRadian(c)) * 50; Span <Vector2F> span = stackalloc Vector2F[] { new Vector2F(100 + cos, 100 - sin), new Vector2F(100 - sin, 100 - cos), new Vector2F(100 - cos, 100 + sin), new Vector2F(100 + sin, 100 + cos), }; node.SetVertexes(span, new Color(255, c % 255, 255, 255)); }, null); tc.End(); }
public void MouseButtonTest() { var tc = new TestCore(); tc.Init(); var font = Font.LoadDynamicFont("TestData/Font/mplus-1m-regular.ttf", 64); Assert.NotNull(font); var node = new TextNode(); node.Font = font; node.FontSize = 80; Engine.AddNode(node); tc.LoopBody(c => { var left = Engine.Mouse.GetMouseButtonState(MouseButton.ButtonLeft); var right = Engine.Mouse.GetMouseButtonState(MouseButton.ButtonRight); node.Text = $"左:{left}\n右{right}"; } , null); tc.End(); }
public void NoRenderTexture() { var tc = new TestCore(); tc.Init(); var texture = Texture2D.Load(@"TestData/IO/AltseedPink.png"); Assert.NotNull(texture); var node = new SpriteNode(); node.Texture = texture; node.CenterPosition = texture.Size / 2; node.CameraGroup = 0b1; Engine.AddNode(node); var camera = new CameraNode(); camera.Position = new Vector2F(100, 0); camera.Scale = new Vector2F(2, 2); camera.Group = 0b1; Engine.AddNode(camera); tc.LoopBody(c => { node.Angle++; } , null); tc.End(); }
public void LineNodeAndCulling() { var tc = new TestCore(); tc.Init(); var line1 = new LineNode() { Color = new Color(255, 0, 0), Point1 = new Vector2F(2000f, 0f), Point2 = new Vector2F(2000f, 1000f), Thickness = 10f, }; Engine.AddNode(line1); tc.LoopBody(c => { if (c == 3) { line1.Point1 = new Vector2F(100f, 0f); line1.Point2 = new Vector2F(100f, 1000f); } }, null); tc.End(); }
public void Basic() { var tc = new TestCore(); tc.Init(); var texture = RenderTexture.Create(new Vector2I(640, 480), TextureFormat.R8G8B8A8_UNORM); Assert.NotNull(texture); var node = new SpriteNode(); node.Texture = texture; Engine.AddNode(node); var mp = MediaPlayer.Load(@"TestData/Movie/Test1.mp4"); mp.Play(false); tc.LoopBody(c => { mp.WriteToRenderTexture(texture); } , null); tc.End(); }
public void GetPosition() { var tc = new TestCore(); tc.Init(); var bgm = Altseed2.Sound.Load(@"TestData/Sound/bgm1.ogg", false); Assert.NotNull(bgm); int bgm_id = Engine.Sound.Play(bgm); var font = Font.LoadDynamicFont("TestData/Font/mplus-1m-regular.ttf", 100); Assert.NotNull(font); var textNode = new TextNode(); textNode.Font = font; Engine.AddNode(textNode); tc.LoopBody(c => { textNode.Text = $"{Engine.Sound.GetPlaybackPosition(bgm_id)}"; }, null); Engine.Sound.StopAll(); tc.End(); }
public void Zenkaku() { var tc = new TestCore(); tc.Init(); // pack files Assert.True(Engine.File.Pack("TestData/IO/", "pack.pack")); // add package Assert.True(Engine.File.AddRootPackage("pack.pack")); StaticFile test1 = null; StaticFile test2 = null; StaticFile testPack1 = null; StaticFile testPack2 = null; #if !CI test1 = StaticFile.Create("TestData/IO/全角 テスト.txt"); test2 = StaticFile.Create("TestData/IO/全角 テスト.txt"); testPack1 = StaticFile.Create("全角 テスト.txt"); testPack2 = StaticFile.Create("全角 テスト.txt"); Assert.AreNotEqual(test1, null); Assert.AreNotEqual(testPack1, null); Assert.AreNotEqual(test2, null); Assert.AreNotEqual(testPack2, null); Assert.AreNotEqual(test1.Size, 0); Assert.AreNotEqual(testPack1.Size, 0); Assert.AreNotEqual(test2.Size, 0); Assert.AreNotEqual(testPack2.Size, 0); #endif tc.End(); }
public void FileRoot() { var tc = new TestCore(); tc.Init(); Assert.True(Engine.File.Pack("TestData/IO/pack/", "pack.pack")); Assert.True(Engine.File.PackWithPassword("TestData/IO/pack/", "password.pack", "altseed")); // default root Assert.True(Engine.File.Exists("TestData/IO/test.txt")); // add directory root Assert.True(Engine.File.AddRootDirectory("TestData/IO/root/")); // directory root Assert.False(Engine.File.Exists("test.txt")); Assert.True(Engine.File.Exists("space test.txt")); #if !CI Assert.True(Engine.File.Exists("全角 テスト.txt")); Assert.True(Engine.File.Exists("全角 テスト.txt")); #endif // clear root Engine.File.ClearRootDirectories(); Assert.True(Engine.File.Exists("TestData/IO/test.txt")); Assert.True(Engine.File.Exists("TestData/IO/../IO/test.txt")); Assert.False(Engine.File.Exists("space test.txt")); #if !CI Assert.False(Engine.File.Exists("全角 テスト.txt")); Assert.False(Engine.File.Exists("全角 テスト.txt")); #endif // pack file root Assert.True(Engine.File.AddRootPackage("pack.pack")); Assert.True(Engine.File.Exists("test.txt")); Assert.True(Engine.File.Exists("space test.txt")); #if !CI Assert.True(Engine.File.Exists("全角 テスト.txt")); Assert.True(Engine.File.Exists("全角 テスト.txt")); #endif Assert.True(Engine.File.Exists("testDir/test.txt")); Assert.True(Engine.File.Exists("test dir/test.txt")); Engine.File.ClearRootDirectories(); // pack file with password root Assert.True(Engine.File.AddRootPackageWithPassword("password.pack", "altseed")); Assert.True(Engine.File.Exists("test.txt")); Assert.True(Engine.File.Exists("space test.txt")); #if !CI Assert.True(Engine.File.Exists("全角 テスト.txt")); Assert.True(Engine.File.Exists("全角 テスト.txt")); #endif Assert.True(Engine.File.Exists("testDir/test.txt")); Assert.True(Engine.File.Exists("test dir/test.txt")); tc.End(); }
public void ListBox() { var tc = new TestCore(new Configuration { EnabledCoreModules = CoreModules.Default | CoreModules.Tool }); tc.Init(); int current = 1; tc.LoopBody(c => { bool open = true; if (Engine.Tool.Begin("Test", ref open, ToolWindowFlags.None)) { List <string> items = new List <string>() { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" }; Engine.Tool.ListBox("ListBox", ref current, items, 3); Engine.Tool.Combo("Combo", ref current, items, 3); Engine.Tool.End(); } } , null); tc.End(); }
public void Pivot() { var tc = new TestCore(); tc.Init(); var font = Font.LoadDynamicFont("TestData/Font/mplus-1m-regular.ttf", 100); var font2 = Font.LoadDynamicFont("TestData/Font/GenYoMinJP-Bold.ttf", 100); Assert.NotNull(font); var rotated = new AnchorTransformerNode() { Position = new Vector2F(300.0f, 300.0f), Pivot = new Vector2F(0.5f, 0.5f), }; var text = new TextNode(); text.Font = font; text.Text = "中心で回転します"; rotated.Size = text.ContentSize; Engine.AddNode(text); text.AddChildNode(rotated); tc.LoopBody(c => { text.Text = "中心で回転します" + c.ToString(); rotated.Size = text.ContentSize; rotated.Angle += 1.0f; } , null); tc.End(); }
public void RemovingNodeCauseCrashWithMaterial() { var tc = new TestCore(new Configuration() { WaitVSync = false }); tc.Init(); Engine.TargetFPS = 10000; SpriteNode node = null; #if !CI tc.Duration = 50000; #endif tc.LoopBody(c => { if (node != null) { Engine.RemoveNode(node); } node = new SpriteNode(); node.Texture = Texture2D.Load(@"TestData/IO/AltseedPink.png"); node.CenterPosition = node.Texture.Size / 2; node.Position = new Vector2F(200, 200); node.Material = Material.Create(); var psCode = @" Texture2D mainTex : register(t0); SamplerState mainSamp : register(s0); struct PS_INPUT { float4 Position : SV_POSITION; float4 Color : COLOR0; float2 UV1 : UV0; float2 UV2 : UV1; }; float4 main(PS_INPUT input) : SV_TARGET { float4 c; c = mainTex.Sample(mainSamp, 1.0f - input.UV1) * input.Color; return c; }"; node.Material.SetShader(Shader.Create("ps", psCode, ShaderStage.Pixel)); Engine.AddNode(node); if (c % 100 == 0) { GC.Collect(); GC.WaitForFullGCComplete(); } } , null); tc.End(); }
public void IBPolygonNode() { var tc = new TestCore(); tc.Init(); var node = new PolygonNode() { Position = new Vector2F(250, 250) }; Engine.AddNode(node); //Span<Vector2F> span = stackalloc Vector2F[] //{ // new Vector2F(-100, -100), // new Vector2F(-50, -100), // new Vector2F(-50, -50), // new Vector2F(-100, -50), // new Vector2F(50, 50), // new Vector2F(100, 50), // new Vector2F(100, 100), // new Vector2F(50, 100), //}; //node.SetVertexes(span, new Color(255, 0, 0)); //node.Buffers = new[] //{ // new IndexBuffer(0, 1, 2), // new IndexBuffer(0, 2, 3), // new IndexBuffer(4, 5, 6), // new IndexBuffer(4, 6, 7), //}; node.SetVertexGroupsFromPositions(new[] { new[] { new Vector2F(-100, -100), new Vector2F(-50, -100), new Vector2F(-50, -50), new Vector2F(-100, -50), }, new[] { new Vector2F(50, 50), new Vector2F(100, 50), new Vector2F(100, 100), new Vector2F(50, 100), }, }, new Color(255, 0, 0)); tc.LoopBody(null, null); tc.End(); }