Exemple #1
0
		public Game(Root root, RenderWindow renderWindow)
		{
			_root = root;
			_renderWindow = renderWindow;
			_renderItems = new List<IRenderItem>();
			_context = this;
		}
Exemple #2
0
		public virtual void Start( RenderWindow window, ushort numGroupsInit, ushort numGroupsLoad, Real initProportion )
		{
			mWindow = window;
			mNumGroupsInit = numGroupsInit;
			mNumGroupsLoad = numGroupsLoad;
			mInitProportion = initProportion;
			// We need to pre-initialise the 'Bootstrap' group so we can use
			// the basic contents in the loading screen
			ResourceGroupManager.Instance.InitializeResourceGroup( "Bootstrap" );

			OverlayManager omgr = OverlayManager.Instance;
			mLoadOverlay = omgr.GetByName( "Core/LoadOverlay" );
			if ( mLoadOverlay == null )
			{
				throw new KeyNotFoundException( "Cannot find loading overlay" );
			}
			mLoadOverlay.Show();

			// Save links to the bar and to the loading text, for updates as we go
			mLoadingBarElement = omgr.Elements.GetElement( "Core/LoadPanel/Bar/Progress" );
			mLoadingCommentElement = omgr.Elements.GetElement( "Core/LoadPanel/Comment" );
			mLoadingDescriptionElement = omgr.Elements.GetElement( "Core/LoadPanel/Description" );

			OverlayElement barContainer = omgr.Elements.GetElement( "Core/LoadPanel/Bar" );
			mProgressBarMaxSize = barContainer.Width;
			mLoadingBarElement.Width = 0;

			// self is listener
			ResourceGroupManager.Instance.AddResourceGroupListener( this );
		}
Exemple #3
0
        protected override void Dispose(bool disposing)
        {
            if (!this.IsDisposed)
            {
                if (disposing)
                {
                    this.renderWindow = null;
                }
            }

            base.Dispose(disposing);
        }
 /// <summary>
 /// Stops the gamer services component from updating
 /// </summary>
 public void Shutdown()
 {
     _engine.FrameStarted -= Update;
     _engine = null;
     _renderSystem = null;
     _window = null;
 }
Exemple #5
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="rw"></param>
		public override void WindowResized( RenderWindow rw )
		{
			if ( this.TrayManager == null )
			{
				return;
			}

			OverlayElementContainer center = this.TrayManager.TrayContainer[ (int)TrayLocation.Center ];
			OverlayElementContainer left = this.TrayManager.TrayContainer[ (int)TrayLocation.Left ];

			if ( center.IsVisible && rw.Width < 1280 - center.Width )
			{
				while ( center.IsVisible )
				{
					this.TrayManager.MoveWidgetToTray( this.TrayManager.GetWidget( TrayLocation.Center, 0 ), TrayLocation.Left );
				}
			}
			else if ( left.IsVisible && rw.Width >= 1280 - left.Width )
			{
				while ( left.IsVisible )
				{
					this.TrayManager.MoveWidgetToTray( this.TrayManager.GetWidget( TrayLocation.Left, 0 ), TrayLocation.Center );
				}
			}
			base.WindowResized( rw );
		}
Exemple #6
0
		/// <summary>
		/// This is the Constructor for the MouseSelection object, scene must be fully initialized and 
		/// valid camera and window must be passed in, generic name will be created
		/// </summary>
		/// <param name="camera">Camera</param>
		/// <param name="window">RenderWindow</param>
		public MouseSelector( Camera camera, RenderWindow window )
			: this( _nameGenerator.GetNextUniqueName(), camera, window )
		{
		}
Exemple #7
0
		/// <summary>
		/// Extendeded to setup a default tray interface and camera controller.
		/// </summary>
		/// <param name="window"></param>
		/// <param name="keyboard"></param>
		/// <param name="mouse"></param>
		protected internal override void Setup( RenderWindow window, SIS.Keyboard keyboard, SIS.Mouse mouse )
		{
			Window = window;
			Keyboard = keyboard;
			Mouse = mouse;

			LocateResources();
			CreateSceneManager();
			SetupView();

			this.TrayManager = new SdkTrayManager( "SampleControls", window, mouse, this as ISdkTrayListener );  // create a tray interface

			LoadResources();
			ResourcesLoaded = true;

			// Show stats and logo and Hide the cursor
			this.TrayManager.ShowFrameStats( TrayLocation.BottomLeft );
			this.TrayManager.ShowLogo( TrayLocation.BottomRight );
			this.TrayManager.HideCursor();

			// create a params panel for displaying sample details
			List<string> items = new List<string>
								 {
									 "cam.pX", 
									 "cam.pY", 
									 "cam.pZ", 
									 String.Empty, 
									 "cam.oW", 
									 "cam.oX", 
									 "cam.oY", 
									 "cam.oZ", 
									 String.Empty, 
									 "Filtering", 
									 "Poly Mode"
								 };
			this.DetailsPanel = this.TrayManager.CreateParamsPanel( TrayLocation.None, "DetailsPanel", 180, items );
			this.DetailsPanel.SetParamValue( 9, "Bilinear" );
			this.DetailsPanel.SetParamValue( 10, "Solid" );
			this.DetailsPanel.Hide();

			SetupContent();
			ContentSetup = true;

			IsDone = false;
		}
 /// <summary>
 /// Do some final initialisations
 /// </summary>
 /// <param name="renderwindow">The target RenderWindow</param>
 /// <param name="camera">The 'listening' camera</param>
 public virtual void SetRenderWindow(RenderWindow renderwindow, Camera camera)
 {
     FileManager.Instance.LogSupportedFiles();
     this.window = renderwindow;
     this.cam = camera;
 }
		/// <summary>
		/// Window has closed
		/// </summary>
		/// <param name="window">RenderWindow that caused the event</param>
		public void WindowClosed( RenderWindow window )
		{
			Contract.RequiresNotNull( window, "window" );

			if ( this._windows.Contains( window ) )
			{
				// Notify listeners of close
				foreach ( var listener in this._listeners[ window ] )
				{
					listener.WindowClosed( window );
				}

				// Notify Window of closure
				window.Dispose();

				return;
			}
		}
Exemple #10
0
		/// <summary>
		///
		/// </summary>
		/// <param name="parent"></param>
		/// <param name="useKeyboard"></param>
		/// <param name="useMouse"></param>
		/// <param name="useGamepad"></param>
		/// <param name="ownMouse"></param>
		public override void Initialize( Axiom.Graphics.RenderWindow parent, bool useKeyboard, bool useMouse, bool useGamepad, bool ownMouse )
		{
			Contract.Requires( parent.GetType().Name == "OpenTKWindow", "RenderSystem", "OpenTK InputManager requires OpenTK OpenGL Renderer." );

			this.parent = parent;

			INativeWindow window = (INativeWindow)parent[ "nativewindow" ];

			if ( window == null )
				return;

			keyboard = window.InputDriver.Keyboard[ 0 ];
			//keyboard = window.Keyboard;

			if ( useMouse )
			{
				mouse = window.InputDriver.Mouse[ 0 ];
				if ( ownMouse )
				{
					this.ownMouse = true;
					System.Windows.Forms.Cursor.Hide();
				}
				// mouse starts out in the center of the window
				center.X = parent.Width / 2;
				center.Y = parent.Height / 2;

				if ( ownMouse )
				{
					center = window.PointToScreen( center );
					System.Windows.Forms.Cursor.Position = center;
					mouseX = oldX = center.X;
					mouseY = oldY = center.Y;
				}
				else
				{
					System.Drawing.Point center2 = window.PointToScreen( center );
					System.Windows.Forms.Cursor.Position = center2;
					mouseX = oldX = center.X;
					mouseY = oldY = center.Y;
				}
			}
		}
Exemple #11
0
        public virtual bool Setup()
        {
            // instantiate the Root singleton
            engine = new Root( "AxiomEngine.log" );
              //  engine = Root.Instance;
            ResourceGroupManager.Instance.AddResourceLocation("./media/", "Folder", "General", false, true);
            Axiom.Core.ResourceGroupManager.Instance.InitializeAllResourceGroups();

            engine.RenderSystem = engine.RenderSystems.First().Value;

             //   window = Root.Instance.Initialize(false);
            window = CreateRenderWindow(this.pictureEdit1);
            // add event handlers for frame events
            engine.FrameStarted += OnFrameStarted;
            //   engine.FrameRenderingQueued += OnFrameRenderingQueued;
            // engine.FrameEnded += OnFrameEnded;

               // 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

            ResourceGroupManager.Instance.InitializeAllResourceGroups();

            //ShowDebugOverlay(showDebugOverlay);

            //CreateGUI();

             //   input = SetupInput();

            // call the overridden CreateScene method

            CreateScene();
            return true;
        }
Exemple #12
0
 public void Initialize(RenderWindow window, bool ownMouse)
 {
     _input.Initialize(window, true, true, false, ownMouse);
 }
Exemple #13
0
		/// <summary>
		///    Initializes the renderer.
		/// </summary>
		/// <remarks>
		///     This method can only be called after a renderer has been
		///     selected with <see cref="Root.RenderSystem"/>, and it will initialize
		///     the selected rendering system ready for use.
		/// </remarks>
		/// <param name="autoCreateWindow">
		///     If true, a rendering window will automatically be created The window will be
		///     created based on the options currently set on the render system.
		/// </param>
		/// <param name="windowTitle">Title to use by the window.</param>
		/// <returns>A reference to the automatically created window (if requested), or null otherwise.</returns>
		public RenderWindow Initialize( bool autoCreateWindow, string windowTitle )
		{
			if ( this.activeRenderSystem == null )
			{
				throw new AxiomException( "Cannot initialize - no render system has been selected." );
			}

			new ControllerManager();

#if !(XBOX || XBOX360)
			PlatformInformation.Log( LogManager.Instance.DefaultLog );
#endif
			// initialize the current render system
			this.autoWindow = this.activeRenderSystem.Initialize( autoCreateWindow, windowTitle );

			// if they chose to auto create a window, also initialize several subsystems
			if ( autoCreateWindow )
			{
				OneTimePostWindowInit();
			}

			// initialize timer
			this.timer.Reset();

#if SILVERLIGHT && !WINDOWS_PHONE
			ThreadUI.Invoke(delegate
								{
									var drawingSurface = (DrawingSurface) autoWindow["DRAWINGSURFACE"];
									drawingSurface.Draw += (s, args) =>
															{
																try
																{
																	inDrawCallback = true;
																	if (!RenderOneFrame())
																		queuedEnd = true;
																}
																catch (Exception ex)
																{
																	if (LogManager.Instance != null)
																		LogManager.Instance.Write(LogManager.BuildExceptionString(ex));
																}
																finally
																{
																	inDrawCallback = false;
																}
															};
								});
#endif
			this._isInitialized = true;
			return this.autoWindow;
		}
        /// <summary>
        ///    Initializes the renderer.
        /// </summary>
        /// <remarks>
        ///     This method can only be called after a renderer has been
        ///     selected with <see cref="Root.RenderSystem"/>, and it will initialize
        ///     the selected rendering system ready for use.
        /// </remarks>
        /// <param name="autoCreateWindow">
        ///     If true, a rendering window will automatically be created (saving a call to
        ///     <see cref="RenderSystem.CreateRenderWindow"/>). The window will be
        ///     created based on the options currently set on the render system.
        /// </param>
        /// <param name="windowTitle">Title to use by the window.</param>
        /// <returns>A reference to the automatically created window (if requested), or null otherwise.</returns>
        public RenderWindow Initialize(bool autoCreateWindow, string windowTitle, string initialLoadBitmap)
        {
            if(activeRenderSystem == null) {
                throw new AxiomException("Cannot initialize - no render system has been selected.");
            }

            new ControllerManager();

            // initialize the current render system
            autoWindow = activeRenderSystem.Initialize(autoCreateWindow, windowTitle, initialLoadBitmap);

            // if they chose to auto create a window, also initialize several subsystems
            if(autoCreateWindow) {
                OneTimePostWindowInit();
            }

            // initialize timer
            timer.Reset();

            return autoWindow;
        }
Exemple #15
0
		/// <summary>
		/// Window lost/regained the focus
		/// </summary>
		/// <param name="rw">The RenderWindow which created this event</param>
		public void WindowFocusChange( RenderWindow rw )
		{
		}
		/// <summary>
		/// Window has either gained or lost the focus
		/// </summary>
		/// <param name="window">RenderWindow that caused the event</param>
		/// <param name="hasFocus">True if window has focus</param>
		public void WindowFocusChange( RenderWindow window, bool hasFocus )
		{
			Contract.RequiresNotNull( window, "window" );

			if ( this._windows.Contains( window ) )
			{
				// Notify Window of focus change
				window.IsActive = hasFocus;

				// Notify listeners of focus change
				foreach ( var listener in this._listeners[ window ] )
				{
					listener.WindowFocusChange( window );
				}

				return;
			}
		}
		/// <summary>
		/// Window has changed size
		/// </summary>
		/// <param name="window">RenderWindow that caused the event</param>
		public void WindowResized( RenderWindow window )
		{
			Contract.RequiresNotNull( window, "window" );

			if ( this._windows.Contains( window ) )
			{
				// Notify Window of Move or Resize
				window.WindowMovedOrResized();

				// Notify listeners of Resize
				foreach ( var listener in this._listeners[ window ] )
				{
					listener.WindowResized( window );
				}
				return;
			}
		}
Exemple #18
0
		/// <summary>
		///		Subclasses should initialize the underlying input subsystem using this
		///		method.
		/// </summary>
		/// <param name="parent">Parent window that the input belongs to.</param>
		/// <param name="useGamepad"></param>
		/// <param name="ownMouse">
		///		If true, input will be taken over from the OS and exclusive to the window.
		///		If false, input will still be shared with other apps.
		///	</param>
		/// <param name="useKeyboard"></param>
		/// <param name="useMouse"></param>
		public abstract void Initialize( RenderWindow parent, bool useKeyboard, bool useMouse, bool useGamepad, bool ownMouse );
Exemple #19
0
		/// <summary>Returns the size in pixels of a box that could contain the whole string.</summary>
		private Pair<int> StrBBox( string text, float char_height, RenderWindow window )
		{
			int height = 0, width = 0;
			Real vsX, vsY, veX, veY;
			int w, h;

			w = window.Width;
			h = window.Height;

			for ( var i = 0; i < text.Length; i++ )
			{
				GetGlyphTexCoords( text[ i ], out vsX, out vsY, out veX, out veY );

				// Calculate view-space width and height of char
				vsY = char_height;
				vsX = GetGlyphAspectRatio( text[ i ] )*char_height;

				width += (int)( vsX*w );
				if ( vsY*h > height || ( ( i == 0 ) && text[ i - 1 ] == '\n' ) )
				{
					height += (int)( vsY*h );
				}
			}

			return new Pair<int>( height, width );
		}
        /// <summary>
        ///		Intializes DirectInput for use on Win32 platforms.
        /// </summary>
        /// <param name="window"></param>
        /// <param name="useKeyboard"></param>
        /// <param name="useMouse"></param>
        /// <param name="useGamepad"></param>
        public override void Initialize( RenderWindow window, bool useKeyboard, bool useMouse, bool useGamepad,
                                         bool ownMouse )
        {
            this.useKeyboard = useKeyboard;
            this.useMouse = useMouse;
            this.useGamepad = useGamepad;
            this.ownMouse = ownMouse;
            this.window = window;

            drawingSurface = (DrawingSurface)window[ "DRAWINGSURFACE" ];

            // initialize keyboard if needed
            if ( useKeyboard )
            {
                for (var ui = drawingSurface as FrameworkElement; ui != null; ui = ui.Parent as FrameworkElement)
                {
                    ui.KeyDown += ( s, e ) =>
                                  {
                                      var key = ConvertKeyEnum( e.Key );
                                      keys[ (int)key ] = true;
                                      modifiers |= ConvertModifierKeysEnum( e.Key );

                                      if ( useKeyboardEvents )
                                          OnKeyDown( new KeyEventArgs( key, modifiers ) );

                                      //HACK: temporary
                                      if (key == KeyCodes.F9)
                                      {
                                          foreach (var cam in Root.Instance.SceneManager.Cameras)
                                              cam.PolygonMode = cam.PolygonMode == PolygonMode.Wireframe
                                                                    ? PolygonMode.Solid
                                                                    : PolygonMode.Wireframe;
                                      }
                                  };
                    ui.KeyUp += ( s, e ) =>
                                {
                                    var key = ConvertKeyEnum( e.Key );
                                    keys[ (int)key ] = false;
                                    modifiers &= ~ConvertModifierKeysEnum( e.Key );

                                    if ( useKeyboardEvents )
                                        OnKeyUp( new KeyEventArgs( key, modifiers ) );
                                };
                }
            }

            // initialize the mouse if needed
            if ( useMouse )
            {
                drawingSurface.MouseEnter += ( s, e ) =>
                                             {
                                                 var p = e.GetPosition( drawingSurface );
                                                 mouseAbsX = (int)p.X;
                                                 mouseAbsY = (int)p.Y;
                                             };

                drawingSurface.MouseMove += ( s, e ) =>
                                            {
                                                if ( mouseCaptured )
                                                {
                                                    var p = e.GetPosition( drawingSurface );
                                                    if (true)
                                                    {
                                                        mouseRelX = mouseAbsX - (int)p.X;
                                                        mouseRelY = mouseAbsY - (int)p.Y;
                                                        mouseAbsX -= mouseRelX;
                                                        mouseAbsY -= mouseRelY;
                                                    }
                                                    else
                                                    {
                                                        mouseRelX = (int)p.X - mouseAbsX;
                                                        mouseRelY = (int)p.Y - mouseAbsY;
                                                        mouseAbsX += mouseRelX;
                                                        mouseAbsY += mouseRelY;
                                                    }
                                                }
                                            };

                drawingSurface.MouseLeftButtonDown += ( s, e ) =>
                                                      {
                                                          var p = e.GetPosition(drawingSurface);
                                                          mouseAbsX = (int)p.X;
                                                          mouseAbsY = (int)p.Y;
                                                          mouseCaptured = ((UIElement)s).CaptureMouse();
                                                          modifiers |= ModifierKeys.MouseButton0;
                                                      };

                drawingSurface.MouseLeftButtonUp += ( s, e ) =>
                                                    {
                                                        ((UIElement)s).ReleaseMouseCapture();
                                                        mouseCaptured = false;
                                                        modifiers &= ~ModifierKeys.MouseButton0;
                                                    };

                drawingSurface.MouseRightButtonDown += ( s, e ) => modifiers |= ModifierKeys.MouseButton1;

                drawingSurface.MouseRightButtonUp += ( s, e ) => modifiers &= ~ModifierKeys.MouseButton1;
            }

            // we are initialized
            isInitialized = true;

            // mouse starts off in the center
            mouseAbsX = window.Width >> 1;
            mouseAbsY = window.Height >> 1;
        }
Exemple #21
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="rw"></param>
		public override void WindowResized( RenderWindow rw )
		{
			this.Camera.AspectRatio = (Real)this.Viewport.ActualWidth / this.Viewport.ActualHeight;
		}
		public void InitializeContext( RenderWindow primary )
		{
			//Set main and current context
			this.mainContext = null;
			this.mainContext = (GLES2Context) primary[ "GLCONTEXT" ];
			this.currentContext = this.mainContext;

			//sET PRIMARY CONTEXT AS ACTIVE
			if ( this.currentContext != null )
			{
				this.currentContext.SetCurrent();
			}

			//Setup GLSupport
			this.glSupport.InitializeExtensions();

			LogManager.Instance.Write( "**************************************" );
			LogManager.Instance.Write( "*** OpenGL ES 2.x Renderer Started ***" );
			LogManager.Instance.Write( "**************************************" );
		}
        public override void SetRenderWindow(RenderWindow renderwindow, Camera camera)
        {
            base.SetRenderWindow(renderwindow, camera);

            // link the device to our current System.Windows.Form (since we need DirectX we're sure that we're in Windows)
            device.SetCooperativeLevel((System.Windows.Forms.Control)window.Handle, CooperativeLevel.Priority);

            // create a buffer for the listener
            BufferDescription desc = new BufferDescription();
            desc.Control3D = true;
            desc.PrimaryBuffer = true;
            Buffer lbuffer = new Buffer(desc, device);
            listener = new Listener3D(lbuffer);

            // let the log know that we're using DirectSound and it's set up
            LogManager.Instance.Write("DirectSound SoundSystem initialised");
        }
		/// <summary>
		/// Add a listener to listen to renderwindow events (multiple listener's per renderwindow is fine)
		/// The same listener can listen to multiple windows, as the Window Pointer is sent along with
		/// any messages.
		/// </summary>
		/// <param name="window">The RenderWindow you are interested in monitoring</param>
		/// <param name="listener">Your callback listener</param>
		public void RegisterListener( RenderWindow window, IWindowEventListener listener )
		{
			Contract.RequiresNotNull( window, "window" );
			Contract.RequiresNotNull( listener, "listener" );

			if ( !this._listeners.ContainsKey( window ) )
			{
				this._listeners.Add( window, new List<IWindowEventListener>() );
			}
			this._listeners[ window ].Add( listener );
		}
Exemple #25
0
		/// <summary>
		/// This is the Constructor for the MouseSelection object, scene must be fully initialized and 
		/// valid camera and window must be passed in, name must be passed
		/// </summary>
		/// <param name="name">string</param>
		/// <param name="camera">Camera</param>
		/// <param name="window">RenderWindow</param>
		public MouseSelector( string name, Camera camera, RenderWindow window )
		{
			_Camera = camera;
			_Window = window;
			_name = name;
			_rect = new SelectionRectangle( _name );
			_Camera.ParentSceneNode.CreateChildSceneNode( _name + "_node" ).AttachObject( _rect );
			Log( _name + " created, and attached to " + _name + "_node." );

		}
		/// <summary>
		/// Remove previously added listener
		/// </summary>
		/// <param name="window">The RenderWindow you registered with</param>
		/// <param name="listener">The listener registered</param>
		public void UnregisterListener( RenderWindow window, IWindowEventListener listener )
		{
			Contract.RequiresNotNull( window, "window" );
			Contract.RequiresNotNull( listener, "listener" );

			if ( this._listeners.ContainsKey( window ) )
			{
				this._listeners[ window ].Remove( listener );
			}
		}
 /// <summary>
 /// Creates a new instance of <see cref="XnaGamerServices"/>
 /// </summary>
 /// <param name="engine">The engine</param>
 /// <param name="renderSystem">the rendersystem in use</param>
 /// <param name="window">The primary window</param>
 public XnaGamerServices( Root engine, XnaRenderSystem renderSystem, RenderWindow window )
 {
     _engine = engine;
     _renderSystem = renderSystem;
     _window = window;
 }
		/// <summary>
		/// Called by RenderWindows upon creation for Ogre generated windows. You are free to add your
		/// external windows here too if needed.
		/// </summary>
		/// <param name="window">The RenderWindow to monitor</param>
		public void RegisterWindow( RenderWindow window )
		{
			Contract.RequiresNotNull( window, "window" );

			this._windows.Add( window );
			this._listeners.Add( window, new List<IWindowEventListener>() );
		}
        protected bool ConfigureAxiom()
        {
            // HACK: Temporary
            RenderSystem renderSystem = Root.Instance.RenderSystems[0];
            Root.Instance.RenderSystem = renderSystem;

            Root.Instance.Initialize(false);

            window = Root.Instance.CreateRenderWindow("Main Window", axiomPictureBox.Width, axiomPictureBox.Height, false,
                                                      "externalWindow", axiomPictureBox, "useNVPerfHUD", true);
            Root.Instance.Initialize(false);

            return true;
        }
		/// <summary>
		/// Called by RenderWindows upon destruction for Ogre generated windows. You are free to remove your
		/// external windows here too if needed.
		/// </summary>
		/// <param name="window">The RenderWindow to remove from list</param>
		public void UnregisterWindow( RenderWindow window )
		{
			Contract.RequiresNotNull( window, "window" );

			if ( this._windows.Contains( window ) )
			{
				this._windows.Remove( window );
			}

			if ( this._listeners.ContainsKey( window ) )
			{
				this._listeners[ window ].Clear();
				this._listeners.Remove( window );
			}
		}