private BSONArray decodeArray() { BSONObject obj = decodeDocument(); int i = 0; BSONArray array = new BSONArray(); while (obj.ContainsKey(Convert.ToString(i))) { array.Add(obj [Convert.ToString(i)]); i += 1; } return(array); }
/// Transforms a position in world space to Bellows polar coordinates public BSONArray WorldToBellowsPosition(Vector3 vec) { // Transform point to be relative to whatever this Sound Master is attached to // (usually the camera) vec = transform.InverseTransformPoint(vec); // X value in bellows is simply polar direction float bellowsX = Mathf.Atan2(vec.z, vec.x) / (Mathf.PI * 2); // Y value in bellows is just the height float bellowsY = vec.y; // Z value in bellows is the distance to the sound, ignoring height float bellowsZ = Mathf.Sqrt( (vec.x * vec.x) + (vec.z * vec.z) ); BSONArray a = new BSONArray(); a.Add (bellowsX); a.Add (bellowsY); a.Add (bellowsZ); return a; }
private BSONArray decodeArray() { BSONObject obj = decodeDocument (); int i = 0; BSONArray array = new BSONArray (); while(obj.ContainsKey(Convert.ToString(i))) { array.Add (obj [Convert.ToString(i)]); i += 1; } return array; }