Abstract class which allows input to be read from various controllers.
Temporary implementation only. This class is likely to be refactored into a better design when I get time to look at it properly. For now it's a quick-and-dirty way to get what I need.
상속: IDisposable
 /// <summary>
 ///	Creates an InputReader implemented using Silverlight.
 /// </summary>
 /// <returns></returns>
 public InputReader CreateInputReader()
 {
     if ( inputReader == null )
     {
         inputReader = new SilverlightInputReader();
     }
     return inputReader;
 }
예제 #2
0
		public void Dispose()
		{
			if ( inputReader != null )
			{
				inputReader.Dispose();
				inputReader = null;
			}
			LogManager.Instance.Write( "OpenTK Platform Manager Shutdown." );
		}
예제 #3
0
파일: Input.cs 프로젝트: vvnurmi/MOOLGOSS
 public Input()
 {
     _input = new Axiom.Platforms.Win32.Win32InputReader();
     var maxKeyCode = (int)Enum.GetValues(typeof(KeyCodes)).Cast<KeyCodes>().Max();
     _previousKeyStates = new bool[maxKeyCode];
     _currentKeyStates = new bool[maxKeyCode];
     var maxMouseCode = (int)Enum.GetValues(typeof(MouseButtons)).Cast<MouseButtons>().Max();
     _previousMouseStates = new bool[maxMouseCode + 1];
     _currentMouseStates = new bool[maxMouseCode + 1];
 }
예제 #4
0
		/// <summary>
		///		Creates an InputReader implemented using Microsoft DirectInput (tm).
		/// </summary>
		/// <returns></returns>
		public InputReader CreateInputReader()
		{
			if ( inputReader == null )
				inputReader = new Win32InputReader();
			return inputReader;
		}
 /// <summary>
 ///		Creates an InputReader implemented using Microsoft DirectInput (tm).
 /// </summary>
 /// <returns></returns>
 public Axiom.Input.InputReader CreateInputReader()
 {
     inputReader = new SdlInputReader();
     return inputReader;
 }
예제 #6
0
		public virtual bool Setup()
		{
			// instantiate the Root singleton
			//engine = new Root( "AxiomEngine.log" );
			engine = Root.Instance;

			// add event handlers for frame events
			engine.FrameStarted += OnFrameStarted;
			engine.FrameRenderingQueued += OnFrameRenderingQueued;
			engine.FrameEnded += OnFrameEnded;

			window = Root.Instance.Initialize( true, "Axiom Engine Demo Window" );
			TechDemoListener rwl = new TechDemoListener( window );
			WindowEventMonitor.Instance.RegisterListener( window, rwl );

			ChooseSceneManager();

			CreateCamera();

			CreateViewports();

			// set default mipmap level
			TextureManager.Instance.DefaultMipmapCount = 5;

			// Create any resource listeners (for loading screens)
			this.CreateResourceListener();
			// Load resources

			this.LoadResources();

			ShowDebugOverlay( showDebugOverlay );

			//CreateGUI();


			input = SetupInput();

			// call the overridden CreateScene method

			CreateScene();
			return true;
		}
 public virtual void Detach()
 {
     if (input != null) {
         input.Dispose();
         input = null;
     }
 }
 public virtual void Attach(InputReader reader)
 {
     Detach();
     input = reader;
 }
        /// <summary>
        ///   Attach this input handler to an input reader
        /// </summary>
        /// <param name="reader"></param>
        public override void Attach(InputReader reader)
        {
            base.Attach(reader);
            if (input != null) {
                // add the KeyUp and KeyDown callbacks
                input.KeyDown += input_KeyDown;
                input.KeyUp += input_KeyUp;
                // handle keyboard lost as well

                // add the MouseUp, MouseDown and MouseMoved callbacks
                input.MouseDown += input_MouseDown;
                input.MouseUp += input_MouseUp;
                input.MouseMoved += input_MouseMoved;
                input.MouseLost += input_MouseLost;
            }
        }
예제 #10
0
        public bool Setup()
        {
            // instantiate the Root singleton
            //engine = new Root( "AxiomEngine.log" );
            engine = new Root("EULog.txt");
            List<RenderSystem> renderSystems = new List<RenderSystem>(engine.RenderSystems.Values);
            //renderSystems[0]
            engine.RenderSystem = renderSystems[0];
            const string CONFIG_FILE = @"EngineConfig.xml";
            string resourceConfigPath = Path.GetFullPath(CONFIG_FILE);

            if (File.Exists(resourceConfigPath))
            {
                EngineConfig config = new EngineConfig();

                // load the config file
                // relative from the location of debug and releases executables
                config.ReadXml(CONFIG_FILE);

                // interrogate the available resource paths
                foreach (EngineConfig.FilePathRow row in config.FilePath)
                {
                    ResourceGroupManager.Instance.AddResourceLocation(Path.GetFullPath(row.src), row.type, row.group);
                }
            }

            // add event handlers for frame events
            engine.FrameStarted += OnFrameStarted;
            engine.FrameRenderingQueued += OnFrameRenderingQueued;
            engine.FrameEnded += OnFrameEnded;

            window = Root.Instance.Initialize(true, "Axiom Engine Demo Window");

            TechDemoListener rwl = new TechDemoListener(window);
            WindowEventMonitor.Instance.RegisterListener(window, rwl);

            ChooseSceneManager();
            CreateCamera();
            CreateViewports();

            // set default mipmap level
            TextureManager.Instance.DefaultMipmapCount = 5;

            // Create any resource listeners (for loading screens)
            this.CreateResourceListener();
            // Load resources
            this.LoadResources();

            scene.AmbientLight = ColorEx.Gray;
            scene.SetSkyBox(true, "AR/SpaceSkyBox", 500);
            //scene.SetSkyDome(true, "Examples/CloudySky", 5, 8);

            ParticleSystem smokeSystem =
                ParticleSystemManager.Instance.CreateSystem("SmokeSystem", "Examples/Smoke");

            // create an entity to have follow the path
            // create a scene node for the entity and attach the entity
            /*
             *             Entity ogreHead = scene.CreateEntity("OgreHead", "razor.mesh");
            SceneNode headNode = scene.RootSceneNode.CreateChildSceneNode(Vector3.Zero, Quaternion.Identity);
            headNode.AttachObject(ogreHead);
            */
            Entity razorEntity = scene.CreateEntity("Razor", "razor.mesh");
            SceneNode razorNode = scene.RootSceneNode.CreateChildSceneNode(Vector3.Zero, Quaternion.Identity);
            razorNode.AttachObject(razorEntity);
            razorNode.Pitch(90);

            Entity ogreHead = scene.CreateEntity("OgreHead", "spacevessel.mesh");
            SceneNode headNode = scene.RootSceneNode.CreateChildSceneNode(new Vector3(300,0,0), Quaternion.Identity);
            headNode.AttachObject(ogreHead);

            scene.RootSceneNode.CreateChildSceneNode(new Vector3(0,50,0)).AttachObject(smokeSystem);

            input = SetupInput();

            return true;
        }
예제 #11
0
        public void OnUpdateInput(Axiom.Input.InputReader inputReader)
        {
            if (mposx != inputReader.AbsoluteMouseX || mposy != inputReader.AbsoluteMouseY)
            {
                mposx = inputReader.AbsoluteMouseX;
                mposy = inputReader.AbsoluteMouseY;

                Core.BrowserManager[_browserId].MouseMove(mposx, mposy);
            }


            string status = "off";

            if (inputReader.IsMousePressed(MouseButtons.Left))
            {
                status    = "on";
                IsPressed = true;

                Core.BrowserManager[_browserId].MouseDown(MouseButton.Left);
            }
            if (!inputReader.IsMousePressed(MouseButtons.Left) && IsPressed)
            {
                Core.BrowserManager[_browserId].MouseUp(MouseButton.Left);

                //var _camera = Game.Context.Camera;
                //var _renderWindow = Game.Context.RenderWindow;
                //var _ray = _camera.GetCameraToViewportRay(
                //        inputReader.AbsoluteMouseX / (float)_renderWindow.Width,
                //        inputReader.AbsoluteMouseY / (float)_renderWindow.Height);
                //RaySceneQuery _sceneQuery = _root.SceneManager.CreateRayQuery(
                //    _ray, (uint)SceneQueryTypeMask.WorldGeometry);
                //_sceneQuery.AddWorldFragmentType(WorldFragmentType.SingleIntersection);
                //_sceneQuery.AddWorldFragmentType(WorldFragmentType.CustomGeometry);
                //var results = _sceneQuery.Execute();


                //foreach (RaySceneQueryResultEntry result in results)
                //{

                //    if (result.SceneObject != null)
                //    {


                // result.SceneObject.ShowBoundingBox = true;
                //var woot = _ray.GetPoint(result.Distance);
                //Vector3[] corners = result.SceneObject.GetWorldBoundingBox().Corners;

                //var res = (from v in corners
                //           orderby v.Distance(woot)
                //           select v).Take(4);
                ////var i = 1;
                ////i++;

                //foreach (var v in res)
                //{
                //    var e = _root.SceneManager.CreateEntity("1BasicCube" + r.Next().ToString(), PrefabEntity.Cube);
                //    e.MaterialName = "CBDynamicMaterial";

                //    var s = Root.Instance.SceneManager.RootSceneNode.CreateChildSceneNode();
                //    s.Position = v;
                //    s.Scale = new Vector3(0.5f, 0.5f, 0.5f);
                //    s.AttachObject(e);
                //    s.Yaw(45);
                //}

                //    }
                //}



                IsPressed = false;
            }


            //_element.Text = String.Format("X: {0} Y: {1} Status: {2}",
            //    inputReader.AbsoluteMouseX,
            //    inputReader.AbsoluteMouseY,
            //    status);
        }
예제 #12
0
		public void OnLoad()
		{
			//ResourceGroupManager.Instance.AddResourceLocation("media", "Folder", true);

			_root.SceneManager = _sceneManager = _root.CreateSceneManager(SceneType.ExteriorClose);
			_sceneManager.ClearScene();

			_camera = _sceneManager.CreateCamera("MainCamera");

			_camera.Position = new Vector3(0, 0, 500);
			_camera.LookAt(new Vector3(0, 0, -300));
			_camera.Near = 5;
			_camera.AutoAspectRatio = true;
			_camera.FieldOfView = 0.70f;
			_viewport = _renderWindow.AddViewport(_camera, 0, 0, 1.0f, 1.0f, 100);
			_viewport.BackgroundColor = ColorEx.Black; ;

			_light = _sceneManager.CreateLight("light1");
			_light.Type = LightType.Directional;
			_light.Position = new Vector3(0, 150, 300);
			_light.Diffuse = ColorEx.Blue;
			_light.Specular = ColorEx.Blue;
			//_light.Direction = new Vector3(0, 0, -300);
			_sceneManager.AmbientLight = ColorEx.White;// new ColorEx(0.2f, 0.2f, 0.2f);

			ResourceGroupManager.Instance.InitializeAllResourceGroups();


			_inputReader = PlatformManager.Instance.CreateInputReader();
			_inputReader.Initialize(_renderWindow, true, true, false, false);

			_inputReader.UseKeyboardEvents = true;
			_inputReader.UseMouseEvents = false;

			//_renderItems.Add(new BasicCube());
			_renderItems.Add(new CubeBrowser());
			foreach (var i in _renderItems)
			{
				i.Initialise(_root);
			}
		}
예제 #13
0
        protected virtual bool Setup()
        {
            // instantiate the Root singleton
            engine = new Root("EngineConfig.xml", "AxiomEngine.log");

            // add event handlers for frame events
            engine.FrameStarted += new FrameEvent(OnFrameStarted);
            engine.FrameEnded += new FrameEvent(OnFrameEnded);

            // allow for setting up resource gathering
            SetupResources();

            //show the config dialog and collect options
            if(!Configure()) {
                // shutting right back down
                engine.Shutdown();

                return false;
            }

            ChooseSceneManager();
            CreateCamera();
            CreateViewports();

            // set default mipmap level
            TextureManager.Instance.DefaultNumMipMaps = 5;

            // call the overridden CreateScene method
            CreateScene();

            // retreive and initialize the input system
            input = PlatformManager.Instance.CreateInputReader();
            input.Initialize(window, true, true, false, false, false);

            return true;
        }
예제 #14
0
파일: Game.cs 프로젝트: WolfgangSt/axiom
 private InputReader _setupInput()
 {
     _input = new XBoxInput();
     return _input;
 }