Ejemplo n.º 1
0
 public void Collect(OperatorPart startPoint)
 {
     Clear();
     startPoint.TraverseWithFunction(this, this);
     if (!CollectedMeshes.Any())
     {
         Logger.Warn(_parent, "Found no mesh supplier, have you forgotten to add an input?");
     }
 }
Ejemplo n.º 2
0
        private static void CreateAndAddConnection(OperatorPart input, OperatorPart output)
        {
            if (input == null || output == null)
            {
                return;
            }

            if (output.Type != input.Type)
            {
                MessageBox.Show("You can not connect " + output.Type.ToString() + " to " + input.Type.ToString(),
                                "Sorry");
                return;
            }

            if (output.Parent == input.Parent)
            {
                MessageBox.Show("You can not connect an operator to itself.",
                                "Sorry");
                return;
            }
            // check for cycle
            var parent           = input.Parent;
            var outputsOfInputOp = parent.Outputs;
            var cc = new OperatorPart.CycleChecker(outputsOfInputOp);

            output.TraverseWithFunction(cc, null);
            if (cc.HasCycle)
            {
                MessageBox.Show("You can not connect " + output.Type.ToString() + " to " + input.Type.ToString(),
                                "As this would build a cycle, sorry");
                return;
            }


            var newConnection = new Connection(output.Parent, output, input.Parent, input, input.IsMultiInput ? input.Connections.Count : 0);

            if (input.IsMultiInput || input.Connections.Count == 0)
            {
                App.Current.MainWindow.InsertConnectionAt(newConnection);
            }
            else
            {
                App.Current.MainWindow.ReplaceConnectionAt(newConnection);
            }
            App.Current.UpdateRequiredAfterUserInteraction = true;
        }
Ejemplo n.º 3
0
        public void Setup(OperatorPart outputOpPart, double startTime = 0, double endTime = 184, double frameRate   = 30, double width                = 1920, double height = 1080,
                          string fileExtension = "png", bool skipExistingFiles            = false, string directory = "output", string filenameFormat = "[T]", SharpDX.DXGI.Format imageFormat = Format.R8G8B8A8_UNorm)
        {
            try
            {
                Dispose();

                _outputOpPart      = outputOpPart;
                _directory         = directory;
                _fileNameFormat    = filenameFormat;
                _startTime         = startTime;
                _endTime           = endTime;
                _frameRate         = frameRate;
                _width             = (int)width;
                _height            = (int)height;
                _samples           = 2;
                _fileExtension     = fileExtension.ToLower();
                _skipExistingFiles = skipExistingFiles;

                _defaultContext = new OperatorPartContext(0.0f);
                _defaultContext.Variables.Add("Screensize.Width", _width);
                _defaultContext.Variables.Add("Screensize.Height", _height);
                _defaultContext.Variables.Add("AspectRatio", (float)_width / _height);
                _defaultContext.Variables.Add("Samples", _samples);
                _defaultContext.Variables.Add("FullScreen", 0.0f);
                _defaultContext.Variables.Add("LoopMode", 0.0f);
                _defaultContext.ImageBufferFormat = imageFormat;

                _frameTime = 1.0 / _frameRate;

                Directory.CreateDirectory(_directory);

                _renderer = new DefaultRenderer();

                _texture = ShaderResourceView.FromFile(D3DDevice.Device, "./assets-common/image/white.png");


                _renderTargetResource = null;
                ResourceManager.ValidateRenderTargetResource(ref _renderTargetResource, _outputOpPart, D3DDevice.Device, _width, _height, imageFormat);
                _renderTargetView = new RenderTargetView(D3DDevice.Device, _renderTargetResource.Texture);

                _renderDepthResource = null;
                ResourceManager.ValidateDepthStencilResource(ref _renderDepthResource, _outputOpPart, D3DDevice.Device, _width, _height);
                var depthViewDesc = new DepthStencilViewDescription();
                depthViewDesc.Format    = Format.D32_Float;
                depthViewDesc.Dimension = DepthStencilViewDimension.Texture2D;

                _renderTargetDepthView = new DepthStencilView(D3DDevice.Device, _renderDepthResource.Texture, depthViewDesc);

                _gpuSyncer = new BlockingGpuSyncer(D3DDevice.Device);

                D3DDevice.Device.ImmediateContext.OutputMerger.SetTargets(_renderTargetDepthView, _renderTargetView);
                _viewport = new ViewportF(0, 0, _width, _height, 0.0f, 1.0f);
                D3DDevice.Device.ImmediateContext.Rasterizer.SetViewport(_viewport);


                var timeAccessorCollector = new OperatorPart.CollectOpPartFunctionsOfType <OperatorPartTraits.ITimeAccessor>();
                _outputOpPart.TraverseWithFunction(timeAccessorCollector, null);
                _timeAccessorOpPartFunctions = new List <OperatorPart.Function>();
                foreach (var opPartFunction in timeAccessorCollector.CollectedOpPartFunctions)
                {
                    _timeAccessorOpPartFunctions.Add(opPartFunction as OperatorPart.Function);
                }
                _currentTime = _startTime;
            }
            catch (Exception e)
            {
                Logger.Error("Failed to setup image-sequence {0}", e.Message);
            }
        }