public void TestSaveScene3D(string sceneName) { var srcScene = SceneFactory.CreateRecord3D(sceneName); srcScene.AttachToCurrentTest($"{sceneName}.glb"); srcScene.AttachToCurrentTest($"{sceneName}.html"); }
public void RenderSceneToSVG() { using var svg = SVGSceneDrawing2D.CreateGraphic(); var scene = SceneFactory.CreateRecord3D("Scene1"); scene.DrawTo(svg, 1024, 1024, new Vector3(7, 5, 20)); AttachmentInfo.From("document.svg").WriteAllText(svg.ToSVGContent()); }
public void TestRender3DSceneToBitmap(string sceneName) { var scene = SceneFactory.CreateRecord3D(sceneName); scene.DrawCube(Matrix4x4.Identity, COLOR.Red, COLOR.Green, COLOR.Blue); AttachmentInfo .From($"{sceneName}.png") .WriteObject(f => Canvas2DFactory.SaveToBitmap(f, 1024, 1024, null, scene)); }
public void TestClipScene3D(string sceneName) { var srcScene = SceneFactory.CreateRecord3D(sceneName); var bounds = srcScene.BoundingMatrix; for (int i = -1; i <= 1; ++i) { var dstScene = new Record3D(); srcScene.DrawTo(new PlaneClip3D(dstScene, new Plane(Vector3.UnitX, i))); bounds = dstScene.BoundingMatrix; dstScene.AttachToCurrentTest($"{sceneName}_{i}.glb"); dstScene.AttachToCurrentTest($"{sceneName}_{i}.html"); } }
public void TestPaintersAlgorythmPipeline(string sceneName) { var scene = new Record3D(); scene.DrawFloorXZ((-50, 0, -50), (100, 100), 10, COLOR.Green, COLOR.DarkGreen); scene.DrawAsset(Matrix4x4.CreateTranslation(0, 5, -10), SceneFactory.CreateRecord3D(sceneName)); // scene.DrawAsset(Matrix4x4.CreateTranslation(0, 5, 0), SceneFactory.CreateRecord3D(sceneName)); scene.AttachToCurrentTest("scene.glb"); scene.AttachToCurrentTest("scene.html"); // render scene with WPF var renderTarget = new WPFRenderTarget(1024, 1024); renderTarget.Draw(dc => { PerspectiveTransform .CreateLookingAtCenter((dc, 1024, 1024), (10, 5, 30)) .DrawScene(scene); }); AttachmentInfo .From($"WPF_{sceneName}.png") .WriteObject(f => renderTarget.SaveToPNG(f)); // render with MemoryBitmap var mem = new Bitmaps.MemoryBitmap(1024, 1024, Bitmaps.Pixel.RGBA32.Format); var mdc = Backends.InteropDrawing.CreateDrawingContext(mem); PerspectiveTransform .CreateLookingAtCenter((mdc, 1024, 1024), (10, 5, 30)) .DrawScene(scene); mem.Save(new AttachmentInfo($"Span_{sceneName}.png")); }