void Update() { CheckConnection(); if (NodeInformation.isMaster()) { InputMessage inputMessage = new InputMessage(); TimeSynchronizer.BuildMessage(inputMessage.inputTimeMessage); InputSynchronizer.BuildMessage(this, inputMessage.inputInputMessage); ParticleSynchronizer.BuildMessage(inputMessage.inputParticleMessage); AnimatorSynchronizer.BuildMessage(inputMessage.inputAnimatorMessage); TrackingSynchronizer.BuildMessage(inputMessage.inputTrackingMessage); TransformationSynchronizer.BuildMessage(inputMessage.inputTransformationMessage); EventSynchronizer.BuildMessage(inputMessage.inputEventsMessage); node.BroadcastMessage(inputMessage); } else { InputMessage inputMessage = new InputMessage(); ((Client)node).WaitForNextMessage(inputMessage); TimeSynchronizer.ProcessMessage(inputMessage.inputTimeMessage); InputSynchronizer.ProcessMessage(this, inputMessage.inputInputMessage); ParticleSynchronizer.ProcessMessage(inputMessage.inputParticleMessage); AnimatorSynchronizer.ProcessMessage(inputMessage.inputAnimatorMessage); TrackingSynchronizer.ProcessMessage(inputMessage.inputTrackingMessage); TransformationSynchronizer.ProcessMessage(inputMessage.inputTransformationMessage); EventSynchronizer.ProcessMessage(inputMessage.inputEventsMessage); } StartCoroutine(EndOfFrame()); }
void Start() { flyStick = GameObject.Find("Flystick"); GUISynchronizer.Prepare(); started = false; if (!NodeInformation.isMaster()) { QualitySettings.vSyncCount = 0; node = new Client(); } else { node = new Server(NodeInformation.developmentMode ? 0 : NodeInformation.slaves.Count); } }
void Start() { _started = false; NodeInformation.Load(); this.networkAddress = NodeInformation.master.ip; this.networkPort = NodeInformation.master.port; if (NodeInformation.IsMaster()) { isServer = true; this.StartServer(); //Instantiate the origin-GameObject GameObject objOrigin = Instantiate(origin, originParent); DataDistributor dd = objOrigin.GetComponent <DataDistributor>(); dd.ines = this; dd.parent = originParent.gameObject; //Spawn the object for the clients NetworkServer.Spawn(objOrigin); //Test Master; if we remove this, then the master won't see anything (same goes for config) originSlave = FindOrigin(); NodeInformation.SpawnScreenplanes(originSlave.transform.Find("ScreenPlanes")); trackerSettings = (TrackerSettings)originSlave.transform.Find("CameraHolder").GetComponent("TrackerSettings"); trackerSettings.HostSettings = (TrackerHostSettings)GameObject.Find("NodeManager/TrackerHostSettings").GetComponent("TrackerHostSettings"); trackerSettings = (TrackerSettings)originSlave.transform.Find("Flystick").GetComponent("TrackerSettings"); trackerSettings.HostSettings = (TrackerHostSettings)GameObject.Find("NodeManager/TrackerHostSettings").GetComponent("TrackerHostSettings"); //trackerSettings.gameObject.SetActive(false); } else { this.StartClient(); //The camera manipulation happens in Update() //GameObject objOrigin = Instantiate(origin, originParent); //////Spawn the object for the clients //NetworkServer.Spawn(objOrigin); // deactivate music and sound for clients AudioListener.volume = 0f; } }
void CheckConnection() { if (!started) { node.Connect(); started = true; } else { if (NodeInformation.isMaster() && node.connections.Count != ((Server)node).targetClientNumber || !NodeInformation.isMaster() && node.connections.Count == 0) { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif } } }
private static void CallScripts(List <StoredEvent> events) { Dictionary <NetworkInstanceId, NetworkIdentity> networkIdentities = NodeInformation.isMaster() ? NetworkServer.objects : ClientScene.objects; foreach (StoredEvent storedEvent in events) { NetworkInstanceId networkInstanceId = new NetworkInstanceId(storedEvent.networkId); if (networkIdentities.ContainsKey(networkInstanceId)) { EventType type = (EventType)storedEvent.type; if (type == EventType.OnClick) { TriggerGUIEvent(type, networkInstanceId); } else { TriggerCollisionEvent(type, networkInstanceId, storedEvent.data, networkIdentities); } } } }
void Start() { NodeInformation.developmentMode = developmentMode; NodeInformation.Load(); NetworkManager networkManager = GetComponent <NetworkManager>(); networkManager.networkAddress = NodeInformation.master.ip; networkManager.networkPort = NodeInformation.master.port; if (NodeInformation.isMaster()) { networkManager.StartServer(); //Instantiate the origin-GameObject GameObject objOrigin = Instantiate(origin, originParent); objOrigin.transform.localPosition = NodeInformation.own.originPosition; //Spawn the object for the clients NetworkServer.Spawn(objOrigin); //Test Master; if we remove this, then the master won't see anything (same goes for config) originSlave = FindOrigin(); NodeInformation.SpawnScreenplanes(originSlave.transform.Find("ScreenPlanes")); trackerSettings = (TrackerSettings)originSlave.transform.Find("CameraHolder").GetComponent("TrackerSettings"); trackerSettings.HostSettings = (TrackerHostSettings)GameObject.Find("NodeManager/TrackerHostSettings").GetComponent("TrackerHostSettings"); trackerSettings = (TrackerSettings)originSlave.transform.Find("Flystick").GetComponent("TrackerSettings"); trackerSettings.HostSettings = (TrackerHostSettings)GameObject.Find("NodeManager/TrackerHostSettings").GetComponent("TrackerHostSettings"); } else { networkManager.StartClient(); //The camera manipulation happens in Update() // deactivate music and sound for clients AudioListener.volume = 0f; } }
public void SetClientOriginScreenplanes() { //The slave needs to turn the camera and adjust the screenplane if (!NodeInformation.IsMaster()) { //Only do it once! if (originSlave == null) { //the origin-GameObject has the tag "MainCamera" to find it easily originSlave = FindOrigin(); //Since the client needs some time to get the object from the server, we can only continue if we have the origin if (originSlave != null) { originSlave.transform.parent = originParent; NodeInformation.SpawnScreenplanes(originSlave.transform.Find("ScreenPlanes")); //Find the camera to turn it to the right direction Transform CameraTransform = originSlave.transform.Find("CameraHolder/Camera"); CameraTransform.eulerAngles = NodeInformation.own.cameraRoation; //Apply the interpupillary distance //Maybe we need to change this a bit, so that the distance is calculated by considering the direction the User looks. //We see that when we test it. if (NodeInformation.own.cameraEye == "left") { CameraTransform.localPosition += new Vector3(-0.03f, 0, 0); } else { CameraTransform.localPosition += new Vector3(0.03f, 0, 0); } } } } }