Пример #1
0
        //=========================================================================================
        /// <summary>
        /// Debug only function that draws debug information for all objects in the level.
        /// </summary>
        //=========================================================================================
        public void DebugDraw()
        {
            // If there is no camera then make one:

                if ( m_camera == null )
                {
                    // Make a camera:

                    m_camera = new Camera();
                }

                // If this is debug mode and the debug camera is on then use that instead

                #if DEBUG

                    // Save the previously used camera

                    Camera previous_camera = m_camera;

                    // See if we are to use the debug camera:

                    if ( DebugLevel.UseDebugCamera ) m_camera = DebugLevel.DebugCamera;

                #endif

                // Lock the level data so that the data collections are not modified whilst we enumerate:

                m_level.Data.Lock();

                // Run through the list of renderable objects and debug draw them all:

                Dictionary<int,GameObject>.Enumerator e = m_level.Data.Objects.GetEnumerator();

                while ( e.MoveNext() )
                {
                    // Debug draw this object:

                    e.Current.Value.OnDebugDraw();
                }

                // Unlock the level data:

                m_level.Data.Unlock();

                // If this is debug mode and the debug camera is on then restore the previous camera used

                #if DEBUG

                    // See if we are to use the debug camera: if so then restore the normal camera

                    if ( DebugLevel.UseDebugCamera ) m_camera = previous_camera;

                #endif
        }
Пример #2
0
 //=========================================================================================
 /// <summary>
 /// Visibility function. Determines if the object is visible.
 /// </summary>
 /// <param name="c"> Camera the scene is being viewed from. </param>
 /// <returns> True because the shroud is always visible. </returns>
 //=========================================================================================
 public override bool IsVisible(Camera c)
 {
     return true;
 }
Пример #3
0
        //=========================================================================================
        /// <summary>
        /// Renders the level with the currently selected camera. If none is selected then a 
        /// default camera will be used instead.
        /// </summary>
        //=========================================================================================
        public void Draw()
        {
            // If there is no camera then make one:

            if ( m_camera == null )
            {
                // Make a camera:

                m_camera = new Camera();
            }

            // If this is debug mode and the debug camera is on then use that instead

            #if DEBUG

                // Save the previously used camera

                Camera previous_camera = m_camera;

                // See if we are to use the debug camera:

                if ( DebugLevel.UseDebugCamera ) m_camera = DebugLevel.DebugCamera;

            #endif

            // Lock the level data so that the data collections are not modified whilst we enumerate:

            m_level.Data.Lock();

                // Add all visible objects into the render heap:

                Dictionary<int,GameObject>.Enumerator e = m_level.Data.RenderableObjects.GetEnumerator();

                while ( e.MoveNext() )
                {
                    // Get this object:

                    GameObject obj = e.Current.Value;

                    // See if it is visible: if not then ignore

                    if ( obj.IsVisible( m_camera ) == false ) continue;

                    // Add all visible objects into the render heap:

                    m_render_heap.Add( obj.Depth , obj );
                }

            // Unlock the level data:

            m_level.Data.Unlock();

            // Render objects in the render heap, starting with the deepest first:

            while ( m_render_heap.Count > 0 )
            {
                // Get this object:

                GameObject obj = m_render_heap.Remove();

                // Draw it:

                obj.OnDraw();
            }

            // Let the particle emitter do it's rendering:

            m_level.Emitter.Draw();

            // If in debug mode then do a debug draw if enabled:

            #if DEBUG

                if ( DebugLevel.ShowDebugInfo ) DebugDraw();

            #endif

            // If this is debug mode and the debug camera is on then restore the previous camera used

            #if DEBUG

                // See if we are to use the debug camera: if so then restore the normal camera

                if ( DebugLevel.UseDebugCamera ) m_camera = previous_camera;

            #endif
        }
