public override void DidOrderIn(PresentationViewController presentationViewController) { var banana = Utils.SCAddChildNode(ContentNode, "banana", "Scenes.scnassets/banana/banana", 5); banana.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 2)); banana.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0, NMath.PI * 2, 0, 1.5f))); banana.Position = new SCNVector3(2.5f, 5, 10); var gaussianBlurFilter = new CIGaussianBlur() { Radius = 10 }; gaussianBlurFilter.SetDefaults(); banana.Filters = new CIFilter[] { gaussianBlurFilter }; banana = (SCNNode)banana.Copy(); ContentNode.AddChildNode(banana); banana.Position = new SCNVector3(6, 5, 10); var pixellateFilter = new CIPixellate(); pixellateFilter.SetDefaults(); banana.Filters = new CIFilter[] { pixellateFilter }; banana = (SCNNode)banana.Copy(); ContentNode.AddChildNode(banana); banana.Position = new SCNVector3(9.5f, 5, 10); var filter = CIFilter.FromName("CIEdgeWork"); filter.SetDefaults(); banana.Filters = new CIFilter[] { filter }; }
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 (); }); }
public Slide() { ContentNode = SCNNode.Create(); GroundNode = SCNNode.Create(); ContentNode.AddChildNode(GroundNode); TextManager = new SlideTextManager(); ContentNode.AddChildNode(TextManager.TextNode); // Default parameters LightIntensities = new float[] { 1.0f }; MainLightPosition = new SCNVector3(0, 3, -13); EnableShadows = false; FloorImageName = null; FloorImageExtension = null; FloorReflectivity = 0.25f; FloorFalloff = 3.0f; TransitionDuration = 1.0f; TransitionOffsetX = 0.0f; TransitionOffsetZ = 0.0f; TransitionRotation = 0.0f; Altitude = 5.0f; Pitch = 0.0f; IsNewIn10_9 = false; }
public override void SetupSlide(PresentationViewController presentationViewController) { // Set the slide's title and subtitle and add some text TextManager.SetTitle("Materials"); TextManager.SetSubtitle("Property contents"); TextManager.AddBulletAtLevel("Color", 0); TextManager.AddBulletAtLevel("CGColorRef / NSColor / UIColor", 0); var node = SCNNode.Create(); node.Name = "material-cube"; node.Geometry = SCNBox.Create(W, W, W, W * 0.02f); Material = node.Geometry.FirstMaterial; Material.Diffuse.Contents = NSColor.Red; Object = node; node.Position = new SCNVector3(8, 11, 0); ContentNode.AddChildNode(node); node.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy((float)Math.PI * 2, new SCNVector3(0.4f, 1, 0), 4))); MaterialLayerSlideReference = this; }
public override void SetupSlide(PresentationViewController presentationViewController) { // Set the slide's title and subtitle and add some text TextManager.SetTitle("Animations"); TextManager.SetSubtitle("Implicit animations"); TextManager.AddCode("#// Begin a transaction \n" + "#SCNTransaction#.Begin (); \n" + "#SCNTransaction#.AnimationDuration = 2.0f; \n\n" + "// Change properties \n" + "aNode.#Opacity# = 1.0f; \n" + "aNode.#Rotation# = \n" + " new SCNVector4 (0, 1, 0, NMath.PI * 4); \n\n" + "// Commit the transaction \n" + "SCNTransaction.#Commit ()#;#"); // A simple torus that we will animate to illustrate the code AnimatedNode = SCNNode.Create(); AnimatedNode.Position = new SCNVector3(10, 7, 0); // Use an extra node that we can tilt it and cumulate that with the animation var torusNode = SCNNode.Create(); torusNode.Geometry = SCNTorus.Create(4.0f, 1.5f); torusNode.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI * 0.7f)); torusNode.Geometry.FirstMaterial.Diffuse.Contents = NSColor.Red; torusNode.Geometry.FirstMaterial.Specular.Contents = NSColor.White; torusNode.Geometry.FirstMaterial.Reflective.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/envmap", "jpg")); torusNode.Geometry.FirstMaterial.FresnelExponent = 0.7f; AnimatedNode.AddChildNode(torusNode); ContentNode.AddChildNode(AnimatedNode); }
public override void SetupSlide(PresentationViewController presentationViewController) { // Set the slide's title and subtitle and add some text TextManager.SetTitle("Animations"); TextManager.SetSubtitle("Explicit animations"); TextManager.AddCode("#// Create an animation \n" + "animation = #CABasicAnimation#.FromKeyPath (\"rotation\"); \n\n" + "// Configure the animation \n" + "animation.#Duration# = 2.0f; \n" + "animation.#To# = NSValue.FromVector (new SCNVector4 (0, 1, 0, NMath.PI * 2)); \n" + "animation.#RepeatCount# = float.MaxValue; \n\n" + "// Play the animation \n" + "aNode.#AddAnimation #(animation, \"myAnimation\");#"); // A simple torus that we will animate to illustrate the code AnimatedNode = SCNNode.Create(); AnimatedNode.Position = new SCNVector3(9, 5.7f, 16); // Use an extra node that we can tilt it and cumulate that with the animation var torusNode = SCNNode.Create(); torusNode.Geometry = SCNTorus.Create(4.0f, 1.5f); torusNode.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI * 0.5f)); torusNode.Geometry.FirstMaterial.Diffuse.Contents = NSColor.Red; torusNode.Geometry.FirstMaterial.Specular.Contents = NSColor.White; torusNode.Geometry.FirstMaterial.Reflective.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/envmap", "jpg")); torusNode.Geometry.FirstMaterial.FresnelExponent = 0.7f; AnimatedNode.AddChildNode(torusNode); ContentNode.AddChildNode(AnimatedNode); }
private void AddBox(string title, CGRect frame, int level, NSColor color) { var node = Utils.SCBoxNode(title, frame, color, 2.0f, true); node.Scale = new SCNVector3(0.02f, 0.02f, 0.02f); node.Position = new SCNVector3(-5, 1.5f * level, 10); ContentNode.AddChildNode(node); }
public override void PresentStep(int index, PresentationViewController presentationViewController) { SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0; switch (index) { case 0: // Set the slide's title and subtile and add some text TextManager.SetTitle("Node Attributes"); TextManager.SetSubtitle("Lights"); TextManager.AddBulletAtLevel("SCNLight", 0); TextManager.AddBulletAtLevel("Four light types", 0); TextManager.AddBulletAtLevel("Omni", 1); TextManager.AddBulletAtLevel("Directional", 1); TextManager.AddBulletAtLevel("Spot", 1); TextManager.AddBulletAtLevel("Ambient", 1); break; case 1: // Add some code var codeExampleNode = TextManager.AddCode("#aNode.#Light# = SCNLight.Create (); \naNode.Light.LightType = SCNLightType.Omni;#"); codeExampleNode.Position = new SCNVector3(14, 11, 1); // Add a light to the scene LightNode = SCNNode.Create(); LightNode.Light = SCNLight.Create(); LightNode.Light.LightType = SCNLightType.Omni; LightNode.Light.Color = NSColor.Black; // initially off LightNode.Light.SetAttribute(new NSNumber(30), SCNLightAttribute.AttenuationStartKey); LightNode.Light.SetAttribute(new NSNumber(40), SCNLightAttribute.AttenuationEndKey); LightNode.Position = new SCNVector3(5, 3.5f, 0); ContentNode.AddChildNode(LightNode); // Load two images to help visualize the light (on and off) LightOffImageNode = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/light-off", "tiff"), 7, false); LightOnImageNode = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/light-on", "tiff"), 7, false); LightOnImageNode.Opacity = 0; LightNode.AddChildNode(LightOnImageNode); LightNode.AddChildNode(LightOffImageNode); break; case 2: // Switch the light on SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1; LightNode.Light.Color = NSColor.FromCalibratedRgba(1, 1, 0.8f, 1); LightOnImageNode.Opacity = 1.0f; LightOffImageNode.Opacity = 0.0f; SCNTransaction.Commit(); break; } SCNTransaction.Commit(); }
public override void PresentStep(int index, PresentationViewController presentationViewController) { // Set the slide's title TextManager.SetTitle("Labs"); var relatedImage = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/labs", "png"), 35, false); relatedImage.Position = new SCNVector3(0, 30, 0); relatedImage.CastsShadow = false; ContentNode.AddChildNode(relatedImage); }
public override void SetupSlide(PresentationViewController presentationViewController) { RedColor = NSColor.FromDeviceRgba(168.0f / 255.0f, 21.0f / 255.0f, 0.0f / 255.0f, 1); GreenColor = NSColor.FromDeviceRgba(154.0f / 255.0f, 197.0f / 255.0f, 58.0f / 255.0f, 1); BlueColor = NSColor.FromDeviceRgba(49.0f / 255.0f, 80.0f / 255.0f, 201.0f / 255.0f, 1); PurpleColor = NSColor.FromDeviceRgba(190.0f / 255.0f, 56.0f / 255.0f, 243.0f / 255.0f, 1); // Create the diagram but hide it DiagramNode = CloningDiagramNode(); DiagramNode.Opacity = 0.0f; ContentNode.AddChildNode(DiagramNode); }
private void AddBox(string title, CGRect frame, int level, NSColor color) { var node = Utils.SCBoxNode(title, frame, color, 2.0f, true); node.Pivot = SCNMatrix4.CreateTranslation(0, frame.Size.Height / 2, 0); node.Scale = new SCNVector3(0.02f, 0.02f, 0.02f); node.Position = new SCNVector3(-5, (0.02f * frame.Size.Height / 2) + (1.5f * level), 10.0f); node.Rotation = new SCNVector4(1, 0, 0, (float)(Math.PI / 2)); node.Opacity = 0.0f; ContentNode.AddChildNode(node); Boxes.Add(node); }
public override void SetupSlide(PresentationViewController presentationViewController) { var labelNode = Utils.SCLabelNode("XAMARIN 2014", Utils.LabelSize.Normal, false); labelNode.Position = new SCNVector3(-3.6f, 29.5f, 20); // Reducing the text's flatness makes it smoother, less tesselated var text = (SCNText)labelNode.Geometry; text.Flatness = 0.1f; ContentNode.AddChildNode(labelNode); }
public override void SetupSlide(PresentationViewController presentationViewController) { // Add some text TextManager.SetTitle("Renderers"); TextManager.SetSubtitle("View creation in Interface Builder"); TextManager.AddBulletAtLevel("Drag an SCNView from the library", 0); // And an image var imageNode = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/renderers/Interface Builder", "png"), 8.3f, false); imageNode.Position = new SCNVector3(0.0f, 3.2f, 11.0f); ContentNode.AddChildNode(imageNode); }
public override void SetupSlide(PresentationViewController presentationViewController) { TextManager.SetTitle("Renderers"); // Add labels var node = Utils.SCLabelNode("SCNView", Utils.LabelSize.Normal, true); node.Position = new SCNVector3(-14, 7, 0); ContentNode.AddChildNode(node); node = Utils.SCLabelNode("SCNLayer", Utils.LabelSize.Normal, true); node.Position = new SCNVector3(-2.2f, 7, 0); ContentNode.AddChildNode(node); node = Utils.SCLabelNode("SCNRenderer", Utils.LabelSize.Normal, true); node.Position = new SCNVector3(9.5f, 7, 0); ContentNode.AddChildNode(node); // Add images - SCNView var box = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/renderers/renderer-window", "png"), 8, true); box.Position = new SCNVector3(-10, 3, 5); ContentNode.AddChildNode(box); box = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/renderers/teapot", "tiff"), 6, true); box.Position = new SCNVector3(-10, 3, 5.1f); ContentNode.AddChildNode(box); // Add images - SCNLayer box = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/renderers/renderer-layer", "png"), 7.4f, true); box.Position = new SCNVector3(0, 3.5f, 5); box.Rotation = new SCNVector4(0, 0, 1, (float)(Math.PI / 20)); ContentNode.AddChildNode(box); box = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/renderers/teapot", "tiff"), 6, true); box.Position = new SCNVector3(0, 3.5f, 5.1f); box.Rotation = new SCNVector4(0, 0, 1, (float)(Math.PI / 20)); ContentNode.AddChildNode(box); // Add images - SCNRenderer box = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/renderers/renderer-framebuffer", "png"), 8, true); box.Position = new SCNVector3(10, 3.2f, 5); ContentNode.AddChildNode(box); box = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/renderers/teapot", "tiff"), 6, true); box.Position = new SCNVector3(10, 3, 5.1f); ContentNode.AddChildNode(box); }
public override void SetupSlide(PresentationViewController presentationViewController) { TextManager.SetTitle("Depth of Field"); TextManager.SetSubtitle("SCNCamera"); // Create a node that will contain the chess board var intermediateNode = SCNNode.Create(); intermediateNode.Scale = new SCNVector3(35.0f, 35.0f, 35.0f); intermediateNode.Position = new SCNVector3(0, 2.1f, 20); intermediateNode.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 2)); ContentNode.AddChildNode(intermediateNode); // Load the chess model and add to "intermediateNode" Utils.SCAddChildNode(intermediateNode, "Line01", "Scenes.scnassets/chess/chess", 1); }
public override void SetupSlide(PresentationViewController presentationViewController) { TextManager.SetTitle("Scene Manipulation"); TextManager.SetSubtitle("Retrieving a node"); TextManager.AddCode("#// Get by name \n" + "var aNode = scene.RootNode \n" + " .#FindChildNode #(\"aName\", true);#"); sceneGraphDiagramNode = SlideSceneGraph.SharedScenegraphDiagramNode(); SlideSceneGraph.ScenegraphDiagramGoToStep(7); sceneGraphDiagramNode.Opacity = 0.0f; sceneGraphDiagramNode.Position = new SCNVector3(1.5f, 8.0f, 0); ContentNode.AddChildNode(sceneGraphDiagramNode); }
private SCNNode AddLabInfoNode(string title, float yPosition) { var labInfoNode = Utils.SCBoxNode (title, new CGRect (0, 0, 293.33f, 93.33f), NSColor.FromDeviceRgba (31 / 255, 31 / 255, 31 / 255, 1), 0.0f, false); labInfoNode.Scale = new SCNVector3 (0.015f, 0.015f, 0.015f); labInfoNode.Pivot = SCNMatrix4.CreateTranslation (new SCNVector3 (145.33f, 46.66f, 5)); labInfoNode.Position = new SCNVector3 (6.9f, yPosition, 10.0f); labInfoNode.Rotation = new SCNVector4 (0, 1, 0, (float)(Math.PI)); labInfoNode.Opacity = 0.0f; var colorBox = Utils.SCBoxNode (null, new CGRect (293.33f, 0, 40, 93.33f), NSColor.FromDeviceRgba (1, 214 / 255, 37 / 255, 1), 0.0f, false); colorBox.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Constant; ContentNode.AddChildNode (labInfoNode); labInfoNode.AddChildNode (colorBox); return labInfoNode; }
public override void SetupSlide(PresentationViewController presentationViewController) { TextManager.SetTitle("Materials"); TextManager.AddBulletAtLevel("Determines the appearance of the geometry", 0); TextManager.AddBulletAtLevel("SCNMaterial", 0); TextManager.AddBulletAtLevel("Material properties", 0); TextManager.AddBulletAtLevel("SCNMaterialProperty", 1); TextManager.AddBulletAtLevel("Contents is a color or an image", 1); // Prepare the diagram but hide it for now SceneGraphDiagramNode = SlideSceneGraph.SharedScenegraphDiagramNode(); SlideSceneGraph.ScenegraphDiagramGoToStep(0); SceneGraphDiagramNode.Position = new SCNVector3(3.0f, 8.0f, 0); SceneGraphDiagramNode.Opacity = 0.0f; ContentNode.AddChildNode(SceneGraphDiagramNode); }
public override void SetupSlide(PresentationViewController presentationViewController) { // Add some text TextManager.SetTitle("Displaying the Scene"); TextManager.SetSubtitle("Game Template"); TextManager.AddBulletAtLevel("Start with the Xcode game template", 0); TextManager.AddBulletAtLevel("Or drag an SCNView from the library", 0); // And an image var imageNode = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/renderers/Interface Builder", "png"), 8.3f, false); imageNode.Position = new SCNVector3(-4.0f, 3.2f, 11.0f); ContentNode.AddChildNode(imageNode); imageNode = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/game_big", "png"), 7, false); imageNode.Position = new SCNVector3(5.0f, 3.5f, 11.0f); imageNode.Geometry.FirstMaterial.Diffuse.MagnificationFilter = SCNFilterMode.Nearest; ContentNode.AddChildNode(imageNode); }
private void PlaceFeature(string message, CGPoint p, float offset) { // Create and configure a node with a text geometry, and add it to the scene var text = SCNText.Create(message, 5); text.Font = Font; text.Flatness = 0.4f; text.Materials = Materials; var textNode = SCNNode.Create(); textNode.Geometry = text; textNode.Position = new SCNVector3(p.X, p.Y + Altitude, 0); textNode.Scale = new SCNVector3(0.02f, 0.02f, 0.02f); ContentNode.AddChildNode(textNode); // Animation the node's position and opacity var positionAnimation = CABasicAnimation.FromKeyPath("position.z"); positionAnimation.From = NSNumber.FromInt16(-10); positionAnimation.To = NSNumber.FromInt16(14); positionAnimation.Duration = 7.0f; positionAnimation.TimeOffset = -offset * positionAnimation.Duration; positionAnimation.RepeatCount = float.MaxValue; textNode.AddAnimation(positionAnimation, new NSString("positionAnimation")); var opacityAnimation = CAKeyFrameAnimation.FromKeyPath("opacity"); opacityAnimation.KeyTimes = new NSNumber[] { 0.0f, 0.2f, 0.9f, 1.0f }; opacityAnimation.Values = new NSNumber[] { 0.0f, 1.0f, 1.0f, 0.0f }; opacityAnimation.Duration = positionAnimation.Duration; opacityAnimation.TimeOffset = positionAnimation.TimeOffset; opacityAnimation.RepeatCount = float.MaxValue; textNode.AddAnimation(opacityAnimation, new NSString("opacityAnimation")); }
public override void PresentStep(int index, PresentationViewController presentationViewController) { // Animate by default SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0; switch (index) { case 0: TextManager.FlipInText(SlideTextManager.TextType.Bullet); break; case 1: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddEmptyLine(); TextManager.AddCode("#// Rotate forever\n" + "[aNode #runAction:#\n" + " [SCNAction repeatActionForever:\n" + " [SCNAction rotateByX:0 y:M_PI*2 z:0 duration:5.0]]];#"); TextManager.FlipInText(SlideTextManager.TextType.Code); break; case 2: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.FlipOutText(SlideTextManager.TextType.Code); TextManager.AddBulletAtLevel("Move", 0); TextManager.AddBulletAtLevel("Rotate", 0); TextManager.AddBulletAtLevel("Scale", 0); TextManager.AddBulletAtLevel("Opacity", 0); TextManager.AddBulletAtLevel("Remove", 0); TextManager.AddBulletAtLevel("Wait", 0); TextManager.AddBulletAtLevel("Custom block", 0); TextManager.FlipInText(SlideTextManager.TextType.Bullet); break; case 3: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddEmptyLine(); TextManager.AddBulletAtLevel("Directly targets the render tree", 0); TextManager.FlipInText(SlideTextManager.TextType.Bullet); break; case 4: TextManager.AddBulletAtLevel("node.position / node.presentationNode.position", 0); //labels var label1 = TextManager.AddTextAtLevel("Action", 0); label1.Position = new SCNVector3(-15, 3, 0); var label2 = TextManager.AddTextAtLevel("Animation", 0); label2.Position = new SCNVector3(-15, -2, 0); //animation var animNode = SCNNode.Create(); var cubeSize = 4.0f; animNode.Position = new SCNVector3(-5, cubeSize / 2, 0); var cube = SCNBox.Create(cubeSize, cubeSize, cubeSize, 0.05f * cubeSize); cube.FirstMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/texture", "png")); cube.FirstMaterial.Diffuse.MipFilter = SCNFilterMode.Linear; cube.FirstMaterial.Diffuse.WrapS = SCNWrapMode.Repeat; cube.FirstMaterial.Diffuse.WrapT = SCNWrapMode.Repeat; animNode.Geometry = cube; ContentNode.AddChildNode(animNode); SCNTransaction.Begin(); SCNNode animPosIndicator = null; SCNAnimationEvent startEvt = SCNAnimationEvent.Create(0, (CAAnimation animation, NSObject animatedObject, bool playingBackward) => { SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0; animPosIndicator.Position = new SCNVector3(10, animPosIndicator.Position.Y, animPosIndicator.Position.Z); SCNTransaction.Commit(); }); SCNAnimationEvent endEvt = SCNAnimationEvent.Create(1, (CAAnimation animation, NSObject animatedObject, bool playingBackward) => { SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0; animPosIndicator.Position = new SCNVector3(-5, animPosIndicator.Position.Y, animPosIndicator.Position.Z); SCNTransaction.Commit(); }); var anim = CABasicAnimation.FromKeyPath("position.x"); anim.Duration = 3; anim.From = new NSNumber(0.0); anim.To = new NSNumber(15.0); anim.Additive = true; anim.AutoReverses = true; anim.AnimationEvents = new SCNAnimationEvent[] { startEvt, endEvt }; anim.RepeatCount = float.MaxValue; animNode.AddAnimation(anim, new NSString("cubeAnimation")); //action var actionNode = SCNNode.Create(); actionNode.Position = new SCNVector3(-5, cubeSize * 1.5f + 1, 0); actionNode.Geometry = cube; ContentNode.AddChildNode(actionNode); var mv = SCNAction.MoveBy(15, 0, 0, 3); actionNode.RunAction(SCNAction.RepeatActionForever(SCNAction.Sequence(new SCNAction[] { mv, mv.ReversedAction() }))); //position indicator var positionIndicator = SCNNode.Create(); positionIndicator.Geometry = SCNCylinder.Create(0.5f, 0.01f); positionIndicator.Geometry.FirstMaterial.Diffuse.Contents = NSColor.Red; positionIndicator.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Constant; positionIndicator.EulerAngles = new SCNVector3(NMath.PI / 2, 0, 0); positionIndicator.Position = new SCNVector3(0, 0, cubeSize * 0.5f); actionNode.AddChildNode(positionIndicator); //anim pos indicator animPosIndicator = positionIndicator.Clone(); animPosIndicator.Position = new SCNVector3(5, cubeSize / 2, cubeSize * 0.5f); ContentNode.AddChildNode(animPosIndicator); SCNTransaction.Commit(); break; } SCNTransaction.Commit(); }
public override void PresentStep(int index, PresentationViewController presentationViewController) { //animate by default SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1; switch (index) { case 0: SCNTransaction.AnimationDuration = 0; // Set the slide's title and subtitle and add some text TextManager.SetTitle("Morphing"); TextManager.AddBulletAtLevel("Linear morph between multiple targets", 0); // Initial state, no ambient occlusion // This also shows how uniforms from shader modifiers can be set using KVC MapNode.Geometry.SetValueForKey(new NSNumber(0), new NSString("ambientOcclusionYFactor")); break; case 1: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); // Reveal the map and show the gauges MapNode.Opacity = 1.0f; GaugeAProgressNode = SCNNode.Create(); GaugeBProgressNode = SCNNode.Create(); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0; GaugeANode = Utils.SCGaugeNode("Target A", ref GaugeAProgressNode); GaugeANode.Position = new SCNVector3(-10.5f, 15, -5); ContentNode.AddChildNode(GaugeANode); GaugeBNode = Utils.SCGaugeNode("Target B", ref GaugeBProgressNode); GaugeBNode.Position = new SCNVector3(-10.5f, 13, -5); ContentNode.AddChildNode(GaugeBNode); SCNTransaction.Commit(); break; case 2: // Morph and update the gauges GaugeAProgressNode.Scale = new SCNVector3(1, 1, 1); MapNode.Morpher.SetWeight(0.65f, 0); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1; GaugeAProgressNode.Opacity = 1.0f; SCNTransaction.Commit(); var shadowPlane = MapNode.ChildNodes [0]; shadowPlane.Scale = new SCNVector3(0.35f, 1, 1); MapNode.ParentNode.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 4) * 0.75f); break; case 3: // Morph and update the gauges GaugeAProgressNode.Scale = new SCNVector3(1, 0.01f, 1); MapNode.Morpher.SetWeight(0, 0); shadowPlane = MapNode.ChildNodes [0]; shadowPlane.Scale = new SCNVector3(1, 1, 1); MapNode.ParentNode.Rotation = new SCNVector4(1, 0, 0, 0); SCNTransaction.SetCompletionBlock(() => { SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.5f; GaugeAProgressNode.Opacity = 0.0f; SCNTransaction.Commit(); }); break; case 4: // Morph and update the gauges GaugeBProgressNode.Scale = new SCNVector3(1, 1, 1); MapNode.Morpher.SetWeight(0.4f, 1); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.1f; GaugeBProgressNode.Opacity = 1.0f; SCNTransaction.Commit(); shadowPlane = MapNode.ChildNodes [0]; shadowPlane.Scale = new SCNVector3(1, 0.6f, 1); MapNode.ParentNode.Rotation = new SCNVector4(0, 1, 0, -(float)(Math.PI / 4) * 0.5f); break; case 5: // Morph and update the gauges GaugeBProgressNode.Scale = new SCNVector3(1, 0.01f, 1); MapNode.Morpher.SetWeight(0, 1); shadowPlane = MapNode.ChildNodes [0]; shadowPlane.Scale = new SCNVector3(1, 1, 1); MapNode.ParentNode.Rotation = new SCNVector4(0, 1, 0, 0); SCNTransaction.SetCompletionBlock(() => { SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.5f; GaugeBProgressNode.Opacity = 0.0f; SCNTransaction.Commit(); }); break; case 6: // Morph and update the gauges GaugeAProgressNode.Scale = new SCNVector3(1, 1, 1); GaugeBProgressNode.Scale = new SCNVector3(1, 1, 1); MapNode.Morpher.SetWeight(0.65f, 0); MapNode.Morpher.SetWeight(0.30f, 1); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.1f; GaugeAProgressNode.Opacity = 1.0f; GaugeBProgressNode.Opacity = 1.0f; SCNTransaction.Commit(); shadowPlane = MapNode.ChildNodes [0]; shadowPlane.Scale = new SCNVector3(0.4f, 0.7f, 1); shadowPlane.Opacity = 0.2f; MapNode.Geometry.SetValueForKey(new NSNumber(0.35f), new NSString("ambientOcclusionYFactor")); MapNode.Position = new SCNVector3(0, 0, 5); MapNode.ParentNode.Rotation = new SCNVector4(0, 1, 0, -(float)(Math.PI / 4) * 0.5f); MapNode.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 4) * 0.75f); break; case 7: SCNTransaction.AnimationDuration = 0.5f; // Hide everything and update the text MapNode.Opacity = 0; GaugeANode.Opacity = 0.0f; GaugeBNode.Opacity = 0.0f; TextManager.SetSubtitle("SCNMorpher"); TextManager.AddBulletAtLevel("Topology must match", 0); TextManager.AddBulletAtLevel("Can be loaded from DAEs", 0); TextManager.AddBulletAtLevel("Can be created programmatically", 0); break; } SCNTransaction.Commit(); }
public override void PresentStep(int index, PresentationViewController presentationViewController) { switch (index) { case 0: // Set the slide's title and subtitle TextManager.SetTitle("Scene Graph"); TextManager.SetSubtitle("Summary"); break; case 1: // A node that will help visualize the position of the stars WireframeBoxNode = SCNNode.Create(); WireframeBoxNode.Rotation = new SCNVector4(0, 1, 0, (float)(Math.PI / 4)); WireframeBoxNode.Geometry = SCNBox.Create(1, 1, 1, 0); WireframeBoxNode.Geometry.FirstMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/box_wireframe", "png")); WireframeBoxNode.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Constant; // no lighting WireframeBoxNode.Geometry.FirstMaterial.DoubleSided = true; // double sided // Sun SunNode = SCNNode.Create(); SunNode.Position = new SCNVector3(0, 30, 0); ContentNode.AddChildNode(SunNode); SunNode.AddChildNode((SCNNode)WireframeBoxNode.Copy()); // Earth-rotation (center of rotation of the Earth around the Sun) var earthRotationNode = SCNNode.Create(); SunNode.AddChildNode(earthRotationNode); // Earth-group (will contain the Earth, and the Moon) EarthGroupNode = SCNNode.Create(); EarthGroupNode.Position = new SCNVector3(15, 0, 0); earthRotationNode.AddChildNode(EarthGroupNode); // Earth EarthNode = (SCNNode)WireframeBoxNode.Copy(); EarthNode.Position = new SCNVector3(0, 0, 0); EarthGroupNode.AddChildNode(EarthNode); // Rotate the Earth around the Sun var animation = CABasicAnimation.FromKeyPath("rotation"); animation.Duration = 10.0f; animation.To = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2))); animation.RepeatCount = float.MaxValue; earthRotationNode.AddAnimation(animation, new NSString("earth rotation around sun")); // Rotate the Earth animation = CABasicAnimation.FromKeyPath("rotation"); animation.Duration = 1.0f; animation.From = NSValue.FromVector(new SCNVector4(0, 1, 0, 0)); animation.To = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2))); animation.RepeatCount = float.MaxValue; EarthNode.AddAnimation(animation, new NSString("earth rotation")); break; case 2: // Moon-rotation (center of rotation of the Moon around the Earth) var moonRotationNode = SCNNode.Create(); EarthGroupNode.AddChildNode(moonRotationNode); // Moon MoonNode = (SCNNode)WireframeBoxNode.Copy(); MoonNode.Position = new SCNVector3(5, 0, 0); moonRotationNode.AddChildNode(MoonNode); // Rotate the moon around the Earth animation = CABasicAnimation.FromKeyPath("rotation"); animation.Duration = 1.5f; animation.To = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2))); animation.RepeatCount = float.MaxValue; moonRotationNode.AddAnimation(animation, new NSString("moon rotation around earth")); // Rotate the moon animation = CABasicAnimation.FromKeyPath("rotation"); animation.Duration = 1.5f; animation.To = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2))); animation.RepeatCount = float.MaxValue; MoonNode.AddAnimation(animation, new NSString("moon rotation")); break; case 3: // Add geometries (spheres) to represent the stars SunNode.Geometry = SCNSphere.Create(2.5f); EarthNode.Geometry = SCNSphere.Create(1.5f); MoonNode.Geometry = SCNSphere.Create(0.75f); // Add a textured plane to represent Earth's orbit var earthOrbit = SCNNode.Create(); earthOrbit.Opacity = 0.4f; earthOrbit.Geometry = SCNPlane.Create(31, 31); earthOrbit.Geometry.FirstMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/orbit", "png")); earthOrbit.Geometry.FirstMaterial.Diffuse.MipFilter = SCNFilterMode.Linear; earthOrbit.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 2)); earthOrbit.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Constant; // no lighting SunNode.AddChildNode(earthOrbit); break; case 4: // Add a halo to the Sun (a simple textured plane that does not write to depth) SunHaloNode = SCNNode.Create(); SunHaloNode.Geometry = SCNPlane.Create(30, 30); SunHaloNode.Rotation = new SCNVector4(1, 0, 0, Pitch * (float)(Math.PI / 180.0f)); SunHaloNode.Geometry.FirstMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/sun-halo", "png")); SunHaloNode.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Constant; // no lighting SunHaloNode.Geometry.FirstMaterial.WritesToDepthBuffer = false; // do not write to depth SunHaloNode.Opacity = 0.2f; SunNode.AddChildNode(SunHaloNode); // Add materials to the stars EarthNode.Geometry.FirstMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/earth-diffuse-mini", "jpg")); EarthNode.Geometry.FirstMaterial.Emission.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/earth-emissive-mini", "jpg")); EarthNode.Geometry.FirstMaterial.Specular.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/earth-specular-mini", "jpg")); MoonNode.Geometry.FirstMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/moon", "jpg")); SunNode.Geometry.FirstMaterial.Multiply.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/sun", "jpg")); SunNode.Geometry.FirstMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes/earth/sun", "jpg")); SunNode.Geometry.FirstMaterial.Multiply.Intensity = 0.5f; SunNode.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Constant; SunNode.Geometry.FirstMaterial.Multiply.WrapS = SunNode.Geometry.FirstMaterial.Diffuse.WrapS = SunNode.Geometry.FirstMaterial.Multiply.WrapT = SunNode.Geometry.FirstMaterial.Diffuse.WrapT = SCNWrapMode.Repeat; EarthNode.Geometry.FirstMaterial.LocksAmbientWithDiffuse = MoonNode.Geometry.FirstMaterial.LocksAmbientWithDiffuse = SunNode.Geometry.FirstMaterial.LocksAmbientWithDiffuse = true; EarthNode.Geometry.FirstMaterial.Shininess = 0.1f; EarthNode.Geometry.FirstMaterial.Specular.Intensity = 0.5f; MoonNode.Geometry.FirstMaterial.Specular.Contents = NSColor.Gray; // Achieve a lava effect by animating textures animation = CABasicAnimation.FromKeyPath("contentsTransform"); animation.Duration = 10.0f; var animationTransform1 = CATransform3D.MakeTranslation(0, 0, 0); animationTransform1 = animationTransform1.Concat(CATransform3D.MakeScale(3, 3, 3)); var animationTransform2 = CATransform3D.MakeTranslation(1, 0, 0); animationTransform2 = animationTransform1.Concat(CATransform3D.MakeScale(3, 3, 3)); animation.From = NSValue.FromCATransform3D(animationTransform1); animation.To = NSValue.FromCATransform3D(animationTransform2); animation.RepeatCount = float.MaxValue; SunNode.Geometry.FirstMaterial.Diffuse.AddAnimation(animation, new NSString("sun-texture")); animation = CABasicAnimation.FromKeyPath("contentsTransform"); animation.Duration = 30.0f; animationTransform1 = CATransform3D.MakeTranslation(0, 0, 0); animationTransform1 = animationTransform1.Concat(CATransform3D.MakeScale(5, 5, 5)); animationTransform2 = CATransform3D.MakeTranslation(1, 0, 0); animationTransform2 = animationTransform1.Concat(CATransform3D.MakeScale(5, 5, 5)); animation.From = NSValue.FromCATransform3D(animationTransform1); animation.To = NSValue.FromCATransform3D(animationTransform2); animation.RepeatCount = float.MaxValue; SunNode.Geometry.FirstMaterial.Multiply.AddAnimation(animation, new NSString("sun-texture2")); break; case 5: // We will turn off all the lights in the scene and add a new light // to give the impression that the Sun lights the scene var lightNode = SCNNode.Create(); lightNode.Light = SCNLight.Create(); lightNode.Light.Color = NSColor.Black; // initially switched off lightNode.Light.LightType = SCNLightType.Omni; SunNode.AddChildNode(lightNode); // Configure attenuation distances because we don't want to light the floor lightNode.Light.SetAttribute(new NSNumber(20), SCNLightAttribute.AttenuationEndKey); lightNode.Light.SetAttribute(new NSNumber(19.5), SCNLightAttribute.AttenuationStartKey); // Animation SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1; lightNode.Light.Color = NSColor.White; // switch on presentationViewController.UpdateLightingWithIntensities(new float[] { 0.0f }); //switch off all the other lights SunHaloNode.Opacity = 0.5f; // make the halo stronger SCNTransaction.Commit(); break; } }
public override void PresentStep(int index, PresentationViewController presentationViewController) { SCNTransaction.Begin(); switch (index) { case 1: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.SetSubtitle("API"); TextManager.AddEmptyLine(); TextManager.AddCode("#aMaterial.#ShaderModifiers# = new SCNShaderModifiers {\n" + " <Entry Point> = <GLSL Code>\n" + "};#"); TextManager.FlipInText(SlideTextManager.TextType.Code); TextManager.FlipInText(SlideTextManager.TextType.Subtitle); break; case 2: TextManager.FlipOutText(SlideTextManager.TextType.Code); TextManager.AddEmptyLine(); TextManager.AddCode("#aMaterial.#ShaderModifiers# = new SCNShaderModifiers { \n" + " EntryCGPointragment = \n" + " new Vector3 (1.0f) - #output#.Color.GetRgb () \n" + "};#"); TextManager.FlipInText(SlideTextManager.TextType.Code); break; case 3: TextManager.FlipOutText(SlideTextManager.TextType.Code); TextManager.FlipOutText(SlideTextManager.TextType.Subtitle); TextManager.SetSubtitle("Entry points"); TextManager.AddBulletAtLevel("Geometry", 0); TextManager.AddBulletAtLevel("Surface", 0); TextManager.AddBulletAtLevel("Lighting", 0); TextManager.AddBulletAtLevel("Fragment", 0); TextManager.FlipInText(SlideTextManager.TextType.Bullet); TextManager.FlipInText(SlideTextManager.TextType.Subtitle); break; case 4: SCNTransaction.AnimationDuration = 1; TextManager.HighlightBullet(0); // Create a (very) tesselated plane var plane = SCNPlane.Create(10, 10); plane.WidthSegmentCount = 200; plane.HeightSegmentCount = 200; // Setup the material (same as the floor) plane.FirstMaterial.Diffuse.WrapS = SCNWrapMode.Mirror; plane.FirstMaterial.Diffuse.WrapT = SCNWrapMode.Mirror; plane.FirstMaterial.Diffuse.Contents = new NSImage("/Library/Desktop Pictures/Circles.jpg"); plane.FirstMaterial.Diffuse.ContentsTransform = SCNMatrix4.CreateFromAxisAngle(new SCNVector3(0, 0, 1), NMath.PI / 4); plane.FirstMaterial.Specular.Contents = NSColor.White; plane.FirstMaterial.Reflective.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/envmap", "jpg")); plane.FirstMaterial.Reflective.Intensity = 0.0f; // Create a node to hold that plane PlaneNode = SCNNode.Create(); PlaneNode.Position = new SCNVector3(0, 0.1f, 0); PlaneNode.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 2)); PlaneNode.Scale = new SCNVector3(5, 5, 1); PlaneNode.Geometry = plane; ContentNode.AddChildNode(PlaneNode); // Attach the "wave" shader modifier, and set an initial intensity value of 0 var shaderFile = NSBundle.MainBundle.PathForResource("Shaders/wave", "shader"); var geometryModifier = File.ReadAllText(shaderFile); PlaneNode.Geometry.ShaderModifiers = new SCNShaderModifiers { EntryPointGeometry = geometryModifier }; PlaneNode.Geometry.SetValueForKey(new NSNumber(0.0f), new NSString("intensity")); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0; // Show the pseudo code for the deformation var textNode = TextManager.AddCode("#float len = #geometry#.Position.Xy.Length;\n" + "aMaterial.ShaderModifiers = new SCNShaderModifiers { \n" + " #EntryPointGeometry# = geometry.Position.Y \n" + "};#"); textNode.Position = new SCNVector3(8.5f, 7, 0); SCNTransaction.Commit(); break; case 5: // Progressively increase the intensity SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 2; PlaneNode.Geometry.SetValueForKey(new NSNumber(1.0f), new NSString("intensity")); PlaneNode.Geometry.FirstMaterial.Reflective.Intensity = 0.3f; SCNTransaction.Commit(); // Redraw forever ((SCNView)presentationViewController.View).Playing = true; ((SCNView)presentationViewController.View).Loops = true; break; case 6: SCNTransaction.AnimationDuration = 1; TextManager.FadeOutText(SlideTextManager.TextType.Code); // Hide the plane used for the previous modifier PlaneNode.Geometry.SetValueForKey(new NSNumber(0.0f), new NSString("intensity")); PlaneNode.Geometry.FirstMaterial.Reflective.Intensity = 0.0f; PlaneNode.Opacity = 0.0f; // Create a sphere to illustrate the "car paint" modifier var sphere = SCNSphere.Create(6); sphere.SegmentCount = 100; sphere.FirstMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/noise", "png")); sphere.FirstMaterial.Diffuse.WrapS = SCNWrapMode.Repeat; sphere.FirstMaterial.Diffuse.WrapT = SCNWrapMode.Repeat; sphere.FirstMaterial.Reflective.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/envmap3", "jpg")); sphere.FirstMaterial.FresnelExponent = 1.3f; SphereNode = SCNNode.FromGeometry(sphere); SphereNode.Position = new SCNVector3(5, 6, 0); GroundNode.AddChildNode(SphereNode); // Attach the "car paint" shader modifier shaderFile = NSBundle.MainBundle.PathForResource("Shaders/carPaint", "shader"); var surfaceModifier = File.ReadAllText(shaderFile); sphere.FirstMaterial.ShaderModifiers = new SCNShaderModifiers { EntryPointSurface = surfaceModifier }; var rotationAnimation = CABasicAnimation.FromKeyPath("rotation"); rotationAnimation.Duration = 15.0f; rotationAnimation.RepeatCount = float.MaxValue; rotationAnimation.By = NSValue.FromVector(new SCNVector4(0, 1, 0, -(float)(Math.PI * 2))); SphereNode.AddAnimation(rotationAnimation, new NSString("sphereNodeAnimation")); TextManager.HighlightBullet(1); break; case 7: SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1.5f; SCNTransaction.AnimationTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut); // Move the camera closer presentationViewController.CameraNode.Position = new SCNVector3(5, -0.5f, -17); SCNTransaction.Commit(); break; case 8: SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1.0f; SCNTransaction.AnimationTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut); // Move back presentationViewController.CameraNode.Position = new SCNVector3(0, 0, 0); SCNTransaction.Commit(); break; case 9: SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1.0f; // Hide the sphere used for the previous modifier SphereNode.Opacity = 0.0f; SphereNode.Position = new SCNVector3(6, 4, -8); SCNTransaction.Commit(); SCNTransaction.AnimationDuration = 0; TextManager.HighlightBullet(2); // Load the model, animate var intermediateNode = SCNNode.Create(); intermediateNode.Position = new SCNVector3(4, 0.1f, 10); TorusNode = Utils.SCAddChildNode(intermediateNode, "torus", "Scenes/torus/torus", 11); rotationAnimation = CABasicAnimation.FromKeyPath("rotation"); rotationAnimation.Duration = 10.0f; rotationAnimation.RepeatCount = float.MaxValue; rotationAnimation.To = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2))); TorusNode.AddAnimation(rotationAnimation, new NSString("torusNodeAnimation")); GroundNode.AddChildNode(intermediateNode); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1.0f; intermediateNode.Position = new SCNVector3(4, 0.1f, 0); SCNTransaction.Commit(); break; case 10: // Attach the shader modifier shaderFile = NSBundle.MainBundle.PathForResource("Shaders/toon", "shader"); var lightingModifier = File.ReadAllText(shaderFile); TorusNode.Geometry.ShaderModifiers = new SCNShaderModifiers { EntryPointLightingModel = lightingModifier }; break; case 11: SCNTransaction.AnimationDuration = 1.0f; // Hide the torus used for the previous modifier TorusNode.Position = new SCNVector3(TorusNode.Position.X, TorusNode.Position.Y, TorusNode.Position.Z - 10); TorusNode.Opacity = 0.0f; // Load the model, animate intermediateNode = SCNNode.Create(); intermediateNode.Position = new SCNVector3(4, -2.6f, 14); intermediateNode.Scale = new SCNVector3(70, 70, 70); XRayNode = Utils.SCAddChildNode(intermediateNode, "node", "Scenes/bunny", 12); XRayNode.Position = new SCNVector3(0, 0, 0); XRayNode.Opacity = 0.0f; GroundNode.AddChildNode(intermediateNode); rotationAnimation = CABasicAnimation.FromKeyPath("rotation"); rotationAnimation.Duration = 10.0f; rotationAnimation.RepeatCount = float.MaxValue; rotationAnimation.From = NSValue.FromVector(new SCNVector4(0, 1, 0, 0)); rotationAnimation.To = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)(Math.PI * 2))); intermediateNode.AddAnimation(rotationAnimation, new NSString("bunnyNodeAnimation")); TextManager.HighlightBullet(3); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1.0f; XRayNode.Opacity = 1.0f; intermediateNode.Position = new SCNVector3(4, -2.6f, -2); SCNTransaction.Commit(); break; case 12: // Attach the "x ray" modifier shaderFile = NSBundle.MainBundle.PathForResource("Shaders/xRay", "shader"); var fragmentModifier = File.ReadAllText(shaderFile); XRayNode.Geometry.ShaderModifiers = new SCNShaderModifiers { EntryPointFragment = fragmentModifier }; XRayNode.Geometry.FirstMaterial.ReadsFromDepthBuffer = false; break; case 13: // Highlight everything TextManager.HighlightBullet(-1); // Hide the node used for the previous modifier XRayNode.Opacity = 0.0f; XRayNode.ParentNode.Position = new SCNVector3(4, -2.6f, -5); // Create the model sphere = SCNSphere.Create(5); sphere.SegmentCount = 150; // tesselate a lot VirusNode = SCNNode.FromGeometry(sphere); VirusNode.Position = new SCNVector3(3, 6, 0); VirusNode.Rotation = new SCNVector4(1, 0, 0, Pitch * (float)(Math.PI / 180.0f)); GroundNode.AddChildNode(VirusNode); // Set the shader modifiers var geomFile = NSBundle.MainBundle.PathForResource("Shaders/sm_geom", "shader"); var surfFile = NSBundle.MainBundle.PathForResource("Shaders/sm_surf", "shader"); var lightFile = NSBundle.MainBundle.PathForResource("Shaders/sm_light", "shader"); var fragFile = NSBundle.MainBundle.PathForResource("Shaders/sm_frag", "shader"); geometryModifier = File.ReadAllText(geomFile); surfaceModifier = File.ReadAllText(surfFile); lightingModifier = File.ReadAllText(lightFile); fragmentModifier = File.ReadAllText(fragFile); VirusNode.Geometry.FirstMaterial.ShaderModifiers = new SCNShaderModifiers { EntryPointGeometry = geometryModifier, EntryPointSurface = surfaceModifier, EntryPointLightingModel = lightingModifier, EntryPointFragment = fragmentModifier }; break; case 14: SCNTransaction.AnimationDuration = 1.0f; // Hide the node used for the previous modifier VirusNode.Opacity = 0.0f; VirusNode.Position = new SCNVector3(3, 6, -10); // Change the text TextManager.FadeOutText(SlideTextManager.TextType.Code); TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.FlipOutText(SlideTextManager.TextType.Subtitle); TextManager.SetSubtitle("SCNShadable"); TextManager.AddBulletAtLevel("Protocol adopted by SCNMaterial and SCNGeometry", 0); TextManager.AddBulletAtLevel("Shaders parameters are animatable", 0); TextManager.AddBulletAtLevel("Texture samplers are bound to a SCNMaterialProperty", 0); TextManager.AddCode("#var aProperty = SCNMaterialProperty.#Create# (anImage);\n" + "aMaterial.#SetValueForKey# (aProperty, #new NSString# (\"aSampler\"));#"); TextManager.FlipInText(SlideTextManager.TextType.Subtitle); TextManager.FlipInText(SlideTextManager.TextType.Bullet); TextManager.FlipInText(SlideTextManager.TextType.Code); break; } SCNTransaction.Commit(); }
public override void PresentStep(int index, PresentationViewController presentationViewController) { SCNTransaction.Begin(); switch (index) { case 1: TextManager.FlipOutText(SlideTextManager.TextType.Code); TextManager.FlipOutText(SlideTextManager.TextType.Subtitle); TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.SetSubtitle("Entry points"); var textNode = Utils.SCLabelNode("Geometry", Utils.LabelSize.Normal, false); textNode.Position = new SCNVector3(-13.5f, 9, 0); ContentNode.AddChildNode(textNode); textNode = Utils.SCLabelNode("Surface", Utils.LabelSize.Normal, false); textNode.Position = new SCNVector3(-5.3f, 9, 0); ContentNode.AddChildNode(textNode); textNode = Utils.SCLabelNode("Lighting", Utils.LabelSize.Normal, false); textNode.Position = new SCNVector3(2, 9, 0); ContentNode.AddChildNode(textNode); textNode = Utils.SCLabelNode("Fragment", Utils.LabelSize.Normal, false); textNode.Position = new SCNVector3(9.5f, 9, 0); ContentNode.AddChildNode(textNode); TextManager.FlipInText(SlideTextManager.TextType.Subtitle); //add spheres var sphere = SCNSphere.Create(3); sphere.FirstMaterial.Diffuse.Contents = NSColor.Red; sphere.FirstMaterial.Specular.Contents = NSColor.White; sphere.FirstMaterial.Specular.Intensity = 1.0f; sphere.FirstMaterial.Shininess = 0.1f; sphere.FirstMaterial.Reflective.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/envmap", "jpg")); sphere.FirstMaterial.FresnelExponent = 2; //GEOMETRY var node = SCNNode.Create(); node.Geometry = (SCNGeometry)sphere.Copy(); node.Position = new SCNVector3(-12, 3, 0); node.Geometry.ShaderModifiers = new SCNShaderModifiers { EntryPointGeometry = "// Waves Modifier\n" + "uniform float Amplitude = 0.2;\n" + "uniform float Frequency = 5.0;\n" + "vec2 nrm = _geometry.position.xz;\n" + "float len = length(nrm)+0.0001; // for robustness\n" + "nrm /= len;\n" + "float a = len + Amplitude*sin(Frequency * _geometry.position.y + u_time * 10.0);\n" + "_geometry.position.xz = nrm * a;\n" }; GroundNode.AddChildNode(node); // SURFACE node = SCNNode.Create(); node.Geometry = (SCNGeometry)sphere.Copy(); node.Position = new SCNVector3(-4, 3, 0); var surfaceModifier = File.ReadAllText(NSBundle.MainBundle.PathForResource("Shaders/sm_surf", "shader")); node.Rotation = new SCNVector4(1, 0, 0, -NMath.PI / 4); node.Geometry.FirstMaterial = (SCNMaterial)node.Geometry.FirstMaterial.Copy(); node.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Lambert; node.Geometry.ShaderModifiers = new SCNShaderModifiers { EntryPointSurface = surfaceModifier }; GroundNode.AddChildNode(node); // LIGHTING node = SCNNode.Create(); node.Geometry = (SCNGeometry)sphere.Copy(); node.Position = new SCNVector3(4, 3, 0); var lightingModifier = File.ReadAllText(NSBundle.MainBundle.PathForResource("Shaders/sm_light", "shader")); node.Geometry.ShaderModifiers = new SCNShaderModifiers { EntryPointLightingModel = lightingModifier }; GroundNode.AddChildNode(node); // FRAGMENT node = SCNNode.Create(); node.Geometry = (SCNGeometry)sphere.Copy(); node.Position = new SCNVector3(12, 3, 0); node.Geometry.FirstMaterial = (SCNMaterial)node.Geometry.FirstMaterial.Copy(); node.Geometry.FirstMaterial.Diffuse.Contents = NSColor.Green; var fragmentModifier = File.ReadAllText(NSBundle.MainBundle.PathForResource("Shaders/sm_frag", "shader")); node.Geometry.ShaderModifiers = new SCNShaderModifiers { EntryPointFragment = fragmentModifier }; GroundNode.AddChildNode(node); //redraw forever ((SCNView)presentationViewController.View).Playing = true; ((SCNView)presentationViewController.View).Loops = true; break; } SCNTransaction.Commit(); }
public override void PresentStep(int index, PresentationViewController presentationViewController) { switch (index) { case 0: break; case 1: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.FlipOutText(SlideTextManager.TextType.Code); TextManager.AddBulletAtLevel("Image", 0); TextManager.AddBulletAtLevel("Name / Path / URL", 1); TextManager.AddBulletAtLevel("NSImage / UIImage / NSData", 1); TextManager.AddBulletAtLevel("SKTexture", 1); TextManager.FlipInText(SlideTextManager.TextType.Bullet); var code = TextManager.AddCode("#material.diffuse.contents = #@\"slate.jpg\"#;#"); code.Position = new SCNVector3(code.Position.X + 6, code.Position.Y - 6.5f, code.Position.Z); Material.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/slate", "jpg")); Material.Normal.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/slate-bump", "png")); Material.Normal.Intensity = 0; break; case 2: SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1.0f; Material.Normal.Intensity = 5.0f; Material.Specular.Contents = NSColor.Gray; SCNTransaction.Commit(); code = TextManager.AddCode("#material.normal.contents = #[SKTexture textureByGeneratingNormalMap]#;#"); code.Position = new SCNVector3(code.Position.X + 2, code.Position.Y - 6.5f, code.Position.Z); break; case 3: TextManager.FadeOutText(SlideTextManager.TextType.Code); TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddBulletAtLevel("Live contents", 0); TextManager.AddBulletAtLevel("CALayer tree", 1); TextManager.AddBulletAtLevel("SKScene (new)", 1); TextManager.FlipInText(SlideTextManager.TextType.Bullet); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1.0f; Material.Normal.Intensity = 2.0f; SCNTransaction.Commit(); PlayerLayer1 = ConfigurePlayer(NSBundle.MainBundle.PathForResource("Movies/movie1", "mov"), "material-cube"); break; case 4: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddEmptyLine(); TextManager.AddBulletAtLevel("Cube map", 0); TextManager.AddBulletAtLevel("NSArray of 6 items", 1); TextManager.FlipInText(SlideTextManager.TextType.Bullet); code = TextManager.AddCode("#material.reflective.contents = #@[aright.png, left.png ... front.png]#;#"); code.Position = new SCNVector3(code.Position.X, code.Position.Y - 9.5f, code.Position.Z); var image = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/cubemap", "png"), 12, false); image.Position = new SCNVector3(-10, 9, 0); image.Opacity = 0; ContentNode.AddChildNode(image); Object.Geometry = SCNTorus.Create(W * 0.5f, W * 0.2f); Material = Object.Geometry.FirstMaterial; Object.Rotation = new SCNVector4(1, 0, 0, (float)Math.PI / 2); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1; var right = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/right", "tga")); var left = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/left", "tga")); var top = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/top", "tga")); var bottom = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/bottom", "tga")); var back = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/back", "tga")); var front = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/front", "tga")); var materialContents = new NSMutableArray(); materialContents.AddObjects(new NSObject[] { right, left, top, bottom, back, front }); Material.Reflective.Contents = materialContents; Material.Diffuse.Contents = NSColor.Red; image.Opacity = 1.0f; SCNTransaction.Commit(); break; } }
private void SetupLookAtScene() { var intermediateNode = SCNNode.Create(); intermediateNode.Scale = new SCNVector3(0.5f, 0.5f, 0.5f); intermediateNode.Position = new SCNVector3(0, 0, 10); ContentNode.AddChildNode(intermediateNode); var ballMaterial = SCNMaterial.Create(); ballMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Scenes.scnassets/pool/pool_8", "png")); ballMaterial.Specular.Contents = NSColor.White; ballMaterial.Shininess = 0.9f; // shinny ballMaterial.Reflective.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/color_envmap", "png")); ballMaterial.Reflective.Intensity = 0.5f; // Node hierarchy for the ball : // _ballNode // |__ cameraTarget : the target for the "look at" constraint // |__ ballRotationNode : will rotate to animate the rolling ball // |__ ballPivotNode : will own the geometry and will be rotated so that the "8" faces the camera at the beginning BallNode = SCNNode.Create(); BallNode.Rotation = new SCNVector4(0, 1, 0, (float)(Math.PI / 4)); intermediateNode.AddChildNode(BallNode); var cameraTarget = SCNNode.Create(); cameraTarget.Name = "cameraTarget"; cameraTarget.Position = new SCNVector3(0, 6, 0); BallNode.AddChildNode(cameraTarget); var ballRotationNode = SCNNode.Create(); ballRotationNode.Position = new SCNVector3(0, 4, 0); BallNode.AddChildNode(ballRotationNode); var ballPivotNode = SCNNode.Create(); ballPivotNode.Geometry = SCNSphere.Create(4.0f); ballPivotNode.Geometry.FirstMaterial = ballMaterial; ballPivotNode.Rotation = new SCNVector4(0, 1, 0, (float)(Math.PI / 2)); ballRotationNode.AddChildNode(ballPivotNode); var arrowMaterial = SCNMaterial.Create(); arrowMaterial.Diffuse.Contents = NSColor.White; arrowMaterial.Reflective.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/chrome", "jpg")); var arrowContainer = SCNNode.Create(); arrowContainer.Name = "arrowContainer"; intermediateNode.AddChildNode(arrowContainer); var arrowPath = Utils.SCArrowBezierPath(new CGSize(6, 2), new CGSize(3, 5), 0.5f, false); // Create the arrows for (var i = 0; i < 11; i++) { var arrowNode = SCNNode.Create(); arrowNode.Position = new SCNVector3(NMath.Cos(NMath.PI * i / 10.0f) * 20.0f, 3 + 18.5f * NMath.Sin(NMath.PI * i / 10.0f), 0); var arrowGeometry = SCNShape.Create(arrowPath, 1); arrowGeometry.ChamferRadius = 0.2f; var arrowSubNode = SCNNode.Create(); arrowSubNode.Geometry = arrowGeometry; arrowSubNode.Geometry.FirstMaterial = arrowMaterial; arrowSubNode.Pivot = SCNMatrix4.CreateTranslation(new SCNVector3(0, 2.5f, 0)); // place the pivot (center of rotation) at the middle of the arrow arrowSubNode.Rotation = new SCNVector4(0, 0, 1, (float)(Math.PI / 2)); arrowNode.AddChildNode(arrowSubNode); arrowContainer.AddChildNode(arrowNode); } }
public override void PresentStep(int index, PresentationViewController presentationViewController) { switch (index) { case 0: // Set the slide's title and subtile and add some code TextManager.SetTitle("Performance"); TextManager.SetSubtitle("Statistics"); TextManager.AddCode("#// Show statistics \n" + "aSCNView.#ShowsStatistics# = true;"); break; case 1: // Place a screenshot in the scene and animate it WindowNode = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/statistics/statistics", "png"), 20, true); ContentNode.AddChildNode(WindowNode); WindowNode.Opacity = 0.0f; WindowNode.Position = new SCNVector3(20, 5.2f, 9); WindowNode.Rotation = new SCNVector4(0, 1, 0, -(float)(Math.PI / 4)); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1; WindowNode.Opacity = 1.0f; WindowNode.Position = new SCNVector3(0, 5.2f, 7); WindowNode.Rotation = new SCNVector4(0, 1, 0, 0); SCNTransaction.Commit(); // The screenshot contains transparent areas so we need to make sure it is rendered // after the text (which also sets its rendering order) WindowNode.RenderingOrder = 2; break; case 2: FpsNode = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/statistics/statistics-fps", "png"), 7, false); WindowNode.AddChildNode(FpsNode); FpsNode.Scale = new SCNVector3(0.75f, 0.75f, 0.75f); FpsNode.Opacity = 0.0f; FpsNode.Position = new SCNVector3(-6, -3, 0.5f); FpsNode.RenderingOrder = 4; SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.5f; FpsNode.Scale = new SCNVector3(1.0f, 1.0f, 1.0f); FpsNode.Opacity = 1.0f; SCNTransaction.Commit(); break; case 3: ButtonNode = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/statistics/statistics-button", "png"), 4, false); WindowNode.AddChildNode(ButtonNode); ButtonNode.Scale = new SCNVector3(0.75f, 0.75f, 0.75f); ButtonNode.Opacity = 0.0f; ButtonNode.Position = new SCNVector3(-7.5f, -2.75f, 0.5f); ButtonNode.RenderingOrder = 5; SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.5f; FpsNode.Opacity = 0.0f; ButtonNode.Scale = new SCNVector3(1.0f, 1.0f, 1.0f); ButtonNode.Opacity = 1.0f; SCNTransaction.Commit(); break; case 4: PanelNode = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/statistics/control-panel", "png"), 10, false); WindowNode.AddChildNode(PanelNode); PanelNode.Scale = new SCNVector3(0.75f, 0.75f, 0.75f); PanelNode.Opacity = 0.0f; PanelNode.Position = new SCNVector3(3.5f, -0.5f, 1.5f); PanelNode.RenderingOrder = 6; SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.5f; PanelNode.Scale = new SCNVector3(1.0f, 1.0f, 1.0f); PanelNode.Opacity = 1.0f; SCNTransaction.Commit(); break; case 5: var detailsNode = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/statistics/statistics-detail", "png"), 9, false); WindowNode.AddChildNode(detailsNode); detailsNode.Scale = new SCNVector3(0.75f, 0.75f, 0.75f); detailsNode.Opacity = 0.0f; detailsNode.Position = new SCNVector3(5, -2.75f, 1.5f); detailsNode.RenderingOrder = 7; SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.5f; PanelNode.Opacity = 0.0f; ButtonNode.Opacity = 0.0f; detailsNode.Scale = new SCNVector3(1.0f, 1.0f, 1.0f); detailsNode.Opacity = 1.0f; SCNTransaction.Commit(); break; } }
// Create a carousel of 3D primitives private void PresentPrimitives() { // Create the carousel node. It will host all the primitives as child nodes. CarouselNode = SCNNode.Create(); CarouselNode.Position = new SCNVector3(0, 0.1f, -5); CarouselNode.Scale = new SCNVector3(0, 0, 0); // start infinitely small ContentNode.AddChildNode(CarouselNode); // Animate the scale to achieve a "grow" effect SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1; CarouselNode.Scale = new SCNVector3(1, 1, 1); SCNTransaction.Commit(); // Rotate the carousel forever var rotationAnimation = CABasicAnimation.FromKeyPath("rotation"); rotationAnimation.Duration = 40.0f; rotationAnimation.RepeatCount = float.MaxValue; rotationAnimation.To = NSValue.FromVector(new SCNVector4(0, 1, 0, (float)Math.PI * 2)); CarouselNode.AddAnimation(rotationAnimation, new NSString("rotationAnimation")); // A material shared by all the primitives var sharedMaterial = SCNMaterial.Create(); sharedMaterial.Reflective.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/envmap", "jpg")); sharedMaterial.Reflective.Intensity = 0.2f; sharedMaterial.DoubleSided = true; PrimitiveIndex = 0; // SCNBox var box = SCNBox.Create(5.0f, 5.0f, 5.0f, 5.0f * 0.05f); box.WidthSegmentCount = 4; box.HeightSegmentCount = 4; box.LengthSegmentCount = 4; box.ChamferSegmentCount = 4; AddPrimitive(box, 5.0f / 2, rotationAnimation, sharedMaterial); // SCNPyramid var pyramid = SCNPyramid.Create(5.0f * 0.8f, 5.0f, 5.0f * 0.8f); pyramid.WidthSegmentCount = 4; pyramid.HeightSegmentCount = 10; pyramid.LengthSegmentCount = 4; AddPrimitive(pyramid, 0, rotationAnimation, sharedMaterial); // SCNCone var cone = SCNCone.Create(0, 5.0f / 2, 5.0f); cone.RadialSegmentCount = 20; cone.HeightSegmentCount = 4; AddPrimitive(cone, 5.0f / 2, rotationAnimation, sharedMaterial); // SCNTube var tube = SCNTube.Create(5.0f * 0.25f, 5.0f * 0.5f, 5.0f); tube.HeightSegmentCount = 5; tube.RadialSegmentCount = 40; AddPrimitive(tube, 5.0f / 2, rotationAnimation, sharedMaterial); // SCNCapsule var capsule = SCNCapsule.Create(5.0f * 0.4f, 5.0f * 1.4f); capsule.HeightSegmentCount = 5; capsule.RadialSegmentCount = 20; AddPrimitive(capsule, 5.0f * 0.7f, rotationAnimation, sharedMaterial); // SCNCylinder var cylinder = SCNCylinder.Create(5.0f * 0.5f, 5.0f); cylinder.HeightSegmentCount = 5; cylinder.RadialSegmentCount = 40; AddPrimitive(cylinder, 5.0f / 2, rotationAnimation, sharedMaterial); // SCNSphere var sphere = SCNSphere.Create(5.0f * 0.5f); sphere.SegmentCount = 20; AddPrimitive(sphere, 5.0f / 2, rotationAnimation, sharedMaterial); // SCNTorus var torus = SCNTorus.Create(5.0f * 0.5f, 5.0f * 0.25f); torus.RingSegmentCount = 40; torus.PipeSegmentCount = 20; AddPrimitive(torus, 5.0f / 4, rotationAnimation, sharedMaterial); // SCNPlane var plane = SCNPlane.Create(5.0f, 5.0f); plane.WidthSegmentCount = 5; plane.HeightSegmentCount = 5; plane.CornerRadius = 5.0f * 0.1f; AddPrimitive(plane, 5.0f / 2, rotationAnimation, sharedMaterial); }
public override void PresentStep(int index, PresentationViewController presentationViewController) { switch (index) { case (int)TechniqueSteps.Intro: break; case (int)TechniqueSteps.Code: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); PlistGroup.RemoveFromParentNode(); TextManager.AddEmptyLine(); TextManager.AddCode("#// Load a technique\nSCNTechnique *technique = [SCNTechnique #techniqueWithDictionary#:aDictionary];\n\n\n" + "// Chain techniques\ntechnique = [SCNTechnique #techniqueBySequencingTechniques#:@[t1, t2 ...];\n\n\n\t\t\t\t\t" + "// Set a technique\naSCNView.#technique# = technique;#"); TextManager.FlipInText(SlideTextManager.TextType.Bullet); TextManager.FlipInText(SlideTextManager.TextType.Code); break; case (int)TechniqueSteps.Files: Pass2.RemoveFromParentNode(); TextManager.FlipOutText(SlideTextManager.TextType.Bullet); TextManager.AddBulletAtLevel("Load from Plist", 0); TextManager.FlipInText(SlideTextManager.TextType.Code); PlistGroup = SCNNode.Create(); ContentNode.AddChildNode(PlistGroup); //add plist icon var node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/plist", "png"), 8, true); node.Position = new SCNVector3(0, 3.7f, 10); PlistGroup.AddChildNode(node); //add plist icon node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/vsh", "png"), 3, true); for (var i = 0; i < 5; i++) { node = node.Clone(); node.Position = new SCNVector3(6, 1.4f, 10 - i); PlistGroup.AddChildNode(node); } node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/fsh", "png"), 3, true); for (var i = 0; i < 5; i++) { node = node.Clone(); node.Position = new SCNVector3(9, 1.4f, 10 - i); PlistGroup.AddChildNode(node); } break; case (int)TechniqueSteps.Plist: //add plist icon node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/technique", "png"), 9, true); node.Position = new SCNVector3(0, 3.5f, 10.1f); node.Opacity = 0.0f; PlistGroup.AddChildNode(node); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.75f; node.Position = new SCNVector3(0, 3.5f, 11); node.Opacity = 1.0f; SCNTransaction.Commit(); break; case (int)TechniqueSteps.Pass1: TextManager.FlipOutText(SlideTextManager.TextType.Bullet); node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/pass1", "png"), 15, true); node.Position = new SCNVector3(0, 3.5f, 10.1f); node.Opacity = 0.0f; ContentNode.AddChildNode(node); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.75f; node.Position = new SCNVector3(0, 3.5f, 11); node.Opacity = 1.0f; SCNTransaction.Commit(); Pass1 = node; break; case (int)TechniqueSteps.Passes3: Pass1.RemoveFromParentNode(); Pass2 = SCNNode.Create(); Pass2.Opacity = 0.0f; Pass2.Position = new SCNVector3(0, 3.5f, 6); node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/pass2", "png"), 8, true); node.Position = new SCNVector3(-8, 0, 0); Pass2.AddChildNode(node); node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/pass3", "png"), 8, true); node.Position = new SCNVector3(0, 0, 0); Pass2.AddChildNode(node); node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/pass4", "png"), 8, true); node.Position = new SCNVector3(8, 0, 0); Pass2.AddChildNode(node); ContentNode.AddChildNode(Pass2); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.75f; Pass2.Position = new SCNVector3(0, 3.5f, 9); Pass2.Opacity = 1.0f; SCNTransaction.Commit(); break; case (int)TechniqueSteps.Passes3Connected: TextManager.AddEmptyLine(); TextManager.AddBulletAtLevel("Connect pass inputs / outputs", 0); node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/link", "png"), 8.75f, true); node.Position = new SCNVector3(0.01f, -2, 0); node.Opacity = 0.0f; Pass2.AddChildNode(node); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.75f; var n = Pass2.ChildNodes [0]; n.Position = new SCNVector3(-7.5f, -0.015f, 0); n = Pass2.ChildNodes [2]; n.Position = new SCNVector3(7.5f, 0.02f, 0); node.Opacity = 1.0f; SCNTransaction.Commit(); break; case (int)TechniqueSteps.Sample: TextManager.FlipOutText(SlideTextManager.TextType.Code); TextManager.FlipOutText(SlideTextManager.TextType.Subtitle); TextManager.SetSubtitle("Example: simple depth of field"); TextManager.FlipInText(SlideTextManager.TextType.Code); Pass3 = SCNNode.Create(); node = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/pass5", "png"), 15, true); node.Position = new SCNVector3(-3, 5, 10.1f); node.Opacity = 0.0f; Pass3.AddChildNode(node); var t0 = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/technique0", "png"), 4, false); t0.Position = new SCNVector3(-8.5f, 1.5f, 10.1f); t0.Opacity = 0.0f; Pass3.AddChildNode(t0); var t1 = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/technique1", "png"), 4, false); t1.Position = new SCNVector3(-3.6f, 1.5f, 10.1f); t1.Opacity = 0.0f; Pass3.AddChildNode(t1); var t2 = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/technique2", "png"), 4, false); t2.Position = new SCNVector3(1.4f, 1.5f, 10.1f); t2.Opacity = 0.0f; Pass3.AddChildNode(t2); var t3 = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/technique/technique3", "png"), 8, false); t3.Position = new SCNVector3(8, 5, 10.1f); t3.Opacity = 0.0f; Pass3.AddChildNode(t3); ContentNode.AddChildNode(Pass3); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.75f; node.Opacity = 1.0f; t0.Opacity = 1.0f; t1.Opacity = 1.0f; t2.Opacity = 1.0f; t3.Opacity = 1.0f; SCNTransaction.Commit(); break; } }