IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Ogre Discussion :

Je ne comprends pas comment utiliser OIS


Sujet :

Ogre

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 2
    Points : 2
    Points
    2
    Par défaut Je ne comprends pas comment utiliser OIS
    Bonjour à toute la communauté française de ogre.

    Je me présente Stomrage. Graphiste 2d/3d dans des projets de jeux amateur depuis 5 ans.Je recherche à comprendre ogre et ainsi élucider le mystère des programmes que code un membre de ma team et pourqoi pas l'aider par la suite.

    Bon bref passons à mon problème. Enfaite j'ai suivi un tutorial sur le site de developpez (les bases d'ogre). Le programme marche youpiiiii ! (je vois un robot...)

    Je voudrais éteindre ce même programme, en appuyant sur la touche "Echap" de mon clavier.
    Le programme se compile !

    Mais quand je lance mon application... J'appuie sur "Echap" mais rien ne se passe.

    Voila étant un gros noob dans la programmation je vous montre mon programme. Mais on ne se moque pas ^^.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
     
    #include "Ogre.h"
    #include "OIS/OIS.h"
     
    class programme:public Ogre::FrameListener
    {
        public :
     
        Ogre::Root* pRoot ;
    	Ogre::SceneManager* pSceneManager ;
    	Ogre::RenderWindow* pRenderWindow;
    	Ogre::Viewport* pViewport ;
    	Ogre::Camera* pCamera ;
    	Ogre::Entity* pEntity;
        Ogre::SceneNode* pNode;
        OIS::InputManager *pInputManager;
        OIS::Mouse *pMouse;
        OIS::Keyboard *pKeyboard;
     
     
        bool quitter;
     
     
     
     
     
        programme()
        {
            pRoot = 0;
            pSceneManager = 0;
            pRenderWindow = 0;
            pCamera = 0;
            pViewport = 0;
            quitter = true;
     
        }
     
        public :
     
        void start();
        void run();
        void Quitter();
     
        bool FrameStarted(const Ogre::FrameEvent &evt);
        bool FrameEnded(const Ogre::FrameEvent &evt);
     
    void CreateObject(Ogre ::String Name)
    {
    	pEntity = pSceneManager->createEntity( Name, "robot.mesh" );
    	pNode = pSceneManager->getRootSceneNode()->createChildSceneNode(Name);
    	pNode->attachObject(pEntity);
    }
     
    void LoadResource()
    {
    	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../../media/models","FileSystem","General");
    	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../../media/materials/scripts","FileSystem","General");
    	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../../media/materials/textures","FileSystem","General");
    	Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../../media/materials/programs","FileSystem","General");
    	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    }
     
    void InitOIS()
    {
     
        OIS::ParamList pl;size_t windowHnd = 0;
    	std::ostringstream windowHndStr;
    	pRenderWindow->getCustomAttribute("WINDOW", &windowHnd);
    	windowHndStr << windowHnd;
    	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    	pInputManager = OIS::InputManager::createInputSystem( pl );
     
        pKeyboard = static_cast<OIS::Keyboard*>(pInputManager->createInputObject(OIS::OISKeyboard, true));
        pMouse = static_cast<OIS::Mouse*>(pInputManager->createInputObject(OIS::OISMouse, true));
     
    	unsigned int width, height, depth;
    	int top, left;
    	pRenderWindow->getMetrics(width, height, depth, left, top);
    	const OIS::MouseState &ms = pMouse->getMouseState();
    	ms.width = width;
    	ms.height = height;
     
    }
     
     
    };
     
    bool programme::FrameStarted(const Ogre::FrameEvent &evt)
    {
        pNode->yaw(Ogre::Degree(1));
        pNode->translate(Ogre::Vector3(1,0,0));
     
        if (pKeyboard->isKeyDown(OIS::KC_ESCAPE)) return quitter = false;
     
    	return quitter = true;
     
    }
     
    bool programme::FrameEnded(const Ogre::FrameEvent &evt)
    {
    	return quitter = true;
    }
     
     
    void programme::run()
    {
     
        pRoot->startRendering();
     
    }
     
    void programme::Quitter()
    {
     
        if(quitter = false)
        {
            delete pRoot;
        }
     
    }
     
    void programme::start()
     
    {
     
        pRoot = new Ogre::Root() ;
     
        pRoot->showConfigDialog();
     
        pRenderWindow = pRoot->initialise(true,"Ma premiere application Ogre");
     
        pSceneManager = pRoot->createSceneManager(Ogre::ST_GENERIC, "MonGestionnaireDeScene");
     
        pCamera = pSceneManager->createCamera("MaCamera");
     
        pCamera->setPosition(Ogre::Vector3(0,0,300));
     
        pCamera->lookAt(Ogre::Vector3(0,0,0));
     
        pCamera->setNearClipDistance(5);
     
        pViewport = pRenderWindow->addViewport(pCamera);
     
        LoadResource();
     
        CreateObject(" Robot ");
     
        pViewport->setBackgroundColour(Ogre::ColourValue(0,0,0));
     
        InitOIS();
     
        pRoot->addFrameListener(this);
     
    }
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
    #define WIN32_LEAN_AND_MEAN
    #include "windows.h"
     
    INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
    #else
    int main(int argc, char **argv)
    #endif
    {
        try {
    	programme Monprogramme ;
    	Monprogramme.start ();
    	Monprogramme.run() ;
    	Monprogramme.Quitter();
     
     
        } catch( Ogre::Exception &e ) {
    #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
            MessageBox( NULL, e.what(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
    #else
            fprintf(stderr, "An exception has occurred: %s\n",
                    e.what());
    #endif
        }
     
        return 0;
    }
    Voila si vous pouviez m'indiquer la méthode pour pouvoir fermer ma fenêtre en appuyant sur "Echap"

  2. #2
    Candidat au Club
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 2
    Points : 2
    Points
    2
    Par défaut
    J'ai résolu mon problème après avoir lu un grand nombre d'exemple.

    (désolé pour le post inutile)

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 8
    Dernier message: 23/05/2010, 21h06
  2. Réponses: 1
    Dernier message: 28/09/2008, 16h10
  3. [MySQL] cron ne comprend pas comment faire
    Par schats dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 26/06/2007, 16h42
  4. Réponses: 3
    Dernier message: 13/06/2007, 17h47
  5. [MySQL] Php, je ne comprends pas comment faire pour introduire des données dans une table
    Par Liondd dans le forum PHP & Base de données
    Réponses: 23
    Dernier message: 14/12/2006, 12h53

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo