Esempio n. 1
0
 public ImageRenderer(MedicalController controller, SceneViewController sceneViewController, IdleHandler idleHandler)
 {
     this.controller          = controller;
     this.sceneViewController = sceneViewController;
     this.idleHandler         = idleHandler;
     TransparencyController.createTransparencyState(TransparencyStateName);
     OgreResourceGroupManager.getInstance().createResourceGroup(RenderTextureResourceGroup);
 }
 protected override void link()
 {
     parentInterface = TransparencyController.getTransparencyObject(parentInterfaceName);
     if (parentInterface == null)
     {
         blacklist("Cannot find parent interface \"{0}\".", parentInterfaceName);
     }
     parentInterface.addSubInterface(this);
 }
 protected override void link()
 {
     base.link();
     watchingInterface = TransparencyController.getTransparencyObject(watchingInterfaceName);
     if (watchingInterface == null)
     {
         blacklist("Cannot find watching interface \"{0}\".", watchingInterfaceName);
     }
 }
Esempio n. 4
0
 void sceneViewController_WindowCreated(SceneViewWindow window)
 {
     if (!TransparencyController.hasTransparencyState(window.CurrentTransparencyState))
     {
         TransparencyController.createTransparencyState(window.CurrentTransparencyState);
     }
     window.RenderingStarted += window_RenderingStarted;
     window.MadeActive       += window_MadeActive;
 }
Esempio n. 5
0
        internal void instantlyApplyBlended(List <TransparencyInterface> unvisitedInterfaces, float endAlphaValue, float percent)
        {
            TransparencyInterface obj = TransparencyController.getTransparencyObject(transparencyObject);

            if (obj != null)
            {
                obj.CurrentAlpha = NumberFunctions.lerp(alphaValue, endAlphaValue, percent);
                unvisitedInterfaces.Remove(obj);
            }
        }
Esempio n. 6
0
        public void instantlyApplyBlendPercent(List <TransparencyInterface> unvisitedInterfaces, float percent)
        {
            TransparencyInterface obj = TransparencyController.getTransparencyObject(transparencyObject);

            if (obj != null)
            {
                obj.CurrentAlpha += (alphaValue - obj.CurrentAlpha) * percent;
                unvisitedInterfaces.Remove(obj);
            }
        }
Esempio n. 7
0
        public void instantlyApply(List <TransparencyInterface> unvisitedInterfaces)
        {
            TransparencyInterface obj = TransparencyController.getTransparencyObject(transparencyObject);

            if (obj != null)
            {
                obj.CurrentAlpha = alphaValue;
                unvisitedInterfaces.Remove(obj);
            }
        }
Esempio n. 8
0
        public void timedApply(float time, List <TransparencyInterface> unvisitedInterfaces, EasingFunction easingFunction)
        {
            TransparencyInterface obj = TransparencyController.getTransparencyObject(transparencyObject);

            if (obj != null)
            {
                obj.timedBlend(alphaValue, time, easingFunction);
                unvisitedInterfaces.Remove(obj);
            }
        }
 protected override void destroy()
 {
     TransparencyController.removeTransparencyObject(this);
     if (subInterfaces != null)
     {
         foreach (TransparencySubInterface subInterface in subInterfaces)
         {
             subInterface._disconnectFromInterface();
         }
     }
 }
 public override void skipTo(float timelineTime)
 {
     if (TransparencyController.hasTransparencyState(TransparencyState))
     {
         if (timelineTime <= EndTime)
         {
             float  currentPosition          = timelineTime - StartTime;
             String currentTransparencyState = TransparencyController.ActiveTransparencyState;
             TransparencyController.ActiveTransparencyState = TransparencyState;
             float percent = 1.0f;
             if (Duration != 0.0f)
             {
                 percent = currentPosition / Duration;
             }
             LayerState.instantlyApplyBlendPercent(percent);
             LayerState.timedApply(Duration - currentPosition);
             TransparencyController.ActiveTransparencyState = currentTransparencyState;
         }
         else
         {
             LayerState.instantlyApply();
             finished = true;
         }
     }
     else
     {
         //Could not find the specified window, so just apply to the active window.
         if (timelineTime <= EndTime)
         {
             float currentPosition = timelineTime - StartTime;
             TransparencyController.ActiveTransparencyState = TransparencyState;
             float percent = 1.0f;
             if (Duration != 0.0f)
             {
                 percent = currentPosition / Duration;
             }
             LayerState.instantlyApplyBlendPercent(percent);
             LayerState.timedApply(Duration - currentPosition);
         }
         else
         {
             LayerState.instantlyApply();
             finished = true;
         }
     }
 }
 public override void started(float timelineTime, Clock clock)
 {
     if (TransparencyController.hasTransparencyState(TransparencyState))
     {
         String currentTransparencyState = TransparencyController.ActiveTransparencyState;
         TransparencyController.ActiveTransparencyState = TransparencyState;
         LayerState.timedApply(Duration);
         TransparencyController.ActiveTransparencyState = currentTransparencyState;
         finished = false;
     }
     else
     {
         //Could not find the specified window, so just apply to the active window.
         LayerState.timedApply(Duration);
         finished = false;
     }
 }
