private void Render(RenderContext context) { context.CameraNode = _cameraObject.CameraNode; var graphicsDevice = context.GraphicsService.GraphicsDevice; graphicsDevice.Clear(Color.White); // Find all objects within camera frustum. var query = Scene.Query <CameraFrustumQuery>(_cameraObject.CameraNode, context); // Draw figure nodes. graphicsDevice.DepthStencilState = DepthStencilState.DepthRead; graphicsDevice.BlendState = BlendState.AlphaBlend; FigureRenderer.Render(query.SceneNodes, context, RenderOrder.BackToFront); UIScreen.Draw(context.DeltaTime); // Draw debug information. DebugRenderer.Render(context); context.CameraNode = null; }
public EditorBase(Microsoft.Xna.Framework.Game game) : base(game) { // Get services from the global service container. var services = (ServiceContainer)ServiceLocator.Current; UIContentManager = services.GetInstance<ContentManager>("UIContent"); InputService = services.GetInstance<IInputService>(); AnimationService = services.GetInstance<IAnimationService>(); GraphicsService = services.GetInstance<IGraphicsService>(); GameObjectService = services.GetInstance<IGameObjectService>(); UIService = services.GetInstance<IUIService>(); // Create a local service container which can be modified in samples: // The local service container is a child container, i.e. it inherits the // services of the global service container. Samples can add new services // or override existing entries without affecting the global services container // or other samples. Services = services.CreateChildContainer(); // Load a UI theme, which defines the appearance and default values of UI controls. Theme theme = UIContentManager.Load<Theme>("BlendBlue/Theme"); FigureRenderer = new FigureRenderer(GraphicsService, 2000); DebugRenderer = new DebugRenderer(GraphicsService, UIContentManager.Load<SpriteFont>("BlendBlue/Default")); UIRenderer = new UIRenderer(GraphicsService.GraphicsDevice, theme); UIScreen = new UIScreen("Main Screen", UIRenderer) { Background = Color.TransparentBlack, }; UIService.Screens.Add(UIScreen); Scene = new Scene(); }
private void SyncMaterialSet() { string materialSetName = model.MaterialSet.Label; var newRenderer = figureRendererLoader.Load(definition.Directory, materialSetName); renderer?.Dispose(); renderer = newRenderer; }
private void SyncMaterialSet() { if (model.MaterialSetAndVariant != currentMaterialSetAndVariant) { var newRenderer = figureRendererLoader.Load(definition.Directory, model.MaterialSetAndVariant); renderer?.Dispose(); renderer = newRenderer; currentMaterialSetAndVariant = model.MaterialSetAndVariant; } }
public FigureSample(Microsoft.Xna.Framework.Game game) : base(game) { _delegateGraphicsScreen = new DelegateGraphicsScreen(GraphicsService) { RenderCallback = Render, }; GraphicsService.Screens.Insert(0, _delegateGraphicsScreen); // Add a custom game object which controls the camera. _cameraObject = new CameraObject(Services); GameObjectService.Objects.Add(_cameraObject); var spriteFont = UIContentManager.Load <SpriteFont>("Default"); var spriteBatch = new SpriteBatch(GraphicsService.GraphicsDevice); _figureRenderer = new FigureRenderer(GraphicsService, 2048); _spriteRenderer = new SpriteRenderer(GraphicsService, spriteBatch, spriteFont); _debugRenderer = new DebugRenderer(GraphicsService, spriteBatch, spriteFont) { DefaultColor = Color.Black, DefaultTextPosition = new Vector2F(20, 40) }; _scene = new Scene(); // To draw figures, they are flattened (= converted to line segments) // internally. Figure.Tolerance defines the allowed error between the // smooth and the flattened curve. Figure.Tolerance = 0.0001f; // Add some FigureNodes to the scene. CreateGrid(); CreateGridClone(); CreateRandomPath(); CreateRectangles(); CreateEllipses(); CreateAlphaBlendedFigures(); CreateChain(); CreateGizmo(spriteFont); CreateFlower(); // Add a game object which handles the picking: _figurePickerObject = new FigurePickerObject(GraphicsService, _scene, _cameraObject, _debugRenderer); GameObjectService.Objects.Add(_figurePickerObject); }
public FigureSample(Microsoft.Xna.Framework.Game game) : base(game) { SampleFramework.IsMouseVisible = false; var delegateGraphicsScreen = new DelegateGraphicsScreen(GraphicsService) { RenderCallback = Render, }; GraphicsService.Screens.Insert(0, delegateGraphicsScreen); // Add a custom game object which controls the camera. _cameraObject = new CameraObject(Services); GameObjectService.Objects.Add(_cameraObject); var spriteFont = UIContentManager.Load<SpriteFont>("UI Themes/BlendBlue/Default"); _figureRenderer = new FigureRenderer(GraphicsService, 2048); _spriteRenderer = new SpriteRenderer(GraphicsService, spriteFont); _debugRenderer = new DebugRenderer(GraphicsService, spriteFont) { DefaultColor = Color.Black, DefaultTextPosition = new Vector2F(20, 40) }; _scene = new Scene(); // To draw figures, they are flattened (= converted to line segments) // internally. Figure.Tolerance defines the allowed error between the // smooth and the flattened curve. Figure.Tolerance = 0.0001f; // Add some FigureNodes to the scene. CreateGrid(); CreateGridClone(); CreateRandomPath(); CreateRectangles(); CreateEllipses(); CreateAlphaBlendedFigures(); CreateChain(); CreateGizmo(spriteFont); CreateFlower(); // Add a game object which handles the picking: GameObjectService.Objects.Add(new FigurePickerObject(GraphicsService, _scene, _cameraObject, _debugRenderer)); }
public EditorBase(Microsoft.Xna.Framework.Game game) : base(game) { // Get services from the global service container. var services = (ServiceContainer)ServiceLocator.Current; UIContentManager = services.GetInstance <ContentManager>("UIContent"); InputService = services.GetInstance <IInputService>(); AnimationService = services.GetInstance <IAnimationService>(); GraphicsService = services.GetInstance <IGraphicsService>(); GameObjectService = services.GetInstance <IGameObjectService>(); UIService = services.GetInstance <IUIService>(); // Create a local service container which can be modified in samples: // The local service container is a child container, i.e. it inherits the // services of the global service container. Samples can add new services // or override existing entries without affecting the global services container // or other samples. Services = services.CreateChildContainer(); // Load a UI theme, which defines the appearance and default values of UI controls. Theme theme = UIContentManager.Load <Theme>("BlendBlue/Theme"); FigureRenderer = new FigureRenderer(GraphicsService, 2000); DebugRenderer = new DebugRenderer(GraphicsService, UIContentManager.Load <SpriteFont>("BlendBlue/Default")); UIRenderer = new UIRenderer(GraphicsService.GraphicsDevice, theme); UIScreen = new UIScreen("Main Screen", UIRenderer) { Background = Color.TransparentBlack, }; UIService.Screens.Add(UIScreen); Scene = new Scene(); }