public static void SetStyles() { Eto.Style.Add <Eto.Forms.Panel>("transparent-form", control => { System.Console.WriteLine(control.ControlObject.GetType().ToString()); var cocoawnd = ((Eto.Mac.Forms.EtoWindow)control.ControlObject); cocoawnd.IsOpaque = false; cocoawnd.BackgroundColor = NSColor.FromCalibratedWhite(1.0f, 0.0f); cocoawnd.StyleMask = NSWindowStyle.Borderless; }); }
public static void SetStyles() { Eto.Style.Add <Eto.Forms.Panel>("transparent-form", control => { System.Console.WriteLine(control.ControlObject.GetType().ToString()); var cocoawnd = ((Eto.Mac.Forms.EtoWindow)control.ControlObject); cocoawnd.IsOpaque = false; cocoawnd.BackgroundColor = NSColor.FromCalibratedWhite(1.0f, 0.0f); cocoawnd.StyleMask = NSWindowStyle.Borderless; cocoawnd.HasShadow = false; }); Eto.Style.Add <Eto.Forms.TextBox>("textbox-rightalign", control => { var tbox = (NSTextField)control.ControlObject; tbox.Alignment = NSTextAlignment.Right; }); }
public static void SetStyles() { Eto.Style.Add <Eto.Mac.Forms.ApplicationHandler>(null, handler => handler.AllowClosingMainForm = true); Eto.Style.Add <Eto.Forms.Form>("main", form => form.Closed += (sender, e) => Eto.Forms.Application.Instance.Quit()); Eto.Style.Add <Eto.Forms.Panel>("transparent-form", control => { System.Console.WriteLine(control.ControlObject.GetType().ToString()); var cocoawnd = ((Eto.Mac.Forms.EtoWindow)control.ControlObject); cocoawnd.IsOpaque = false; cocoawnd.BackgroundColor = NSColor.FromCalibratedWhite(1.0f, 0.0f); cocoawnd.StyleMask = NSWindowStyle.Borderless; cocoawnd.HasShadow = false; }); Eto.Style.Add <Eto.Forms.TextBox>("textbox-rightalign", control => { var tbox = (NSTextField)control.ControlObject; tbox.Alignment = NSTextAlignment.Right; }); }
public void InitLighting() { // Omni light (main light of the scene) Lights [(int)Light.Main] = new SCNNode { Name = "omni", Position = new SCNVector3(0, 3, -13) }; Lights [(int)Light.Main].Light = new SCNLight { LightType = SCNLightType.Omni, AttenuationStartDistance = 10, AttenuationEndDistance = 50, Color = NSColor.Black }; CameraHandle.AddChildNode(Lights [(int)Light.Main]); //make all lights relative to the camera node // Front light Lights [(int)Light.Front] = new SCNNode { Name = "front light", Position = new SCNVector3(0, 0, 0) }; Lights [(int)Light.Front].Light = new SCNLight { LightType = SCNLightType.Directional, Color = NSColor.Black }; CameraHandle.AddChildNode(Lights [(int)Light.Front]); // Spot light Lights [(int)Light.Spot] = new SCNNode { Name = "spot light", Transform = SCNMatrix4.Mult(SCNMatrix4.CreateFromAxisAngle(new SCNVector3(1, 0, 0), -(nfloat)(Math.PI / 2) * 0.8f), SCNMatrix4.CreateFromAxisAngle(new SCNVector3(0, 0, 1), -0.3f)), Position = new SCNVector3(0, 30, -19), Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 2)) }; Lights [(int)Light.Spot].Light = new SCNLight { LightType = SCNLightType.Spot, ShadowRadius = 3, ZNear = 20, ZFar = 100, Color = NSColor.Black, CastsShadow = true }; NarrowSpotlight(false); CameraHandle.AddChildNode(Lights [(int)Light.Spot]); // Left light Lights [(int)Light.Left] = new SCNNode { Name = "left light", Position = new SCNVector3(-20, 10, -20), Rotation = new SCNVector4(0, 1, 0, (float)(Math.PI / 2)) }; Lights [(int)Light.Left].Light = new SCNLight { LightType = SCNLightType.Omni, AttenuationStartDistance = 30, AttenuationEndDistance = 80, Color = NSColor.Black }; CameraHandle.AddChildNode(Lights [(int)Light.Left]); // Right light Lights [(int)Light.Right] = new SCNNode { Name = "right light", Position = new SCNVector3(20, 10, -20) }; Lights [(int)Light.Right].Light = new SCNLight { LightType = SCNLightType.Omni, AttenuationStartDistance = 30, AttenuationEndDistance = 80, Color = NSColor.Black }; CameraHandle.AddChildNode(Lights [(int)Light.Right]); // Ambient light Lights [(int)Light.Ambient] = new SCNNode { Name = "ambient light" }; Lights [(int)Light.Ambient].Light = new SCNLight { LightType = SCNLightType.Ambient, Color = NSColor.FromCalibratedWhite(0.0f, 1.0f) }; Scene.RootNode.AddChildNode(Lights [(int)Light.Ambient]); }
public PresentationViewController(string path) { // Load the presentation settings from the plist file var settingsPath = NSBundle.MainBundle.PathForResource(path, "xml"); SlideSettings = JsonConvert.DeserializeObject <Settings> (File.ReadAllText(settingsPath)); SlideCache = new Dictionary <string, Slide> (); // Create a new empty scene Scene = new SCNScene(); // Create and add a camera to the scene // We create three separate nodes to ease the manipulation of the global position, pitch (ie. orientation around the x axis) and relative position // - cameraHandle is used to control the global position in world space // - cameraPitch is used to rotate the position around the x axis // - cameraNode is sometimes manipulated by slides to move the camera relatively to the global position (cameraHandle). But this node is supposed to always be repositioned at (0, 0, 0) in the end of a slide. CameraHandle = SCNNode.Create(); CameraHandle.Name = "cameraHandle"; Scene.RootNode.AddChildNode(CameraHandle); CameraPitch = SCNNode.Create(); CameraPitch.Name = "cameraPitch"; CameraHandle.AddChildNode(CameraPitch); CameraNode = SCNNode.Create(); CameraNode.Name = "cameraNode"; CameraNode.Camera = new SCNCamera(); // Set the default field of view to 70 degrees (a relatively strong perspective) CameraNode.Camera.XFov = 70.0; CameraNode.Camera.YFov = 42.0; CameraPitch.AddChildNode(CameraNode); // Setup the different lights InitLighting(); // Create and add a reflective floor to the scene var floorMaterial = new SCNMaterial(); floorMaterial.Ambient.Contents = NSColor.Black; floorMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/floor", "png")); floorMaterial.Diffuse.ContentsTransform = SCNMatrix4.CreateFromAxisAngle(new SCNVector3(0, 0, 1), NMath.PI / 4); floorMaterial.Specular.WrapS = floorMaterial.Specular.WrapT = floorMaterial.Diffuse.WrapS = floorMaterial.Diffuse.WrapT = SCNWrapMode.Mirror; Floor = SCNFloor.Create(); Floor.ReflectionFalloffEnd = 3.0f; Floor.FirstMaterial = floorMaterial; var floorNode = SCNNode.Create(); floorNode.Geometry = Floor; Scene.RootNode.AddChildNode(floorNode); floorNode.PhysicsBody = SCNPhysicsBody.CreateStaticBody(); //make floor dynamic for physics slides Scene.PhysicsWorld.Speed = 0; //pause physics to avoid continuous drawing // Use a shader modifier to support a secondary texture for some slides var shaderFile = NSBundle.MainBundle.PathForResource("Shaders/floor", "shader"); var surfaceModifier = File.ReadAllText(shaderFile); floorMaterial.ShaderModifiers = new SCNShaderModifiers { EntryPointSurface = surfaceModifier }; // Set the scene to the view View = new SCNView(CGRect.Empty); ((SCNView)View).Scene = Scene; ((SCNView)View).BackgroundColor = NSColor.Black; // black fog Scene.FogColor = NSColor.FromCalibratedWhite(0, 1); Scene.FogEndDistance = 45; Scene.FogStartDistance = 40; // Turn on jittering for better anti-aliasing when the scene is still ((SCNView)View).JitteringEnabled = true; // Start the presentation GoToSlide(0); }
public override void PresentStep(int index, PresentationViewController presentationViewController) { // Set the slide's title TextManager.SetTitle("Labs"); // Add two labs var lab1TitleNode = Utils.SCBoxNode("Scene Kit Lab", new CGRect(-375, -35, 750, 70), NSColor.FromCalibratedWhite(0.15f, 1.0f), 0.0f, false); lab1TitleNode.Scale = new SCNVector3(0.02f, 0.02f, 0.02f); lab1TitleNode.Position = new SCNVector3(-2.8f, 30.7f, 10.0f); lab1TitleNode.Rotation = new SCNVector4(1, 0, 0, (float)(Math.PI)); lab1TitleNode.Opacity = 0.0f; var lab2TitleNode = (SCNNode)lab1TitleNode.Copy(); lab2TitleNode.Position = new SCNVector3(-2.8f, 29.2f, 10.0f); ContentNode.AddChildNode(lab1TitleNode); ContentNode.AddChildNode(lab2TitleNode); var lab1InfoNode = AddLabInfoNode("\nGraphics and Games Lab A\nTuesday 4:00PM", 30.7f); var lab2InfoNode = AddLabInfoNode("\nGraphics and Games Lab A\nWednesday 9:00AM", 29.2f); var delayInSeconds = 0.75; var popTime = new DispatchTime(DispatchTime.Now, (long)(delayInSeconds * Utils.NSEC_PER_SEC)); DispatchQueue.MainQueue.DispatchAfter(popTime, () => { SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1; lab1TitleNode.Opacity = lab2TitleNode.Opacity = 1.0f; lab1TitleNode.Rotation = lab2TitleNode.Rotation = new SCNVector4(1, 0, 0, 0); lab1InfoNode.Opacity = lab2InfoNode.Opacity = 1.0f; lab1InfoNode.Rotation = lab2InfoNode.Rotation = new SCNVector4(0, 1, 0, 0); SCNTransaction.Commit(); }); }