2017年3月15日 星期三

【03160135 吳亞芳】Week04






解壓縮老師給的Unity project[Pusheen World]



















打開Unity




















選擇[Pusheen World]project
















到FB 2017VR 社團找到老師給的雲端硬碟連結


















進入連結網址選則一張自己喜歡的360度照片並下載在電腦裡


















拖曳圖片進Unity橘色區域(匯入)















修改Texture為Cubemap天空包


















記得Apply套用更變




















在Image資料夾新增一材質
















更改Standard為Skybox→Cubemap















Select





















































-------------------------
前往205實作部分

熟悉控制器與頭罩

開啟Steam並登入
安裝Steam VR
























右上開啟VR模式後設定VR
照著紙片人的動作做






開啟Unity照著學長ppt實作

要先import SteamVR!



1.按下控制器能顯示Hello Trigger Press與Value:壓力(握力)值

程式碼:

using UnityEngine;
using System.Collections;

public class UseController : MonoBehaviour {

// Use this for initialization
void Start () {

}
public SteamVR_TrackedObject rightController;
float pressValue=0;

// Update is called once per frame
void Update () {

if (rightController == null)
return;
var device = SteamVR_Controller.Input ((int)rightController.index);
if (device.GetPressDown (SteamVR_Controller.ButtonMask.Trigger)) {
pressValue = device.GetAxis (Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger).x;
print ("Hello Trigger Press" + "Value:" + pressValue);

}
}
}


2.將控制器操作Trigger.Grip.TouchPad顯示與畫面

程式碼(左控制器):

using UnityEngine;
using System.Collections;

public class myLeftController : MonoBehaviour {
public SteamVR_TrackedObject leftController;
public GameObject controllerInfo;
bool isTriggerPress =false;
bool isTouchPadTouch =false;
bool isTouchPadPress =false;
bool isGripPress =false;
bool isManuPress =false;
Vector2 touchpadPosition=new Vector2();
float pressValue=0;

void Start () {

}

// Update is called once per frame
void Update () {
string infor="Left Controller Information : \n";
if (leftController == null)
return;
var device = SteamVR_Controller.Input ((int)leftController.index);
myTriggerDetect (device);
myTouchPadDetect (device);
myGripDetect (device);
myManuDetect (device);

infor += "Press Tridder : " + isTriggerPress + "\nTrigger Press Value : " + pressValue + "\nTouchpad Press : " + isTouchPadPress + "\nTouchpad touch : " + isTouchPadTouch + "\nTouchpad Position : " + touchpadPosition + "\nGrip Press : " + isGripPress + "\nManu Press : " + isManuPress;
controllerInfo.GetComponent<TextMesh> ().text = infor;

}
void myTriggerDetect(SteamVR_Controller.Device device)
{
if (device.GetPress (SteamVR_Controller.ButtonMask.Trigger)) {
pressValue = device.GetAxis (Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger).x;
isTriggerPress = true;
} else {
isTriggerPress = false;
pressValue = 0;
}
}
void myTouchPadDetect(SteamVR_Controller.Device device)
{
if (device.GetPress (SteamVR_Controller.ButtonMask.Touchpad)) {
isTouchPadPress = true;
} else {
isTouchPadPress = false;
}
if (device.GetTouch (SteamVR_Controller.ButtonMask.Touchpad)) {
isTouchPadPress = true;
touchpadPosition = device.GetAxis (Valve.VR.EVRButtonId.k_EButton_Axis0);
} else 
{
isTouchPadTouch = false;
touchpadPosition = new Vector2 (0, 0);
}
}
void myGripDetect(SteamVR_Controller.Device device)
{
if (device.GetPress (SteamVR_Controller.ButtonMask.Grip)) {
isGripPress = true;
} else {
isGripPress = false;
}
}
void myManuDetect(SteamVR_Controller.Device device)
{
if (device.GetPress (SteamVR_Controller.ButtonMask.ApplicationMenu)) {
isManuPress = true;
}
else{
isManuPress = false;
}
}
}










沒有留言:

張貼留言