public override void Init() { stack = (PostProcessStack)TargetObj; effectInfos = new ObjectInfo[stack.postProcessEffects.Count]; for (int i = 0; i < stack.postProcessEffects.Count; i++) { effectInfos[i] = new ObjectInfo(stack.postProcessEffects[i]); } }
protected override void OnLoad() { //Initialize opengl debug callback _debugProcCallbackHandle = GCHandle.Alloc(_debugProcCallback); GL.Enable(EnableCap.DebugOutput); GL.Enable(EnableCap.DebugOutputSynchronous); GL.DebugMessageCallback(_debugProcCallback, IntPtr.Zero); //Init game contexts Init(); //Load test assets //var sponza = GLTFAssetLoader.Load(@"D:\Blender\Models\sponza-gltf-pbr\sponza.gltf"); //var zelda = GLTFAssetLoader.Load(@"D:\Blender\Models\JourneyPBR\Export\untitled.glb", 0.01f); //var car = AssetLoader.LoadAssets(@"D:\Blender\Models\Audi R8\Models\Audi R8.fbx", 0.1f); //var Sphere = GLTFAssetLoader.Load(@"D:\Blender\Models\Sphere.fbx", 1f); var spire = GLTFAssetLoader.Load(@"D:\Blender\Models\Spire.glb"); var mc = GLTFAssetLoader.Load(@"D:\Blender\Models\beta map split.glb", 1f); mc.Root.Transform.Position -= Vector3.UnitY * 128; GameLoop.Instantiate(mc, null); //GameLoop.Instantiate(Sphere, null); //GameLoop.Instantiate(car, null); //GameLoop.Instantiate(zelda, null); //GameLoop.Instantiate(sponza, null); GameLoop.Instantiate(spire, null); //Add RigidBodys //var rb1 = new RigidBody(); //rb1.DetectionSettings = RigidBody.ContinuousDetectionSettings; //rb1.Shape = new BepuPhysics.Collidables.Sphere(Sphere.Root.Transform.Scale.X); //Sphere.Root.AddScript(rb1); //var rb2 = new RigidBody(); //rb2.RigidBodyType = RigidBodyType.Kinematic; //rb2.Shape = new BepuPhysics.Collidables.Box(1000, 0.1f, 1000); //sponza.Root.AddScript(rb2); //Add Game Camera var c = new Camera(new Viewport(ClientRectangle)); ICamera.MainCamera = c; GameObject CameraObj = new GameObject("Main Camera"); CameraObj.AddScript(c); gameCamController = new FlyCamController(); CameraObj.AddScript(gameCamController); var stack = new PostProcessStack(); stack.AddEffect(new BloomEffect()); stack.AddEffect(new ToneMapACES()); CameraObj.AddScript(stack); GameLoop.Add(CameraObj); var light = new SunLight(); light.Color = Color4.White.ToNumerics().ToOpenTK().Xyz; light.Strength = 2; CameraObj.AddScript(light); gameCamController.Enabled = false; //Spinny thingy //zelda.Root.AddScript(new TurnTable()); //var t = Sphere.Root.GetComponent<Transform>()!; //t.Position = new Vector3(0, 4, 0); //t.Scale = new Vector3(0.1f); Input.Keyboard = KeyboardState; Input.Mouse = MouseState; editorCamController = EditorManager.cam.GameObject.GetScript <FlyCamController>() !; EditMode = true; }
public void DrawUI() { if (!initDraw) { var stack = new PostProcessStack(); stack.AddEffect(new BloomEffect()); stack.AddEffect(new ToneMapACES()); EditorCam.AddScript(stack); initDraw = true; } GuiController.Update(GameObject.GameLoop.NativeWindow, GameObject.GameLoop.RenderDeltaTime); uint dockSpaceID = 0; ImGui.SetNextWindowPos(new System.Numerics.Vector2()); ImGui.SetNextWindowSize(new System.Numerics.Vector2(Size.X, Size.Y)); if (ImGui.Begin("Main Window", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoTitleBar)) { if (ImGui.BeginMenuBar()) { if (ImGui.Button(BaseGame.Play ? "Pause" : "Play")) { BaseGame.Play = !BaseGame.Play; } if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("Import")) { //if (Environment.OSVersion.Platform == PlatformID.Win32NT) //{ // for (int i = 0; i < files.Length; i++) // { // if (files[i].EndsWith(".glb", StringComparison.OrdinalIgnoreCase) || files[i].EndsWith(".gltf", StringComparison.OrdinalIgnoreCase)) // { // var model = GLTFAssetLoader.Load(files[i]); // GameGameLoop.Instantiate(model, null); // } // } //} } ImGui.EndMenu(); } if (ImGui.MenuItem("Edit")) { } if (ImGui.BeginMenu("View")) { for (int i = 0; i < EditorWindows.Count; i++) { if (ImGui.MenuItem(EditorWindows[i].UIName)) { EditorWindows[i].IsActive = true; } } ImGui.EndMenu(); } if (ImGui.MenuItem("Show Metrics")) { showMetrics = !showMetrics; } if (ImGui.MenuItem("Show Example")) { showExample = !showExample; } } ImGui.EndMenuBar(); dockSpaceID = ImGui.GetID("Main Dockspace"); ImGui.DockSpace(dockSpaceID); } ImGui.End(); for (int i = 0; i < EditorWindows.Count; i++) { if (EditorWindows[i].IsActive) { EditorWindows[i].DrawUI(); } } if (showMetrics) { ImGui.ShowMetricsWindow(); } if (showExample) { ImGui.ShowDemoWindow(); } }