今日 實驗室體驗
學長介紹 VR 的 Vive 手把 簡單的trigger 事件撰寫
在 HTC Vive 的兩隻手把中
他總共提供了
GetPress() // 按著就持續進行累加
GetPressDown() // 只偵測按下去一次 , 做一次 "加一"
GetPressUp() //偵測放開時候
360範圍 抓 人體的頭戴裝置 及 手把目前位置
using UnityEngine;
using System.Collections;
public class ex : MonoBehaviour {
public SteamVR_TrackedObject leftController;
public GameObject controllerInfo;
// Use this for initialization
void Start () {
}
int tmp = 0;
// Update is called once per frame
void Update () {
var device = SteamVR_Controller.Input ((int)leftController.index);
//if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger)) {
// print ("123");
//}
if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger)) {
//print ("123");
tmp += 1;
//print ("triggerd time:"+tmp);
print ("triggerd");
}
}
}
手部範例(單純針對左手)
https://github.com/dryjoker/myHTC_Vive_project_exercise/blob/master/myScript/VRLeftController.cs
效果顯示
先拉取一個 GameObject 物件
再Add Component 修改為 Text Mesh 屬性
====================================================================
下半場:
一個專案的載入與體驗
一個 HTC Vive 的 tutorial
這裡我們要載入一個老師已經幫同學預先準備好的
使用 360 theta 來 拍出來的 照片
https://drive.google.com/drive/folders/0ByYbu0zjxrp1YUo1eENtc1FITXM
Step1.拖拉 巨圖 到 Unity Assets Folder 中
Step2. 點選 圖片
去 右側 Inspector 設置 Texture Type 改為 CubeMap
記得 按下 Apply
Step3.
新建材質球
設置成 天空包 性質
選用 CubeMap
Step4.拖拉剛剛的 CubeMap 圖片 放置在 Materiaal 球上
====================================================================
之後我們只要此 製作好的 天空包素材
添加至 Scene中 即可完成
Alt + mouse
或
按 滑鼠右鍵
可以調整 旋轉(視角)
沒有留言:
張貼留言