OculusTouchを使ったコンテンツを作成するにおいて、『Avatar Grab Sample』という非常に参考になるサンプルがあります。これはOculusの中の人ことmfmfさんが作ったサンプルです。
ただし、少々古いサンプルなので、Unity2017+OculusSDK1.16.0の環境において、いくつか修正しないといけない部分があります。この記事では、その修正とサンプルを使うところまで紹介します。
まず、『Avatar Grab Sample』を入手します。『Avatar Grab Sample』はOculusDevelopersフォーラムのこちらでダウンロードできます。
ダウンロードしたらzipファイルを解凍して、中にある「AvatarGrabSample」というUnityPackegeFileを実行して、Unityにインポートしてください。実行する先は、前の記事までで作成してきたプロジェクトにお願いします(Unity2017+OculusUtilities1.16.0-beta + Oculus Avator SDK1.16.0 + Oculus Platform SDK1.16.0の環境)。
インポートが完了すると、Assets内にSamplesというフォルダができているはずです。
このSample->Contentフォルダ内にAvatarWithGrabというUnityファイルがあるのでこれを開きます。これがサンプルシーンなのですが、エラーが出て実行できないはずです。なのでまずバグを修正します。
「Assets/OVR/Scripts/Util/OVRGrabber.cs(105,33): error CS1061: Type `OvrAvatarDriver' does not contain a definition for `GetCurrentPose' and no extension method `GetCurrentPose' of type `OvrAvatarDriver' could be found. Are you missing an assembly reference?」というエラーが発生しているはずです。
Unity2017+OculusSDK1.16.0環境下では、足りない定義があるのでそれを加えていきます。
Assets->OvrAvatar->Scriptsの中に、「OvrAvatarLocalDriver.cs」というスクリプトファイルがあるので、それを開きます。このスクリプト中の、40行目あたりに以下の定義一式を追加します。
public bool MyGetCurrentPose(out PoseFrame pose)
{
pose = new PoseFrame
{
voiceAmplitude = voiceAmplitude,
headPosition = UnityEngine.VR.InputTracking.GetLocalPosition(UnityEngine.VR.VRNode.CenterEye),
headRotation = UnityEngine.VR.InputTracking.GetLocalRotation(UnityEngine.VR.VRNode.CenterEye),
handLeftPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch),
handLeftRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch),
handRightPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch),
handRightRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch),
controllerLeftPose = GetControllerPose(OVRInput.Controller.LTouch),
controllerRightPose = GetControllerPose(OVRInput.Controller.RTouch),
};
return true;
}
次に、Assets->OVR->Scripts->Utilの中に「OVRGrabber.cs」というスクリプトファイルがあるので、それを開きます。このこのスクリプト中、105行目の
m_avatar.Driver.GetCurrentPose(out frame);
を削除して、
((OvrAvatarLocalDriver)m_avatar.Driver).MyGetCurrentPose(out frame);
に変更します。
「The referenced script on this Behaviour is missing!」という警告がいっぱい出ているはずです。これは、このサンプルが作られた当初といくつかSDK内のファイル名が違っているのが原因です。
Assets->OVR->Scripts->Utilの中に、「OVRGrabber.cs」と「OVRGrabbable.cs」いうスクリプトファイルがあります。このファイルの名前のOVRを削除して、それぞれ「Grabber.cs」と「Grabbable.cs」というファイル名に変更します。
■バグの修正(その3)
エラーメッセージは表示されなくなりましたが、まだモノを掴むことができません。これは「Grabber.cs」にAvatarオブジェクトが設定されていないせいです。
HierarchyビューのLocalAvatar->grabber_leftオブジェクトを選択して、Inspectorビューを見ます。Grabberスクリプト中にAvatarという欄がありますが、そこに何も設定されてないはずです。
なので、Assets->OvrAvatar->Content->Orefabの中に、LacalAvatar.prefabというファイルがあるので、これをそのAvatar欄にドラッグして設定します。同様にして、grabber_rightオブジェクトにもLacalAvatar.prefabを設定します。
これで『Avatar Grab Sample』を正常に実行することができるはずです。ただし、まだ「No Oculus Rift App ID has been provided.」というエラーが出ていて気持ちが悪いのでこれも修正しておきます。
「No Oculus Rift App ID has been provided.」を解決するためには、OculusAppIDを取得し、設定する必要があります。OculusDevelopersサイトのManageにアクセスしてください。このページの「Create New App」をクリックします。するとGearVRかOculusRiftかの選択肢が表示されるので、OculusRiftを選んでください。
次にアプリ名の入力画面が表示されるので、適当なアプリ名を入れて「Save and Continue」をクリックします。
次の画面に表示されるAppIDという欄の16桁の数字がOculusAppIDになります。これをコピーします。
Unityに戻って、ツールバー中の「OculusAvatars」をクリックします。Inspector画面にOculusRiftAppIDの入力欄が表示されるので、コピーしたIDをペーストします。
これでエラー表示はなくなるはずです。
『Avatar Grab Sample』を実行してみましょう。
テーブルの上に並んだブロックを手で掴むことができるはずです。掴んだブロックを放り投げたり、他のブロックに衝突させることもできます。
これはOculusTouchを使ったコンテンツを作るうえで非常に参考となるサンプルです。これをベースに様々なコンテンツを作ることができます。これをテンプレートプロジェクトとして保存しておくと良いでしょう。
次の記事では、この『Avatar Grab Sample』を参考に、OculusTouchでオブジェクトを掴む方法を説明していきます。
We'll need to take up references <a href=" http://wilkinsplastering.co.uk/silagra-mf.html ">silagra pills review molly</a> Meritech founding partner Paul Madera said he hoped to one day hire a female partner.
We'll need to take up references <a href=" http://wilkinsplastering.co.uk/silagra-mf.html ">silagra pills review molly</a> Meritech founding partner Paul Madera said he hoped to one day hire a female partner.
I live here <a href=" http://k9prop.info/buy-ethinyl-estradiol-synthetic ">estrace cream how to use rqm</a> “I felt like he could do better at the time because I couldn’t really move like I wanted to.”
I live here <a href=" http://k9prop.info/buy-ethinyl-estradiol-synthetic ">estrace cream how to use rqm</a> “I felt like he could do better at the time because I couldn’t really move like I wanted to.”
There's a three month trial period <a href=" http://www.lasvegascomplaints.com/ou-commander-vicerex/ ">vicerex for sale</a> They go home after what feels like one of the biggest losses in college basketball history
There's a three month trial period <a href=" http://www.lasvegascomplaints.com/ou-commander-vicerex/ ">vicerex for sale</a> They go home after what feels like one of the biggest losses in college basketball history
I'm a housewife <a href=" http://autodent-services.co.uk/medipolis-intensivshop-de-reviews.html ">medipolis-intensivshop.de reviews</a> The message suggests that Facebook is planning to grab and sell users' photos and videos
I'm a housewife <a href=" http://autodent-services.co.uk/medipolis-intensivshop-de-reviews.html ">medipolis-intensivshop.de reviews</a> The message suggests that Facebook is planning to grab and sell users' photos and videos
I've only just arrived <a href=" http://spiritadventures.co.uk/celexa-10-to-20-mg-ncm ">how much does celexa cost without insurance kpi</a> These days he is not the ‘Steady Eddie’ he was once generally perceived to be
I've only just arrived <a href=" http://spiritadventures.co.uk/celexa-10-to-20-mg-ncm ">how much does celexa cost without insurance kpi</a> These days he is not the ‘Steady Eddie’ he was once generally perceived to be
I'm not interested in football <a href=" http://guildwars2forum.com/presolar-medicine/ ">presolar cap</a> The difficulty, as with most plant-based medicines, is to produce enough wasabi consistently to be able to generate a product
I'm not interested in football <a href=" http://guildwars2forum.com/presolar-medicine/ ">presolar cap</a> The difficulty, as with most plant-based medicines, is to produce enough wasabi consistently to be able to generate a product
Pleased to meet you <a href=" http://www.flexss.co.uk/hair-ud/ ">so depressed about hair loss</a> Please refrain from profanity, obscenity, spam, name-calling or attacking others for their views.
Pleased to meet you <a href=" http://www.flexss.co.uk/hair-ud/ ">so depressed about hair loss</a> Please refrain from profanity, obscenity, spam, name-calling or attacking others for their views.
How long have you lived here? <a href=" http://k9prop.info/buy-estradiol-patch-generic-price ">estradiol valerate buy online pharmacy</a> 31, then they get (paid for) 60 days after that, but I can’t see anyone going in,” says one insider
How long have you lived here? <a href=" http://k9prop.info/buy-estradiol-patch-generic-price ">estradiol valerate buy online pharmacy</a> 31, then they get (paid for) 60 days after that, but I can’t see anyone going in,” says one insider
Can you put it on the scales, please? <a href=" http://www.ttr-codnor.co.uk/ponatinib-ll.html ">ponatinib price uk</a> Both options should be explored thoroughly by international studentsbefore making this strategic decision about theirfuture.
Can you put it on the scales, please? <a href=" http://www.ttr-codnor.co.uk/ponatinib-ll.html ">ponatinib price uk</a> Both options should be explored thoroughly by international studentsbefore making this strategic decision about theirfuture.
The manager <a href=" http://tender-care.co.uk/buy-adipessum ">semtex grenade real life</a> Paying only $9 an hour in New York City or the oil-crazed economy of North Dakota would not attract any workers, he said.
The manager <a href=" http://tender-care.co.uk/buy-adipessum ">semtex grenade real life</a> Paying only $9 an hour in New York City or the oil-crazed economy of North Dakota would not attract any workers, he said.