示例#1
0
        internal void RenderColliderShapes(bool enabled)
        {
            colliderShapesRendering = enabled;

            if (!colliderShapesRendering)
            {
                var mainCompositor = (SceneGraphicsCompositorLayers)sceneSystem.SceneInstance.Scene.Settings.GraphicsCompositor;
                var scene          = debugEntityScene.Get <ChildSceneComponent>().Scene;

                foreach (var element in elements)
                {
                    element.RemoveDebugEntity(scene);
                }

                sceneSystem.SceneInstance.Scene.Entities.Remove(debugEntityScene);
                mainCompositor.Master.Renderers.Remove(debugSceneRenderer);
            }
            else
            {
                //we create a child scene to render the shapes, so that they are totally separated from the normal scene
                var mainCompositor = (SceneGraphicsCompositorLayers)sceneSystem.SceneInstance.Scene.Settings.GraphicsCompositor;

                var graphicsCompositor = new SceneGraphicsCompositorLayers
                {
                    Cameras = { mainCompositor.Cameras[0] },
                    Master  =
                    {
                        Renderers        =
                        {
                            new SceneCameraRenderer {
                                Mode     = new PhysicsDebugCameraRendererMode{
                                    Name = "Camera renderer"
                                }
                            },
                        }
                    }
                };

                debugScene = new Scene {
                    Settings = { GraphicsCompositor = graphicsCompositor }
                };

                var childComponent = new ChildSceneComponent {
                    Scene = debugScene
                };
                debugEntityScene = new Entity {
                    childComponent
                };
                debugSceneRenderer = new SceneChildRenderer(childComponent);

                mainCompositor.Master.Add(debugSceneRenderer);
                sceneSystem.SceneInstance.Scene.Entities.Add(debugEntityScene);

                foreach (var element in elements)
                {
                    element.AddDebugEntity(debugScene);
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChildSceneComponentChangedEventArgs"/> struct.
 /// </summary>
 /// <param name="component">The child component.</param>
 /// <param name="previousScene">The previous scene.</param>
 /// <param name="newScene">The new scene.</param>
 public ChildSceneComponentChangedEventArgs(ChildSceneComponent component, Scene previousScene, Scene newScene)
 {
     Component = component;
     PreviousScene = previousScene;
     NewScene = newScene;
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChildSceneComponentChangedEventArgs"/> struct.
 /// </summary>
 /// <param name="component">The child component.</param>
 /// <param name="previousScene">The previous scene.</param>
 /// <param name="newScene">The new scene.</param>
 public ChildSceneComponentChangedEventArgs(ChildSceneComponent component, Scene previousScene, Scene newScene)
 {
     Component     = component;
     PreviousScene = previousScene;
     NewScene      = newScene;
 }