public MainWindow() { InitializeComponent(); Loaded += MainWindow_Loaded; Aardvark.Base.Aardvark.Init(); var useAardvark = true; if (useAardvark) { app = new Aardvark.Application.WinForms.OpenGlApplication(); app.Initialize(rc, 1); var renderControl = rc; var cone = IndexedGeometryPrimitives.solidCone(V3d.OOO, V3d.OOI, 1.0, 0.2, 12, C4b.Red).ToSg(); // build object from indexgeometry primitives var cube = SgPrimitives.Sg.box(Mod.Init(C4b.Blue), Mod.Init(Box3d.Unit)); // or directly using scene graph var initialViewTrafo = CameraViewModule.lookAt(V3d.III * 3.0, V3d.OOO, V3d.OOI); var controlledViewTrafo = Aardvark.Application.DefaultCameraController.control(renderControl.Mouse, renderControl.Keyboard, renderControl.Time, initialViewTrafo); var frustum = renderControl.Sizes.Select(size => FrustumModule.perspective(60.0, 0.1, 10.0, size.X / (float)size.Y)); var whiteShader = Aardvark.Base.Rendering.Effects.SimpleLighting.Effect; var trafo = Effects.Trafo.Effect; var currentAngle = 0.0; var angle = renderControl.Time.Select(t => { if (true) { return(currentAngle += 0.001); } else { return(currentAngle); } }); var rotatingTrafo = angle.Select((whyCantShadowName) => Trafo3d.RotationZ(whyCantShadowName)); var sg = new[] { cone, cube.Trafo(rotatingTrafo) } .ToSg() .WithEffects(new[] { trafo, whiteShader }) .ViewTrafo(controlledViewTrafo.Select(c => c.ViewTrafo)) .ProjTrafo(frustum.Select(f => f.ProjTrafo())); renderControl.RenderTask = Aardvark.Base.RenderTask.ofArray( new[] { app.Runtime.CompileClear(renderControl.FramebufferSignature, Mod.Init(C4f.Red)), app.Runtime.CompileRender(renderControl.FramebufferSignature, sg) } ); //var r = new System.Windows.Forms.Form(); //r.Controls.Add(renderControl); //r.Show(); } }
public static void Run() { using (var app = /*new VulkanApplication() */ new OpenGlApplication()) { var win = app.CreateSimpleRenderWindow(samples: 8); var cone = IndexedGeometryPrimitives.Cone.solidCone(V3d.OOO, V3d.OOI, 1.0, 0.2, 48, C4b.Red).ToSg(); // build object from indexgeometry primitives var cube = SgPrimitives.Sg.box(AValModule.constant(C4b.Blue), AValModule.constant(Box3d.FromCenterAndSize(V3d.Zero, V3d.III))); // or directly using scene graph var initialViewTrafo = CameraView.LookAt(V3d.III * 3.0, V3d.OOO, V3d.OOI); var controlledViewTrafo = Aardvark.Application.DefaultCameraController.control(win.Mouse, win.Keyboard, win.Time, initialViewTrafo); var frustum = win.Sizes.Map(size => FrustumModule.perspective(60.0, 0.1, 10.0, size.X / (float)size.Y)); var whiteShader = Aardvark.Rendering.Effects.SimpleLighting.Effect; var trafo = Effects.Trafo.Effect; var currentAngle = 0.0; var angle = win.Time.Map(t => { return(currentAngle += 0.001); }); var rotatingTrafo = angle.Map(a => Trafo3d.RotationZ(a)); var sg = new[] { cone.Trafo(AValModule.constant(Trafo3d.Translation(1.0, 1.0, 0.0))), cube.Trafo(rotatingTrafo) } .ToSg() .WithEffects(new[] { trafo, whiteShader }) .ViewTrafo(controlledViewTrafo.Map(c => c.ViewTrafo)) .ProjTrafo(frustum.Map(f => f.ProjTrafo())); win.RenderTask = Aardvark.Rendering.RenderTask.ofArray( new[] { app.Runtime.CompileClear(win.FramebufferSignature, AValModule.constant(C4f.Gray10)), app.Runtime.CompileRender(win.FramebufferSignature, sg) } ); win.Run(); } }