public ModelViewer(ITagContainer diContainer) { this.diContainer = diContainer; device = diContainer.GetTag <GraphicsDevice>(); resourcePool = diContainer.GetTag <IResourcePool>(); textureLoader = diContainer.GetTag <IAssetLoader <Texture> >(); Window = diContainer.GetTag <WindowContainer>().NewWindow("Model Viewer"); Window.InitialBounds = new Rect(float.NaN, float.NaN, 1100.0f, 600.0f); Window.AddTag(this); editor = new TwoColumnEditorTag(Window, diContainer); var onceAction = new OnceAction(); Window.AddTag(onceAction); Window.OnContent += onceAction.Invoke; var menuBar = new MenuBarWindowTag(Window); menuBar.AddButton("Open", HandleMenuOpen); fbArea = Window.GetTag <FramebufferArea>(); fbArea.OnResize += HandleResize; fbArea.OnRender += HandleRender; modelMaterialEdit = new ModelMaterialEdit(Window, diContainer); diContainer.GetTag <OpenDocumentSet>().AddEditor(this); openFileModal = new OpenFileModal(diContainer); openFileModal.Filter = "*.dff"; openFileModal.IsFilterChangeable = false; openFileModal.OnOpenedResource += Load; imGuiRenderer = Window.Container.ImGuiRenderer; locationBuffer = new LocationBuffer(device); AddDisposable(locationBuffer); var localDiContainer = diContainer.ExtendedWith(locationBuffer); camera = new Camera(localDiContainer); AddDisposable(camera); controls = new OrbitControlsTag(Window, camera.Location, localDiContainer); AddDisposable(controls); gridRenderer = new DebugGridRenderer(diContainer); gridRenderer.Material.LinkTransformsTo(camera); gridRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(gridRenderer); triangleRenderer = new DebugTriangleLineRenderer(diContainer); triangleRenderer.Material.LinkTransformsTo(camera); triangleRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(triangleRenderer); planeRenderer = new DebugPlaneRenderer(diContainer); planeRenderer.Material.LinkTransformsTo(camera); planeRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(planeRenderer); editor.AddInfoSection("Statistics", HandleStatisticsContent); editor.AddInfoSection("Materials", HandleMaterialsContent); editor.AddInfoSection("Skeleton", HandleSkeletonContent); editor.AddInfoSection("Collision", HandleCollisionContent); }
public WorldViewer(ITagContainer diContainer) { this.diContainer = diContainer; resourcePool = diContainer.GetTag <IResourcePool>(); Window = diContainer.GetTag <WindowContainer>().NewWindow("World Viewer"); Window.AddTag(this); Window.InitialBounds = new Rect(float.NaN, float.NaN, 1100.0f, 600.0f); editor = new TwoColumnEditorTag(Window, diContainer); var onceAction = new OnceAction(); Window.AddTag(onceAction); Window.OnContent += onceAction.Invoke; Window.OnContent += UpdateIntersectionPrimitive; Window.OnKeyDown += HandleKeyDown; var menuBar = new MenuBarWindowTag(Window); menuBar.AddButton("Open", HandleMenuOpen); var gridRenderer = new DebugGridRenderer(diContainer); //gridRenderer.Material.LinkTransformsTo(controls.Projection, controls.View, controls.World); AddDisposable(gridRenderer); modelMaterialEdit = new ModelMaterialEdit(Window, diContainer); modelMaterialEdit.OpenEntriesByDefault = false; diContainer.GetTag <OpenDocumentSet>().AddEditor(this); openFileModal = new OpenFileModal(diContainer); openFileModal.Filter = "*.bsp"; openFileModal.IsFilterChangeable = false; openFileModal.OnOpenedResource += Load; locationBuffer = new LocationBuffer(diContainer.GetTag <GraphicsDevice>()); AddDisposable(locationBuffer); camera = new Camera(diContainer.ExtendedWith(locationBuffer)); AddDisposable(camera); controls = new FlyControlsTag(Window, camera.Location, diContainer); worldTransform = new UniformBuffer <Matrix4x4>(diContainer.GetTag <GraphicsDevice>().ResourceFactory); worldTransform.Ref = Matrix4x4.Identity; AddDisposable(worldTransform); fbArea = Window.GetTag <FramebufferArea>(); fbArea.OnResize += HandleResize; fbArea.OnRender += locationBuffer.Update; fbArea.OnRender += worldTransform.Update; fbArea.OnRender += camera.Update; fbArea.OnRender += gridRenderer.Render; fbArea.OnRender += HandleRender; editor.AddInfoSection("Statistics", HandleStatisticsContent); editor.AddInfoSection("Materials", HandleMaterialsContent, false); editor.AddInfoSection("Sections", HandleSectionsContent, false); editor.AddInfoSection("ViewFrustum Culling", HandleViewFrustumCulling, false); editor.AddInfoSection("Collision", HandleCollision, false); editor.AddInfoSection("Raycast", HandleRaycast, true); boundsRenderer = new DebugBoxLineRenderer(diContainer); boundsRenderer.Color = IColor.Red; boundsRenderer.Material.LinkTransformsTo(camera); boundsRenderer.Material.LinkTransformsTo(world: worldTransform); AddDisposable(boundsRenderer); planeRenderer = new DebugPlaneRenderer(diContainer); planeRenderer.Material.LinkTransformsTo(camera); planeRenderer.Material.LinkTransformsTo(world: worldTransform); AddDisposable(planeRenderer); frustumRenderer = new DebugHexahedronLineRenderer(diContainer); frustumRenderer.Material.LinkTransformsTo(camera); frustumRenderer.Material.LinkTransformsTo(world: worldTransform); AddDisposable(frustumRenderer); triangleRenderer = new DebugTriangleLineRenderer(diContainer); triangleRenderer.Material.LinkTransformsTo(camera); triangleRenderer.Material.LinkTransformsTo(world: worldTransform); AddDisposable(triangleRenderer); rayRenderer = new DebugLineRenderer(diContainer); rayRenderer.Material.LinkTransformsTo(camera); rayRenderer.Material.LinkTransformsTo(world: worldTransform); AddDisposable(rayRenderer); worldRenderer = new WorldRenderer(diContainer.ExtendedWith(camera, locationBuffer)); AddDisposable(worldRenderer); }