begin process at 2008 08 20 14:42:13
1 228 884 membres
250 nouveaux aujourd'hui
14 258 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

Sujet : Problème Ogre/OIS [ Linux / GUI ] (Mxjugg)

Problème Ogre/OIS le 05/06/2008 00:04:10

Mxjugg
Bonjour à tous!
Je début dans la programmation avec Ogre et je sèche sur la gestion des périphériques avec OIS
Apparemment mes fontions de callback ne sont pas appelées (faut dire que la doc OIS est pas très explicite)
Je vous balance mon code:

myapp.hpp
#ifndef myapp_hpp
#define myapp_hpp

#include <OGRE/Ogre.h>
#include <OIS/OIS.h>

classmMouseListener:publicOIS::MouseListener
{
public:
mMouseListener(){}
virtual~mMouseListener(){}
virtualboolmouseMoved(constOIS::MouseEvent&arg);
virtualboolmousePressed(constOIS::MouseEvent&arg,OIS::MouseButtonIDid);
virtualboolmouseReleased(constOIS::MouseEvent&arg,OIS::MouseButtonIDid);
};

classmKeyListener:publicOIS::KeyListener
{
public:
mKeyListener(){}
virtual~mKeyListener(){}
virtualboolkeyPressed(constOIS::KeyEvent&arg);
virtualboolkeyReleased(constOIS::KeyEvent&arg);
};

classmFrameListener:publicOgre::FrameListener
{
public:
virtualboolframeStarted(constOgre::FrameEvent&);
};

classmyApp:publicmMouseListener,publicmKeyListener,publicmFrameListener
{
private:
Ogre::Root*root;
Ogre::RenderWindow*window;
Ogre::SceneManager*scenemanager;
Ogre::Camera*camera;
Ogre::Viewport*viewport;


OIS::InputManager*inputmanager;
OIS::Mouse*mouse;
OIS::Keyboard*keyboard;
mFrameListener*framelistener;
mMouseListener*mouselistener;
mKeyListener*keylistener;

public:
myApp(constOgre::String&name,constOgre::String&plugin="plugins.cfg",constOgre::Realpx=0.,constOgre::Realpy=0.,constOgre::Realpz=0.,constOgre::Realvx=0.,constOgre::Realvy=0.,constOgre::Realvz=0.,constOgre::Realnc=1.,constOgre::Realfc=100.);
voidaddMesh(constOgre::String&,constOgre::String&);
voidaddResourceFile(constOgre::String&);
voidaddOverlay(constOgre::String&);
voidloadListeners();
voidrun();
};

#endif

la doc OIS indique clairement qu'il faut dériver ses listeners. C'est fait.

Ensuite vient le fichier
myapp.cpp

#include "myapp.hpp"

myApp::myApp(constOgre::String&name,constOgre::String&plugin,constOgre::Realpx,constOgre::Realpy,constOgre::Realpz,constOgre::Realvx,constOgre::Realvy,constOgre::Realvz,constOgre::Realnc,constOgre::Realfc)
{
/* initialise Ogre::root */
root=newOgre::Root(plugin,"ogre.cfg","ogre.log");
if(!root->restoreConfig())/* le fichier de config ogre.cfg exist ? */
{
if(!root->showConfigDialog())/* affiche un menu 'ogre' de configuration du système de rendu et enregistre les paramètres dans ogre.cfg : pas besoin de reconfigurer à chaque fois */
{
throwOgre::Exception(0,"ConfigDialogError","showConfigDialog()");
}
}

/* initialise la fenetre */
window=root->initialise(true,name);/* bool autoCreateWindow, const String &windowTitle="OGRE Render Window" */

/* créer le gestionnaire de scène */
scenemanager=root->createSceneManager(Ogre::ST_GENERIC,"SceneManager");/* const String &typeName, const String &instanceName=StringUtil::BLANK */

/* créer la caméra et la configure */
camera=scenemanager->createCamera("Camera");/* createCamera (const String &name) */
camera->setPosition(Ogre::Vector3(px,py,pz));
camera->lookAt(Ogre::Vector3(vx,vy,vz));
camera->setNearClipDistance(nc);
camera->setFarClipDistance(fc);

/* créer la vue */
viewport=window->addViewport(camera);/* la caméra est attachée au viewport de la fenetre */
viewport->setBackgroundColour(Ogre::ColourValue(0.0f,0.0f,0.0f));/* fixer la couleur d'arrière plan */
camera->setAspectRatio(Ogre::Real(viewport->getActualWidth())/Ogre::Real(viewport->getActualHeight()));/* fixer le ratio de la cam */

/* lancer les listeners */
loadListeners();
}

boolmMouseListener::mouseMoved(constOIS::MouseEvent&arg)
{
returntrue;
}

boolmMouseListener::mousePressed(constOIS::MouseEvent&arg,OIS::MouseButtonIDid)
{
returntrue;
}

boolmMouseListener::mouseReleased(constOIS::MouseEvent&arg,OIS::MouseButtonIDid)
{
returntrue;
}

boolmKeyListener::keyPressed(constOIS::KeyEvent&arg)
{
std::cout<<"keyPressed"<<std::endl;/* pti test; jamais vu sur le terminal */
returntrue;
}

boolmKeyListener::keyReleased(constOIS::KeyEvent&arg)
{
returntrue;
}

boolmFrameListener::frameStarted(constOgre::FrameEvent&ev)
{
staticfloattime=0.0f;
time+=ev.timeSinceLastFrame;

if(time>=10.f)
returnfalse;

/* vu que les périphes marchent pas, ils faut bien pouvoir quitter l'appli (= */

returntrue;
}

voidmyApp::loadListeners()
{
size_tw;
window->getCustomAttribute("WINDOW",&w);

/* create OIS input manager system */
inputmanager=OIS::InputManager::createInputSystem(w);

/* create mouse and keyboard w/ input manager */
mouse=static_cast<OIS::Mouse*>(inputmanager->createInputObject(OIS::OISMouse,true));
keyboard=static_cast<OIS::Keyboard*>(inputmanager->createInputObject(OIS::OISKeyboard,true));

/* set mouse */
unsignedintwidth,height,depth;
inttop,left;
window->getMetrics(width,height,depth,left,top);
constOIS::MouseState&mousestate=mouse->getMouseState();
mousestate.width=width;
mousestate.height=height;

/* add a frame listener */
framelistener=newmFrameListener;
root->addFrameListener(framelistener);

/* add mouse and keyboard listener */
mouselistener=newmMouseListener;
keylistener=newmKeyListener;
mouse->setEventCallback(mouselistener);
keyboard->setEventCallback(keylistener);

/* C'EST ICI QUE CA PÈCHE ? , pourtant il me semble que c'est ce qui est indiquer dans la doc OIS (en tout cas ca compile) */
}



Voila. j'espère qu'il y a quelqu'un qui m'aidera a résoudre ce problème.
ps: j'ai lu des tuto sur des wiki concernant ogre/ois et faire un programme en dérivant un classe example ca ne m'interresse pas!
Cya

Re : Problème Ogre/OIS le 06/08/2008 02:24:30

koda_12
C'est un bon choix de se passer d'exemple app
j'ai le même porblème que toi
je cherche si je trouve je poste
si t'as trouvé postes

merci

Re : Problème Ogre/OIS le 06/08/2008 02:44:57

koda_12

 				/* create mouse and keyboard w/ input manager */ 				
mouse = static_cast < OIS :: Mouse *> ( inputmanager -> createInputObject ( OIS :: OISMouse , true ));
keyboard = static_cast < OIS :: Keyboard *> ( inputmanager -> createInputObject ( OIS :: OISKeyboard , true ));

t'as true et true
tu mets false et false
les event se déclencheront
la doc OIS est un peu légère à ce niveau je te le concède

A oui dans mon code avec false et true ça faisait nimp mais on a pas le même code brrrrref...



Re : Problème Ogre/OIS le 12/08/2008 12:15:26

koda_12
/* create mouse and keyboard w/ input manager */                 
mouse     = static_cast<OI::Mouse *>(inputmanager->createInputObject (OIS ::OISMouse , true));                 
keyboard =     static_cast < OIS::Keyboard*>(inputmanager -> createInputObject ( OIS ::OISKeyboard , true ));

le cop colle du code a foiré

Re : Problème Ogre/OIS le 19/08/2008 14:19:16

larles
Tu ne fais pas tes captures d'evenements, alors tu ne recois rien.
OIS te demande de forcer les capture via les methodes capture. Il te suffit a chaque frame de faire un capture()  sur ton OIS::Keyboard et ton OIS::Mouse pour que tes methodes surchargees soient appelles.


Classé sous : string, ogre, ois, constogre, constois

Participer à cet échange

Pub



Appels d'offres

CalendriCode

Août 2008
LMMJVSD
    123
45678910
11121314151617
18192021222324
25262728293031

Téléchargements

Logiciels à télécharger sur le même thème :

Boutique

Boutique de goodies CodeS-SourceS