Source

KODE / samples / KODEOgre / include / App.hpp

#ifndef KODE_OGRE_APP_HPP
#define KODE_OGRE_APP_HPP

#include <memory>
#include <string>

#include <OgreCamera.h>
#include <OgreEntity.h>
#include <OgreLogManager.h>
#include <OgreRoot.h>
#include <OgreViewport.h>
#include <OgreSceneManager.h>
#include <OgreRenderWindow.h>
#include <OgreConfigFile.h>
#include <Overlay/OgreOverlay.h>
#include <Overlay/OgreOverlayElement.h>
#include <Overlay/OgreOverlayManager.h>
#include <OgreWindowEventUtilities.h>

#include <OISEvents.h>
#include <OISInputManager.h>
#include <OISKeyboard.h>
#include <OISMouse.h>

#include <kode/World.hpp>

namespace kode {
    namespace ogre {

        class App : public Ogre::WindowEventListener,
                    public OIS::KeyListener,
                    public OIS::MouseListener {
        public:
            App(const std::string& title="KODE+Ogre app");
            ~App();


            void update(double timeSinceLastFrame);
            void moveCamera();
            void getInput();
            void stop();
            void run();
            virtual void step();


            virtual bool keyPressed(const OIS::KeyEvent &keyEventRef) override;
            virtual bool keyReleased(const OIS::KeyEvent &keyEventRef) override;

            virtual bool mouseMoved(const OIS::MouseEvent &evt) override;
            virtual bool mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID id) override;
            virtual bool mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID id) override;

            virtual void windowResized(Ogre::RenderWindow* rw) override;


            Ogre::LogManager logMgr;
            Ogre::Log*       log;
            Ogre::Root       root;
            Ogre::Timer      timer;

            Ogre::SceneManager* sceneMgr  = nullptr;
            Ogre::RenderWindow* renderWnd = nullptr;
            Ogre::Camera*       camera    = nullptr;
            Ogre::Viewport*     viewport  = nullptr;

            OIS::InputManager* inputMgr = nullptr;
            OIS::Keyboard*     keyboard = nullptr;
            OIS::Mouse*        mouse    = nullptr;


            World world;


            static App* instance;


        private:

            Ogre::FrameEvent frameEvent;

            bool shutDownOgre = false;

            Ogre::Vector3 translateVector;
            Ogre::Real    moveSpeed   = 5;
            Ogre::Degree  rotateSpeed = Ogre::Degree{0.3};
            Ogre::Degree  rotScale    = Ogre::Degree{0};
            float           moveScale   = 0;
        };
    }
}

#endif