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 :

Gérer les animations d'un mesh


Sujet :

Ogre

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 72
    Points : 0
    Points
    0
    Par défaut Gérer les animations d'un mesh
    Bonjour, tous le monde, j'ai un problème (ce qui m'arrive souvent, mais la ce n'est pas de ma faute), c'est que en faite dans la partie 3 du tutoriel, la ou il faut gérer les animation d'un mesh, sur cette ligne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Ogre::AnimationState *animationState = entity->getAnimationState("animationName");
    Et bien entity n'est pas déclarer, je vais essayer de plusieurs façon mais je vous pose quand même la question.

    Merci d'avance.

    Erwan28250

  2. #2
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    26 859
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 26 859
    Points : 218 579
    Points
    218 579
    Billets dans le blog
    120
    Par défaut
    Bonjour,

    Il faut montrer le reste du code + le tutoriel sur lequel vous reposer, car là, c'est juste que la variable entity n'existe pas.
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 72
    Points : 0
    Points
    0
    Par défaut
    Excusez-moi, c'est juste que j'avais mal compris le tutoriel, j'ai résolu le premier problème mais un autre apparaît :

    Voici le code des fichiers :

    AppDemarrage.h

    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
    #ifndef APPDEMARRAGE_H_INCLUDED
    #define APPDEMARRAGE_H_INCLUDED
     
    #include <Ogre.h>
    #include "InputListener.h"
     
    class AppDemarrage
    {
    public:
    	AppDemarrage();
    	~AppDemarrage();
     
    	bool start();
     
    private:
    	void createFrameListener();
    	void createScene();
    	InputListener *mInputListener;
    	Ogre::Root *mRoot;
    	Ogre::Camera* mCamera;
    	Ogre::SceneManager* mSceneMgr;
    	Ogre::RenderWindow *mWindow;
     
    	Ogre::SceneNode* mRobotNode;
    	Ogre::Entity* mRobot;
    	Ogre::AnimationState* mAnimationState;
    };
     
    #endif
    AppDemarrage.cpp

    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
    #include "AppDemarrage.h"
     
    AppDemarrage::AppDemarrage() : mRoot(0)
    {
    }
     
    void AppDemarrage::createFrameListener()
    {
    	mInputListener = new InputListener(mWindow, mCamera, mSceneMgr);
        mRoot->addFrameListener(mInputListener);
     
    	mAnimationState = mRobot->getAnimationState("Idle");
    	mAnimationState->setLoop(true);
    	mAnimationState->setEnabled(true);
    }
     
    bool AppDemarrage::start()
    {
    	mRoot = new Ogre::Root("plugins.cfg", "ogre.cfg", "Ogre.log");
     
    	Ogre::ConfigFile configFile;
    	configFile.load("resources.cfg");
     
    	Ogre::ConfigFile::SectionIterator seci = configFile.getSectionIterator();
    	Ogre::String secName, typeName, archName;
    	while (seci.hasMoreElements())
    	{
    		secName = seci.peekNextKey();
    		Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
    		Ogre::ConfigFile::SettingsMultiMap::iterator i;
    		for (i = settings->begin(); i != settings->end(); ++i)
    		{
    			typeName = i->first;
    			archName = i->second;
    			Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
    				archName, typeName, secName);
    		}
    	}
     
    	if(!(mRoot->restoreConfig() || mRoot->showConfigDialog()))
    	{
    		return false;
    	}
     
    	// variante : configuration sans boite de dialogue
    	if (mRoot->showConfigDialog())
    	{
    		mWindow = mRoot->initialise(true, "Ogre3D");
    	}
     
    	Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
    	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
     
    	mSceneMgr = mRoot->createSceneManager("DefaultSceneManager", "Mon Scene Manager");
    	mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f));
     
    	mCamera = mSceneMgr->createCamera("PlayerCam");
    	mCamera->setPosition(Ogre::Vector3(0,0,100));
    	mCamera->lookAt(Ogre::Vector3(0,0,0));
    	mCamera->setNearClipDistance(5);
     
    	Ogre::Viewport* vp = mWindow->addViewport(mCamera);
    	vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
    	mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
     
    	mRobot = mSceneMgr->createEntity("Robot", "robot.mesh");
     
    	mRobotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("RobotNode");
    	mRobotNode->attachObject(mRobot);
     
    	createFrameListener();
     
    	mRoot->startRendering();
     
    	while(true)
    	{
    		Ogre::WindowEventUtilities::messagePump();
     
    		if(mWindow->isClosed())
    			return false;
     
    		if(!mRoot->renderOneFrame())
    			return false;
    	}
    }
     
    void AppDemarrage::createScene()
    {
     
    }
     
    AppDemarrage::~AppDemarrage()
    {
    	OGRE_DELETE mRoot;
    	OGRE_DELETE mCamera;
    	OGRE_DELETE mSceneMgr;
    	OGRE_DELETE mWindow;
    	delete mRoot;
    }
    InputListener.h

    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
    #ifndef INPUTLISTENER_H_INCLUDED
    #define INPUTLISTENER_H_INCLUDED
     
    #include <Ogre.h>
    #include <OIS/OIS.h>
     
    class InputListener : public Ogre::FrameListener, public Ogre::WindowEventListener
    {
    public:
    	InputListener(Ogre::RenderWindow *wnd, Ogre::Camera *camera, Ogre::SceneManager *sceneMgr);
    	~InputListener();
     
    private:
    	bool frameRenderingQueued(const Ogre::FrameEvent& evt);
    	void startOIS();
    	virtual void windowResized(Ogre::RenderWindow* rw);
    	virtual void windowClosed(Ogre::RenderWindow* rw);
    	Ogre::SceneManager *mSceneMgr;
        Ogre::RenderWindow* mWindow;
        Ogre::Camera*       mCamera;
     
    	bool mToucheAppuyer;
     
    	Ogre::Real mMouvement;
    	Ogre::Real mVitesse;
    	Ogre::Real mVitesseRotation;
     
    	Ogre::Radian mRotationX;
    	Ogre::Radian mRotationY;
     
    	Ogre::AnimationState* mAnimationState;
     
        OIS::InputManager*  mInputManager;
        OIS::Mouse*         mMouse;
        OIS::Keyboard*      mKeyboard;
    };
     
    #endif
    InputListener.cpp

    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
    #include "InputListener.h"
     
    InputListener::InputListener(Ogre::RenderWindow *wnd, Ogre::Camera *camera, Ogre::SceneManager *sceneMgr)
    {
    	mSceneMgr = sceneMgr;
        mWindow = wnd;
        mCamera = camera;
     
    	mVitesse = 100;
    	mVitesseRotation = 0.1;
    	mToucheAppuyer = false;
    	startOIS();
    }
     
    bool InputListener::frameRenderingQueued(const Ogre::FrameEvent& evt)
    {
        if(mWindow->isClosed())
            return false;
     
    	if(mMouse)
    		mKeyboard->capture();
    	if(mKeyboard)
        mMouse->capture();
     
        if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
            return false;
     
    	Ogre::Vector3 deplacement = Ogre::Vector3::ZERO;
    	mMouvement = mVitesse * evt.timeSinceLastFrame;
     
    	if(mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
    		deplacement.x -= mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
    		deplacement.x += mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
    		deplacement.z -= mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
    		deplacement.z += mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_Q))
    		deplacement.y -= mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_E))
    		deplacement.y += mMouvement;
     
    	const OIS::MouseState &mouseState = mMouse->getMouseState();
     
    	mRotationX = Ogre::Degree(-mouseState.Y.rel * mVitesseRotation);
    	mRotationY = Ogre::Degree(-mouseState.X.rel * mVitesseRotation);
     
    	mCamera->yaw(mRotationY);
    	mCamera->pitch(mRotationX);
    	mCamera->moveRelative(deplacement);
     
    	mAnimationState->addTime(evt.timeSinceLastFrame);
     
        return true;
    }
     
    void InputListener::startOIS()
    {
    	Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
     
    	OIS::ParamList pl;
    	size_t windowHnd = 0;
    	std::ostringstream windowHndStr;
     
    	mWindow->getCustomAttribute("WINDOW", &windowHnd);
    	windowHndStr << windowHnd;
    	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
     
    	mInputManager = OIS::InputManager::createInputSystem( pl );
    	mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, false ));
    	mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, false ));
     
    	windowResized(mWindow);
    	Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
    }
     
    void InputListener::windowResized(Ogre::RenderWindow* wnd)
    {
    	unsigned int width, height, depth;
    	int left, top;
    	wnd->getMetrics(width, height, depth, left, top);
     
    	const OIS::MouseState &ms = mMouse->getMouseState();
    	ms.width = width;
    	ms.width = height;
    }
     
    void InputListener::windowClosed(Ogre::RenderWindow* wnd)
    {
    	if( wnd == mWindow )
    	{
    		if( mInputManager )
    		{
    			mInputManager->destroyInputObject( mMouse );
    			mInputManager->destroyInputObject( mKeyboard );
     
    			OIS::InputManager::destroyInputSystem(mInputManager);
    			mInputManager = 0;
    		}
    	}
    }
     
    InputListener::~InputListener()
    {
    	Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
    	windowClosed(mWindow);
    }
    et le main.cpp

    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
    #include "AppDemarrage.h"
     
    #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
    #define WIN32_LEAN_AND_MEAN
    #include "windows.h"
    #endif
     
    #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
    INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
    #else
    int main(int argc, char *argv[])
    #endif
    {
        AppDemarrage app;
     
        try {
            app.start();
        } catch( Ogre::Exception& e ) {
    #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
            MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
    #else
            std::cerr << "An exception has occured: " <<
                e.getFullDescription().c_str() << std::endl;
    #endif
        }
     
        return 0;
    }
    Le problème est celui-ci :



    Pouvez-vous m'aidez.

    Erwan28250

  4. #4
    Membre actif
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2009
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juillet 2009
    Messages : 132
    Points : 283
    Points
    283
    Par défaut
    Regarde dans le fichier Ogre.log, fichier qui contient pas mal de messages intéressants générés pendant l'exécution. Je pense que tu y trouveras un message concernant un fichier robot.skeleton manquant. Si je ne me trompe pas, ce fichier contient les informations d'animations du robot.

  5. #5
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 72
    Points : 0
    Points
    0
    Par défaut
    , Je n'est pas trouver le fichier Ogre.log. mais j'ai essayer d'ajouter le fichier robot.skeleton, il n'y a plus le message d'erreur mais la Windows mes que le programme a cesser de fonctionner.

    Alors, soit il y a une façon de faire, soit il y a un autre problème.

    Erwan28250

  6. #6
    Membre actif
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2009
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juillet 2009
    Messages : 132
    Points : 283
    Points
    283
    Par défaut
    Il y a probablement un autre problème.
    Fais une recherche pour trouver le fichier Ogre.log, qui contiendra peut-être un message d'exception. Sinon utilise le débogueur pour repérer quelle instruction pose problème (si c'est ton code qui pose directement un souci).

  7. #7
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 72
    Points : 0
    Points
    0
    Par défaut
    c'est bon je crois savoir d'où viens le problème, dans la méthode frameRenderingQueued qui ce trouve dans InputListener, il faut mettre dedans

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    mAnimationState->addTime(evt.timeSinceLastFrame);
    pour que l'animation ce répète en continue, donc quand je met cette ligne je jeux plante (en mettant a cesser de fonctionner), mais quand je ne met pas cette ligne, le robot ce met en route et sarrette (on n'a pas le temps de voir ce qui l'a fait, parce que la méthode a fini quand on n'a terminer le chargement mais on voit que c'est jambe on bouger, c'est pour cela que je dit ça).

    Je mes de nouveaux les fichier car j'ai changer d'emplacement quel que truck.

    AppDemarrage.h

    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
    #ifndef APPDEMARRAGE_H_INCLUDED
    #define APPDEMARRAGE_H_INCLUDED
     
    #include <Ogre.h>
    #include "InputListener.h"
     
    class AppDemarrage
    {
    public:
    	AppDemarrage();
    	~AppDemarrage();
     
    	bool start();
     
    private:
    	void createFrameListener();
    	void createScene();
    	InputListener *mInputListener;
    	Ogre::Root *mRoot;
    	Ogre::Camera* mCamera;
    	Ogre::SceneManager* mSceneMgr;
    	Ogre::RenderWindow *mWindow;
     
    	Ogre::SceneNode* mRobotNode;
    	Ogre::Entity* mRobot;
    	Ogre::AnimationState* mAnimationState;
    };
     
    #endif
    AppDemarrage.cpp

    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
    #include "AppDemarrage.h"
     
    AppDemarrage::AppDemarrage() : mRoot(0)
    {
    }
     
    void AppDemarrage::createFrameListener()
    {
    	mInputListener = new InputListener(mWindow, mCamera, mSceneMgr);
        mRoot->addFrameListener(mInputListener);
    }
     
    bool AppDemarrage::start()
    {
    	mRoot = new Ogre::Root("plugins.cfg", "ogre.cfg", "Ogre.log");
     
    	Ogre::ConfigFile configFile;
    	configFile.load("resources.cfg");
     
    	Ogre::ConfigFile::SectionIterator seci = configFile.getSectionIterator();
    	Ogre::String secName, typeName, archName;
    	while (seci.hasMoreElements())
    	{
    		secName = seci.peekNextKey();
    		Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
    		Ogre::ConfigFile::SettingsMultiMap::iterator i;
    		for (i = settings->begin(); i != settings->end(); ++i)
    		{
    			typeName = i->first;
    			archName = i->second;
    			Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
    				archName, typeName, secName);
    		}
    	}
     
    	if(!(mRoot->restoreConfig() || mRoot->showConfigDialog()))
    	{
    		return false;
    	}
     
    	// variante : configuration sans boite de dialogue
    	if (mRoot->showConfigDialog())
    	{
    		mWindow = mRoot->initialise(true, "Ogre3D");
    	}
     
    	Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
    	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
     
    	mSceneMgr = mRoot->createSceneManager("DefaultSceneManager", "Mon Scene Manager");
    	mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f));
     
    	mCamera = mSceneMgr->createCamera("PlayerCam");
    	mCamera->setPosition(Ogre::Vector3(0,0,100));
    	mCamera->lookAt(Ogre::Vector3(0,0,0));
    	mCamera->setNearClipDistance(5);
     
    	createFrameListener();
     
    	Ogre::Viewport* vp = mWindow->addViewport(mCamera);
    	vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
    	mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
     
    	mRobot = mSceneMgr->createEntity("Robot", "robot.mesh");
    	mRobotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("RobotNode");
    	mRobotNode->attachObject(mRobot);
     
    	mAnimationState = mRobot->getAnimationState("Walk");
    	mAnimationState->setLoop(true);
    	mAnimationState->setEnabled(true);
     
    	mRoot->startRendering();
     
    	while(true)
    	{
    		Ogre::WindowEventUtilities::messagePump();
     
    		if(mWindow->isClosed())
    			return false;
     
    		if(!mRoot->renderOneFrame())
    			return false;
    	}
    }
     
    void AppDemarrage::createScene()
    {
     
    }
     
    AppDemarrage::~AppDemarrage()
    {
    	OGRE_DELETE mRoot;
    	OGRE_DELETE mCamera;
    	OGRE_DELETE mSceneMgr;
    	OGRE_DELETE mWindow;
    	delete mRoot;
    }
    InputListener.h

    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
    #ifndef INPUTLISTENER_H_INCLUDED
    #define INPUTLISTENER_H_INCLUDED
     
    #include <Ogre.h>
    #include <OIS/OIS.h>
     
    class InputListener : public Ogre::FrameListener, public Ogre::WindowEventListener
    {
    public:
    	InputListener(Ogre::RenderWindow *wnd, Ogre::Camera *camera, Ogre::SceneManager *sceneMgr);
    	~InputListener();
     
    private:
    	bool frameRenderingQueued(const Ogre::FrameEvent& evt);
    	void startOIS();
    	virtual void windowResized(Ogre::RenderWindow* rw);
    	virtual void windowClosed(Ogre::RenderWindow* rw);
    	Ogre::SceneManager *mSceneMgr;
        Ogre::RenderWindow* mWindow;
        Ogre::Camera*       mCamera;
     
    	bool mToucheAppuyer;
     
    	Ogre::Real mMouvement;
    	Ogre::Real mVitesse;
    	Ogre::Real mVitesseRotation;
     
    	Ogre::Radian mRotationX;
    	Ogre::Radian mRotationY;
     
        OIS::InputManager*  mInputManager;
        OIS::Mouse*         mMouse;
        OIS::Keyboard*      mKeyboard;
     
    	Ogre::AnimationState* mAnimationState;
    };
     
    #endif
    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
    #include "InputListener.h"
     
    InputListener::InputListener(Ogre::RenderWindow *wnd, Ogre::Camera *camera, Ogre::SceneManager *sceneMgr)
    {
    	mSceneMgr = sceneMgr;
        mWindow = wnd;
        mCamera = camera;
     
    	mVitesse = 100;
    	mVitesseRotation = 0.1;
    	mToucheAppuyer = false;
    	startOIS();
    }
     
    bool InputListener::frameRenderingQueued(const Ogre::FrameEvent& evt)
    {
    	if(mWindow->isClosed())
            return false;
     
    	if(mMouse)
    		mKeyboard->capture();
    	if(mKeyboard)
        mMouse->capture();
     
        if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
            return false;
     
    	Ogre::Vector3 deplacement = Ogre::Vector3::ZERO;
    	mMouvement = mVitesse * evt.timeSinceLastFrame;
     
    	if(mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
    		deplacement.x -= mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
    		deplacement.x += mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
    		deplacement.z -= mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
    		deplacement.z += mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_Q))
    		deplacement.y -= mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_E))
    		deplacement.y += mMouvement;
     
    	const OIS::MouseState &mouseState = mMouse->getMouseState();
     
    	mRotationX = Ogre::Degree(-mouseState.Y.rel * mVitesseRotation);
    	mRotationY = Ogre::Degree(-mouseState.X.rel * mVitesseRotation);
     
    	mCamera->yaw(mRotationY);
    	mCamera->pitch(mRotationX);
    	mCamera->moveRelative(deplacement);
     
    	mAnimationState->addTime(evt.timeSinceLastFrame);
     
        return true;
    }
     
    void InputListener::startOIS()
    {
    	Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
     
    	OIS::ParamList pl;
    	size_t windowHnd = 0;
    	std::ostringstream windowHndStr;
     
    	mWindow->getCustomAttribute("WINDOW", &windowHnd);
    	windowHndStr << windowHnd;
    	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
     
    	mInputManager = OIS::InputManager::createInputSystem( pl );
    	mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, false ));
    	mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, false ));
     
    	windowResized(mWindow);
    	Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
    }
     
    void InputListener::windowResized(Ogre::RenderWindow* wnd)
    {
    	unsigned int width, height, depth;
    	int left, top;
    	wnd->getMetrics(width, height, depth, left, top);
     
    	const OIS::MouseState &ms = mMouse->getMouseState();
    	ms.width = width;
    	ms.width = height;
    }
     
    void InputListener::windowClosed(Ogre::RenderWindow* wnd)
    {
    	if( wnd == mWindow )
    	{
    		if( mInputManager )
    		{
    			mInputManager->destroyInputObject( mMouse );
    			mInputManager->destroyInputObject( mKeyboard );
     
    			OIS::InputManager::destroyInputSystem(mInputManager);
    			mInputManager = 0;
    		}
    	}
    }
     
    InputListener::~InputListener()
    {
    	Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
    	windowClosed(mWindow);
    }
    Voila.

    Erwan28250

  8. #8
    Membre actif
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2009
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juillet 2009
    Messages : 132
    Points : 283
    Points
    283
    Par défaut
    Ton pointeur mAnimationState, dans InputListener, n'est pas initialisé au moment où tu appelles sa méthode addTime. T'as oublié un truc.

  9. #9
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 72
    Points : 0
    Points
    0
    Par défaut
    Okay, d'accord, Merci, bon ça c'est compris, mais juste un truck, je sais que la ligne de l'initialisation du pointer vas commencer par :

    Mais apprès, je ne c'est pas quoi mettre.

    ps: Désoler je pose beaucoup de question .

    Merci d'avance.

    Erwan28250

  10. #10
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 72
    Points : 0
    Points
    0
    Par défaut
    En faite, je viens de voir dans le tutoriel qu'il faut mettre ces ligne:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    	mAnimationState = mRobot->getAnimationState("Walk");
    	mAnimationState->setLoop(true);
    	mAnimationState->setEnabled(true);
    dans la méthode createFrameListener(), quand je ne la mes pas dans la méthode createFrameListener(), il met que le jeux a cesser de fonctionner, mais quand je le met, il remet le message d'erreur qu'il y avait plus haut. Je n'est toujours pas réussi a initialiser le pointer.

    Erwan28250

  11. #11
    Membre actif
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2009
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juillet 2009
    Messages : 132
    Points : 283
    Points
    283
    Par défaut
    Tu suis quel tutoriel au juste ? Soit il est incomplet, soit tu n'as pas tout lu.
    Essaie aussi de comprendre en détail le code que tu écris, parce que j'ai l'impression que tu ne comprends pas tout, je me trompe ?

    Bon, si tu écris ce code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    mAnimationState = mRobot->getAnimationState("Walk");
    mAnimationState->setLoop(true);
    mAnimationState->setEnabled(true);
    Dans la méthode AppDemarrage::createFrameListener, il faut t'assurer que la variable mRobot est un pointeur valide (initialisé et non nul). Dans ton code ça ne doit être le cas puisque l'objet mRobot est créé après l'appel à la méthode AppDemarrage::createFrameListener.
    J'en profite pour dire que tu devrais initialiser toutes tes variables attributs dans le constructeur de leur classe (et initialiser les pointeurs à 0).

  12. #12
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 72
    Points : 0
    Points
    0
    Par défaut
    Bonjour, je suis un tutoriel, et pour le code, j'arrive a comprendre la plus part dur code, et pour de ce que j'ai fait sur le code, j'ai suivit le tutoriel.

    Mais je n'arrive pas a comprendre pourquoi ça ne marche pas.

    J'ai changer des truck sur le code :

    AppDemarrage.cpp :

    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
    #include "InputListener.h"
     
    InputListener::InputListener(Ogre::RenderWindow *wnd, Ogre::Camera *camera, Ogre::SceneManager *sceneMgr)
    {
    	mSceneMgr = sceneMgr;
        mWindow = wnd;
        mCamera = camera;
     
    	mVitesse = 100;
    	mVitesseRotation = 0.1;
    	mToucheAppuyer = false;
    	startOIS();
    }
     
    bool InputListener::frameRenderingQueued(const Ogre::FrameEvent& evt)
    {
    	mAnimationState->addTime(evt.timeSinceLastEvent);
     
    	if(mWindow->isClosed())
            return false;
     
    	if(mMouse)
    		mKeyboard->capture();
    	if(mKeyboard)
    		mMouse->capture();
     
        if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
            return false;
     
    	Ogre::Vector3 deplacement = Ogre::Vector3::ZERO;
    	mMouvement = mVitesse * evt.timeSinceLastFrame;
     
    	if(mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
    		deplacement.x -= mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
    		deplacement.x += mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
    		deplacement.z -= mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
    		deplacement.z += mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_Q))
    		deplacement.y -= mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_E))
    		deplacement.y += mMouvement;
     
    	const OIS::MouseState &mouseState = mMouse->getMouseState();
     
    	mRotationX = Ogre::Degree(-mouseState.Y.rel * mVitesseRotation);
    	mRotationY = Ogre::Degree(-mouseState.X.rel * mVitesseRotation);
     
    	mCamera->yaw(mRotationY);
    	mCamera->pitch(mRotationX);
    	mCamera->moveRelative(deplacement);
     
        return true;
    }
     
    void InputListener::startOIS()
    {
    	Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
     
    	OIS::ParamList pl;
    	size_t windowHnd = 0;
    	std::ostringstream windowHndStr;
     
    	mWindow->getCustomAttribute("WINDOW", &windowHnd);
    	windowHndStr << windowHnd;
    	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
     
    	mInputManager = OIS::InputManager::createInputSystem( pl );
    	mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, false ));
    	mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, false ));
     
    	windowResized(mWindow);
    	Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
    }
     
    void InputListener::windowResized(Ogre::RenderWindow* wnd)
    {
    	unsigned int width, height, depth;
    	int left, top;
    	wnd->getMetrics(width, height, depth, left, top);
     
    	const OIS::MouseState &ms = mMouse->getMouseState();
    	ms.width = width;
    	ms.width = height;
    }
     
    void InputListener::windowClosed(Ogre::RenderWindow* wnd)
    {
    	if( wnd == mWindow )
    	{
    		if( mInputManager )
    		{
    			mInputManager->destroyInputObject( mMouse );
    			mInputManager->destroyInputObject( mKeyboard );
     
    			OIS::InputManager::destroyInputSystem(mInputManager);
    			mInputManager = 0;
    		}
    	}
    }
     
    InputListener::~InputListener()
    {
    	Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
    	windowClosed(mWindow);
    }
    InputListener.cpp

    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
    #include "InputListener.h"
     
    InputListener::InputListener(Ogre::RenderWindow *wnd, Ogre::Camera *camera, Ogre::SceneManager *sceneMgr)
    {
    	mSceneMgr = sceneMgr;
        mWindow = wnd;
        mCamera = camera;
     
    	mVitesse = 100;
    	mVitesseRotation = 0.1;
    	mToucheAppuyer = false;
    	startOIS();
    }
     
    bool InputListener::frameRenderingQueued(const Ogre::FrameEvent& evt)
    {
    	mAnimationState->addTime(evt.timeSinceLastEvent);
     
    	if(mWindow->isClosed())
            return false;
     
    	if(mMouse)
    		mKeyboard->capture();
    	if(mKeyboard)
    		mMouse->capture();
     
        if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
            return false;
     
    	Ogre::Vector3 deplacement = Ogre::Vector3::ZERO;
    	mMouvement = mVitesse * evt.timeSinceLastFrame;
     
    	if(mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
    		deplacement.x -= mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
    		deplacement.x += mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
    		deplacement.z -= mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
    		deplacement.z += mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_Q))
    		deplacement.y -= mMouvement;
    	if(mKeyboard->isKeyDown(OIS::KC_E))
    		deplacement.y += mMouvement;
     
    	const OIS::MouseState &mouseState = mMouse->getMouseState();
     
    	mRotationX = Ogre::Degree(-mouseState.Y.rel * mVitesseRotation);
    	mRotationY = Ogre::Degree(-mouseState.X.rel * mVitesseRotation);
     
    	mCamera->yaw(mRotationY);
    	mCamera->pitch(mRotationX);
    	mCamera->moveRelative(deplacement);
     
        return true;
    }
     
    void InputListener::startOIS()
    {
    	Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
     
    	OIS::ParamList pl;
    	size_t windowHnd = 0;
    	std::ostringstream windowHndStr;
     
    	mWindow->getCustomAttribute("WINDOW", &windowHnd);
    	windowHndStr << windowHnd;
    	pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
     
    	mInputManager = OIS::InputManager::createInputSystem( pl );
    	mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, false ));
    	mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, false ));
     
    	windowResized(mWindow);
    	Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
    }
     
    void InputListener::windowResized(Ogre::RenderWindow* wnd)
    {
    	unsigned int width, height, depth;
    	int left, top;
    	wnd->getMetrics(width, height, depth, left, top);
     
    	const OIS::MouseState &ms = mMouse->getMouseState();
    	ms.width = width;
    	ms.width = height;
    }
     
    void InputListener::windowClosed(Ogre::RenderWindow* wnd)
    {
    	if( wnd == mWindow )
    	{
    		if( mInputManager )
    		{
    			mInputManager->destroyInputObject( mMouse );
    			mInputManager->destroyInputObject( mKeyboard );
     
    			OIS::InputManager::destroyInputSystem(mInputManager);
    			mInputManager = 0;
    		}
    	}
    }
     
    InputListener::~InputListener()
    {
    	Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
    	windowClosed(mWindow);
    }
    Erwan28250

  13. #13
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 72
    Points : 0
    Points
    0
    Par défaut
    JérémieL, j'avais réussi a initialiser le pointer, en faite dans les surcharge du constructeur, j'ai ragouter ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Ogre::AnimationState* mAnim
    et dans le constructeur, j'ai rajouter cette ligne:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    mAnimationState = mAnim;
    Maintenant quand je lance le programme je n'est plus l'erreur, mais j'ai un autre problème, l'animation ne marche pas en boucle (J'utilise l'animation Walk), donc sa apparait comme ceci:



    il apparait comme ça et il ne bouge plus. (vous aller me dire que c'est bizarre mon robot est en bois, c'est juste que parce que le robot n'avait pas de texture alors j'ai mis le première que j'ai trouver).

    Je vous donne le InputListener.cpp modifier.

    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
    #include "InputListener.h"
     
    InputListener::InputListener(Ogre::RenderWindow *wnd, Ogre::Camera *camera, Ogre::SceneManager *sceneMgr, Ogre::AnimationState* mAnim)
    {
        mSceneMgr = sceneMgr;
        mWindow = wnd;
        mCamera = camera;
        mAnimationState = mAnim;
     
        mVitesse = 100;
        mVitesseRotation = 0.1;
        mToucheAppuyer = false;
        startOIS();
    }
     
    bool InputListener::frameRenderingQueued(const Ogre::FrameEvent& evt)
    {
        mAnimationState->addTime(evt.timeSinceLastEvent);
     
        if(mWindow->isClosed())
            return false;
     
        if(mMouse)
            mKeyboard->capture();
        if(mKeyboard)
            mMouse->capture();
     
        if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
            return false;
     
        Ogre::Vector3 deplacement = Ogre::Vector3::ZERO;
        mMouvement = mVitesse * evt.timeSinceLastFrame;
     
        if(mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
            deplacement.x -= mMouvement;
        if(mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
            deplacement.x += mMouvement;
        if(mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
            deplacement.z -= mMouvement;
        if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
            deplacement.z += mMouvement;
        if(mKeyboard->isKeyDown(OIS::KC_Q))
            deplacement.y -= mMouvement;
        if(mKeyboard->isKeyDown(OIS::KC_E))
            deplacement.y += mMouvement;
     
        const OIS::MouseState &mouseState = mMouse->getMouseState();
     
        mRotationX = Ogre::Degree(-mouseState.Y.rel * mVitesseRotation);
        mRotationY = Ogre::Degree(-mouseState.X.rel * mVitesseRotation);
     
        mCamera->yaw(mRotationY);
        mCamera->pitch(mRotationX);
        mCamera->moveRelative(deplacement);
     
        return true;
    }
     
    void InputListener::startOIS()
    {
        Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
     
        OIS::ParamList pl;
        size_t windowHnd = 0;
        std::ostringstream windowHndStr;
     
        mWindow->getCustomAttribute("WINDOW", &windowHnd);
        windowHndStr << windowHnd;
        pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
     
        mInputManager = OIS::InputManager::createInputSystem( pl );
        mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, false ));
        mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, false ));
     
        windowResized(mWindow);
        Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
    }
     
    void InputListener::windowResized(Ogre::RenderWindow* wnd)
    {
        unsigned int width, height, depth;
        int left, top;
        wnd->getMetrics(width, height, depth, left, top);
     
        const OIS::MouseState &ms = mMouse->getMouseState();
        ms.width = width;
        ms.width = height;
    }
     
    void InputListener::windowClosed(Ogre::RenderWindow* wnd)
    {
        if( wnd == mWindow )
        {
            if( mInputManager )
            {
                mInputManager->destroyInputObject( mMouse );
                mInputManager->destroyInputObject( mKeyboard );
     
                OIS::InputManager::destroyInputSystem(mInputManager);
                mInputManager = 0;
            }
        }
    }
     
    InputListener::~InputListener()
    {
        Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
        windowClosed(mWindow);
    }
    j'ai peut être oublier quel que chose (ou mal fait quel que chose) mais en tout cas il y n'y a plus l'erreur, c'est déjà une étape de faite .

    Merci d'avance.

    Erwan28250

  14. #14
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Novembre 2012
    Messages
    72
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2012
    Messages : 72
    Points : 0
    Points
    0
    Par défaut
    Problème résolu. je vais faire simple, le code suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    	mAnimationState = mRobot->getAnimationState("Walk");
    	mAnimationState->setLoop(true);
    	mAnimationState->setEnabled(true);
    il faut le mettre avant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    	mInputListener = new InputListener(mWindow, mCamera, mSceneMgr, mAnimationState);
    	mRoot->addFrameListener(mInputListener);
    sinon (comment voulez-vous chercher un objet qui n'existe pas) ça ne marche pas, Le dernier problème était juste devant mes yeux .

    Erwan28250

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

Discussions similaires

  1. [D5][SQL Server] Conserver des images dans la BDD
    Par FONKOU dans le forum Bases de données
    Réponses: 8
    Dernier message: 08/06/2008, 19h58
  2. [Frame] Gérer les composants
    Par chastel dans le forum Débuter
    Réponses: 4
    Dernier message: 07/05/2004, 17h57
  3. Gérer les clics sur les boutons
    Par cyberlewis dans le forum Windows
    Réponses: 4
    Dernier message: 08/02/2004, 15h34
  4. Comment gérer les espaces blancs?
    Par Lambo dans le forum XML/XSL et SOAP
    Réponses: 10
    Dernier message: 16/05/2003, 09h44
  5. gérer les jpg dans une fenetre directdraw???
    Par Anonymous dans le forum DirectX
    Réponses: 1
    Dernier message: 14/06/2002, 13h39

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