/// <summary> /// Creates a new <see cref="SceneCamera"/> instance. /// </summary> /// <param name="window">The scene window this camera will exist in.</param> public SceneCamera(SceneWindow window) { m_window = window; m_window.Update += OnUpdate; m_camPivot = new Entity(window.Scene, "CameraPivot").Transform; Entity cam = new Entity(m_camPivot.Entity, "Camera"); m_camera = new Camera(cam); cam.Transform.LocalRotation = Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.PiOver2); // Add lights relative to the camera Transform light1 = new Entity(cam, "Light1").Transform; Transform light2 = new Entity(cam, "Light2").Transform; Transform light3 = new Entity(cam, "Light3").Transform; light1.LocalRotation = Quaternion.FromEulerAngles(MathHelper.DegreesToRadians(55), 0, MathHelper.DegreesToRadians(40)); light2.LocalRotation = Quaternion.FromEulerAngles(MathHelper.DegreesToRadians(-40), 0, MathHelper.DegreesToRadians(-5)); light3.LocalRotation = Quaternion.FromEulerAngles(MathHelper.DegreesToRadians(-160), 0, MathHelper.DegreesToRadians(-30)); DirectionalLight dirLight1 = new DirectionalLight(light1.Entity); DirectionalLight dirLight2 = new DirectionalLight(light2.Entity); DirectionalLight dirLight3 = new DirectionalLight(light3.Entity); dirLight1.MainColor = new Color4(0.65f, 0.65f, 0.65f, 0.0f); dirLight2.MainColor = new Color4(0.4f, 0.4f, 0.55f, 0.0f); dirLight3.MainColor = new Color4(0.5f, 0.5f, 0.86f, 0.0f); dirLight1.SpecularColor = new Color4(0.75f, 0.75f, 0.75f, 0.0f); dirLight2.SpecularColor = new Color4(0.2f, 0.2f, 0.2f, 0.0f); dirLight3.SpecularColor = new Color4(0.1f, 0.0f, 0.0f, 0.0f); }
/// <summary> /// Constructor. /// </summary> /// <param name="window">The scene window to add meshes to.</param> public SceneMeshes(SceneWindow window) { m_window = window; m_meshesRoot = new Entity(window.Scene, "MeshesRoot"); MeshManager.Instance.MeshesAdded += OnMeshesAdded; MeshManager.Instance.MeshRemoved += OnMeshRemoved; }
/// <summary> /// Constructor. /// </summary> public MainContent(MainWindow window) { // the left controls ActiveMeshControls activeMesh = new ActiveMeshControls(); HSeparator separator = new HSeparator(); MeshList meshList = new MeshList(); VBox leftControls = new VBox(false, 0); leftControls.WidthRequest = 250; leftControls.PackStart(activeMesh, false, false, 0); leftControls.PackStart(separator, false, false, 0); leftControls.PackStart(meshList, true, true, 0); Frame leftFrame = new Frame(); leftFrame.Shadow = ShadowType.EtchedIn; leftFrame.Add(leftControls); // the scene content VBox sceneBox = new VBox(); m_sceneWindow = SceneWindow.CreateSceneWindow(); SceneToolbar sceneToolbar = new SceneToolbar(window, m_sceneWindow); sceneBox.PackStart(sceneToolbar, false, false, 0); sceneBox.PackStart(m_sceneWindow, true, true, 0); // the right controls SmoothingContent smoothing = new SmoothingContent(); VBox rightControls = new VBox(false, 0); rightControls.WidthRequest = 250; rightControls.PackStart(smoothing, true, true, 0); Frame rightFrame = new Frame(); rightFrame.Shadow = ShadowType.EtchedIn; rightFrame.Add(rightControls); // fit everything into the main window HPaned pan1 = new HPaned(); HPaned pan2 = new HPaned(); pan1.Pack1(leftFrame, false, false); pan1.Pack2(sceneBox, true, true); pan2.Pack1(pan1, true, true); pan2.Pack2(rightFrame, false, false); PackStart(pan2, true, true, 0); KeyPressEvent += m_sceneWindow.OnKeyPress; Time.SetStartTime(); GLib.Idle.Add(Update); }
/// <summary> /// Constructor. /// </summary> public SceneToolbar(MainWindow mainWindow, SceneWindow sceneWindow) { m_sceneWindow = sceneWindow; HeightRequest = 30; MenuBar menuBar = new MenuBar(); AccelGroup accelGroup = new AccelGroup(); mainWindow.AddAccelGroup(accelGroup); // view menu MenuItem view_item = new MenuItem("_View"); Menu view_menu = new Menu(); view_item.Submenu = view_menu; menuBar.Append(view_item); MenuItem view_focus = new MenuItem("_Focus Selection"); view_focus.AddAccelerator("activate", accelGroup, new AccelKey(Gdk.Key.F, Gdk.ModifierType.None, AccelFlags.Visible)); view_focus.Activated += ((o, e) => sceneWindow.Meshes.FocusSelected()); view_menu.Append(view_focus); view_menu.Append(new SeparatorMenuItem()); MenuItem view_front = new MenuItem("_Front"); view_front.AddAccelerator("activate", accelGroup, new AccelKey(Gdk.Key.KP_1, Gdk.ModifierType.None, AccelFlags.Visible)); view_front.Activated += ((o, e) => sceneWindow.Camera.EaseCamera(SceneCamera.FRONT_VIEW)); view_menu.Append(view_front); MenuItem view_back = new MenuItem("_Back"); view_back.AddAccelerator("activate", accelGroup, new AccelKey(Gdk.Key.KP_1, Gdk.ModifierType.ControlMask, AccelFlags.Visible)); view_back.Activated += ((o, e) => sceneWindow.Camera.EaseCamera(SceneCamera.BACK_VIEW)); view_menu.Append(view_back); MenuItem view_right = new MenuItem("_Right"); view_right.AddAccelerator("activate", accelGroup, new AccelKey(Gdk.Key.KP_3, Gdk.ModifierType.None, AccelFlags.Visible)); view_right.Activated += ((o, e) => sceneWindow.Camera.EaseCamera(SceneCamera.RIGHT_VIEW)); view_menu.Append(view_right); MenuItem view_left = new MenuItem("_Left"); view_left.AddAccelerator("activate", accelGroup, new AccelKey(Gdk.Key.KP_3, Gdk.ModifierType.ControlMask, AccelFlags.Visible)); view_left.Activated += ((o, e) => sceneWindow.Camera.EaseCamera(SceneCamera.LEFT_VIEW)); view_menu.Append(view_left); MenuItem view_top = new MenuItem("_Top"); view_top.AddAccelerator("activate", accelGroup, new AccelKey(Gdk.Key.KP_7, Gdk.ModifierType.None, AccelFlags.Visible)); view_top.Activated += ((o, e) => sceneWindow.Camera.EaseCamera(SceneCamera.TOP_VIEW)); view_menu.Append(view_top); MenuItem view_bottom = new MenuItem("B_ottom"); view_bottom.AddAccelerator("activate", accelGroup, new AccelKey(Gdk.Key.KP_7, Gdk.ModifierType.ControlMask, AccelFlags.Visible)); view_bottom.Activated += ((o, e) => sceneWindow.Camera.EaseCamera(SceneCamera.BOTTOM_VIEW)); view_menu.Append(view_bottom); // render settings Label frontShadingLabel = new Label("Front Face Mode:"); m_frontShading = new ComboBox(Enum.GetNames(typeof(SceneMeshes.RenderMode))); m_frontShading.TooltipText = "The render style for front faces."; m_frontShading.Active = (int)m_sceneWindow.Meshes.FrontFaceMode; m_frontShading.CanFocus = false; m_frontShading.Changed += OnFrontShadingChanged; Label backShadingLabel = new Label("Back Face Mode:"); m_backShading = new ComboBox(Enum.GetNames(typeof(SceneMeshes.RenderMode))); m_backShading.TooltipText = "The render style for back faces."; m_backShading.Active = (int)m_sceneWindow.Meshes.BackFaceMode; m_backShading.CanFocus = false; m_backShading.Changed += OnBackShadingChanged; // pack elements HBox hBox = new HBox(); hBox.PackStart(menuBar, false, false, 2); hBox.PackStart(new VSeparator(), false, false, 6); hBox.PackStart(frontShadingLabel, false, false, 2); hBox.PackStart(m_frontShading, false, false, 2); hBox.PackStart(new VSeparator(), false, false, 6); hBox.PackStart(backShadingLabel, false, false, 2); hBox.PackStart(m_backShading, false, false, 2); Add(hBox); }