public void personEntered(OpenTSPSPerson person) { // Debug.Log (" person entered with ID " + person.id); GameObject personObject = (GameObject)Instantiate(personMarker, positionForPerson(person), Quaternion.identity); personObject.GetComponentInChildren <Renderer> ().material = materials [person.id % materials.Length]; peopleCubes [person.id] = personObject; }
//maps the OpenTSPS coordinate system into one that matches the size of the boundingPlane private Vector3 positionForPerson(OpenTSPSPerson person) { //Bounds meshBounds = boundingPlane.GetComponent<MeshFilter> ().sharedMesh.bounds; Bounds meshBounds = boundingPlane.GetComponent <MeshRenderer> ().bounds; Vector3 offset = meshBounds.center; Vector3 pos = new Vector3((float)(.5f - person.centroidX) * meshBounds.size.x, 0.25f, (float)(person.centroidY - .5f) * meshBounds.size.z); return(pos + offset); }
public void personWillLeave(OpenTSPSPerson person) { // Debug.Log ("Person leaving with ID " + person.id); if (peopleCubes.ContainsKey(person.id)) { GameObject cubeToRemove = peopleCubes [person.id]; peopleCubes.Remove(person.id); //delete it from the scene Destroy(cubeToRemove); } }
public void personMoved(OpenTSPSPerson person) { // Debug.Log ("Person updated with ID " + person.id); if (peopleCubes.ContainsKey(person.id)) { GameObject cubeToMove = peopleCubes [person.id]; if (m_useSmoothing) { cubeToMove.transform.position = Vector3.Lerp(cubeToMove.transform.position, positionForPerson(person), Time.deltaTime * m_damping); } else { cubeToMove.transform.position = positionForPerson(person); } } }
public void personUpdated(OpenTSPSPerson person) { //don't need to handle the Updated method any differently for this example personMoved(person); }