ARCoreの導入から応用まで @ABC 2018 autumn

ARCoreの導入から応用まで @ABC 2018 autumn

Google AR ハンズオン at ABC2018 Autumn ( https://japan-android-group.connpass.com/event/103063/ )でARCoreの概要説明に使った資料です。6月のABC 2018 springの時の資料 ( https://speakerdeck.com/ktaka/androiddearfalsemeng-wozai-bi-arcorefalsedao-ru-karaying-yong-made )に少しだけ最新情報を追加しました。

Be4b441abb2fdf03acb5bdfddba4b4f2?s=128

Kenichi Takahashi

October 13, 2018
Tweet

Transcript

  1. "3$PSFͷಋೖ͔ΒԠ༻·Ͱ !"#$BVUVNO גࣜձࣾΧϒΫߴڮݑҰ

  2. @ken1_taka ktaka גࣜձࣾΧϒΫιϑτ΢ΣΞΤϯδχΞ ߴڮݑҰ w ܞଳ޲͚%άϥϑΟΫεΤϯδϯ΍ɺੲ͋ͬ ͨ๭"3ΞϓϦͷ։ൃʹܞΘΔ w ݱࡏ͸ΧϒΫͰ%άϥϑΟΫεͷϨϯμϦϯ ά͓ΑͼղੳΤϯδϯͷ࣮૷Λ୲౰

    w ݸਓత׆ಈͱͯ͠"373ͷ࣮ݧΛ͢Δ๣Β຋ ༁ຊΛग़ͨ͠Γɺٕज़ܥࡶࢽ΁ͷղઆهࣄΛد ߘ͢ΔͳͲ͍ͯ͠Δ
  3. 6OJUZʹΑΔʙຊͷ຋༁

  4. ࠓ೔ͷ಺༰ w "3$PSFʹ͍͓ͭͯ͞Β͍ w جຊػೳ w "3$PSFҎ߱Ͱ௥Ճ͞Εͨ৽ػೳ w ։ൃํ๏ w

    +BWB 4DFOFGPSN  w 6OJUZ
  5. "3$PSFʹ͍͓ͭͯ͞Β͍

  6. "3$PSFͱ͸ w "OESPJEͰ"3ΞϓϦΛ࣮ݱ͢ΔͨΊͷ(PPHMF७ਖ਼ϥΠϒϥϦ w "OESPJEεέʔϧͰ޿͘ීٴΛ໨ࢦ͢  NJMMJPO

  7. "3$PSFͷجຊػೳ

  8. .PUJPOUSBDLJOHʢϞʔγϣϯτϥοΩϯάʣ IUUQTEFWFMPQFSTHPPHMFDPNBSEJTDPWFSDPODFQUT$$#:

  9. ϞʔγϣϯτϥοΩϯά w "3$PSF΍"3,JUΛ࢖͑ΔΑ͏ ʹͳͬͯҰ൪خ͍͠ͷ͸ʜ͜ Μͳ෩ʹճΓࠐΊΔ͜ͱ

  10. &OWJSPONFOUBMVOEFSTUBOEJOHʢ؀ڥೝࣝʣ IUUQTEFWFMPQFSTHPPHMFDPNBSEJTDPWFSDPODFQUT$$#:

  11. ฏ໘ͷݕग़ w ਫฏͱਨ௚ͷฏ໘Λೝࣝ w ͔Βਨ௚໘΋Մೳʹ

  12. 0SJFOUFE1PJOUT ʢํ޲Λ͍࣋ͬͯΔ఺ʣ w ฏ໘ͱͯ͠ݕग़Ͱ͖Δͷ͸ਫ ฏ͓Αͼਨ௚ͷ໘ w ͨͩ͠ɺಛ௃఺ͱͯ͠ݕग़͠ ͨ఺ͷํ޲Λऔಘ͢Δ͜ͱ͸ Ͱ͖Δ w

    ಛ௃఺͕ີू͍ͯ͠ΔΑ͏ͳ ৔ॴͩͱݕग़͠΍͍͢ʣ
  13. -JHIUFTUJNBUJPOʢޫݯਪఆʣ IUUQTEFWFMPQFSTHPPHMFDPNBSEJTDPWFSDPODFQUT$$#:

  14. ޫݯਪఆ w पғͷ໌Δ͞ͷมԽ͔Βޫ ͷڧ͞Λਪఆ w ޫͷ౰ͨΔํ޲͸औಘͰ͖ ͳ͍

  15. "3$PSFҎ߱ Ͱ௥Ճ͞Εͨػೳ

  16. $MPVE"ODIPST w ෳ਺୺຤Ͱಉ͡"3ۭؒΛڞ༗ w ͭͷ୺຤͔ΒΫϥ΢υΛ௨͡ ͯଞͷ୺຤ʹڞ༗ w "ODIPSΦϒδΣΫτ w पลͷಛ௃఺

    w "OESPJE͚ͩͰͳ͘J04ͱ΋ڞ ༗ w J04༻ͷ4%,΋͋Δ
  17. +VTUB-JOF w (PPHMF੡ͷ"3ۭؒʹམॻ͖ Ͱ͖ΔΞϓϦ w "OESPJE൛ͱJ04൛͕͋Δ w /FBSCZͰϖΞϦϯάͯ͠୆ Ͱ"3ۭؒΛڞ༗ w

    ιʔε͸ެ։͞Ε͍ͯΔ IUUQTHJUIVCDPNHPPHMFDSFBUJWFMBCKVTUBMJOFBOESPJE
  18. +VTUB-JOF w (PPHMF੡ͷ"3ۭؒʹམॻ͖ Ͱ͖ΔΞϓϦ w "OESPJE൛ͱJ04൛͕͋Δ w /FBSCZͰϖΞϦϯάͯ͠୆ Ͱ"3ۭؒΛڞ༗ w

    ιʔε͸ެ։͞Ε͍ͯΔ IUUQTHJUIVCDPNHPPHMFDSFBUJWFMBCKVTUBMJOFBOESPJE
  19. $MPVE"ODIPSTͷେࣄͳ͜ͱ w ໘౗Λݟͯ͘ΕΔͷ͸Ґஔͱ޲͖ͷΈ w ͦΕΛݩʹ։ൃऀ͕ػೳΛ࣮૷͢Δඞཁ͋Γ w ڞ༗͢Δ"ODIPSͷ৘ใ͸'JSFCBTF΍/FBSCZ౳Λ࢖ͬ ͯ౉͢

  20. ͜ͷ͋ͱͷίʔυϥϘͰ ମݧͰ͖·͢ w $MPVE"ODIPSTͰυϩΠυ܅ ͷ഑ஔ৘ใΛڞ༗ w ΞϯΧʔͷ*%͸'JSFCBTFΛ࢖ͬ ͯଞͷ୺຤ͱڞ༗ w +BWBΛ࢖༻

    IUUQTDPEFMBCTEFWFMPQFSTHPPHMFDPNDPEFMBCTBSDPSFDMPVEBODIPST
  21. "VHNFOUFE*NBHFT w ࢦఆͨ͠ը૾Λೝࣝͯ͠ɺҐ ஔͱ࢟੎ΛτϥοΩϯά͢Δ

  22. ରԠ୺຤ w ݱࡏͷ"3$PSFͷόʔδϣϯ͸  w όʔδϣϯΛॏͶΔ͝ͱʹର Ԡ୺຤΋͍ͩͿ૿͑·ͨ͠ w 9QFSJB9; w

    (BMBYZ" " " /PUF  4 4 4 w -(( )VBXFJ1౳ IUUQTEFWFMPQFSTHPPHMFDPNBSEJTDPWFSTVQQPSUFEEFWJDFT
  23. ։ൃํ๏ +BWB $ /%, 6OJUZ 6OSFBM&OHJOF 8FCͷԿΕͰ΋Մೳ

  24. +BWBͰͷ։ൃ 4DFOFGPSNʹ͍ͭͯ

  25. 4DFOFGPSNͱ͸ w %ϞσϧͷΠϯϙʔτπʔϧɺ"3γʔϯ΁ͷ૊ΈࠐΈ ͕؆୯ʹͰ͖ΔϥΠϒϥϦ w "OESPJE4UVEJPͰ+BWBͰ։ൃͰ͖·͢

  26. https://developers.google.com/ar/develop/java/sceneform/ l"OESPJE։ൃऀʹ%άϥϑΟΫεͱ0QFO(-Λ ֶͿ͜ͱͳ͠ʹ"3$PSFΛۦ࢖͢ΔྗΛ༩͑Δz

  27. ࠷΋جຊతͳखॱ

  28. "OESPJE4UVEJPʹ ϓϥάΠϯΛΠϯετʔϧ͢Δ w 1SFGFSFODFTˠ1MVHJOT <#SPXTFSFQPTJUPSJFT>Λԡ͠ ͯ w (PPHMF4DFOFGPSN5PPMT #FUB ΛΠϯετʔϧ

  29. 1PMZ͔Β%ϞσϧΛ μ΢ϯϩʔυ͢Δ w IUUQTQPMZHPPHMFDPN͔ Β%ϞσϧΛμ΢ϯϩʔυ w ओʹ"3ͱ73Ͱͷ׆༻Λ໨త ͱͨ͠%Ϟσϧڞ༗αΠτ w $$#:Ͱ࢖༻Ͱ͖Δ΋ͷ͕ଟ

    ͍
  30. %ϞσϧΛϓϩδΣΫτʹ Πϯϙʔτ w μ΢ϯϩʔυͨ͠ w YYYQOH w YYYNUM w YYYPCK

    w Λ4BNQMFEBUBʹίϐʔ
  31. %ϞσϧΛϓϩδΣΫτʹ Πϯϙʔτ̎ w YYYPCKΛӈΫϦοΫ ˠ/FXˠ4DFOFGPSN"TTFU ͷॱʹબ୒ w 'JOJTIΛԡ͢

  32. %ϞσϧΛϓϩδΣΫτʹ Πϯϙʔτ w YYYTGB YYYTGCͱ͍͏ϑΝΠ ϧ͕࡞੒͞ΕΔ w %ϞσϧͷϓϨϏϡʔ͕දࣔ ͞ΕΔ w

    TGCͷํ͸BTTFUTͷԼʹஔ͔Ε Δ
  33. ίʔυ্ʹϩʔυ͢Δ ϑΝΠϧΛهड़͢Δ w BTTFUTͷԼͷTGCϑΝΠϧΛ ࢦఆ͢Δ

  34. Ϗϧυ࣮ͯ͠ߦ w ฏ໘Λλοϓͯ͠%ϞσϧΛ ഑ஔ͢ΔͨΊʹඞཁͳػೳ͕ ͜Ε͚ͩͰҰ௨Γ׬੒ʂ

  35. 4DFOFGPSNͷߏ੒ཁૉ w "S'SBHNFOU w 3FOEFSBCMF w .PEFM3FOEFSBCMF w 7JFX3FOEFSBCMF

  36. "S'SBHNFOU w ୺຤Λಈ͔͢͜ͱΛଅ͢6*
 w ೝࣝฏ໘Λࣔ͢6*
 w ฏ໘Λλοϓͨ͠ࡍͷMJTUOFS
 w ฏ໘ʹӨΛམͱ͢


  37. .PEFM3FOEFSBCMF w %ϞσϧΛѻ͏

  38. 7JFX3FOEFSBCMF "OESPJE։ൃऀʹ͸͓ͳ͡ΈͷMBZPVUͷYNMΛ"3্ۭؒʹු͔Ϳ7JFX ͱͯ͠࡞੒Ͱ͖Δʂ

  39. 7JFX3FOEFSBCMF࡞੒खॱ 7JFX3FOEFSBCMFCVJMEFS TFU7JFX UIJT  3MBZPVUTPMBS@DPOUSPMT CVJME  CBDLHSPVOE ʢؙ֯ɺ൒ಁ໌ͷ੨ʣ

    MBZPVUYNM "1*
  40. ͜ͷ͋ͱͷίʔυϥϘͰ ମݧͰ͖·͢ w 4DFOFGPSNΛ࢖ͬͯछྨͷ% ϞσϧΛ഑ஔ w ࣸਅΛࡱͬͯอଘ w ͓·͚ͷ՝୊ w

    ೚ҙͷจࣈྻΛ 7JFX3FOEFSBCMFͰ഑ஔ w IUUQCJUMZ+#PJ2# IUUQTDPEFMBCTEFWFMPQFSTHPPHMFDPNDPEFMBCTTDFOFGPSNJOUSP
  41. 4DFOFGPSNͷ ϨϯμϦϯάΤϯδϯ w ෺ཧϕʔεͷϨϯμϦϯάΤϯ δϯ w ϥΠςΟϯάͷޮՌͳͲ͕ लҳ w Φʔϓϯιʔε

    w IUUQTHJUIVCDPN HPPHMFpMBNFOU
  42. 4DFOFGPSNͷ௥Ճػೳ w HM5'Λ௚઀ϩʔυ w HM5'ʜωοτܦ༝Ͱͷ%Ϟσϧͷ ΍ΓऔΓͰඪ४తͳҐஔΛ֫ಘͭ͠ ͭ͋Δ w "OESPJE4UVEJPͷϓϥάΠϯͰͷ ม׵͕ෆཁ

  43. ΋ͬͱݱ࣮Λ֦ு͍ͨ͠ʜ ͦΜͳ࣌ʹཔΓʹͳΔͷ͸ 6OJUZ

  44. ͜ͷ͋ͱͷίʔυϥϘ 6OJUZฤ  Ͱ࡞Δ΋ͷ IUUQTDPEFMBCTEFWFMPQFSTHPPHMFDPNDPEFMBCTBSDPSFJOUSP

  45. ྫ6OJUZͰ$MPVE"ODIPSTΛ࢖ͬͯ ෳ਺ਓͰϓϨΠ͢Δαϯϓϧ w -JHIU#PBSE w Φʔϓϯιʔε w IUUQTHJUIVCDPN HPPHMFTBNQMFTBSDPSF MJHIUCPBSE

  46. ྫɿ"3ۭؒͰϖοτΛࣂ͏ w ඞཁͳཁૉ w Ξχϝʔγϣϯ͢Δ%Ωϟ ϥ w ෺ཧΤϯδϯ w ஄ΉϘʔϧ

    w ϘʔϧΛ௓Ͷฦ͢চ໘ w ஫໨ͯ͠΄͍͠΋ͷʹ޲͚Δ
  47. Ξχϝʔγϣϯ͢Δ%Ωϟϥ w "TTFU4UPSF͔ΒΠϯϙʔτͯ͠"OEZͱஔ͖׵͑Ͱ0,

  48. ෺ཧΤϯδϯͷ׆༻ w ෺ཧ๏ଇʹԊͬͨৼΔ෣͍Λ ͢ΔϘʔϧ w ϘʔϧΛ௓Ͷฦ͢ฏ໘

  49. ෺ཧ๏ଇʹԊͬͨৼΔ෣͍Λ͢ ΔϘʔϧ w 4QIFSF$PMMJEFS w #PVODZ w 3JHJECPEZ w .BTT

    w 6TF(SBWJUZ
  50. ϘʔϧΛ௓Ͷฦ͢ฏ໘ w .FTI3FOEFSFS w .BUFSJBMʹ4%,ʹ͋Δ 1MBOF(SJEΛઃఆ

  51. ϘʔϧΛ౤͛Δίʔυ ΦϒδΣΫτΛλοϓͨ࣌͠

  52. ϘʔϧΛ౤͛Δίʔυ ΦϒδΣΫτΛυϥοάʢϑϦοΫʣ։࢝

  53. ϘʔϧΛ౤͛Δίʔυ ΦϒδΣΫτΛυϥοά͍ͯ͠Δؒ

  54. ϘʔϧΛ౤͛Δίʔυ ΦϒδΣΫτͷυϥοάऴྃʢࢦΛ཭ͨ͠ʣ

  55. %ΦϒδΣΫτͱΧϝϥ ͷҐஔؔ܎ ᶃೣͷݱࡏҐஔ ᶄΧϝϥͷݱࡏҐஔ ᶅೣͷσϑΥϧτํ޲ͷϕΫτ ϧʢ9 : ;Ͱද͢ͱ  ʣ

    ᶆೣ͔ΒΧϝϥ΁ͷํ޲ͷϕΫ τϧ ᶇΧϝϥͷํʹ޲͔ͤΔͨΊͷ ճస
  56. ΦϒδΣΫτΛΧϝϥͷํ޲ʹ ޲͚Δࡍͷճస Vector3 GetLookVector () { Vector3 lookVector = Camera.main.transform.position

    - hitTransform.transform.position; lookVector.y = 0.0f; // Y軸の差分は無視する lookVector.Normalize (); return lookVector; } hitTransform.transform.rotation = Quaternion.LookRotation (GetLookVector());
  57. ྫ%ϓϦϯτ෩ΤϑΣΫτ ࢦఆͨ͠:࠲ඪͷ9;ฏ໘ͰΫϦοϐϯά͢ΔγΣʔμʔͷهड़ͱɺͦͷ:࠲ඪͷ஋ ΛϑϨʔϜ͝ͱʹҠಈͤ͞ΔεΫϦϓτͷ૊Έ߹ΘͤͰ࣮ݱ

  58. ௥Ճ͢ΔγΣʔμʔͷϓϩύςΟ w @$POTUSVDU: w ΫϦοϐϯά͢Δ:࠲ඪͷ஋ w @$POTUSVDU(BQ w ੵ૚͍ͯ͘͠ࡍʹ৭Λม͑Δڥ քͷߴ͞

    w @$POTUSVDU$PMPS w ੵ૚͍ͯ͘͠ࡍͷڥքͷ৭ ৄࡉ͸IUUQTXXXLBCVLVDPKQEFWFMPQFSTBSE@QSJOU
  59. γΣʔμʔͷίʔυ if(IN.worldPos.y > _ConstructY + _ConstructGap) { discard; } ඳը͞Εͳ͍Α͏ΫϦοϐϯά͢ΔॲཧͰ͢ɻ

    ϐΫηϧͷϫʔϧυҐஔͷ:࠲ඪͷ஋͕ʮΫϦοϐϯά͢Δ:࠲ඪ ڥ քͷߴ͞ʯΑΓେ͖͍ʢΫϦοϐϯά͢ΔҐஔΑΓߴ͍Ґஔʹ͋Δʣ৔ ߹ɺEJTDBSEͯ͠ඳը͠ͳ͍Α͏ʹ͠·͢ɻ
  60. γΣʔμʔͷίʔυ if(IN.worldPos.y < _ConstructY) { fixed4 c = tex2D(_MainTex, IN.uv_MainTex);

    o.Albedo = c.rgb; o.Alpha = c.a; } else { o.Albedo = _ConstructColor.rgb; o.Alpha = _ConstructColor.a; } ϐΫηϧͷϫʔϧυҐஔͷ:࠲ඪͷ஋͕ΫϦοϐϯά͢Δ:࠲ඪΑΓখ͍͞৔ ߹ɺ௨ৗඳըͷର৅ͱͯ͠ςΫενϟ͔Βͷ৭Λ൓ө͠·͢ɻ:࠲ඪͷ஋Ҏ্ ͷ৔߹ɺڥք෦෼ͷඳըର৅ͱͯ͠ڥքͷ৭Λ൓ө͠·͢ɻ
  61. ࠷ޙʹʜ ೔ຊޠͰ࣭໰ɺ૬ஊͰ͖ΔϑΥʔϥϜ IUUQCJUMZWSBS@KB ͥͻ͝ొ࿥͍ͩ͘͞ʂ ೔ຊޠͰؾܰʹ࣭໰ɺ૬ ஊͰ͖ΔΑ͏ʹཱͯͯΈ ·ͨ͠ (PPHMFΞΧ΢ϯτ͕͋Ε ͹ԿํͰ΋ࢀՃՄೳͰ͢