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

ARKitに入門して🍣三昧/arsushi_with_arkit_20170721

 ARKitに入門して🍣三昧/arsushi_with_arkit_20170721

Presentation for iOS Creators' Meetup vol.4

fromkk

July 21, 2017
Tweet

More Decks by fromkk

Other Decks in Programming

Transcript

  1. ARKitʹೖ໳ͯ͠!ࡾດ
    iOS Creators' Meetup vol.4
    1

    View full-size slide

  2. Profile
    Kazuya Ueoka
    Timers inc.ͷiOSΤϯδχΞ
    Twitter: @fromkk
    Github: fromkk
    Qiita: fromkk
    2

    View full-size slide

  3. WWDC 2017Ͱൃද͞ΕͨARKit
    602 Introducing ARKit: Augmented Reality for iOS
    3

    View full-size slide

  4. AR(Augmented Reality)
    4 ֦ுݱ࣮
    4 Χϝϥ!ͰࡱӨͨ͠ө૾ʹ3Dͷ෺ମ౳Λ഑ஔ͢ΔࣄͰݱ࣮
    ʹԾ૝తͳ෺ମ͕͍Δ༷ʹݟ͑Δٕज़
    4

    View full-size slide

  5. ͲΜͳࣄ͕ग़དྷΔ
    ͔
    4 Made with ARKit
    4 Awesome ARKit
    5

    View full-size slide

  6. ͲΜͳΞϓϦʹ޲͍͍ͯΔ͔
    4 ήʔϜ
    4 EC౳ͷ෺ൢ
    4 ڭҭɾֶशܥ
    and more...
    6

    View full-size slide

  7. ARKit
    4 ϋΠϨϕϧͳAPI
    4 iOSରԠ(A9Ҏ্)
    4 SceneKit(3D), SpriteKit(2D), Metal(ΧελϜϨϯμϦ
    ϯά)ରԠ
    4 Կԯ΋ͷσόΠε͕ARKitʹରԠࡁΈ
    7

    View full-size slide

  8. ओཁͳػೳ
    4 ϫʔϧυτϥοΩϯάʢಛ௃఺ΛτϥοΩϯάʣ
    4 γʔϯͷཧղʢচͷ൑அɾ౰ͨΓ൑ఆɾ໌Δ͞ਪଌʣ
    4 ϨϯμϦϯά
    UnityɾUnrealରԠ
    8

    View full-size slide

  9. Architecture
    9

    View full-size slide

  10. ARSession
    ARKitͷجຊͱͳΔΫϥε
    4 func run(_ configuration:
    ARSessionConfiguration, options: RunOptions =
    [])
    4 ఆظతʹτϥοΩϯά৘ใΛؚΜͩ ARFrame Λ
    ARSessinoDelegate Ͱड͚औΔࣄ͕ग़དྷΔ
    10

    View full-size slide

  11. ARWorldTrackingSessionConfiguration
    ݱ࣮ੈքΛτϥοΩϯά͢ΔҝͷઃఆΫϥε
    4 class var isSupported: Bool ͰτϥοΩϯάʹରԠ͠
    ͍ͯΔ͔൑அ͢Δࣄ͕ग़དྷΔ
    4 var planeDetection: PlaneDetection
    4 struct PlaneDetection : OptionSet {
    static var horizontal: PlaneDetection
    }
    11

    View full-size slide

  12. ARSCNView
    ARΛදࣔ͢Δҝʹར༻͢ΔView
    4 SCNView Λܧঝ
    4 delegate: ARSCNViewDelegate Ͱ ARAnchor ͕௥Ճ͞Ε
    ͨ౳ͷ௨஌Λड͚औΔࣄ͕ग़དྷΔ
    12

    View full-size slide

  13. ౰ͨΓ൑ఆ
    ARSCNView.hitTest(_ point: CGPoint,
    types: .ResultType) -> [ARHitTestResult]
    13

    View full-size slide

  14. ARHitTestResult.ResultType
    4 featurePoint ࠷΋͍ۙಛ௃఺
    4 estimatedHorizontalPlane ਪఆͷਫฏ໘
    4 existingPlane طଘͷฏ໘ΞϯΧʔ
    4 existingPlaneUsingExtent طଘͷฏ໘ΞϯΧʔͷൣғΛ
    ར༻͢Δ
    14

    View full-size slide

  15. օ͞Μ!͸޷͖Ͱ͔͢ʁ
    16

    View full-size slide

  16. Ͱ͢ΑͶʁ
    17

    View full-size slide

  17. !͕ແݶʹݱΕΔ༷ͳੈքʹಌΕ·͢ΑͶ"
    18

    View full-size slide

  18. ࡞ͬͯΈ·͠ΐ͏!
    19

    View full-size slide

  19. ؆୯ͳྲྀΕ
    4 ARSCNView ʹ SCNScene Λ௥Ճ͢Δ
    4 ARSession ͷ run ϝυουʹ
    ARWorldTrackingSessionConfiguration Ληοτ
    4 scene.rootNode ʹ SCNNode Λ௥Ճ͍ͯ͘͠
    4 ී௨ʹ UIGestureRecognizer ͕ར༻ग़དྷΔ
    20

    View full-size slide

  20. લఏ৚݅
    4 ΧϝϥΛར༻͢Δҝ Info.plist ʹ
    NSCameraUsageDescription Λهड़͓ͯ͘͠
    21

    View full-size slide

  21. Recap
    4 ؆୯ʹݱ࣮ੈքʹण࢘Λେྔʹ഑ஔ͢Δࣄ͕ग़དྷ·ͨ͠!
    4 SceneKit ͷ஌͕ࣝ͋Ε͹৭ʑग़དྷͦ͏"
    4 iOS 11ͷϦϦʔεͱڞʹͲͷ༷ͳARKitରԠͷΞϓϦ͕ग़ͯ
    ͘Δָ͔͠ΈͰ͢Ͷ❗
    4 (ͪͳΈʹ)iPadͷSwift Playground 2(beta)Ͱ΋ಈ͘$
    23

    View full-size slide

  22. Sample code
    4 https://github.com/fromkk/ARSushi
    4 https://github.com/fromkk/
    ARKitForSwiftPlayground2
    24

    View full-size slide

  23. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠!
    25

    View full-size slide