Example #1
0
        /// <summary>
        /// Loops until it gets a new assignment and sends it to the RenderClient (or all assignments have been rendered)
        /// </summary>
        public void TryToGetNewAssignment()
        {
            while (Master.singleton.finishedAssignments < Master.singleton.totalNumberOfAssignments - assignmentsAtClients)
            {
                if (!NetworkSupport.IsConnected(client))
                {
                    LostConnection();
                    return;
                }

                Master.singleton.availableAssignments.TryDequeue(out Assignment newAssignment);

                if (!Master.singleton.progressData.Continue) // test whether rendering should end (Stop button pressed)
                {
                    return;
                }

                if (newAssignment == null) // TryDequeue was not succesfull
                {
                    continue;
                }

                lock (stream)
                {
                    NetworkSupport.SendObject(newAssignment, stream);
                    assignmentsAtClients++;
                    unfinishedAssignments.Add(newAssignment);
                }

                break;
            }
        }
Example #2
0
        /// <summary>
        /// Sends special Assignment which can signal to client that rendering stopped or that client should be reset and wait for more work
        /// </summary>
        public void SendSpecialAssignment(Assignment.AssignmentType assignmentType)
        {
            Assignment newAssignment = new Assignment(assignmentType);

            lock (stream)
            {
                NetworkSupport.SendObject(newAssignment, stream);
            }
        }
Example #3
0
        /// <summary>
        /// Sends all objects which are necessary to render scene to client
        /// Assignment - special type of assignment (reset) to indicate (new) start of work
        /// IRayScene - scene representation like solids, textures, lights, camera, ...
        /// IRenderer - renderer itself including IImageFunction; needed for RenderPixel method
        /// Receives number of threads available to render at RenderClient
        /// </summary>
        public void ExchangeNecessaryInfo()
        {
            // Set assemblies - needed for correct serialization/deserialization
            NetworkSupport.SendString(Assembly.GetExecutingAssembly().GetName().Name, stream);
            string targetAssembly = NetworkSupport.ReceiveString(stream);

            NetworkSupport.SetAssemblyNames(Assembly.GetExecutingAssembly().GetName().Name, targetAssembly);

            NetworkSupport.SendObject(new Assignment(Assignment.AssignmentType.Reset), stream);

            NetworkSupport.SendObject(Master.singleton.scenes[0], stream);

            NetworkSupport.SendObject(Master.singleton.renderers[0], stream);

            threadCountAtClient = NetworkSupport.ReceiveInt(stream);
        }