//private bool enterTrigger, exitTrigger; /// <summary> /// 消息处理 /// </summary> /// <param name="_data"></param> public void MessageManage(string _data) { if (_data != "") { dataTest = _data; string[] strs = dataTest.Split(ValueSheet.sliceStr); for (int i = 0; i < strs.Length; i++) { try { if (i == 0) { CamRotation.x = UtilityFunction.Mapping(float.Parse(strs[i]), -1, 1, -30, 30); } if (i == 1) { CamRotation.y = 0; /*UtilityFunction.Mapping(float.Parse(strs[i]),-1,1,-30,30);*/ } if (i == 2) { CamRotation.z = UtilityFunction.Mapping(float.Parse(strs[i]), -1, 1, 5, -5); } if (i == 3) { ValueSheet.EnterTrigger = Convert.ToBoolean(int.Parse(strs[i])); } if (i == 4) { ValueSheet.ExitTrigger = Convert.ToBoolean(int.Parse(strs[i])); } Debug.Log("GET DATA"); } catch (Exception) { dataTest = "data format wrong: x y z 1/0 1/0" + "\n" + "current udpData: " + _data.ToString(); } } float y = UtilityFunction.Mapping(CamRotation.z, -5, 5, 30, -30); CamRotation = new Vector3(CamRotation.x, y, CamRotation.z); ValueSheet.CamRotation = CamRotation; Debug.Log(CamRotation); } }
//IEnumerator Sent() { // udp_Send(_sSend, m_ip, ValueSheet.m_TargetPort); // yield return new WaitForSeconds(25 / 1000); // StartCoroutine(Sent()); //} string CreateMessage() { string splitChar = "%"; string x = UtilityFunction.Mapping(ValueSheet.CamRotation.x, ValueSheet.Cam_X_RotMinium, ValueSheet.Cam_X_RotMaxium, -1, 1).ToString("0.000"); string y = UtilityFunction.Mapping(ValueSheet.CamRotation.y, ValueSheet.Cam_Y_RotMinium, ValueSheet.Cam_Y_RotMaxium, -1, 1).ToString("0.000"); string z = UtilityFunction.Mapping(ValueSheet.CamRotation.z, ValueSheet.Cam_Z_RotMinium, ValueSheet.Cam_Z_RotMaxium, -1, 1).ToString("0.000"); string str = x + splitChar + y + splitChar + z; return(str); }
void GenerateSlot() { for (int i = 0; i < DisplaySlotNum + 2; i++) { float xPos = UtilityFunction.Mapping(i, 0, DisplaySlotNum + 2 - 1, -800f, 800f); float scale = Mathf.Sin(Mathf.Deg2Rad * UtilityFunction.Mapping(i, 0, DisplaySlotNum + 2 - 1, 0, 180)); slotHolder.Add(new SlotHolder(new Vector3(xPos, 0, 0), new Vector3(scale, scale, scale))); } int value = 0; foreach (var item in VideoFrameNImages) { item.SetLocation(slotHolder[value].SlotPos, 0); item.SetScale(slotHolder[value].SlotScale, 0); value++; } }
void JoyStickMovement(ref Vector3 cameraRotation) { float zAxis = -Input.GetAxis("Mouse X"); float xAxis = Input.GetAxis("Mouse Y"); #region value filter //--z--filter if (tempzAxis == 0 && zAxis == 0) { currentZAxis = 0; } else if (zAxis == 0 && tempzAxis != 0) { currentZAxis = Mathf.Clamp(tempzAxis, -1.5f, 1.5f); } else if (zAxis != 0 && tempzAxis != 0) { currentZAxis = Mathf.Clamp(zAxis, -1.5f, 1.5f); } //----X---filter if (tempxAxis == 0 && xAxis == 0) { currentXAxis = 0; } else if (xAxis == 0 && tempxAxis != 0) { currentXAxis = Mathf.Clamp(tempxAxis, -1.5f, 1.5f); } else if (xAxis != 0 && tempxAxis != 0) { currentXAxis = Mathf.Clamp(xAxis, -1.5f, 1.5f); } #endregion float cameraZ = cameraRotation.z; float cameraX = cameraRotation.x; float cameraY = cameraRotation.y; //Debug.Log(cameraZ.ToString()); float z = UtilityFunction.Mapping(currentZAxis, -1.5f, 1.5f, ValueSheet.Cam_Z_RotMinium, ValueSheet.Cam_Z_RotMaxium); float x = UtilityFunction.Mapping(currentXAxis, -1.5f, 1.5f, ValueSheet.Cam_X_RotMinium, ValueSheet.Cam_X_RotMaxium); float y = UtilityFunction.Mapping(z, ValueSheet.Cam_Z_RotMinium, ValueSheet.Cam_Z_RotMaxium, ValueSheet.Cam_Y_RotMaxium, ValueSheet.Cam_Y_RotMinium); cameraZ = cameraZ + (z - cameraZ) * ValueSheet.EaseingValue; cameraX = cameraX + (x - cameraX) * ValueSheet.EaseingValue; cameraY = cameraY + (y - cameraY) * ValueSheet.EaseingValue; cameraRotation = new Vector3(cameraX, cameraY, cameraZ); CamTransZ.localRotation = Quaternion.Euler(new Vector3(0, 0, cameraRotation.z)); CamX.localRotation = Quaternion.Euler(new Vector3(cameraRotation.x, 0, 0)); CamY.localRotation = Quaternion.Euler(new Vector3(0, cameraRotation.y, 0)); tempzAxis = zAxis; tempxAxis = xAxis; }