protected override void Initialize() { // must be initialized. required by Content loading and rendering (will add itself to the Services) // note that MonoGame requires this to be initialized in the constructor, while WpfInterop requires it to // be called inside Initialize (before base.Initialize()) graphicsDeviceManager = new WpfGraphicsDeviceService(this); // must be called after the WpfGraphicsDeviceService instance was created base.Initialize(); // Create a spritebatch for drawing sprites spriteBatch = new SpriteBatch(GraphicsDevice); //graphicsDeviceManager.PreferMultiSampling = false; //graphicsDeviceManager.ApplyChanges(); // wpf and keyboard need reference to the host control in order to receive input // this means every WpfGame control will have it's own keyboard & mouse manager which will only react if the mouse is in the control keyboard = new WpfKeyboard(this); mouse = new WpfMouse(this); spriteFrames = new List <Texture2D>(); Texture2D tex = new Texture2D(GraphicsDevice, 1, 1); tex.SetData(new Color[] { Color.Red }); texRectangle = new TextureSprite(tex); tex = new Texture2D(GraphicsDevice, 1, 1); tex.SetData(new Color[] { Color.LightBlue }); texPixel = new TextureSprite(tex); // content loading now possible }
public WpfKeyboardListener(WpfGame game, WpfKeyboardListenerSettings settings) { this.RepeatPress = settings.RepeatPress; this.InitialDelay = settings.InitialDelayMilliseconds; this.RepeatDelay = settings.RepeatDelayMilliseconds; _keyboard = new WpfKeyboard(game); }
protected override void Initialize() { SizeChanged += Game_SizeChanged; // must be initialized. required by Content loading and rendering (will add itself to the Services) _graphicsDeviceManager = new WpfGraphicsDeviceService(this); // wpf and keyboard need reference to the host control in order to receive input // this means every WpfGame control will have it's own keyboard & mouse manager which will only react if the mouse is in the control _keyboard = new WpfKeyboard(this); _mouse = new WpfMouse(this); // must be called after the WpfGraphicsDeviceService instance was created base.Initialize(); // content loading now possible Global.GraphicsDevice = GraphicsDevice; //Global.GraphicsDeviceManager = GraphicsDeviceManager; Global.SpriteBatch = new Microsoft.Xna.Framework.Graphics.SpriteBatch(GraphicsDevice); Global.FontDefault = Global.LoadFont("Fonts\\Cheepicus12.font").GetFont(Font.FontSizes.One); var con = new SadConsole.Console(10, 10); Global.CurrentScreen = con; con.FillWithRandomGarbage(); }
public static void Init(MainGame game) { wpfKey = new WpfKeyboard(game); wpfMouse = new WpfMouse(game) { CaptureMouseWithin = false }; }
public void Update(WpfKeyboard keyboard, WpfMouse mouse) { PreviousKeyboardState = CurrentKeyboardState; CurrentKeyboardState = keyboard.GetState(); KeyboardStateExtended = new KeyboardStateExtended(CurrentKeyboardState, PreviousKeyboardState); PreviousMouseState = CurrentMouseState; CurrentMouseState = mouse.GetState(); MouseStateExtended = new MouseStateExtended(CurrentMouseState, PreviousMouseState); }
public GameViewPort() { Graphics = new WpfGraphicsDeviceService(this); Content.RootDirectory = "Content"; _keyboard = new WpfKeyboard(this); _mouse = new WpfMouse(this); // must be called after the WpfGraphicsDeviceService instance was created base.Initialize(); }
public void Init() { InitParticle(); CreateProjection(); Keyboard = GameView.Instance._keyboard; Mouse = GameView.Instance._mouse; //SetMouse(); }
protected override void Initialize() { this._graphicsDeviceManager = new WpfGraphicsDeviceService(this); this.SpriteBatch = new SpriteBatch(this.GraphicsDevice); this._keyboard = new WpfKeyboard(this); this._mouse = new WpfMouse(this); this.InitializeComponents(); base.Initialize(); this._isInitialized = true; }
public MapRenderComponent(WpfGame game) : base(game) { _keyboard = new WpfKeyboard(game); _mouse = new WpfMouse(game) { CaptureMouseWithin = false }; _input = new InputModel(); }
protected override void Initialize() { _graphicsDeviceService = new WpfGraphicsDeviceService(this); camera = new Camera2D(GraphicsDevice); keyboard = new WpfKeyboard(this); mouse = new WpfMouse(this); base.Initialize(); Content.RootDirectory = "Content"; spriteBatch = new SpriteBatch(GraphicsDevice); texture = Content.Load <Texture2D>("10000"); }
protected override void Initialize() { _deviceSrv = new WpfGraphicsDeviceService(this); _mouse = new WpfMouse(this); _keyboard = new WpfKeyboard(this); _sbatch = new SpriteBatch(GraphicsDevice); _map = new MapControl(_sbatch, GraphicsDevice, GraphicsDevice.Viewport.Bounds.ToMapRectangle()); base.Initialize(); DisplayInitialized?.Invoke(this); }
protected override void Initialize() { _disposed = false; _graphicsDeviceService = new WpfGraphicsDeviceService(this) { PreferMultiSampling = true }; Components.Add(new FpsComponent(this)); Components.Add(new TimingComponent(this)); _msaaMessage = new TextComponent(this, GetMsaaMessage(), new Vector2(1, 0), HorizontalAlignment.Right); Components.Add(_msaaMessage); float tilt = MathHelper.ToRadians(0); // 0 degree angle // Use the world matrix to tilt the cube along x and y axes. _worldMatrix = Matrix.CreateRotationX(tilt) * Matrix.CreateRotationY(tilt); _viewMatrix = Matrix.CreateLookAt(new Vector3(25, 25, 25), Vector3.Zero, Vector3.Up); _basicEffect = new BasicEffect(GraphicsDevice); _basicEffect.World = _worldMatrix; _basicEffect.View = _viewMatrix; RefreshProjection(); // primitive color _basicEffect.AmbientLightColor = new Vector3(0.1f, 0.1f, 0.1f); _basicEffect.DiffuseColor = new Vector3(1.0f, 1.0f, 1.0f); _basicEffect.SpecularColor = new Vector3(0.25f, 0.25f, 0.25f); _basicEffect.SpecularPower = 5.0f; _basicEffect.Alpha = 1.0f; // get a bunch of white cubes _basicEffect.LightingEnabled = false; _filled = new RasterizerState { CullMode = CullMode.None, FillMode = FillMode.Solid }; _wireframe = new RasterizerState { CullMode = CullMode.None, FillMode = FillMode.WireFrame }; SetupCube(); _keyboard = new WpfKeyboard(this); base.Initialize(); }
protected override void Initialize() { base.Initialize(); // must be initialized. required by Content loading and rendering (will add itself to the Services) _graphicsDeviceManager = new WpfGraphicsDeviceService(this); // wpf and keyboard need reference to the host control in order to receive input // this means every WpfGame control will have it's own keyboard & mouse manager which will only react if the mouse is in the control _keyboard = new WpfKeyboard(this); _mouse = new WpfMouse(this); _terrainScene = new TerrainScene(_graphicsDeviceManager, Content); }
protected override void Initialize() { // must be initialized. required by Content loading and rendering (will add itself to the Services) graphicsDeviceManager = new WpfGraphicsDeviceService(this); // wpf and keyboard need reference to the host control in order to receive input // this means every WpfGame control will have it's own keyboard & mouse manager which will only react if the mouse is in the control keyboard = new WpfKeyboard(this); mouse = new WpfMouse(this); showGround = false; // must be called after the WpfGraphicsDeviceService instance was created base.Initialize(); // content loading now possible }
protected override void Initialize() { // must be initialized. required by Content loading and rendering (will add itself to the Services) // note that MonoGame requires this to be initialized in the constructor, while WpfInterop requires it to // be called inside Initialize (before base.Initialize()) _graphicsDeviceManager = new WpfGraphicsDeviceService(this); // wpf and keyboard need reference to the host control in order to receive input // this means every WpfGame control will have it's own keyboard & mouse manager which will only react if the mouse is in the control _keyboard = new WpfKeyboard(this); _mouse = new WpfMouse(this); // must be called after the WpfGraphicsDeviceService instance was created base.Initialize(); // content loading now possible }
public void Init() { var dist = 10.0f; Position = new Vector3(dist, dist, 1); Dir = Vector3.Normalize(new Vector3(-dist, -dist, 0)); Up = Vector3.UnitZ; CreateLookAt(); CreateProjection(); KeyboardState = new WpfKeyboard(Game); MouseState = new WpfMouse(Game); //SetMouse(); }
protected override void Initialize() { new WpfGraphicsDeviceService(this); base.Initialize(); _keyboard = new WpfKeyboard(this); _mouse = new WpfMouse(this); // default font is pre-compiled font for Windows (Arial 12, ? as default char) // I get away with this because // 1) it's just a demo application // 2) it can only run on windows/directX anyway (interop for WPF afterall) // 3) This means it doesn't require content compiler to be installed on any machine that runs this demo _font = Content.Load <SpriteFont>("DefaultFont"); _spriteBatch = new SpriteBatch(GraphicsDevice); }
protected override void Initialize() { TargetElapsedTime = TimeSpan.FromSeconds(1.0f / 60.0f); _graphicsDeviceManager = new WpfGraphicsDeviceService(this); _basicEffect = new BasicEffect(GraphicsDevice); _keyboard = new WpfKeyboard(this); _mouse = new WpfMouse(this); _gameScope = _parentScope.BeginLifetimeScope(gameScopeBuilder => { var assembly = Assembly.GetExecutingAssembly(); gameScopeBuilder.RegisterAssemblyTypes(assembly) .As <ISystem>() .AsSelf() .SingleInstance() .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies); gameScopeBuilder.RegisterType <SystemManager>() .AsSelf() .SingleInstance() .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies); gameScopeBuilder.RegisterType <InputManager>() .AsSelf() .SingleInstance() .PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies); gameScopeBuilder.RegisterInstance(GraphicsDevice).AsSelf().SingleInstance(); gameScopeBuilder.RegisterInstance(_basicEffect).AsSelf().SingleInstance(); gameScopeBuilder.RegisterInstance(_keyboard).AsSelf().SingleInstance(); gameScopeBuilder.RegisterInstance(_mouse).AsSelf().SingleInstance(); gameScopeBuilder.RegisterInstance(this).AsSelf().SingleInstance(); }); _systemManager = _gameScope.Resolve <SystemManager>(); _systemManager.Initialize(); base.Initialize(); }
protected override void Initialize() { Components.Add(new DebugInfo(this)); _graphics = new WpfGraphicsDeviceService(this); SprBatch = new SpriteBatch(_graphics.GraphicsDevice); _keyboard = new WpfKeyboard(this); _mouse = new WpfMouse(this); World = new Map(_generator); _spawners = new List <Spawner>(); //Win.AddSlider("Scale", 1, 100, 70); //Win.AddSlider("Octaves", 1, 8, 4); //Win.AddSlider("Persistance", 0.1, 2.0, 0.3); //Win.AddSlider("Lacunarity", 1, 10, 3); //Win.AddSlider("NoiseHeight", 0, 2, 1); Win.AddSlider("UpdatePerFrame", -100, 1000, 1); //Reset(); base.Initialize(); }
protected override void Initialize() { // must be initialized. required by Content loading and rendering(will add itself to the Services) // note that MonoGame requires this to be initialized in the constructor, while WpfInterop requires it to // be called inside Initialize (before base.Initialize()) _graphicsDeviceManager = new WpfGraphicsDeviceService(this) { DpiScalingFactor = 1, PreferMultiSampling = true }; // wpf and keyboard need reference to the host control in order to receive input // this means every WpfGame control will have it's own keyboard & mouse manager which will only react if the mouse is in the control _keyboard = new WpfKeyboard(this); _mouse = new WpfMouse(this); // must be called after the WpfGraphicsDeviceService instance was created base.Initialize(); UpdateUniforms(0); VertexBuffer = new VertexBuffer(GraphicsDevice, VertexPositionColorTexture.VertexDeclaration, 4, BufferUsage.None); IndexBuffer = new IndexBuffer(GraphicsDevice, IndexElementSize.ThirtyTwoBits, 6, BufferUsage.None); var vertices = new VertexPositionColorTexture[4]; vertices[0] = new VertexPositionColorTexture(new Vector3(-1, -1, 0), Color.White, new Vector2(0, 1)); vertices[1] = new VertexPositionColorTexture(new Vector3(1, 1, 0), Color.White, new Vector2(1, 0)); vertices[2] = new VertexPositionColorTexture(new Vector3(-1, 1, 0), Color.White, new Vector2(0, 0)); vertices[3] = new VertexPositionColorTexture(new Vector3(1, -1, 0), Color.White, new Vector2(1, 1)); var indices = new int[] { 0, 2, 1, 0, 3, 1 }; VertexBuffer.SetData(vertices); IndexBuffer.SetData(indices); Channel0 = new Channel(Texture2D.FromStream(GraphicsDevice, File.OpenRead("assets/textures/test.png")), TextureType.Texture2D); if (CompileShader(out var error)) { var shaderbinary = File.ReadAllBytes($"temp/tempshader.dx11"); Shader = new Effect(GraphicsDevice, shaderbinary); SetUniforms(Shader); } }
protected override void Initialize() { // must be initialized. required by Content loading and rendering (will add itself to the Services) _graphicsDeviceManager = new WpfGraphicsDeviceService(this); // wpf and keyboard need reference to the host control in order to receive input // this means every WpfGame control will have it's own keyboard & mouse manager which will only react if the mouse is in the control _keyboard = new WpfKeyboard(this); _mouse = new WpfMouse(this); _spriteBatch = new SpriteBatch(GraphicsDevice); GameManager.SetupDevice(_graphicsDeviceManager.GraphicsDevice, Content, _spriteBatch); _fusionEngineASM = Assembly.LoadFrom("./FusionEngine.dll"); _entities = new ConcurrentDictionary <string, Entity>(); _hasSelected = false; Position.X = 400; Position.Y = 200; // must be called after the WpfGraphicsDeviceService instance was created base.Initialize(); }
public Keyboard(WpfGame game) { WpfKeyboard = new WpfKeyboard(game); }
public void Register(EditorGame game) { _mouse = new WpfMouse(game); _keyboard = new WpfKeyboard(game); }
public void Update(WpfKeyboard keyboard) { PreviousKeyboardState = CurrentKeyboardState; CurrentKeyboardState = keyboard.GetState(); KeyboardStateExtended = new KeyboardStateExtended(CurrentKeyboardState, PreviousKeyboardState); }
public WpfInputStates(UIElement uiElement) { _keyboard = new WpfKeyboard(uiElement); _mouse = new WpfMouse(uiElement); }
protected override void Initialize() { _disposed = false; new WpfGraphicsDeviceService(this); Components.Add(new FpsComponent(this)); Components.Add(new TimingComponent(this)); Components.Add(new TextComponent(this, "Leftclick anywhere in the game to change background color", new Vector2(1, 0), HorizontalAlignment.Right)); float tilt = MathHelper.ToRadians(0); // 0 degree angle // Use the world matrix to tilt the cube along x and y axes. _worldMatrix = Matrix.CreateRotationX(tilt) * Matrix.CreateRotationY(tilt); _viewMatrix = Matrix.CreateLookAt(new Vector3(5, 5, 5), Vector3.Zero, Vector3.Up); _basicEffect = new BasicEffect(GraphicsDevice); _basicEffect.World = _worldMatrix; _basicEffect.View = _viewMatrix; RefreshProjection(); // primitive color _basicEffect.AmbientLightColor = new Vector3(0.1f, 0.1f, 0.1f); _basicEffect.DiffuseColor = new Vector3(1.0f, 1.0f, 1.0f); _basicEffect.SpecularColor = new Vector3(0.25f, 0.25f, 0.25f); _basicEffect.SpecularPower = 5.0f; _basicEffect.Alpha = 1.0f; _basicEffect.LightingEnabled = true; if (_basicEffect.LightingEnabled) { _basicEffect.DirectionalLight0.Enabled = true; // enable each light individually if (_basicEffect.DirectionalLight0.Enabled) { // x direction _basicEffect.DirectionalLight0.DiffuseColor = new Vector3(1, 0, 0); // range is 0 to 1 _basicEffect.DirectionalLight0.Direction = Vector3.Normalize(new Vector3(-1, 0, 0)); // points from the light to the origin of the scene _basicEffect.DirectionalLight0.SpecularColor = Vector3.One; } _basicEffect.DirectionalLight1.Enabled = true; if (_basicEffect.DirectionalLight1.Enabled) { // y direction _basicEffect.DirectionalLight1.DiffuseColor = new Vector3(0, 0.75f, 0); _basicEffect.DirectionalLight1.Direction = Vector3.Normalize(new Vector3(0, -1, 0)); _basicEffect.DirectionalLight1.SpecularColor = Vector3.One; } _basicEffect.DirectionalLight2.Enabled = true; if (_basicEffect.DirectionalLight2.Enabled) { // z direction _basicEffect.DirectionalLight2.DiffuseColor = new Vector3(0, 0, 0.5f); _basicEffect.DirectionalLight2.Direction = Vector3.Normalize(new Vector3(0, 0, -1)); _basicEffect.DirectionalLight2.SpecularColor = Vector3.One; } } _vertexDeclaration = new VertexDeclaration( new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0), new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0) ); Vector3 topLeftFront = new Vector3(-1.0f, 1.0f, 1.0f); Vector3 bottomLeftFront = new Vector3(-1.0f, -1.0f, 1.0f); Vector3 topRightFront = new Vector3(1.0f, 1.0f, 1.0f); Vector3 bottomRightFront = new Vector3(1.0f, -1.0f, 1.0f); Vector3 topLeftBack = new Vector3(-1.0f, 1.0f, -1.0f); Vector3 topRightBack = new Vector3(1.0f, 1.0f, -1.0f); Vector3 bottomLeftBack = new Vector3(-1.0f, -1.0f, -1.0f); Vector3 bottomRightBack = new Vector3(1.0f, -1.0f, -1.0f); Vector2 textureTopLeft = new Vector2(0.0f, 0.0f); Vector2 textureTopRight = new Vector2(1.0f, 0.0f); Vector2 textureBottomLeft = new Vector2(0.0f, 1.0f); Vector2 textureBottomRight = new Vector2(1.0f, 1.0f); Vector3 frontNormal = new Vector3(0.0f, 0.0f, 1.0f); Vector3 backNormal = new Vector3(0.0f, 0.0f, -1.0f); Vector3 topNormal = new Vector3(0.0f, 1.0f, 0.0f); Vector3 bottomNormal = new Vector3(0.0f, -1.0f, 0.0f); Vector3 leftNormal = new Vector3(-1.0f, 0.0f, 0.0f); Vector3 rightNormal = new Vector3(1.0f, 0.0f, 0.0f); var cubeVertices = new VertexPositionNormalTexture[36]; // Front face. cubeVertices[0] = new VertexPositionNormalTexture(topLeftFront, frontNormal, textureTopLeft); cubeVertices[1] = new VertexPositionNormalTexture(bottomLeftFront, frontNormal, textureBottomLeft); cubeVertices[2] = new VertexPositionNormalTexture(topRightFront, frontNormal, textureTopRight); cubeVertices[3] = new VertexPositionNormalTexture(bottomLeftFront, frontNormal, textureBottomLeft); cubeVertices[4] = new VertexPositionNormalTexture(bottomRightFront, frontNormal, textureBottomRight); cubeVertices[5] = new VertexPositionNormalTexture(topRightFront, frontNormal, textureTopRight); // Back face. cubeVertices[6] = new VertexPositionNormalTexture(topLeftBack, backNormal, textureTopRight); cubeVertices[7] = new VertexPositionNormalTexture(topRightBack, backNormal, textureTopLeft); cubeVertices[8] = new VertexPositionNormalTexture(bottomLeftBack, backNormal, textureBottomRight); cubeVertices[9] = new VertexPositionNormalTexture(bottomLeftBack, backNormal, textureBottomRight); cubeVertices[10] = new VertexPositionNormalTexture(topRightBack, backNormal, textureTopLeft); cubeVertices[11] = new VertexPositionNormalTexture(bottomRightBack, backNormal, textureBottomLeft); // Top face. cubeVertices[12] = new VertexPositionNormalTexture(topLeftFront, topNormal, textureBottomLeft); cubeVertices[13] = new VertexPositionNormalTexture(topRightBack, topNormal, textureTopRight); cubeVertices[14] = new VertexPositionNormalTexture(topLeftBack, topNormal, textureTopLeft); cubeVertices[15] = new VertexPositionNormalTexture(topLeftFront, topNormal, textureBottomLeft); cubeVertices[16] = new VertexPositionNormalTexture(topRightFront, topNormal, textureBottomRight); cubeVertices[17] = new VertexPositionNormalTexture(topRightBack, topNormal, textureTopRight); // Bottom face. cubeVertices[18] = new VertexPositionNormalTexture(bottomLeftFront, bottomNormal, textureTopLeft); cubeVertices[19] = new VertexPositionNormalTexture(bottomLeftBack, bottomNormal, textureBottomLeft); cubeVertices[20] = new VertexPositionNormalTexture(bottomRightBack, bottomNormal, textureBottomRight); cubeVertices[21] = new VertexPositionNormalTexture(bottomLeftFront, bottomNormal, textureTopLeft); cubeVertices[22] = new VertexPositionNormalTexture(bottomRightBack, bottomNormal, textureBottomRight); cubeVertices[23] = new VertexPositionNormalTexture(bottomRightFront, bottomNormal, textureTopRight); // Left face. cubeVertices[24] = new VertexPositionNormalTexture(topLeftFront, leftNormal, textureTopRight); cubeVertices[25] = new VertexPositionNormalTexture(bottomLeftBack, leftNormal, textureBottomLeft); cubeVertices[26] = new VertexPositionNormalTexture(bottomLeftFront, leftNormal, textureBottomRight); cubeVertices[27] = new VertexPositionNormalTexture(topLeftBack, leftNormal, textureTopLeft); cubeVertices[28] = new VertexPositionNormalTexture(bottomLeftBack, leftNormal, textureBottomLeft); cubeVertices[29] = new VertexPositionNormalTexture(topLeftFront, leftNormal, textureTopRight); // Right face. cubeVertices[30] = new VertexPositionNormalTexture(topRightFront, rightNormal, textureTopLeft); cubeVertices[31] = new VertexPositionNormalTexture(bottomRightFront, rightNormal, textureBottomLeft); cubeVertices[32] = new VertexPositionNormalTexture(bottomRightBack, rightNormal, textureBottomRight); cubeVertices[33] = new VertexPositionNormalTexture(topRightBack, rightNormal, textureTopRight); cubeVertices[34] = new VertexPositionNormalTexture(topRightFront, rightNormal, textureTopLeft); cubeVertices[35] = new VertexPositionNormalTexture(bottomRightBack, rightNormal, textureBottomRight); _vertexBuffer = new VertexBuffer(GraphicsDevice, _vertexDeclaration, cubeVertices.Length, BufferUsage.None); _vertexBuffer.SetData(cubeVertices); _keyboard = new WpfKeyboard(this); _mouse = new WpfMouse(this); base.Initialize(); }
public ToolsetInputService(ToolsetGame game) { _mouse = new WpfMouse(game); _keyboard = new WpfKeyboard(game); }
public Keyboard(WpfGame wpfGame) { _keyboard = new WpfKeyboard(wpfGame); }
public KeyboardComponent(WpfGame game) : base(game) { _wpfKeyboard = new WpfKeyboard(Game); UpdateOrder = (int)ComponentUpdateOrderEnum.Input; }