环境:unity2017.4.11,插件版本:zCore-5.0.0.unitypackage,
将插件导入统一后,将zSpace /资源/ zCore拖到场景中,就可以进行开发了。
一:将主摄像机拖入到zCore中绑定,然后双击zCore过去会看到,几个框框,其中有个视图的框,将模型放到框里,在zSpace机器上才能正常显示。
二:摄像机上不能有滤镜,注意摄像机的渲染,这里如果有警告,消除警告,否则场景里模型会有黑影
三:在Playersetting里,将other Setting下的Color Space 改为Gamma,否则不会有谍影效果
将XR Settings里的Virtual Reality Supported勾上,并选择Stereo Display(non head-mounted),删除其他选项
四:有三个事件,触控笔移动(会一直触发),按键被按下(中间键是0,左键是2,右键是1),按键被释放
_zCore.TargetMove + = HandleMove;
_zCore.TargetButtonPress + = HandleButtonPress;
_zCore.TargetButtonRelease + = HandleButtonRelease;
用触控笔发射线来进行与物体交互,对于UI,可以启用鼠标来点击,或者去重写UI事件,让射线检测到也可以点击(可以参考VRTK插件)或者用3D模型来做UI
贴个脚本(由于时间紧网上找的脚本然后修改就用了,所以有点乱)
使用com.ootii.Messages;
使用系统;
使用System.Collections;
使用System.Collections.Generic;
使用UnityEngine;
使用zSpace.Core;
公共类RayGrapGameObject:MonoBehaviour {
private GameObject _stylusBeamObject = null;
public LineRenderer _stylusBeamRenderer = null;
// private StylusState RayGrapGameObject.Ra_stylusState = StylusState.Idle;
private StylusState _stylusState = StylusState.Idle;
//用于初始化(初始化)
private ZCore _zCore = null;
private bool _wasButtonPressed = false;
private static readonly float DEFAULT_STYLUS_BEAM_WIDTH = 0.002f;
private static readonly float DEFAULT_STYLUS_BEAM_LENGTH = 2f;
private float _stylusBeamLength = DEFAULT_STYLUS_BEAM_LENGTH;
private GameObject _grabObject = null;
private Vector3 _initialGrabOffset = Vector3.zero;
private Quaternion _initialGrabRotation = Quaternion.identity;
private float _initialGrabDistance = 0.0f;
private Transform mainCameraTrans;
//4.299965 - 0.891 //4.299965 - 2.044
private float D_Vakue = 3.408965f; //相机与TVM物体的高度的差值;
private float D_Vakue_wolin = 2.255965f; //相机与wolin物体的高度的差值;
private bool isCanMove = true; //是否可以移动镜头
public Transform volin_1;
公共变革索芳;
公共改造玄转;
公共BoxCollider TVMCollider;
公共转型TVM;
private void Awake(){
//Debuger.EnableOnScreen (true);
_zCore = GameObject.FindObjectOfType <ZCore>();
if(_zCore == null){
Debug.LogError(“无法找到参考”);
this.enabled = false;
返回;
}
_zCore.TargetMove + = HandleMove;
_zCore.TargetButtonPress + = HandleButtonPress;
_zCore.TargetButtonRelease + = HandleButtonRelease;
mainCameraTrans = Camera.main.transform;
MessageDispatcher.AddListener(“ON_SEND_SETUP_0_MSG”,OnRecv);
MessageDispatcher.AddListener(“ON_SEND_SETUP_2_MSG”,OnRecv2);
MessageDispatcher.AddListener(“ON_SEN