Пример #4
0
        //=========================================================================================
        /// <summary> 
        /// Renders the gui and all it's widgets.
        /// </summary>
        //=========================================================================================
        public void Draw()
        {
            // If there is no camera then make one:

            if ( m_camera == null )
            {
                // Make a camera:

                m_camera = new Camera();
            }

            // If this is debug mode and the debug camera is on then use that instead

            #if DEBUG

                // Save the previously used camera

                Camera previous_camera = m_camera;

                // See if we are to use the debug camera:

                if ( DebugGui.UseDebugCamera ) m_camera = DebugGui.DebugCamera;

            #endif

            // Lock the lists of widgets before we do this:

            m_data.Lock();

                // Run through the list of widgets and add them all into the render heap:

                Dictionary<int,GuiWidget>.Enumerator e = m_data.Objects.GetEnumerator();

                while ( e.MoveNext() )
                {
                    // Add into the render heap:

                    m_render_heap.Add( e.Current.Value.Depth , e.Current.Value );
                }

            // Unlock the lists of widgets:

            m_data.Unlock();

            // Render objects in the render heap, starting with the deepest first:

            while ( m_render_heap.Count > 0 )
            {
                // Get this object:

                GuiWidget obj = m_render_heap.Remove();

                // Draw it:

                obj.OnDraw();
            }

            // If in debug mode then do a debug draw if enabled:

            #if DEBUG

                // If debug information is enabled, then show it:

                if ( DebugGui.ShowDebugInfo ) DebugDraw();

                // Do any debug drawing the gui debug module wants to do in debug mode:

                DebugGui.Draw();

                // See if we are to use the debug camera: if so then restore the normal camera

                if ( DebugGui.UseDebugCamera ) m_camera = previous_camera;

            #endif
        }
Пример #5
0
        //=========================================================================================
        /// <summary>
        /// Adds all debug commands to do with the gui to the debug console.
        /// </summary>
        //=========================================================================================
        public static void Initialize()
        {
            // Add console commands on windows

            #if WINDOWS_DEBUG

                DebugConsole.AddCommand( "GInfo"        , new DebugConsole.Function_bool_bool(Con_GInfo)        );
                DebugConsole.AddCommand( "GEdit"        , new DebugConsole.Function_void_int(Con_GEdit)         );
                DebugConsole.AddCommand( "GSave"        , new DebugConsole.Function_void_string(Con_GSave)      );
                DebugConsole.AddCommand( "GLoad"        , new DebugConsole.Function_void_string(Con_GLoad)      );
                DebugConsole.AddCommand( "GNew"         , new DebugConsole.Function_void_string(Con_GNew)       );
                DebugConsole.AddCommand( "GDelete"      , new DebugConsole.Function_void_int(Con_GDelete)       );
                DebugConsole.AddCommand( "GClone"       , new DebugConsole.Function_void_int(Con_GClone)        );
                DebugConsole.AddCommand( "GMoveCamera"  , new DebugConsole.Function_bool_bool(Con_GMoveCamera)  );

            #endif

            // Make the debug camera:

            s_debug_camera = new Camera();
        }
Пример #6
0
        //=========================================================================================
        /// <summary>
        /// This function allows the game object to tell if it is visible with the given camera 
        /// view. This is used by the renderer for vis testing.
        /// </summary>
        /// <param name="c"> Camera the scene is being viewed from. </param>
        /// <returns> True if the object should be drawn, false otherwise. </returns>
        //=========================================================================================
        public override bool IsVisible(Camera c)
        {
            // The sky is always visible:

            return true;
        }
Пример #7
0
        //=========================================================================================
        /// <summary>
        /// Adds all debug commands to do with the level to the debug console.
        /// </summary>
        //=========================================================================================
        public static void Initialize()
        {
            // Add console commands on windows

            #if WINDOWS_DEBUG

                DebugConsole.AddCommand( "LInfo"        , new DebugConsole.Function_bool_bool(Con_LInfo)        );
                DebugConsole.AddCommand( "LEdit"        , new DebugConsole.Function_void_int(Con_LEdit)         );
                DebugConsole.AddCommand( "LSave"        , new DebugConsole.Function_void_string(Con_LSave)      );
                DebugConsole.AddCommand( "LLoad"        , new DebugConsole.Function_void_string(Con_LLoad)      );
                DebugConsole.AddCommand( "LNew"         , new DebugConsole.Function_void_string(Con_LNew)       );
                DebugConsole.AddCommand( "LDelete"      , new DebugConsole.Function_void_int(Con_LDelete)       );
                DebugConsole.AddCommand( "LClone"       , new DebugConsole.Function_void_int(Con_LClone)        );
                DebugConsole.AddCommand( "LMoveCamera"  , new DebugConsole.Function_bool_bool(Con_LMoveCamera)  );
                DebugConsole.AddCommand( "LFrameStep"   , new DebugConsole.Function_bool_bool(Con_LFrameStep)   );

            #endif

            // Make the debug camera:

            s_debug_camera = new Camera();
        }