Beispiel #1
0
	public PositionUpdate(NatNetRigidbody rb, Vector3 p, Quaternion r)
	{
		rigidbody = rb;
		position = p;
		rotation = r;
		frameTime = Time.time;
	}
	void natNetUpdateHandler(NatNetRigidbody rb)
	{
		if(objects.ContainsKey(rb.id))
		{
			objects[rb.id].transform.position = rb.position;
			objects[rb.id].transform.rotation = rb.rotation;
		}
		else
		{
			objects.Add(rb.id, Instantiate(prefab, rb.position, rb.rotation) as GameObject);
		}
	}
Beispiel #3
0
	public void processMessage(OscMessage m)
	{
		var rb = SimpleJSON.JSON.Parse(m.Values[0].ToString());
		Vector3 position = new Vector3(float.Parse(rb["position"][0]), float.Parse(rb["position"][1]),float.Parse(rb["position"][2]));
		Quaternion rotation = new Quaternion(float.Parse(rb["orientation"][0]),float.Parse(rb["orientation"][1]),float.Parse(rb["orientation"][2]),float.Parse(rb["orientation"][3]));
		int id = int.Parse(rb["id"]);
		bool found = false;
		
		foreach(NatNetRigidbody current in rigidbodies)
		{
			if(current.id == id)
			{
				current.Update(position, rotation);
				onNatNetUpdate(current);
				found = true;
				break;
			}
		}
		
		if (!found)
		{
			NatNetRigidbody r = new NatNetRigidbody(id, position, rotation);
			rigidbodies.Add(r);
			onNatNetUpdate(r);
		}
	}