Exemple #1
0
        internal IEnumerable <SceneBuildStatus> changeSceneStatus(String file, ResourceProvider resourceProvider)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            sceneViewController.resetAllCameraPositions();
            unloadScene();
            SimObjectErrorManager.Clear();

            foreach (var status in medicalController.openScene(file, resourceProvider))
            {
                yield return(status);
            }

            SimSubScene defaultScene = medicalController.CurrentScene.getDefaultSubScene();

            if (BeforeSceneLoadProperties != null)
            {
                BeforeSceneLoadProperties.Invoke(medicalController.CurrentScene);
            }
            if (defaultScene != null)
            {
                OgreSceneManager ogreScene = defaultScene.getSimElementManager <OgreSceneManager>();

                SimulationScene medicalScene = defaultScene.getSimElementManager <SimulationScene>();
                sceneViewController.createFromPresets(medicalScene.WindowPresets.Default, false);

                sceneViewController.createCameras(medicalController.CurrentScene);
                lightManager.sceneLoaded(medicalController.CurrentScene);

                if (SceneLoaded != null)
                {
                    SceneLoaded.Invoke(medicalController.CurrentScene);
                }

                anatomyController.sceneLoaded();
            }

            if (SimObjectErrorManager.HasErrors)
            {
                NotificationManager.showCallbackNotification("Errors loading the scene.\nClick for details.", MessageBoxIcons.Error, showLoadErrorGui);
            }

            sw.Stop();
            Logging.Log.Debug("Scene '{0}' loaded in {1} ms", file, sw.ElapsedMilliseconds);
        }
Exemple #2
0
 public void renderDebug(SimSubScene subScene)
 {
     if (enabled)
     {
         BulletScene sceneManager = subScene.getSimElementManager <BulletScene>();
         if (sceneManager != null)
         {
             sceneManager.drawDebug(drawingSurface);
         }
     }
     else if (firstFrameDisabled)
     {
         BulletScene sceneManager = subScene.getSimElementManager <BulletScene>();
         if (sceneManager != null)
         {
             sceneManager.clearDebug(drawingSurface);
         }
         firstFrameDisabled = false;
     }
 }
Exemple #3
0
 /// <summary>
 /// Register this class with the factory to be built.
 /// </summary>
 /// <param name="subscene">The subscene to add this definition to.</param>
 /// <param name="instance">The SimObject that will get the product.</param>
 public override void registerScene(SimSubScene subscene, SimObjectBase instance)
 {
     if (subscene.hasSimElementManagerType(typeof(OgreSceneManager)))
     {
         OgreSceneManager sceneManager = subscene.getSimElementManager <OgreSceneManager>();
         sceneManager.getOgreFactory().addSceneNodeDefinition(instance, this);
     }
     else
     {
         Log.Default.sendMessage("Cannot add SceneNodeDefinition {0} to SimSubScene {1} because it does not contain an OgreSceneManager.", LogLevel.Warning, OgreInterface.PluginName);
     }
 }
 public override void registerScene(SimSubScene subscene, SimObjectBase instance)
 {
     if (subscene.hasSimElementManagerType(typeof(BEPUikScene)))
     {
         BEPUikScene sceneManager = subscene.getSimElementManager <BEPUikScene>();
         sceneManager.IkFactory.addControl(this, instance);
     }
     else
     {
         Log.Default.sendMessage("Cannot add BEPUikDragControl {0} to SimSubScene {1} because it does not contain a BEPUikScene.", LogLevel.Warning, BEPUikInterface.PluginName, Name, subscene.Name);
     }
 }
