Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 15, 2011, 9:47:11 PM (13 years ago)
Author:
landauf
Message:

merged usability branch back to trunk

incomplete summary of the changes in this branch:

  • enhanced keyboard navigation in GUIs
  • implemented new graphics menu and changeable window size at runtime
  • added developer mode
  • HUD shows if game is paused, game pauses if ingame menu is opened
  • removed a few obsolete commands and hid some that are more for internal use
  • numpad works in console and gui
  • faster loading of level info
  • enhanced usage of compositors (Shader class)
  • improved camera handling, configurable FOV and aspect ratio
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/tools/Shader.h

    r5781 r8079  
    3636#include <vector>
    3737
     38#include <OgreCompositorInstance.h>
     39
     40#include "util/MultiType.h"
    3841#include "util/OgreForwardRefs.h"
    39 #include "tools/interfaces/Tickable.h"
     42#include "core/ViewportEventListener.h"
    4043
    4144namespace orxonox
    4245{
    43     class _ToolsExport Shader : public Tickable
     46    /**
     47        @brief Shader is a wrapper class around Ogre::CompositorInstance. It provides some
     48        functions to easily change the visibility and parameters for shader programs.
     49    */
     50    class _ToolsExport Shader : public ViewportEventListener, public Ogre::CompositorInstance::Listener
    4451    {
    45         typedef std::pair<bool, void*>                  ParameterPointer;
    46         typedef std::map<std::string, ParameterPointer> ParameterMap;
    47         typedef std::vector<ParameterMap>               PassVector;
    48         typedef std::vector<PassVector>                 TechniqueVector;
    49         typedef std::map<std::string, TechniqueVector>  MaterialMap;
    50 
    5152        public:
    5253            Shader(Ogre::SceneManager* scenemanager = 0);
    5354            virtual ~Shader();
    5455
    55             virtual void tick(float dt);
    56 
     56            /// Defines if the shader is visible or not.
    5757            inline void setVisible(bool bVisible)
    5858            {
     
    6363                }
    6464            }
     65            /// Returns whether or not the shader is visible.
    6566            inline bool isVisible() const
    6667                { return this->bVisible_; }
    6768            void updateVisibility();
    6869
    69             inline void setCompositor(const std::string& compositor)
     70            /// Defines the compositor's name (located in a .compositor file).
     71            inline void setCompositorName(const std::string& name)
    7072            {
    71                 if (this->compositor_ != compositor)
     73                if (this->compositorName_ != name)
    7274                {
    73                     this->compositor_ = compositor;
    74                     this->changedCompositor();
     75                    this->compositorName_ = name;
     76                    this->changedCompositorName();
    7577                }
    7678            }
    77             inline const std::string& getCompositor() const
    78                 { return this->compositor_; }
    79             void changedCompositor();
     79            /// Returns the compositor's name.
     80            inline const std::string& getCompositorName() const
     81                { return this->compositorName_; }
     82            void changedCompositorName();
     83            void changedCompositorName(Ogre::Viewport* viewport);
    8084
    81             void setSceneManager(Ogre::SceneManager* scenemanager);
     85            /// Sets the scenemanager (usually provided in the constructor, but can be set later). Shouldn't be changed once it's set.
     86            inline void setSceneManager(Ogre::SceneManager* scenemanager)
     87                { this->scenemanager_ = scenemanager; }
     88            /// Returns the scene manager.
    8289            inline Ogre::SceneManager* getSceneManager() const
    8390                { return this->scenemanager_; }
    8491
    85             void setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, float value);
    86             void setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, int value);
     92            virtual void cameraChanged(Ogre::Viewport* viewport, Ogre::Camera* oldCamera);
    8793
    88             static bool _setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, float value);
    89             static bool _setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, int value);
    90             static float getParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter);
    91             static bool  getParameterIsFloat(const std::string& material, size_t technique, size_t pass, const std::string& parameter);
    92             static bool  getParameterIsInt  (const std::string& material, size_t technique, size_t pass, const std::string& parameter);
    93             static ParameterPointer* getParameterPointer(const std::string& material, size_t technique, size_t pass, const std::string& parameter);
     94            void setParameter(size_t technique, size_t pass, const std::string& parameter, float value);
     95            void setParameter(size_t technique, size_t pass, const std::string& parameter, int value);
     96
     97            virtual void notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr& materialPtr);
    9498
    9599        private:
    96             Ogre::SceneManager* scenemanager_;
    97             Ogre::CompositorInstance* compositorInstance_;
    98             bool bVisible_;
    99             bool bLoadCompositor_;
    100             bool bViewportInitialized_;
    101             std::string compositor_;
    102             std::string oldcompositor_;
     100            static bool hasCgProgramManager();
    103101
    104             static MaterialMap parameters_s;
    105             static bool bLoadedCgPlugin_s;
     102            Ogre::SceneManager* scenemanager_;              ///< The scenemanager for which the shader is active
     103            Ogre::CompositorInstance* compositorInstance_;  ///< The compositor instance representing the wrapped compositor
     104            bool bVisible_;                                 ///< True if the shader should be visible
     105            bool bLoadCompositor_;                          ///< True if the compositor should be loaded (usually false if no graphics)
     106            std::string compositorName_;                    ///< The name of the current compositor
     107            std::string oldcompositorName_;                 ///< The name of the previous compositor (used to unregister)
     108
     109        private:
     110            void addAsListener();
     111
     112            /// Helper struct to store parameters for shader programs.
     113            struct ParameterContainer
     114            {
     115                size_t technique_;          ///< The ID of the technique
     116                size_t pass_;               ///< The ID of the pass
     117                std::string parameter_;     ///< The name of the parameter
     118
     119                int valueInt_;              ///< The desired int value of the parameter
     120                float valueFloat_;          ///< The desired float value of the parameter
     121
     122                MT_Type::Value valueType_;  ///< The type of the parameter (currently only int or float)
     123            };
     124
     125            std::list<ParameterContainer> parameters_;  ///< The list of parameters that should be set on the next update
     126            bool registeredAsListener_;                 ///< True if the shader should register itself as listener at the compositor
    106127    };
    107128}
Note: See TracChangeset for help on using the changeset viewer.