public bool ComputeIntersection(Vector3 source, Vector3 direction, ref IntersectionResults results) { var overlay = OpenVR.Overlay; if (overlay == null) { return(false); } var input = new VROverlayIntersectionParams_t(); input.eOrigin = SteamVR_Render.instance.trackingSpace; input.vSource.v0 = source.x; input.vSource.v1 = source.y; input.vSource.v2 = -source.z; input.vDirection.v0 = direction.x; input.vDirection.v1 = direction.y; input.vDirection.v2 = -direction.z; var output = new VROverlayIntersectionResults_t(); if (!overlay.ComputeOverlayIntersection(handle, ref input, ref output)) { return(false); } results.point = new Vector3(output.vPoint.v0, output.vPoint.v1, -output.vPoint.v2); results.normal = new Vector3(output.vNormal.v0, output.vNormal.v1, -output.vNormal.v2); results.UVs = new Vector2(output.vUVs.v0, output.vUVs.v1); results.distance = output.fDistance; return(true); }
//オーバーレイと交点を持つかチェック private bool ComputeOverlayIntersection(Vector3 pos, Vector3 rotvect, ref VROverlayIntersectionResults_t results) { #pragma warning disable 0219 string Tag = "[" + this.GetType().Name + ":" + System.Reflection.MethodBase.GetCurrentMethod(); //クラス名とメソッド名を自動取得 #pragma warning restore 0219 //レイ照射情報 VROverlayIntersectionParams_t param = new VROverlayIntersectionParams_t(); //レイ発射元位置 param.vSource = new HmdVector3_t { v0 = pos.x, v1 = pos.y, v2 = -pos.z //右手系 to 左手系 }; //レイ発射単位方向ベクトル param.vDirection = new HmdVector3_t { v0 = rotvect.x, v1 = rotvect.y, v2 = -rotvect.z //右手系 to 左手系 }; //ルーム空間座標系で照射 param.eOrigin = ETrackingUniverseOrigin.TrackingUniverseStanding; //Overlayと交差していればtrue、していなければfalseで、詳細情報がresultsに入る return(overlay.ComputeOverlayIntersection(overlayHandle, ref param, ref results)); }
public bool ComputeIntersection(Vector3 source, Vector3 direction, ref SteamVR_Overlay.IntersectionResults results) { CVROverlay overlay = OpenVR.Overlay; if (overlay == null) { return(false); } VROverlayIntersectionParams_t vroverlayIntersectionParams_t = default(VROverlayIntersectionParams_t); vroverlayIntersectionParams_t.eOrigin = SteamVR_Render.instance.trackingSpace; vroverlayIntersectionParams_t.vSource.v0 = source.x; vroverlayIntersectionParams_t.vSource.v1 = source.y; vroverlayIntersectionParams_t.vSource.v2 = -source.z; vroverlayIntersectionParams_t.vDirection.v0 = direction.x; vroverlayIntersectionParams_t.vDirection.v1 = direction.y; vroverlayIntersectionParams_t.vDirection.v2 = -direction.z; VROverlayIntersectionResults_t vroverlayIntersectionResults_t = default(VROverlayIntersectionResults_t); if (!overlay.ComputeOverlayIntersection(this.handle, ref vroverlayIntersectionParams_t, ref vroverlayIntersectionResults_t)) { return(false); } results.point = new Vector3(vroverlayIntersectionResults_t.vPoint.v0, vroverlayIntersectionResults_t.vPoint.v1, -vroverlayIntersectionResults_t.vPoint.v2); results.normal = new Vector3(vroverlayIntersectionResults_t.vNormal.v0, vroverlayIntersectionResults_t.vNormal.v1, -vroverlayIntersectionResults_t.vNormal.v2); results.UVs = new Vector2(vroverlayIntersectionResults_t.vUVs.v0, vroverlayIntersectionResults_t.vUVs.v1); results.distance = vroverlayIntersectionResults_t.fDistance; return(true); }
public static bool ComputeIntersection(ulong handle, Vector3 source, Vector3 direction, ETrackingUniverseOrigin trackingUniverseOrigin, ref IntersectionResults results) { var input = new VROverlayIntersectionParams_t { eOrigin = trackingUniverseOrigin, vSource = { v0 = source.x, v1 = source.y, v2 = -source.z }, vDirection = { v0 = direction.x, v1 = direction.y, v2 = -direction.z } }; var output = new VROverlayIntersectionResults_t(); if (!OpenVR.Overlay.ComputeOverlayIntersection(handle, ref input, ref output)) { return(false); } results.point = new Vector3(output.vPoint.v0, output.vPoint.v1, -output.vPoint.v2); results.normal = new Vector3(output.vNormal.v0, output.vNormal.v1, -output.vNormal.v2); results.UVs = new Vector2(output.vUVs.v0, output.vUVs.v1); results.distance = output.fDistance; return(true); }
/// <summary> /// Compute a given Ray and determine if it hit an Overlay /// </summary> /// <param name="source"></param> /// <param name="direction"></param> /// <param name="results"></param> /// <returns></returns> private bool ComputeIntersection(HOTK_OverlayBase hotkOverlay, Vector3 source, Vector3 direction, ref SteamVR_Overlay.IntersectionResults results) { var overlay = OpenVR.Overlay; if (overlay == null) { return(false); } var input = new VROverlayIntersectionParams_t { eOrigin = SteamVR_Render.instance.trackingSpace, vSource = { v0 = source.x, v1 = source.y, v2 = -source.z }, vDirection = { v0 = direction.x, v1 = direction.y, v2 = -direction.z } }; var output = new VROverlayIntersectionResults_t(); if (!overlay.ComputeOverlayIntersection(hotkOverlay.Handle, ref input, ref output)) { return(false); } results.point = new Vector3(output.vPoint.v0, output.vPoint.v1, -output.vPoint.v2); results.normal = new Vector3(output.vNormal.v0, output.vNormal.v1, -output.vNormal.v2); results.UVs = new Vector2(output.vUVs.v0, output.vUVs.v1); results.distance = output.fDistance; return(true); }
public bool ComputeIntersection(Vector3 source, Vector3 direction, ref IntersectionResults results) { var vr = SteamVR.instance; var input = new VROverlayIntersectionParams_t(); input.eOrigin = SteamVR_Render.instance.trackingSpace; input.vSource.v = new float[] { source.x, source.y, -source.z }; input.vDirection.v = new float[] { direction.x, direction.y, -direction.z }; var output = new VROverlayIntersectionResults_t(); if (!vr.overlay.ComputeOverlayIntersection(handle, ref input, ref output)) { return(false); } results.point = new Vector3(output.vPoint.v[0], output.vPoint.v[1], -output.vPoint.v[2]); results.normal = new Vector3(output.vNormal.v[0], output.vNormal.v[1], -output.vNormal.v[2]); results.UVs = new Vector2(output.vUVs.v[0], output.vUVs.v[1]); results.distance = output.fDistance; return(true); }
public abstract bool ComputeOverlayIntersection(ulong ulOverlayHandle,ref VROverlayIntersectionParams_t pParams,ref VROverlayIntersectionResults_t pResults);
public override bool ComputeOverlayIntersection(ulong ulOverlayHandle,ref VROverlayIntersectionParams_t pParams,ref VROverlayIntersectionResults_t pResults) { CheckIfUsable(); bool result = VRNativeEntrypoints.VR_IVROverlay_ComputeOverlayIntersection(m_pVROverlay,ulOverlayHandle,ref pParams,ref pResults); return result; }