Esempio n. 12
0
        public VirtualTextureSceneViewLink(StandaloneController standaloneController)
        {
            this.standaloneController            = standaloneController;
            standaloneController.SceneLoaded    += standaloneController_SceneLoaded;
            standaloneController.SceneUnloading += standaloneController_SceneUnloading;

            cameraLink = new CameraLink(standaloneController.SceneViewController);

            CompressedTextureSupport textureFormat = OgreInterface.Instance.SelectedTextureFormat;

            virtualTextureManager = new VirtualTextureManager(UnifiedMaterialBuilder.GetNumCompressedTexturesNeeded(textureFormat), MedicalConfig.PhysicalTextureSize, MedicalConfig.PageSize, 4096, textureFormat, MedicalConfig.VirtualTextureStagingBufferCount, MedicalConfig.FeedbackBufferSize, MedicalConfig.TextureCacheSize, UnifiedMaterialBuilder.AreTexturesPagedOnDisk(textureFormat));
            virtualTextureManager.MaxStagingUploadPerFrame = MedicalConfig.MaxStagingVirtualTextureUploadsPerFrame;
            virtualTextureManager.TransparentFeedbackBufferVisibilityMask = TransparencyController.TransparentVisibilityMask;
            virtualTextureManager.OpaqueFeedbackBufferVisibilityMask      = TransparencyController.OpaqueVisibilityMask;
            virtualTextureManager.MipSampleBias      = -3;
            virtualTextureManager.AutoAdjustMipLevel = false;

            materialBuilder = new UnifiedMaterialBuilder(virtualTextureManager, OgreInterface.Instance.SelectedTextureFormat, standaloneController.MedicalController.PluginManager.createLiveResourceManager("UnifiedShaders"));
            OgreInterface.Instance.MaterialParser.addMaterialBuilder(materialBuilder);
            TransparencyController.initialize(materialBuilder);

            standaloneController.MainWindow.DestroyInternalResources += MainWindow_DestroyInternalResources;
            standaloneController.MainWindow.CreateInternalResources  += MainWindow_CreateInternalResources;
        }
Esempio n. 13
0
 /// <summary>
 /// Unhide everything
 /// </summary>
 public void unhideAll()
 {
     TransparencyController.smoothSetAllAlphas(1.0f, MedicalConfig.CameraTransitionTime, EasingFunction.EaseOutQuadratic);
 }
Esempio n. 14
0
 void window_RenderingStarted(SceneViewWindow window, bool currentCameraRender)
 {
     TransparencyController.applyTransparencyState(window.CurrentTransparencyState);
 }
Esempio n. 15
0
 void sceneViewController_WindowDestroyed(SceneViewWindow window)
 {
     TransparencyController.removeTransparencyState(window.CurrentTransparencyState);
     window.RenderingStarted -= window_RenderingStarted;
     window.MadeActive       -= window_MadeActive;
 }
Esempio n. 16
0
 public void preRender()
 {
     TransparencyController.applyTransparencyState(sceneViewController.ActiveWindow.CurrentTransparencyState);
 }
