public D3DWFScene(FormsHost host, FrameworkElement overlay, ContextStateProcessor context, EngineNotificator notify) { this.host = host; this.overlay = overlay; host.HandleCreated += OnHandleCreated; host.Unloaded += OnUnloaded; this.Context = context; this.notify = notify; loker = new object(); }
public Scene(FormsHost host, FrameworkElement overlay, ContextStateProcessor context, EngineNotificator notify) { this.host = host; this.overlay = overlay; host.HandleCreated += OnHandleCreated; host.Unloaded += OnUnloaded; this.Context = context; this.notify = notify; input = new CurrentInputObserver(Application.Current.MainWindow, new WPFInputPublisher(Application.Current.MainWindow)); }
public static GenneralContextState Full(ContextStateProcessor processor, AxisAlignedBox octreeBounds, EngineNotificator notificator, ILabLogger logger) { var syncContext = new RenderLoopSynchronizationContext(); var octree = new OctreeManager(processor, octreeBounds, 5, syncContext); notificator.Subscribe(octree); var geoPool = new GeometryPool(notificator, syncContext); notificator.Subscribe(geoPool); return(new GenneralContextState(processor, octree, geoPool, notificator, syncContext, logger)); }
public void Init(FormsHost host, FrameworkElement overlay) { context = new ContextStateProcessor(); context.AddState(0, x => new GenneralContextState(x, notificator)); context.SwitchTo(0); scene = new SceneView(host, overlay, context, notificator); scene.RenderStarted += OnRenderStarted; primitiveDrawer.SetContext(context); VisualTreeviewer.RenderModeSwither = new RenderModeSwitherCommand(context); }
public SceneView(FormsHost host, FrameworkElement overlay, ContextStateProcessor context, EngineNotificator notify) : base(host, overlay, context, notify) { //try { // Fwk.ImageSharp.ImagePr.Load(Path.Combine(AppContext.BaseDirectory, "Textures", "spnza_bricks_a_diff.png")); //} catch (Exception ex) { // ex.ToString(); //} //var center = new Vector3(); //var point = new Vector3(10, 10, 10); //var res = point + center; //var v = new Vector3(10, 10, 10) + new Vector3(5, 20, 0); //var v = new Vector3(5, 20, 0) - new Vector3(10, 10, 10); //var normal = v; //normal.Normalize(); //var point1 = new Vector3(5, 20, 0) - normal * v.Length()/2; //var point2 = new Vector3(10, 10, 10) + normal * v.Length() / 2; }
public WFScene(FormsHost host, FrameworkElement overlay, ContextStateProcessor context, EngineNotificator notify) : base(host, overlay, context, notify) { }
public D3DWFScene(FormsHost host, FrameworkElement overlay, ContextStateProcessor context) : this(host, overlay, context, new EngineNotificator()) { }
GenneralContextState(ContextStateProcessor processor, IOctreeManager octree, IGeometryMemoryPool geoPool, EngineNotificator notificator, RenderLoopSynchronizationContext context, ILabLogger logger) : base(processor, new ManagerContainer(notificator, octree, processor, geoPool, context, logger)) { }
public void SetContext(ContextStateProcessor context, EngineNotificator notificator) { this.context = context; this.notificator = notificator; }
static void Main(string[] args) { WindowCreateInfo windowCI = new WindowCreateInfo { X = 50, Y = 50, WindowWidth = 960, WindowHeight = 540, WindowInitialState = WindowState.Normal, WindowTitle = "Veldrid NeoDemo" }; Sdl2Window w = VeldridStartup.CreateWindow(windowCI); window = new Sdl2WindowWrapper(w); var context = new ContextStateProcessor(new EngineNotificator()); context.AddState(0, x => new GenneralContextState(x)); context.SwitchTo(0); var game = new Game(window, context); //==== D3DShaderInfo[] shaders = { new D3DShaderInfo { Path = Path.Combine(AppContext.BaseDirectory, "Shaders", "Cube"), Stage = ShaderStages.Vertex.ToString(), EntryPoint = "VS" }, new D3DShaderInfo { Path = Path.Combine(AppContext.BaseDirectory, "Shaders", "Cube"), Stage = ShaderStages.Fragment.ToString(), EntryPoint = "FS" } }; var mb = new Helpers.MeshBulder(); var camera = context.GetEntityManager() .CreateEntity(new ElementTag(Guid.NewGuid().ToString())) .AddComponent(new CameraBuilder.CameraComponent(window.Width, window.Height)); // .AddComponent(new CameraBuilder.GraphicsComponent()); var mage = Image.Load(Path.Combine(AppContext.BaseDirectory, "Textures", "spnza_bricks_a_diff.png")); var image = new TextureInfo() { Path = Path.Combine(AppContext.BaseDirectory, "Textures", "spnza_bricks_a_diff.png"), ///Image = Image.Load(Path.Combine(AppContext.BaseDirectory, "Textures", "spnza_bricks_a_diff.png")) }; var box = GetCubeVertice(); box = mb.BuildBox(Vector3.Zero, 1, 1, 1); var geo = context.GetEntityManager() .CreateEntity(new ElementTag(Guid.NewGuid().ToString())) .AddComponent(new TexturedGeometryGraphicsComponent(shaders, box, image) { Matrix = Matrix4x4.CreateTranslation(Vector3.UnitX * 1) }); var geo1 = context.GetEntityManager() .CreateEntity(new ElementTag(Guid.NewGuid().ToString())) .AddComponent(new TexturedGeometryGraphicsComponent(shaders, mb.BuildSphere(Vector3.Zero, 1), image) { Matrix = Matrix4x4.CreateTranslation(Vector3.UnitY * -1) }); context.GetSystemManager() .CreateSystem <VeldridRenderSystem>() .Init(game.gd, game.factory, window); context.EntityOrder .RegisterOrder <VeldridRenderSystem>(camera.Tag, 0) .RegisterOrder <VeldridRenderSystem>(geo.Tag, 1) .RegisterOrder <VeldridRenderSystem>(geo1.Tag, 2); //==== game.Run(new EngineNotificator()); }
public GenneralContextState(ContextStateProcessor processor) : base(processor) { }
public GenneralContextState(ContextStateProcessor processor, EngineNotificator notificator) : base(processor, new ManagerContainer(notificator, processor)) { }