Exemple #5
0
 public override void registerScene(SimSubScene subscene, SimObjectBase instance)
 {
     if (subscene.hasSimElementManagerType(typeof(BehaviorManager)))
     {
         BehaviorManager behaviorManager = subscene.getSimElementManager <BehaviorManager>();
         behaviorManager.getBehaviorFactory().addBehaviorDefinition(instance, this);
     }
     else
     {
         Log.Default.sendMessage("Cannot add BehaviorDefinition {0} to SimSubScene {1} because it does not contain a BehaviorManager.", LogLevel.Warning, "Behavior", Name, subscene.Name);
     }
 }
 public override void registerScene(SimSubScene subscene, SimObjectBase instance)
 {
     if (subscene.hasSimElementManagerType(typeof(BulletScene)))
     {
         BulletScene sceneManager = subscene.getSimElementManager <BulletScene>();
         sceneManager.getBulletFactory().addRigidBody(this, instance);
     }
     else
     {
         Log.Default.sendMessage("Cannot add RigidBodyDefinition {0} to SimSubScene {1} because it does not contain a BulletSceneManager.", LogLevel.Warning, BulletInterface.PluginName, Name, subscene.Name);
     }
 }
Exemple #7
0
        public void sceneUnloading(SimScene scene)
        {
            SimSubScene subScene = scene.getDefaultSubScene();

            if (subScene != null && manualObject != null)
            {
                OgreSceneManager sceneManager = subScene.getSimElementManager <OgreSceneManager>();
                sceneManager.SceneManager.getRootSceneNode().removeChild(sceneNode);
                sceneNode.detachObject(manualObject);
                sceneManager.SceneManager.destroyManualObject(manualObject);
                sceneManager.SceneManager.destroySceneNode(sceneNode);
                manualObject = null;
                sceneNode    = null;
            }
        }
 public void renderDebug(SimSubScene subScene)
 {
     if (enabled)
     {
         BEPUikScene sceneManager = subScene.getSimElementManager <BEPUikScene>();
         if (sceneManager != null)
         {
             sceneManager.drawDebug(drawingSurface, drawMode);
         }
     }
     else if (clearDebugSurface)
     {
         drawingSurface.clearAll();
         clearDebugSurface = false;
     }
 }
Exemple #9
0
        public void sceneLoaded(SimScene scene)
        {
            if (!activeSceneLights.ContainsKey(scene))
            {
                SimSubScene subScene = scene.getDefaultSubScene();

                if (subScene.hasSimElementManagerType(typeof(OgreSceneManager)))
                {
                    OgreSceneManager sceneManager = subScene.getSimElementManager <OgreSceneManager>();
                    Light            light        = sceneManager.SceneManager.createLight("CameraLight");
                    LightMover       lightMover   = new LightMover(light);
                    sceneManager.SceneManager.addSceneListener(lightMover);
                    activeSceneLights.Add(scene, lightMover);
                }
            }
        }
        internal void destroyCamera(SimScene scene)
        {
            if (cameraPositioner != null)
            {
                SimSubScene      defaultScene = scene.getDefaultSubScene();
                OgreSceneManager sceneManager = defaultScene.getSimElementManager <OgreSceneManager>();

                renderTexture.destroyViewport(vp);
                vp = null;

                node.detachObject(camera);
                sceneManager.SceneManager.destroyCamera(camera);
                sceneManager.SceneManager.destroySceneNode(node);
                cameraPositioner = null;
            }
        }
Exemple #11
0
 public void renderDebug(SimSubScene subScene)
 {
     if (enabled)
     {
         BehaviorManager manager = subScene.getSimElementManager <BehaviorManager>();
         if (manager != null)
         {
             manager.renderDebugInfo(drawingSurface);
         }
     }
     else if (clearSurface)
     {
         clearSurface = false;
         drawingSurface.clearAll();
     }
 }
Exemple #12
0
 public SceneView createSceneView(SimSubScene subScene, String name, Vector3 positon, Vector3 lookAt, int zIndex)
 {
     if (subScene.hasSimElementManagerType(typeof(OgreSceneManager)))
     {
         OgreSceneManager sceneManager = subScene.getSimElementManager <OgreSceneManager>();
         OgreSceneView    camControl   = new OgreSceneView(name, sceneManager, OgreRenderTarget, zIndex);
         camControl.Translation = positon;
         camControl.LookAt      = lookAt;
         return(camControl);
     }
     else
     {
         Log.Default.sendMessage("Cannot create a camera in the subscene {0} named {1} because the subscene has no OgreSceneManager.", LogLevel.Warning, OgreInterface.PluginName, subScene.Name, name);
         return(null);
     }
 }
