public ScreenViewerServer(int FileSendTCP_Port, bool OnlyWindowScreen, string Password, int Sleep, ScreenShotMethod method, IPAddress ip, int TCP_Port, int UDP_Video_Port, int UDP_Audio_Port = -1, int DeviceNumber = -1) { try { this.FileSendTCP_Port = FileSendTCP_Port; this.OnlyWindowScreen = OnlyWindowScreen; this.ServerStart = true; this.Password = Password; this.Sleep = Sleep; this.Clients = new List <ClientInfo>(); this.method = method; this.ip = ip; this.TCP_Port = TCP_Port; this.UDP_Video_Port = UDP_Video_Port; this.TCP = new TcpListener(this.ip, this.TCP_Port); this.FileSendTCP = new TcpListener(this.ip, this.FileSendTCP_Port); this.UDP_Video = new UdpClient(new IPEndPoint(this.ip, this.UDP_Video_Port)); if (UDP_Audio_Port == -1) { this.EnableAudio = false; }//if else { this.EnableAudio = true; this.UDP_Audio_Port = UDP_Audio_Port; this.UDP_Audio = new UdpClient(new IPEndPoint(this.ip, this.UDP_Audio_Port)); this.DeviceNumber = DeviceNumber; } //else } //try catch (Exception ex) { throw ex; } //catch } //ScreenViewerServer
/// <summary> /// Function, calculates all the camera positions. Places the camera around the scene. /// Positions are calculated around the scene like a voluminous sphere. At every position a /// defined method is called. /// </summary> /// <param name="minDistance">Radius, where the first camera positions will be set</param> /// <param name="maxDistance">Radius, where the last camera positions will be set</param> /// <param name="method">Method that is called at every single camera position</param> /// <returns>IEnumerator</returns> private IEnumerator CalculateOrbitCamera(float minDistance, float maxDistance, ScreenShotMethod method) { // Calculate the increasement for every dimension per loop pass float xDistance = (maxDistance - minDistance); float xIncrease = xDistance / XRadiusSteps; float yIncrease = _yRotationAngle / YRotationSteps; float zIncrease = _zRotationAngle / ZRotationSteps; float initialYIncrease = yIncrease; float initialZIncrease = zIncrease; // temporary variable for the position of the camera Vector3 CamPos = new Vector3(0, 0, 0); for (float x = minDistance; x <= maxDistance; x += xIncrease) { for (float z = _zAngleOffset; z <= _zRotationAngle - _zAngleOffset; z += zIncrease) { // Optimization: Increase the y steps for a balanced set of positions if (x > (maxDistance / 2) && z < _zRotationAngle / 3) { yIncrease = initialYIncrease / 3; } if (x > (maxDistance * 0.75) && z < _zRotationAngle / 3) { yIncrease = initialYIncrease / 4; } // Optimization: Increase the z steps for a balanced set of positions zIncrease = (z < (_zRotationAngle / 2)) ? (initialZIncrease * 0.75f) : initialZIncrease; for (float y = 0; y <= _yRotationAngle; y += yIncrease) { CamPos.y = x * Mathf.Sin(z * Mathf.PI / 180.0f); CamPos.z = x * Mathf.Cos(z * Mathf.PI / 180.0f); CamPos.x = CamPos.z * Mathf.Sin(y * Mathf.PI / 180.0f); CamPos.z = CamPos.z * Mathf.Cos(y * Mathf.PI / 180.0f); // CamPos += CalculateRandomOffset(); (Old implementation, where an offset will be added to the positions) transform.position = CamPos; yield return(StartCoroutine(method())); } } } }