FOVE0向けのプログラムをUnityを使って作成しています。
その際にカメラを設定しておき、そこからHMDに接続してVR空間に映し出すといった感じだと思います。
そのなかでいろんな空間を見ることができるのがVR、HMDの面白さだと思うのですが、自分が作ろうとしているプログラムは画面を固定したいのです。なので首を動かしても同じ映像が流れるようなプログラムを作りたい!!
FOVE0
このような画面をHMDで首を動かしてもこの状態になるようにしたいです!
現在のカメラはFOVE向けの仕様になっています。
2Dで作れば簡単にできると思うのですが、それを3Dで行いたいのです。
是非教えていただければと思います。
CameraControllerの中身は
using UnityEngine;
using UnityEngine.VR;
using System.Collections;
public class CameraController : MonoBehaviour
{
void Update() { // TODO: ここで固定したい位置があれば指定しておく Vector3 basePos = Vector3.zero; Quaternion baseRot = Quaternion.identity; // VR.InputTracking から hmd の位置を取得 Vector3 trackingPos = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.CenterEye); Quaternion trackingRot = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.CenterEye); //カメラの角度と反対方向へ傾ける //transform.rotation = transform.rotation * Quaternion.Inverse( //ローカル回転をワールド回転にしている //transform.rotation * UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.CenterEye) //); //transform.rotation = Quaternion.identity; // CameraController 自体のrotationを位置に反映 //trackingPos = transform.rotation * trackingPos; transform.localRotation = baseRot * trackingRot; // 固定したい位置から hmd の位置を // 差し引いて実質 hmd の移動を無効化する transform.localPosition = basePos - trackingPos; //transform.localPosition = Vector3.zero; //transform.localRotation = Quaternion.identity; //transform.localScale = Vector3.one; }
}
これです。
よろしくお願いします。
回答3件
あなたの回答
tips
プレビュー