public void ReceiveCallback_RemoteSurface(IAsyncResult ar) { Byte[] receiveBytes = _udpClient_RemoteSurface.EndReceive(ar, ref _anyIP_RemoteSurface); string result = System.Text.Encoding.UTF8.GetString(receiveBytes); string[] trackermessage = result.Split(MessageSeparators.L0); result = trackermessage[0] + MessageSeparators.L0 + trackermessage[1]; Sensor[] sensors = _retrieveSensors(trackermessage[2]); foreach (Sensor s in sensors) { Debug.Log("_REMOTE_SENSOR______________________________________ " + s.id); } if (SurfaceMessage.isMessage(result)) { SurfaceRectangle s = new SurfaceRectangle(result); Debug.Log("SURFACE_________________________________________ " + s.ToString()); s.sensors = sensors; if (_main != null) { _main.setRemoteSurface(s); } if (_calibration != null) { _calibration.setRemoteSurface(s); } _udpClient_RemoteSurface.Close(); } else { _udpClient_RemoteSurface.BeginReceive(new AsyncCallback(this.ReceiveCallback_RemoteSurface), null); } }
void Update() { if (!_DoWeHaveASurface && mainScript.surfaceRectangle != null) { surfaceRect = mainScript.surfaceRectangle; _DoWeHaveASurface = true; _surfaceVertices = new List <GameObject>(); _screenCenter = new GameObject(); _screenCenter.name = "ScreenCenter"; Transform newTrans = _screenCenter.transform; newTrans.position = (surfaceRect.SurfaceBottomLeft + surfaceRect.SurfaceTopRight) * 0.5f; Vector3 upwards = (surfaceRect.SurfaceTopLeft - surfaceRect.SurfaceBottomLeft).normalized; Vector3 right = (surfaceRect.SurfaceTopRight - surfaceRect.SurfaceTopLeft).normalized; newTrans.rotation = Quaternion.LookRotation(Vector3.Cross(upwards, right), upwards); SurfaceCenter = newTrans; Debug.Log("We HAVE SURFACE"); _instantiateSphere(surfaceRect.SurfaceBottomLeft, "BL", SurfaceCenter); _instantiateSphere(surfaceRect.SurfaceBottomRight, "BR", SurfaceCenter); _instantiateSphere(surfaceRect.SurfaceTopLeft, "TL", SurfaceCenter); _instantiateSphere(surfaceRect.SurfaceTopRight, "TR", SurfaceCenter); } else if (_DoWeHaveASurface) { if (Input.GetKeyDown(KeyCode.Q)) { foreach (GameObject go in _surfaceVertices) { go.GetComponent <MeshRenderer>().enabled = !go.GetComponent <MeshRenderer>().enabled; } } } }
internal void setSurface(SurfaceRectangle surface) { if (_surface == null) { _surface = surface; } }
internal void create(Location location, SurfaceRectangle localSurface, SurfaceRectangle remoteSurfaceProxy, float length) { _handheldListener = new UDPHandheldListener(int.Parse(_properties.localSetupInfo.receiveHandheldPort), "negativespace"); _location = location; _localSurface = localSurface; _remoteSurfaceProxy = remoteSurfaceProxy; _negativeSpaceLength = length; _createNegativeSpaceMesh(); NegativeSpaceCenter = new GameObject("NegativeSpaceCenter"); NegativeSpaceCenter.transform.position = (_localSurface.SurfaceBottomLeft + _remoteSurfaceProxy.SurfaceTopRight) * 0.5f; NegativeSpaceCenter.transform.rotation = GameObject.Find("localScreenCenter").transform.rotation; _log.WriteLine(this, "Waiting for handheld at " + _properties.localSetupInfo.receiveHandheldPort); _log.WriteLine(this, "Negative Space Created for Location " + _location + " with length " + _negativeSpaceLength); _handCursor = new GameObject("HandCursor"); _handCursor.transform.position = Vector3.zero; _handCursor.transform.rotation = Quaternion.identity; _handCursor.transform.parent = _main.LocalOrigin.transform; _handCursor.AddComponent <NegativeSpaceCursor>(); _spaceCreated = true; }
void Update() { if (_surface != null) { gameObject.GetComponent <TrackerClient>().setSurface(_surface); _surface = null; } }
internal void receiveSurface(string stringToParse) { string[] s = stringToParse.Split(MessageSeparators.L1); string name = s[0]; Vector3 bl = convertRemoteStringToVector3(s[1]); Vector3 br = convertRemoteStringToVector3(s[2]); Vector3 tl = convertRemoteStringToVector3(s[3]); Vector3 tr = convertRemoteStringToVector3(s[4]); surfaceRectangle = new SurfaceRectangle(bl, br, tl, tr); }
public void set(SurfaceRectangle surface) { transform.localPosition = (surface.SurfaceBottomLeft + surface.SurfaceTopRight) / 2; transform.localRotation = surface.rotation; BL.transform.position = surface.SurfaceBottomLeft; BR.transform.position = surface.SurfaceBottomRight; TL.transform.position = surface.SurfaceTopLeft; TR.transform.position = surface.SurfaceTopRight; }
public void calibrate(SurfaceRectangle r) { // Position and Orientation Vector3 up = r.SurfaceTopLeft - r.SurfaceBottomLeft; Vector3 right = r.SurfaceTopRight - r.SurfaceTopLeft; Vector3 center = (r.SurfaceTopLeft + r.SurfaceBottomRight) * 0.5f; transform.rotation = Quaternion.LookRotation(Vector3.Cross(right, up), up); transform.position = center; width = (r.SurfaceTopRight - r.SurfaceTopLeft).magnitude; height = (r.SurfaceTopRight - r.SurfaceBottomRight).magnitude; // Camera Camera.main.orthographicSize = (r.SurfaceTopLeft - r.SurfaceBottomLeft).magnitude * 0.5f; }
public void ReceiveCallback_LocalSurface(IAsyncResult ar) { Byte[] receiveBytes = _udpClient_LocalSurface.EndReceive(ar, ref _anyIP_LocalSurface); string result = System.Text.Encoding.UTF8.GetString(receiveBytes); if (SurfaceMessage.isMessage(result)) { _surface = new SurfaceRectangle(result); Debug.Log(_surface.ToString()); _udpClient_LocalSurface.Close(); } else { _udpClient_LocalSurface.BeginReceive(new AsyncCallback(this.ReceiveCallback_LocalSurface), null); } }
public void ReceiveCallback_RemoteSurface(IAsyncResult ar) { Byte[] receiveBytes = _udpClient_RemoteSurface.EndReceive(ar, ref _anyIP_RemoteSurface); string result = System.Text.Encoding.UTF8.GetString(receiveBytes); string[] trackermessage = result.Split(MessageSeparators.L0); result = trackermessage[0] + MessageSeparators.L0 + trackermessage[1]; Sensor[] sensors = _retrieveSensors(trackermessage[2]); if (SurfaceMessage.isMessage(result)) { SurfaceRectangle s = new SurfaceRectangle(result); s.sensors = sensors; _main.setRemoteSurface(s); _udpClient_RemoteSurface.Close(); } else { _udpClient_RemoteSurface.BeginReceive(new AsyncCallback(this.ReceiveCallback_RemoteSurface), null); } }
public void Calibrate(SurfaceRectangle r) { // Position and Orientation Vector3 up = r.SurfaceTopLeft - r.SurfaceBottomLeft; Vector3 right = r.SurfaceTopRight - r.SurfaceTopLeft; Vector3 center = (r.SurfaceTopLeft + r.SurfaceBottomRight) * 0.5f; transform.rotation = Quaternion.LookRotation(Vector3.Cross(right, up), up); transform.position = center; width = (r.SurfaceTopRight - r.SurfaceTopLeft).magnitude; height = (r.SurfaceTopRight - r.SurfaceBottomRight).magnitude; // Camera Camera.main.orthographicSize = (r.SurfaceTopLeft - r.SurfaceBottomLeft).magnitude * 0.5f; // not only camera... EVERYTHING! float scale = (r.SurfaceTopLeft - r.SurfaceBottomLeft).magnitude * 0.5f; transform.localScale = new Vector3(scale, scale, scale); print("calibrei"); }
public void Calibrate(SurfaceRectangle r) { // Position and Orientation Vector3 up = r.SurfaceTopLeft - r.SurfaceBottomLeft; Vector3 right = r.SurfaceTopRight - r.SurfaceTopLeft; Vector3 center = (r.SurfaceTopLeft + r.SurfaceBottomRight) * 0.5f; transform.rotation = Quaternion.LookRotation(Vector3.Cross(right, up), up); transform.position = center; width = (r.SurfaceTopRight - r.SurfaceTopLeft).magnitude; height = (r.SurfaceTopRight - r.SurfaceBottomRight).magnitude; // Camera Camera.main.orthographicSize = (r.SurfaceTopLeft - r.SurfaceBottomLeft).magnitude * 0.5f; // not only camera... EVERYTHING! float scale = (r.SurfaceTopLeft - r.SurfaceBottomLeft).magnitude * 0.5f; transform.localScale = new Vector3(scale, scale, scale); print("calibrei"); // borders border1.localPosition = new Vector3(-width / scale / 2.0f, 0, 0); border2.localPosition = new Vector3(width / scale / 2.0f, 0, 0); border3.localPosition = new Vector3(0, -height / scale / 2.0f, 0); border4.localPosition = new Vector3(0, height / scale / 2.0f, 0); border1.localScale = new Vector3(height / scale - 0.01f, 0.01f, 0.01f); border2.localScale = new Vector3(height / scale - 0.01f, 0.01f, 0.01f); border3.localScale = new Vector3(width / scale - 0.01f, 0.01f, 0.01f); border4.localScale = new Vector3(width / scale - 0.01f, 0.01f, 0.01f); border1.LookAt(center, Vector3.Cross(up, right)); border2.LookAt(center, Vector3.Cross(up, right)); border3.LookAt(center, Vector3.Cross(up, right)); border4.LookAt(center, Vector3.Cross(up, right)); }
internal void create(Location location, SurfaceRectangle localSurface, SurfaceRectangle remoteSurfaceProxy, float length) { _handheldListener = new UDPHandheldListener(int.Parse(_properties.localSetupInfo.receiveHandheldPort)); Debug.Log(this.ToString() + ": Receiving Handheld data in " + _properties.localSetupInfo.receiveHandheldPort); _location = location; _localSurface = localSurface; _remoteSurfaceProxy = remoteSurfaceProxy; _negativeSpaceLength = length; //_createNegativeSpaceMesh(); _negativeSpaceWalls("bottomWall", _localSurface.SurfaceBottomLeft, _localSurface.SurfaceBottomRight, _remoteSurfaceProxy.SurfaceBottomRight, _remoteSurfaceProxy.SurfaceBottomLeft); _negativeSpaceWalls("leftWall", _localSurface.SurfaceBottomLeft, _remoteSurfaceProxy.SurfaceBottomLeft, _remoteSurfaceProxy.SurfaceTopLeft, _localSurface.SurfaceTopLeft); _negativeSpaceWalls("rightWall", _remoteSurfaceProxy.SurfaceBottomRight, _localSurface.SurfaceBottomRight, _localSurface.SurfaceTopRight, _remoteSurfaceProxy.SurfaceTopRight); _negativeSpaceWalls("topWall", _remoteSurfaceProxy.SurfaceTopLeft, _remoteSurfaceProxy.SurfaceTopRight, _localSurface.SurfaceTopRight, _localSurface.SurfaceTopLeft); NegativeSpaceCenter = new GameObject("NegativeSpaceCenter"); NegativeSpaceCenter.transform.position = (_localSurface.SurfaceBottomLeft + _remoteSurfaceProxy.SurfaceTopRight) * 0.5f; NegativeSpaceCenter.transform.rotation = GameObject.Find("localScreenCenter").transform.rotation; bottomCenterPosition = (_localSurface.SurfaceBottomLeft + _remoteSurfaceProxy.SurfaceBottomRight) * 0.5f; _handCursor = new GameObject("HandCursor"); _handCursor.transform.position = Vector3.zero; _handCursor.transform.rotation = Quaternion.identity; _handCursor.transform.parent = _main.LocalOrigin.transform; _handCursor.AddComponent <HandCursor>(); GameObject projector = GameObject.Find("Projector"); projector.transform.parent = _handCursor.transform; projector.transform.localPosition = Vector3.zero; projector.transform.rotation = _handCursor.transform.rotation; _spaceCreated = true; }
internal void setLocalSurface(SurfaceRectangle s) { }
void Update() { checkKeyboardInput(); bool ready = ConfigLoaded & _localSurfaceReceived & _remoteSurfaceReceived & _workspace.Connected; if (ready) { if (!Configured) { // space setup here Configured = true; _log.Show = false; _bodiesListener.startListening(int.Parse(_properties.localSetupInfo.trackerBroadcastPort)); GameObject localOrigin = new GameObject("LocalOrigin"); localOrigin.transform.rotation = Quaternion.identity; localOrigin.transform.position = Vector3.zero; GameObject remoteOrigin = new GameObject("RemoteOrigin"); remoteOrigin.transform.rotation = Quaternion.identity; remoteOrigin.transform.position = Vector3.zero; GameObject localScreenCenter = new GameObject("localScreenCenter"); localScreenCenter.transform.position = _localSurface.Center; localScreenCenter.transform.rotation = _localSurface.Perpendicular; Vector3 BLp = _calculateRemoteProxy(_localSurface.SurfaceBottomLeft, localScreenCenter, _properties.negativeSpaceLength); Vector3 BRp = _calculateRemoteProxy(_localSurface.SurfaceBottomRight, localScreenCenter, _properties.negativeSpaceLength); Vector3 TRp = _calculateRemoteProxy(_localSurface.SurfaceTopRight, localScreenCenter, _properties.negativeSpaceLength); Vector3 TLp = _calculateRemoteProxy(_localSurface.SurfaceTopLeft, localScreenCenter, _properties.negativeSpaceLength); SurfaceRectangle remoteSurfaceProxy = new SurfaceRectangle(BLp, BRp, TLp, TRp); GameObject remoteScreenCenter = new GameObject("remoteScreenCenter"); remoteScreenCenter.transform.position = _remoteSurface.Center; remoteScreenCenter.transform.rotation = _remoteSurface.Perpendicular; localOrigin.transform.parent = localScreenCenter.transform; remoteOrigin.transform.parent = remoteScreenCenter.transform; remoteScreenCenter.transform.position = localScreenCenter.transform.position; remoteScreenCenter.transform.rotation = Quaternion.LookRotation(-localScreenCenter.transform.forward, localScreenCenter.transform.up); remoteScreenCenter.transform.position = remoteSurfaceProxy.Center; _localSurface.CenterGameObject = localScreenCenter; _remoteSurface.CenterGameObject = remoteScreenCenter; _localOrigin = localOrigin; _remoteOrigin = remoteOrigin; _negativeSpace.create(location, _localSurface, remoteSurfaceProxy, _properties.negativeSpaceLength); centerCamera(); _prespectiveProjection.init(_localSurface); _tcpKinectListener.init(); _tracker.init(); ScreenDisplay screenDisplay = GameObject.Find("ScreenDisplay").GetComponent <ScreenDisplay>(); screenDisplay.screenCenter = localScreenCenter.transform; screenDisplay.init(); } else { if (false & Input.GetKeyDown(KeyCode.Space)) { if (_prespectiveProjection.Running && _prespectiveProjection.Active) { _prespectiveProjection.Active = false; centerCamera(); } else if (_prespectiveProjection.Running && !_prespectiveProjection.Active) { _prespectiveProjection.Active = true; } } } } else { } }
public void setLocalSurface(SurfaceRectangle localSurface) { Debug.Log("LOCAL: " + localSurface.ToString()); _localSurface = localSurface; _localSurfaceReceived = true; }
public void setRemoteSurface(SurfaceRectangle remoteSurface) { Debug.Log("REMOTE: " + remoteSurface.ToString()); _remoteSurface = remoteSurface; _remoteSurfaceReceived = true; }
void Awake() { Application.runInBackground = true; surfaceRectangle = null; }
internal void setLocalSurface(SurfaceRectangle s) { Debug.Log("] LOCAL SURFACE " + s.ToString()); _localSurface = s; }
internal void init(SurfaceRectangle surface) { _surface = surface; _running = true; }
internal void setRemoteSurface(SurfaceRectangle s) { }
void Update() { if (__localSurfaceReceived && __remoteSurfaceReceived) { if (!__everythingIsNiceAndWellConfigured) { Debug.Log("XXX " + this.ToString() + ": Creating the negative world!!!!! XXX"); GameObject localOrigin = new GameObject("LocalOrigin"); localOrigin.transform.rotation = Quaternion.identity; localOrigin.transform.position = Vector3.zero; GameObject remoteOrigin = new GameObject("RemoteOrigin"); remoteOrigin.transform.rotation = Quaternion.identity; remoteOrigin.transform.position = Vector3.zero; GameObject localScreenCenter = new GameObject("localScreenCenter"); localScreenCenter.transform.position = _localSurface.Center; localScreenCenter.transform.rotation = _localSurface.Perpendicular; Vector3 BLp = _calculateRemoteProxy(_localSurface.SurfaceBottomLeft, localScreenCenter, properties.negativeSpaceLength); Vector3 BRp = _calculateRemoteProxy(_localSurface.SurfaceBottomRight, localScreenCenter, properties.negativeSpaceLength); Vector3 TRp = _calculateRemoteProxy(_localSurface.SurfaceTopRight, localScreenCenter, properties.negativeSpaceLength); Vector3 TLp = _calculateRemoteProxy(_localSurface.SurfaceTopLeft, localScreenCenter, properties.negativeSpaceLength); SurfaceRectangle remoteSurfaceProxy = new SurfaceRectangle(BLp, BRp, TLp, TRp); /*GameObject lbl = new GameObject("lbl"); * lbl.transform.position = _localSurface.SurfaceBottomLeft; * lbl.transform.rotation = _localSurface.Perpendicular; * GameObject lbr = new GameObject("lbr"); * lbr.transform.position = _localSurface.SurfaceBottomRight; * lbr.transform.rotation = _localSurface.Perpendicular; * GameObject ltr = new GameObject("ltr"); * ltr.transform.position = _localSurface.SurfaceTopRight; * ltr.transform.rotation = _localSurface.Perpendicular; * GameObject rbl = new GameObject("rbl"); * rbl.transform.position = _remoteSurface.SurfaceBottomLeft; * rbl.transform.rotation = _remoteSurface.Perpendicular; * GameObject rbr = new GameObject("rbr"); * rbr.transform.position = _remoteSurface.SurfaceBottomRight; * rbr.transform.rotation = _remoteSurface.Perpendicular; * GameObject rtr = new GameObject("rtr"); * rtr.transform.position = _remoteSurface.SurfaceTopRight; * rtr.transform.rotation = _remoteSurface.Perpendicular; */ GameObject remoteScreenCenter = new GameObject("remoteScreenCenter"); remoteScreenCenter.transform.position = _remoteSurface.Center; remoteScreenCenter.transform.rotation = _remoteSurface.Perpendicular; localOrigin.transform.parent = localScreenCenter.transform; remoteOrigin.transform.parent = remoteScreenCenter.transform; remoteScreenCenter.transform.position = localScreenCenter.transform.position; remoteScreenCenter.transform.rotation = Quaternion.LookRotation(-localScreenCenter.transform.forward, localScreenCenter.transform.up); remoteScreenCenter.transform.position = remoteSurfaceProxy.Center; _localSurface.CenterGameObject = localScreenCenter; _remoteSurface.CenterGameObject = remoteScreenCenter; _localOrigin = localOrigin; _remoteOrigin = remoteOrigin; Transform mist = GameObject.Find("mist").transform; mist.position = new Vector3(0, _remoteOrigin.transform.position.y - mist.localScale.x, 0); foreach (Sensor sensor in _localSurface.sensors) { GameObject g = new GameObject(sensor.id); g.transform.parent = _localOrigin.transform; g.transform.localPosition = sensor.position; g.transform.localRotation = sensor.rotation; } foreach (Sensor sensor in _remoteSurface.sensors) { GameObject g = new GameObject(sensor.id); g.transform.parent = _remoteOrigin.transform; g.transform.localPosition = sensor.position; g.transform.localRotation = sensor.rotation; } _negativeSpace.create(location, _localSurface, remoteSurfaceProxy, properties.negativeSpaceLength); _projection.init(_localSurface); GetComponent <TcpKinectListener>().Init(); __everythingIsNiceAndWellConfigured = true; GameObject.Find("Checkerboard").GetComponent <Checkerboard>().Init(); GameObject hideScreenGo = GameObject.Find("HideScreen"); hideScreenGo.transform.position = localScreenCenter.transform.position; hideScreenGo.transform.rotation = localScreenCenter.transform.rotation; //GameObject.Find("Projector").GetComponent<SimpleProjector>().init(remoteScreenCenter.transform); } } }
public void setRemoteSurface(SurfaceRectangle surfaceRectangle) { Debug.Log("Received Remote Surface: " + surfaceRectangle.ToString()); _remoteSurface = surfaceRectangle; __remoteSurfaceReceived = true; }
public void setLocalSurface(SurfaceRectangle surfaceRectangle) { Debug.Log("Received Local Surface: " + surfaceRectangle.ToString()); _localSurface = surfaceRectangle; __localSurfaceReceived = true; }
internal void init(SurfaceRectangle surface) { _surface = surface; _running = true; GameObject.Find("Main").GetComponent <VisualLog>().WriteLine(this, "Perspective Projection started"); }
// Update is called once per frame internal void setRemoteSurface(SurfaceRectangle s) { Debug.Log("] REMOTE SURFACE " + s.ToString()); _remoteSurface = s; }