Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Intro_to_Scene_Kit.pdf

 Intro_to_Scene_Kit.pdf

Mike Bluestein

October 11, 2014
Tweet

More Decks by Mike Bluestein

Other Decks in Technology

Transcript

  1. Scene Kit is a high level 3D Graphics API for

    OS X and iOS that lets you build 3D applications declaratively without needing a deep understanding of OpenGL. What is Scene Kit?
  2. What is Scene Kit? Use Cases • Data Visualization •

    Casual 3D Games • Presentation Apps Image Credit NASA Apple Toy Car Sample - WWDC 2014
  3. Scene Kit Basics ▪ Represent the scene graph ▪ Graph

    is made up of a node tree ▪ Nodes define positions in space ▪ Attributes are applied to nodes Scene
  4. Scene Kit Basics ▪ Defines the 3D shape and surface

    ▪ Vertices ▪ Normals ▪ Texture coordinates ▪ 9 Built-in primitives Geometry
  5. Scene Kit Basics ▪ Defines the 3D shape and surface

    ▪ Vertices ▪ Normals ▪ Texture coordinates ▪ 9 Built-in primitives Geometry
  6. Scene Kit Basics ▪ Defines the 3D shape and surface

    ▪ Vertices ▪ Normals ▪ Texture coordinates ▪ 9 Built-in primitives Geometry
  7. Scene Kit Basics ▪ Defines the 3D shape and surface

    ▪ Vertices ▪ Normals ▪ Texture coordinates ▪ 9 Built-in primitives Geometry
  8. Scene Kit Basics ▪ Defines the 3D shape and surface

    ▪ Vertices ▪ Normals ▪ Texture coordinates ▪ 9 Built-in primitives Geometry
  9. Scene Kit Basics ▪ Defines the 3D shape and surface

    ▪ Vertices ▪ Normals ▪ Texture coordinates ▪ 9 Built-in primitives Geometry
  10. Scene Kit Basics ▪ Defines the 3D shape and surface

    ▪ Vertices ▪ Normals ▪ Texture coordinates ▪ 9 Built-in primitives Geometry
  11. Scene Kit Basics ▪ Defines the 3D shape and surface

    ▪ Vertices ▪ Normals ▪ Texture coordinates ▪ 9 Built-in primitives Geometry
  12. Scene Kit Basics ▪ Defines the 3D shape and surface

    ▪ Vertices ▪ Normals ▪ Texture coordinates ▪ 9 Built-in primitives Geometry
  13. Scene Kit Basics ▪ Illuminates a scene ▪ Ambient ▪

    Directional ▪ Omni ▪ Spot Lighting
  14. Scene Kit Basics ▪ Illuminates a scene ▪ Ambient ▪

    Directional ▪ Omni ▪ Spot Lighting
  15. Scene Kit Basics ▪ Applied to geometry ▪ Determine its

    appearance ▪ Color ▪ Image ▪ CALayer ▪ SKNode Materials
  16. Scene Kit Basics ▪ Applied to geometry ▪ Determine its

    appearance ▪ Color ▪ Image ▪ CALayer ▪ SKNode Materials
  17. Scene Kit Basics ▪ Applied to geometry ▪ Determine its

    appearance ▪ Color ▪ Image ▪ CALayer ▪ SKNode Materials
  18. Scene Kit Basics ▪ Attached to a node ▪ Point

    of view ▪ Field of view ▪ Depth of field Camera model from http://sketchup.google.com/3dwarehouse/details?mid=39a71b5000f5d6d0e97500ab69cb75f8

  19. Scene Kit Basics ▪ Attached to a node ▪ Point

    of view ▪ Field of view ▪ Depth of field Camera model from http://sketchup.google.com/3dwarehouse/details?mid=39a71b5000f5d6d0e97500ab69cb75f8

  20. Scene Kit Basics ▪ Can be user to load a

    scene ▪ Commonly used file format (DAE) ▪ Exported from most 3D art tools ▪ Can be manipulated in code ▪ Viewable in OS X and Xcode Collada Files
  21. Scene Kit Basics ▪ Can be user to load a

    scene ▪ Commonly used file format (DAE) ▪ Exported from most 3D art tools ▪ Can be manipulated in code ▪ Viewable in OS X and Xcode Collada Files
  22. Animation ▪ Core Animation programming model ▪ Use SCNTransaction instead

    of CATransaction Implicit SCNTransaction.Begin ();
 SCNTransaction.AnimationDuration = 4.0;
 boxNode.Rotation = new SCNVector4 (0, 1, 0, (float)Math.PI * 4);
 SCNTransaction.Commit ();
  23. Animation ▪ Core Animation programming model ▪ Use SCNTransaction instead

    of CATransaction Implicit SCNTransaction.Begin ();
 SCNTransaction.AnimationDuration = 4.0;
 boxNode.Rotation = new SCNVector4 (0, 1, 0, (float)Math.PI * 4);
 SCNTransaction.Commit ();
  24. Animation ▪ Uses Core Animation API Explicit var anim =

    CABasicAnimation.FromKeyPath (“rotation”);
 anim.To = NSValue.FromVector ( new SCNVector4 (1, 0, 0, (float)(Math.PI * 4)));
 anim.Duration = 4.0f; 
 boxNode.AddAnimation (anim, new NSString ("rotateBoxAnimation"));
  25. Animation ▪ Uses Core Animation API Explicit var anim =

    CABasicAnimation.FromKeyPath (“rotation”);
 anim.To = NSValue.FromVector ( new SCNVector4 (1, 0, 0, (float)(Math.PI * 4)));
 anim.Duration = 4.0f; 
 boxNode.AddAnimation (anim, new NSString ("rotateBoxAnimation"));
  26. Animation ▪ Allow declarative animations ▪ Available through SCNAction ▪

    Similar to actions in Sprite Kit ▪ Run action on a node ▪ Updates the presentation tree Actions boxNode.RunAction ( SCNAction.RotateBy ((float)Math.PI * 4, 0, 0, 4.0));

  27. Animation ▪ Allow declarative animations ▪ Available through SCNAction ▪

    Similar to actions in Sprite Kit ▪ Run action on a node ▪ Updates the presentation tree Actions boxNode.RunAction ( SCNAction.RotateBy ((float)Math.PI * 4, 0, 0, 4.0));

  28. Effects ▪ SCNParticleSystem ▪ Customizable ▪ Can be applied to

    geometries ▪ Affected by physics ▪ Editor in Xcode Particle Systems
  29. Effects ▪ SCNParticleSystem ▪ Customizable ▪ Can be applied to

    geometries ▪ Affected by physics ▪ Editor in Xcode Particle Systems
  30. Effects ▪ SCNParticleSystem ▪ Customizable ▪ Can be applied to

    geometries ▪ Affected by physics ▪ Editor in Xcode Particle Systems
  31. Effects ▪ Applied to node ▪ Effects entire node hierarchy

    ▪ Can apply multiple CI filters Core Image var filter = new CIPixellate ();
 filter.SetDefaults ();
 boxNode.Filters = new CIFilter[] { filter } ;
  32. Effects ▪ Applied to node ▪ Effects entire node hierarchy

    ▪ Can apply multiple CI filters Core Image var filter = new CIPixellate ();
 filter.SetDefaults ();
 boxNode.Filters = new CIFilter[] { filter } ;
  33. Physics 3D Rigid Body Physics • Physics applied implicitly •

    Set a PhysicsBody property on a node • Simulates animation and collision
  34. Physics ▪ Apply forces to physics bodies ▪ Several available:

    ▪ Drag, Electric, Magnetic ▪ Radial Gravity, Linear Gravity ▪ Turbulence, String, Noise Physics Fields
  35. Physics ▪ Apply forces to physics bodies ▪ Several available:

    ▪ Drag, Electric, Magnetic ▪ Radial Gravity, Linear Gravity ▪ Turbulence, String, Noise Physics Fields
  36. Sprite Kit Integration ▪ Can overlay SKNodes ▪ Rendered with

    scene ▪ Can apply to materials ▪ Map SKNodes onto surfaces Overlays and Materials Apple Toy Car Sample ported to C#