void Start() { if (ht.ContainsKey(port)) { //Debug.Log("HoloClient Instance Found"); this.Instance = (HoloClient)ht[port]; } else { //HoloClient hc = new HoloClient(port); this.Instance = this.gameObject.AddComponent <HoloClient>(); this.Instance.Init(port, output_rate); ht[port] = this.Instance; //Debug.Log("HoloClient Instance " + this.Instance); } Transform hL = transform.FindChild("HoloCameraL"); Transform hR = transform.FindChild("HoloCameraR"); if (hL) { holoL = hL.gameObject.GetComponent <Camera>(); } if (hR) { holoR = hR.gameObject.GetComponent <Camera>(); } }
// Use this for initialization void Start() { this.Instance = this.gameObject.AddComponent <HoloClient>(); this.Instance.Init(port, output_rate); //from0toTable = new Quaternion(0.666f, -0.230f, 0.230f, 0.671f); //re_from0toTable = Quaternion.Inverse(from0toTable); calibratedCam = new GameObject("calibratedCam"); calibratedCam.transform.position = new Vector3(); calibratedCam.transform.rotation = new Quaternion(); calibratedCamChild = new GameObject("calibratedCamChild"); calibratedCamChild.transform.parent = calibratedCam.transform; tableParent = new GameObject("calibratedTableParent"); tableParent.transform.position = new Vector3(); tableParent.transform.rotation = new Quaternion(); tableChild = new GameObject("calibratedTableOrigin"); tableChild.transform.parent = tableParent.transform; storedTable = new GameObject("StoredTableRelativeToViveMeter"); storedTable.transform.parent = this.transform.parent.Find("ViveMeter"); Vector3 pos = new Vector3(-0.134f, -0.977f, -0.906f); //origin //pos = new Vector3(-0.284f, -0.967f, -1.01f);//point2 //pos = new Vector3(-0.347f,-0.787f,-1.046f);//point3 //pos = new Vector3(-0.346f, -0.966f, -0.933f);//point4 //pos = new Vector3(-0.545f, -0.962f, -0.676f);//point5 //Vector3 pos2 = this.rotateAroundAxis(pos, new Vector3(0, 0, 0), pointQuat); //Debug.Log("pos2 x: " + pos2.x + " y: " + pos2.y + " z: " + pos2.z); //Vector3 mid_pos = this.rotateAroundAxis(pos, new Vector3(0, 0, 0), re_from0toTable); //Vector3 final_pos = new Vector3(mid_pos.x, mid_pos.z, -mid_pos.y); ////this.transform.localPosition = final_pos; //this.transform.parent.Find("ViveMeter").localPosition = final_pos; //meter_position = final_pos; //Vector3 init_pos = new Vector3(0.134f, -0.977f, -0.906f); //Vector3 end_pos = new Vector3(0.6551008f, -0.9704683f, -0.6384149f); //meter_rot = Quaternion.FromToRotation(init_pos, end_pos); //this.transform.parent.Find("ViveMeter").localRotation = meter_rot; //Quaternion re_rot = new Quaternion(from0toTable.x, from0toTable.z, -from0toTable.y, from0toTable.w); //rot_calib = Quaternion.Inverse(meter_rot * re_rot); filePath = Path.Combine(Application.streamingAssetsPath, fileName); /* GIOVA*/ if (!ViveEmitter) { ViveEmitter = GameObject.Find("ViveEmitter"); } if (!ViveCASTTracker) { ViveCASTTracker = GameObject.Find("ViveTracker"); } if (!ViveHoloTracker) { ViveHoloTracker = GameObject.Find("HoloTracker"); } //if (!ViveCASTTrackerDebug) // ViveCASTTrackerDebug = GameObject.Find("ViveTrackerFromHolo"); if (!CASTOrigin) { CASTOrigin = GameObject.Find("Origin"); } camera_rot = new Quaternion(0, 0, 0, 1); //Debug.Log("HoloReceiver Started"); // this.enabled = false; }