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

初めてのVR開発

 初めてのVR開発

ABC2017 SpringのBeginnerトラックのセッション。スマートフォン用のVRアプリ開発を始めてみたい、または興味を持っているという方に何からどう始めれば良いのか解説します。Unityで3Dグラフィクスを使用する方法だけでなく、Google VR SDKのVR Viewと写真や動画を使って簡単に自分のアプリにVRの要素を追加する方法も紹介しています。

Kenichi Takahashi

May 28, 2017
Tweet

More Decks by Kenichi Takahashi

Other Decks in Programming

Transcript

  1. ߴڮݑҰ (@ken1_taka) • Android, iOS, 3DάϥϑΟΫε • ܞଳ޲͚3DάϥϑΟΫεΤϯδϯ΍ɺੲ͋ͬͨ๭AR ΞϓϦͷ։ൃʹܞΘΔ •

    גࣜձࣾΧϒΫ ιϑτ΢ΣΞΤϯδχΞ • 3DϓϦϯλΛ׆༻ͨ͠΋ͷͮ͘ΓϓϥοτϑΥʔϜ
  2. جຊతʹ͸͜Ε͔ΒVR։ൃΛ ࢝ΊΔͱ͍͏ਓ޲͚ 1ষ ͢΂ͯͷਓʹόʔνϟϧͳ͢΂ͯͷ΋ͷ Λ 2ষ ΦϒδΣΫτͱεέʔϧ 3ষ VRͷϏϧυͱ࣮ߦ 4ষ

    ஫ࢹ఺ϕʔεͷίϯτϩʔϧ 5ষ ϫʔϧυۭؒͷUI 6ষ ҰਓশͷΩϟϥΫλʔ 7ষ ෺ཧͱ؀ڥ 8ষ ΢ΥʔΫεϧʔͱϨϯμϦϯά 9ষ 360౓શํҐͷ׆༻ 10ষ VRۭؒͰͷࣾձੑ 11ষ ࣍ʹԿ͕ى͜Δͷ͔ ෇࿥A GearVR༻ͷϏϧυͱλονύου͔Β ͷೖྗ ෇࿥B DaydreamίϯτϩʔϥʔΛ࢖ͬͯΈΔ
  3. ࡢ೥ɺ DTPલͷߍਖ਼Λ࢓্͛ͨே… • Google VR SDK for Untiy͕ 0.8.5ʹΞοϓσʔτ •

    ಥવLegacyͱ͍͏ϑΥϧμ ͕ݱΕ… • GvrMain͸deprectedʹ(;_;) • ୅ΘΓʹGvrViewerMainΛ࢖ ͑ͱ…
  4. –Jonathan Linowes “How does one write a book that does

    not have obsolete content the day it's published?” ʮൃച೔ʹݹ͘ͳͬͨ಺༰ͷͳ͍ຊͳͲ͔͚Δ ͷͩΖ͏͔…ʯ
  5. ݴ͍͍ͨ͜ͱ͸… • ͜͏͍͏͜ͱ͸Α͋͘Δ • ಛʹGoogle VR SDKͰ͸… • SDKͷߋ৽ͷνΣοΫΛଵΒͳ͍ •

    ୯ʹ໊લ͕มΘΔΑ͏ͳ͜ͱͰ͸ͳ͘ɺΑΓศརͩͬ ͨΓɺߴػೳͳ΋ͷ͕௥Ճ͞Ε͍ͯͨΓ͢Δ͜ͱ΋͋ Δ
  6. ϞόΠϧܕ • εϚʔτϑΥϯͱ૊߹ͤΔHMD • ඳըੑೳ͸εϚʔτϑΥϯ࣍ୈ • खܰ • ҆Ձ •

    ϙδγϣϯτϥοΩϯά͕ແ͍ʢ3DoFʣ • ίϯτϩʔϥʔ͕ແ͍ • Cardboard͸ԡ͠Ϙλϯ̍ͭ
  7. 6DoF • 6 Degrees of Freedomͷུ • ্ԼɺࠨӈɺલޙͷҠಈ • ϩʔϧɺϐονɺϤʔͷ

    ̏࣠Ͱͷճస • ̏࣠ͷճసͷΈͷ৔߹ Λ3DoFͱ͍͏ https://ja.wikipedia.org/wiki/6DoF
  8. ϞόΠϧܕͷܽ఺ͷվળ܏޲ • Daydream΍Gear VR • 3DoFͰยख༻ͷΈͳ͕Βίϯτϩʔϥ͕͋Δ • ੑೳ΋ߴ͘ͳ͖͍ͬͯͯΔʢϨΠςϯγ 20msʣ •

    2017೥຤ʹ͸DaydreamͰεϚʔτϑΥϯແ͠Ͱ୯ମͰಈ ࡞ɺ׌ͭϙδγϣϯτϥοΩϯά(6DoF)ػೳ͕͋ΔHMD ͕ొ৔༧ఆ
  9. ശఉΛ೷͚ͩ͘ͳΒ Ϗϧυ͢Δ͚ͩ • Virtual Reality Supportedʹ νΣοΫΛೖΕΔ • Virtual Reality

    SDKsʹ CardboardΛ௥Ճ͢Δ • ύέʔδ໊ɺMinimum API Level౳AndroidΞϓϦ ͷઃఆΛߦ͏
  10. ϨΠͷিಥ൑ఆͷεΫϦϓτ • Camera.main.transform.forward … ݟ͍ͯΔํ޲ͷϕΫτϧ • Ray(camera.position, Camera.main.transform.forward) … ΧϝϥͷҐஔ͔Βݟ͍ͯΔํ޲

    ΁৳͹͢ϨΠ • Physics.Raycast(ray, out hit) … ϨΠͱଞͷΦϒδΣΫτͱͷিಥ൑ఆΛߦ͏ɻhitʹ͸౰ ͨͬͨΦϒδΣΫτ΍ͦͷҐஔ͕ೖΔɻ Ray ray = new Ray (camera.position, Camera.main.transform.forward);
 RaycastHit hit;
 if (Physics.Raycast (ray, out hit) && (hit.collider.gameObject == gameObject)) {
 // ౰ͨͬͨ࣌ͷॲཧ
 }
  11. ্ԼҠಈͷεΫϦϓτ float moveY = Camera.main.transform.forward.y * velocity * Time.deltaTime;
 float

    newY = transform.position.y + moveY;
 transform.position = new Vector3 (transform.position.x, newY, transform.position.z);
 • Camera.main.transform.forwad.y … ݟ͍ͯΔํ޲ͷϕΫτϧͷY࣠੒෼ʢਫฏͰ0ʣ • velocity … ઃఆͨ͠଎౓ • Time.deltaTime … લϑϨʔϜ͔Βͷܦա࣌ؒ • Y࣠੒෼ x ଎౓ x ܦա࣌ؒ ʹ Y࣠ʢ্Լํ޲ʣͷҠಈڑ཭
  12. VRViewΛ૊ΈࠐΉखॱ 1. build.gradleʹඞཁͳdependencesΛ௥Ճ 2. ϨΠΞ΢τʹ VrPanoramaView Λ௥Ճ 3. assetsͱͯ͠ύϊϥϚը૾ϑΝΠϧΛ௥Ճ 4.

    javaͷίʔυΛগʑ A. assetsͷը૾ϑΝΠϧͷಡΈࠐΜͰBitmapԽ B. VrPanoramaViewʹBitmapΛϩʔυ
  13. 4. javaͷίʔυΛগʑʢͦͷ̎ʣ • VrPanoramaView.OptionsΛઃఆ • MONO or STEREO • VrPanoramaViewʹBitmapΛϩʔυ

    VrPanoramaView.Options panoOptions = new VrPanoramaView.Options();
 panoOptions.inputType = VrPanoramaView.Options.TYPE_MONO;
 VrPanoramaView vrView = (VrPanoramaView)findViewById(R.id.pano_view); vrView.loadImageFromBitmap(bmp, panoOptions);