Esempio n. 17
0
        private IEnumerable <IdleStatus> renderImage(ImageRendererProperties properties, Action <FreeImageBitmap> renderingCompletedCallback)
        {
            if (imageRendererProgress != null)
            {
                imageRendererProgress.Visible = properties.ShowUIUpdates;
                imageRendererProgress.Cancel  = false;
                imageRendererProgress.update(0, "Rendering Image");
            }

            FreeImageBitmap bitmap      = null;
            SceneViewWindow sceneWindow = sceneViewController.ActiveWindow;

            if (sceneWindow != null)
            {
                if (ImageRenderStarted != null)
                {
                    ImageRenderStarted.Invoke(this, EventArgs.Empty);
                }

                //Background color
                Engine.Color backgroundColor = properties.CustomBackgroundColor;
                if (properties.UseWindowBackgroundColor)
                {
                    backgroundColor = sceneWindow.BackColor;
                }

                //Size (with AA)
                //int width = properties.Width * properties.AntiAliasingMode;
                //int height = properties.Height * properties.AntiAliasingMode;

                //Camera position
                Vector3 cameraPosition = sceneWindow.Translation;
                Vector3 cameraLookAt   = sceneWindow.LookAt;
                if (!properties.UseActiveViewportLocation)
                {
                    cameraPosition = properties.CameraPosition;
                    cameraLookAt   = properties.CameraLookAt;
                }

                //Turn off background if needed
                if (background != null)
                {
                    background.setVisible(properties.ShowBackground);
                }

                //Layer override
                String activeTransparencyState = TransparencyController.ActiveTransparencyState;
                if (properties.OverrideLayers)
                {
                    TransparencyController.ActiveTransparencyState = TransparencyStateName;
                    if (properties.LayerState != null)
                    {
                        properties.LayerState.instantlyApply();
                    }
                    else
                    {
                        Log.Warning("ImageRenderer was told to override layers but no layer state was provided.");
                    }
                }

                TransparencyController.applyTransparencyState(TransparencyController.ActiveTransparencyState);

                //Render
                IEnumerable <IdleStatus> process = createRender(properties.Width, properties.Height, properties.AntiAliasingMode, properties.ShowWatermark, properties.TransparentBackground, backgroundColor, sceneWindow.Camera, cameraPosition, cameraLookAt, sceneWindow.MinNearDistance, sceneWindow.NearPlaneWorld, sceneWindow.NearFarLength, properties,
                                                                (product) =>
                {
                    bitmap = product;
                });
                foreach (IdleStatus idleStatus in process)
                {
                    yield return(idleStatus);
                }

                //Turn off layer override
                if (properties.OverrideLayers)
                {
                    TransparencyController.ActiveTransparencyState = activeTransparencyState;
                }

                //Reactivate background
                if (background != null)
                {
                    background.setVisible(true);
                }

                if (ImageRenderCompleted != null)
                {
                    ImageRenderCompleted.Invoke(this, EventArgs.Empty);
                }
            }

            if (imageRendererProgress != null && properties.ShowUIUpdates)
            {
                imageRendererProgress.Visible = false;
            }

            renderingCompletedCallback(bitmap);
            yield break;
        }
        protected override void constructed()
        {
            transparencyStates = new List <TransparencyState>();
            transparencyStates.Add(new TransparencyState(startingTransparency));

            SceneNodeElement sceneNode = Owner.getElement(nodeName) as SceneNodeElement;

            if (sceneNode == null)
            {
                blacklist("Cannot find Node '{0}'", nodeName);
            }

            if (childNodeName != null && childNodeName != String.Empty)
            {
                sceneNode = sceneNode.findChildNode(childNodeName);
                if (sceneNode == null)
                {
                    blacklist("Could not find child node '{0}' in node '{1}'.", childNodeName, nodeName);
                }
            }
            entity = sceneNode.getNodeObject(entityName) as Entity;

            if (entity == null)
            {
                if (entityName == null)
                {
                    blacklist("entityName is Null");
                }
                else
                {
                    blacklist("Cannot find entity named '{0}' in node '{1}'.", entityName, nodeName);
                }
            }

            originalRenderGroup = entity.getRenderQueueGroup();

            if (subEntityIndex >= entity.getNumSubEntities())
            {
                blacklist("Entity '{0}' only has '{1}' SubEntities. Index '{2}' is invalid.", entity.getName(), entity.getNumSubEntities(), subEntityIndex);
            }

            subEntity        = entity.getSubEntity(subEntityIndex);
            baseMaterialName = subEntity.getMaterialName();
            MaterialManager materialManager    = MaterialManager.getInstance();
            bool            useDefinedMaterial = !(alphaMaterialName == null || alphaMaterialName.Equals(String.Empty));

            if (useDefinedMaterial)
            {
                if (materialManager.resourceExists(alphaMaterialName))
                {
                    finalAlphaMaterialName = alphaMaterialName;
                }
                else
                {
                    blacklist("A custom material '{0}' is defined that cannot be found.  This object will not be able to be alpha controlled.", this.alphaMaterialName);
                }
            }
            else
            {
                if (materialManager.resourceExists(baseMaterialName + alphaSuffix))
                {
                    finalAlphaMaterialName = baseMaterialName + alphaSuffix;
                }
                else
                {
                    blacklist("Cannot find automatic alpha material '{0}'.  Please ensure one exists or define a custom alpha behavior.", baseMaterialName + alphaSuffix);
                }
            }

            using (var mat = subEntity.getMaterial())
            {
                usesVirtualTexture = TransparencyController.isVirtualTextureMaterial(mat.Value);
                if (!usesVirtualTexture)
                {
                    entity.setVisibilityFlags(TransparencyController.HiddenVisibilityMask);
                }
            }

            TransparencyController.addTransparencyObject(this);

            applyAlphaToMaterial(getCurrentTransparency(activeTransparencyState));
        }