Exemple #13
0
        public void sceneLoaded(SimScene scene)
        {
            SimSubScene subScene = scene.getDefaultSubScene();

            if (subScene != null)
            {
                OgreSceneManager sceneManager = subScene.getSimElementManager <OgreSceneManager>();
                manualObject = sceneManager.SceneManager.createManualObject(name + "__MeasurementManualObject");
                manualObject.setRenderQueueGroup(95);
                manualObject.RedrawRequired += manualObject_RedrawRequired;
                sceneNode = sceneManager.SceneManager.createSceneNode(name + "__MeasurementManualObjectSceneNode");
                sceneNode.attachObject(manualObject);
                sceneNode.setVisible(visible);
                sceneNode.setPosition(origin);
                sceneManager.SceneManager.getRootSceneNode().addChild(sceneNode);
                redraw();
            }
        }
Exemple #14
0
        public void sceneUnloading(SimScene scene)
        {
            if (scene != null && activeSceneLights.ContainsKey(scene))
            {
                SimSubScene subScene = scene.getDefaultSubScene();

                if (subScene.hasSimElementManagerType(typeof(OgreSceneManager)))
                {
                    LightMover lightMover = activeSceneLights[scene];

                    OgreSceneManager sceneManager = subScene.getSimElementManager <OgreSceneManager>();
                    sceneManager.SceneManager.destroyLight(lightMover.Light);
                    sceneManager.SceneManager.removeSceneListener(lightMover);

                    activeSceneLights.Remove(scene);
                }
            }
        }
        internal void createCamera(SimScene scene, FeedbackCameraPositioner cameraPositioner)
        {
            this.cameraPositioner = cameraPositioner;
            SimSubScene      defaultScene = scene.getDefaultSubScene();
            OgreSceneManager sceneManager = defaultScene.getSimElementManager <OgreSceneManager>();

            camera = sceneManager.SceneManager.createCamera("VirtualTexturing.FeedbackBufferCamera" + id);
            camera.setNearClipDistance(1.0f);
            camera.setAutoAspectRatio(true);
            camera.setFOVy(new Degree(10.0f));
            node = sceneManager.SceneManager.createSceneNode("VirtualTexturing.FeedbackBufferCameraNode" + id);
            node.attachObject(camera);

            vp = renderTexture.addViewport(camera);
            vp.setMaterialScheme(Scheme);
            vp.setVisibilityMask(visibilityMask);
            vp.setBackgroundColor(new Engine.Color(0.0f, 0.0f, 0.0f, 1.0f));
            vp.clear();
        }
 /// <summary>
 /// Create a new DebugDrawingSurface named name in the specified scene
 /// that renders in the specified way.
 /// </summary>
 /// <param name="name">The name of the DrawingSurface. Must be unique.</param>
 /// <param name="sceneName">The name of the scene to create the surface into.</param>
 /// <param name="drawingType">The DrawingType of the surface.</param>
 /// <returns>A new DebugDrawingSurface configured appropriatly.</returns>
 public DebugDrawingSurface createDebugDrawingSurface(String name, SimSubScene scene)
 {
     if (scene != null)
     {
         if (scene.hasSimElementManagerType(typeof(OgreSceneManager)))
         {
             return(new OgreDebugSurface(name, scene.getSimElementManager <OgreSceneManager>().SceneManager));
         }
         else
         {
             Log.Default.sendMessage("Could not find an OgreSceneManager in the SimSubScene {0}. Could not create OgreDebugSurface.", LogLevel.Error, PluginName, scene.Name);
             return(null);
         }
     }
     else
     {
         Log.Default.sendMessage("Could not create OgreDebugSurface. SimSubScene was null.", LogLevel.Error, PluginName);
         return(null);
     }
 }