//async void sendMessage(string gstrType, Vector3 positionChange, Quaternion rotationChange, float scaleChange) { GstrMessage gstr = new GstrMessage(); gstr.name = objName; gstr.gstrType = gstrType; gstr.posChange = positionChange; gstr.rotChange = rotationChange; gstr.scaleChange = scaleChange; //transfer to holo axis //gstr.pos = new Vector3(gstr.pos.x, gstr.pos.z, gstr.pos.y); string message = JsonUtility.ToJson(gstr); //await UDPCtrl.SendMessage(message); }
// Update is called once per frame void Update() { if (Vuforia.DefaultTrackableEventHandler.findMarker && UDPController.msgReceived) // { var headPosition = Camera.main.transform.position; var gazeDirection = Camera.main.transform.forward; //RaycastHit hitInfo; //if (Physics.Raycast(headPosition, gazeDirection, out hitInfo)) //{ gstrMessage = JsonUtility.FromJson <GstrMessage>(UDPController.message); gstrType = gstrMessage.gstrType; if (gstrType == "dragging") { positionChange = gstrMessage.posChange; Box_Transform.position = positionOrigin + positionChange; Debug.Log("dragging to " + positionChange); } else if (gstrType == "rotating") { rotChange = gstrMessage.rotChange; Box_Transform.localRotation = rotOrigin * rotChange; //Box_Transform.Rotate(rotChange.x, rotChange.y, rotChange.z, Space.World); Debug.Log("rotation change:" + rotChange); } else if (gstrType == "pinching") { scaleChange = gstrMessage.scaleChange; Box_Transform.localScale = new Vector3(scaleOrigin.x * scaleChange, scaleOrigin.y * scaleChange, scaleOrigin.z * scaleChange); //var finalScale = Mathf.Clamp(scaleOrigin * scaleChange, minScale, maxScale); //Box_Transform.localScale = new Vector3(finalScale, finalScale, finalScale); } UDPController.msgReceived = false; //} } }