|
|
@@ -259,6 +259,8 @@ public class InfraredDemo : JCUnityLib.ViewBase
|
|
|
public static bool running { get => infraredCameraHelper != null; }
|
|
|
private bool _inited;
|
|
|
|
|
|
+ Camera leftCamera = null;
|
|
|
+ Camera rightCamera = null;
|
|
|
|
|
|
#region 参数控制
|
|
|
|
|
|
@@ -660,49 +662,43 @@ public class InfraredDemo : JCUnityLib.ViewBase
|
|
|
if (SB_EventSystem.ins) SB_EventSystem.ins.MoveSimulateMouseByInfrared(point);
|
|
|
//移动目标游戏
|
|
|
if (GeneratingTarget.gm != null) GeneratingTarget.gm.shootingEvent.OnPositionUpdate(point);
|
|
|
+
|
|
|
+ ShowUICrosshairs(cameraLocation, 0);
|
|
|
};
|
|
|
+
|
|
|
//双点情况下更新
|
|
|
infraredCameraHelper.OnPositionUpdate2 += (Vector2[] points, Vector2[] cameraLocations) =>
|
|
|
{
|
|
|
- string _posText = "";
|
|
|
- // HideUICrosshairs(0);
|
|
|
- // HideUICrosshairs(1);
|
|
|
+
|
|
|
+ // 获取左右相机
|
|
|
+ if (leftCamera == null) leftCamera = GameObject.Find("BowCameraFixedFirst")?.GetComponent<Camera>();
|
|
|
+ if (rightCamera == null) rightCamera = GameObject.Find("BowCameraFixedSecond")?.GetComponent<Camera>();
|
|
|
float halfScreenWidth = Screen.width / 2f; // 假设为全屏宽度的一半
|
|
|
for (int i = 0; i < points.Length; i++)
|
|
|
{
|
|
|
Vector2 point = points[i];
|
|
|
// 判断是否为右屏并调整坐标
|
|
|
- if (i == 1)
|
|
|
- {
|
|
|
- point.x -= halfScreenWidth; // 同步到右屏坐标系
|
|
|
- }
|
|
|
+ //if (i == 1)
|
|
|
+ //{
|
|
|
+ // point.x -= halfScreenWidth; // 同步到右屏坐标系
|
|
|
+ //}
|
|
|
|
|
|
- Ray ray = Camera.main.ScreenPointToRay(point);
|
|
|
- Vector3 rayEndPoint = ray.GetPoint(200);
|
|
|
- Quaternion quat = Quaternion.LookRotation(rayEndPoint - Camera.main.transform.position);
|
|
|
- if (i == 1)
|
|
|
+ if (i == 0 && leftCamera != null)
|
|
|
{
|
|
|
+ Ray ray1 = leftCamera.ScreenPointToRay(point);
|
|
|
+ Vector3 rayEndPoint1 = ray1.GetPoint(200);
|
|
|
+ Quaternion quat = Quaternion.LookRotation(rayEndPoint1 - ray1.origin);
|
|
|
if (CameraToLook.ins != null) CameraToLook.ins.localRotation = quat;
|
|
|
-
|
|
|
- // ShowUICrosshairs(cameraLocations[0], 0);
|
|
|
- // ShowGameUICrosshairs(points[0], 0);
|
|
|
- _posText += "红0:" + points[0].ToString("F2");
|
|
|
-
|
|
|
+ ShowUICrosshairs(cameraLocations[0], 0);
|
|
|
}
|
|
|
- if (i == 0) //大点算2p
|
|
|
+ if (i == 1 && rightCamera != null) //大点算2p
|
|
|
{
|
|
|
- if (CameraToLookNew.ins != null)
|
|
|
- {
|
|
|
- Transform m_controlObj = CameraToLookNew.ins.transform;
|
|
|
- m_controlObj.localRotation = quat;
|
|
|
- }
|
|
|
-
|
|
|
- //ShowUICrosshairs(cameraLocations[1], 1);
|
|
|
- // ShowGameUICrosshairs(points[1], 1);
|
|
|
- _posText += "\n";
|
|
|
- _posText += "黄1:" + points[1].ToString("F2");
|
|
|
+ Ray ray2 = rightCamera.ScreenPointToRay(point);
|
|
|
+ Vector3 rayEndPoint2 = ray2.GetPoint(200);
|
|
|
+ Quaternion quat = Quaternion.LookRotation(rayEndPoint2 - ray2.origin);
|
|
|
+ if (CameraToLookNew.ins != null) CameraToLookNew.ins.localRotation2P = quat;
|
|
|
+ ShowUICrosshairs(cameraLocations[1], 1);
|
|
|
}
|
|
|
- // if (PosInfo) PosInfo.text = _posText;
|
|
|
}
|
|
|
|
|
|
};
|
|
|
@@ -955,25 +951,25 @@ public class InfraredDemo : JCUnityLib.ViewBase
|
|
|
if (ScreenLocate.Main)
|
|
|
{
|
|
|
var _sl = ScreenLocate.Main;
|
|
|
- var buffer = _sl.infraredSpotBuffer;
|
|
|
- if (buffer != null)
|
|
|
- {
|
|
|
- for (int i = 0; i < buffer.Length; i++)
|
|
|
- {
|
|
|
- if (buffer[i].CameraLocation != null)
|
|
|
- {
|
|
|
- //添加一个偏移量,使得最后输出的准心是指向正中心
|
|
|
- Vector2 newPoint2 = _sl.GetOffsetCameraLocation(buffer[i].CameraLocation.Value);
|
|
|
- // 检测到光点
|
|
|
- var pos = newPoint2.pixelToLocalPosition_AnchorCenter(_sl.mUVCCameraInfo.Size, _cameraRender.rectTransform.rect);
|
|
|
- _crosshairsInCamera[i].gameObject.SetActive(true);
|
|
|
- _crosshairsInCamera[i].anchoredPosition = pos;
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- _crosshairsInCamera[i].gameObject.SetActive(false);
|
|
|
- }
|
|
|
- }
|
|
|
+ //var buffer = _sl.infraredSpotBuffer;
|
|
|
+ //if (buffer != null)
|
|
|
+ //{
|
|
|
+ // for (int i = 0; i < buffer.Length; i++)
|
|
|
+ // {
|
|
|
+ // if (buffer[i].CameraLocation != null)
|
|
|
+ // {
|
|
|
+ // //添加一个偏移量,使得最后输出的准心是指向正中心
|
|
|
+ // Vector2 newPoint2 = _sl.GetOffsetCameraLocation(buffer[i].CameraLocation.Value);
|
|
|
+ // // 检测到光点
|
|
|
+ // var pos = newPoint2.pixelToLocalPosition_AnchorCenter(_sl.mUVCCameraInfo.Size, _cameraRender.rectTransform.rect);
|
|
|
+ // _crosshairsInCamera[i].gameObject.SetActive(true);
|
|
|
+ // _crosshairsInCamera[i].anchoredPosition = pos;
|
|
|
+
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // _crosshairsInCamera[i].gameObject.SetActive(false);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
//渲染固定摄像机分辨率
|
|
|
SetCalibrationFixedText(_sl.mUVCCameraInfo.CurrentCalibrationResolution);
|
|
|
//渲染摄像机大小
|
|
|
@@ -983,7 +979,31 @@ public class InfraredDemo : JCUnityLib.ViewBase
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 更新屏幕下的十字准心位置
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="value"></param>
|
|
|
+ void ShowUICrosshairs(Vector2 newPoint2, int index)
|
|
|
+ {
|
|
|
+ ////获取一个偏移量,使得最后输出的准心是指向正中心
|
|
|
+ //Vector2 newPoint2 = value - ICHelper.GetCenterOffset(value, "CameraLocation");
|
|
|
+ // 检测到光点
|
|
|
+ var pos = newPoint2.pixelToLocalPosition_AnchorCenter(infraredCameraHelper.GetUVCCameraInfo().Size, _cameraRender.rectTransform.rect);
|
|
|
+ //红色为最大值则按顺序赋值,反之最小
|
|
|
+ int curIndex = index;
|
|
|
+ //if (bIdentifyRed)
|
|
|
+ //{
|
|
|
+ // curIndex = index;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // curIndex = 1 - index;
|
|
|
+ //}
|
|
|
+ _crosshairsInCamera[curIndex].gameObject.SetActive(true);
|
|
|
+ _crosshairsInCamera[curIndex].anchoredPosition = pos;
|
|
|
+
|
|
|
|
|
|
+ }
|
|
|
bool showPoints = false;
|
|
|
public void SetLocatePointsToCameraRender(List<Vector2> points, float w, float h)
|
|
|
{
|