public void processAvatarMessage(AvatarMessage av) { Sensors sensors = GameObject.Find("Main").GetComponent <Sensors>(); foreach (string s in av.calibrations) { string[] chunks = s.Split(';'); string id = chunks[0]; float px = float.Parse(chunks[1]); float py = float.Parse(chunks[2]); float pz = float.Parse(chunks[3]); float rx = float.Parse(chunks[4]); float ry = float.Parse(chunks[5]); float rz = float.Parse(chunks[6]); float rw = float.Parse(chunks[7]); GameObject cloudobj = new GameObject(id); cloudobj.transform.localPosition = new Vector3(px, py, pz); cloudobj.transform.localRotation = new Quaternion(rx, ry, rz, rw); cloudobj.transform.localScale = new Vector3(-1, 1, 1); cloudobj.AddComponent <PointCloudSimple>(); PointCloudSimple cloud = cloudobj.GetComponent <PointCloudSimple>(); _clouds.Add(id, cloud); _cloudGameObjects.Add(id, cloudobj); sensors.addSensor(id, new Vector3(px, py, pz), new Quaternion(rx, ry, rz, rw)); } Camera.main.GetComponent <MouseOrbitImproved>().target = _cloudGameObjects.First().Value.transform; }
public void processAvatarMessage(AvatarMessage av) { foreach (string s in av.calibrations) { string[] chunks = s.Split(';'); string id = chunks[0]; float px = float.Parse(chunks[1]); float py = float.Parse(chunks[2]); float pz = float.Parse(chunks[3]); float rx = float.Parse(chunks[4]); float ry = float.Parse(chunks[5]); float rz = float.Parse(chunks[6]); float rw = float.Parse(chunks[7]); Vector3 pi = new Vector3(px, py, pz); Quaternion ri = new Quaternion(rx, ry, rz, rw); GameObject cloudobj = new GameObject(id); cloudobj.transform.localPosition = Vector3.zero; cloudobj.transform.localRotation = Quaternion.identity; cloudobj.transform.localScale = new Vector3(-1, 1, 1); cloudobj.AddComponent <PointCloudSimple>(); PointCloudSimple cloud = cloudobj.GetComponent <PointCloudSimple>(); _clouds.Add(id, cloud); _cloudGameObjects.Add(id, cloudobj); // GameObject origin = GameObject.Find("RemoteOrigin"); cloudobj.transform.parent = origin.transform; cloudobj.transform.localPosition = pi; cloudobj.transform.localRotation = ri; } }
public Sensor(string sensorID, GameObject sensorGameObject) { bodies = new Dictionary<string, SensorBody> (); _active = true; SensorID = sensorID; lastBodiesMessage = null; _sensorGameObject = sensorGameObject; SensorGameObject.name = sensorID; center1 = new Vector3 (); center2 = new Vector3 (); up1 = new Vector3 (); up2 = new Vector3 (); _floorValues = new List<Vector3> (); _bestFitPlanePoints = new List<Vector3> (); _material = _chooseMaterial (); CommonUtils.changeGameObjectMaterial (_sensorGameObject, _material); GameObject cloudobj = new GameObject ("PointCloud"); cloudobj.transform.parent = sensorGameObject.transform; cloudobj.transform.localPosition = Vector3.zero; cloudobj.transform.localRotation = Quaternion.identity; cloudobj.transform.localScale = new Vector3 (-1, 1, 1); cloudobj.AddComponent<PointCloudSimple> (); lastCloud = cloudobj.GetComponent<PointCloudSimple> (); }
public override void OnInspectorGUI() { DrawDefaultInspector(); if (GUILayout.Button("Save Position")) { PointCloudSimple c = (PointCloudSimple)target; string lines = "posx=" + c.transform.position.x + "\r\nposy=" + c.transform.position.y + "\r\nposz= " + c.transform.position.z + "\r\nrotx=" + c.transform.rotation.eulerAngles.x + "\r\nroty= " + c.transform.rotation.eulerAngles.y + "\r\nrotz=" + c.transform.rotation.eulerAngles.z; // Write the string to a file. System.IO.StreamWriter file = new System.IO.StreamWriter(target.name + ".ini"); file.WriteLine(lines); file.Close(); } }