Пример #1
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (FContextChanged)
            {
                if (FContextIn.PluginIO.IsConnected)
                {
                    if (FContextIn[0] != null)
                    {
                        try
                        {
                            FDepthGenerator = (DepthGenerator)FContextIn[0].GetProductionNodeByName("Depth1");
                            FFov[0]         = new Vector2D(FDepthGenerator.FieldOfView.HorizontalAngle, FDepthGenerator.FieldOfView.VerticalAngle) * (float)VMath.RadToCyc;

                            FHistogram = new int[FDepthGenerator.DeviceMaxDepth];

                            //Set the resolution of the texture
                            var mapMode = FDepthGenerator.MapOutputMode;
                            FTexWidth  = mapMode.XRes;
                            FTexHeight = mapMode.YRes;

                            //Reinitalie the vvvv texture
                            Reinitialize();

                            FContextChanged = false;
                        }
                        catch (Exception ex)
                        {
                            FLogger.Log(ex);
                        }
                    }
                }
                else
                {
                    CleanUp();
                    FContextChanged = false;
                }
            }

            if (FDepthGenerator != null)
            {
                if (FEnabledIn.IsChanged)
                {
                    if (FEnabledIn[0])
                    {
                        FDepthGenerator.StartGenerating();
                    }
                    else
                    {
                        FDepthGenerator.StopGenerating();
                    }
                }

                bool imageGeneratorChanged = false;
                try
                {
                    var imageGenerator = (ImageGenerator)FContextIn[0].GetProductionNodeByName("Image1");
                    if (FImageGenerator != imageGenerator)
                    {
                        FImageGenerator       = imageGenerator;
                        imageGeneratorChanged = true;
                    }
                }
                catch
                {}

                if (FAdaptView.IsChanged || imageGeneratorChanged)
                {
                    if (FImageGenerator == null || !FAdaptView[0])
                    {
                        FDepthGenerator.AlternativeViewpointCapability.ResetViewpoint();
                    }
                    else
                    {
                        FDepthGenerator.AlternativeViewpointCapability.SetViewpoint(FImageGenerator);
                    }
                }

                if (FDepthGenerator.IsDataNew)
                {
                    Update();
                }
            }
        }