Page 1 of 1

Basic example of mouse look?

Posted: Sat Feb 05, 2005 23:58
by stodge
I don't suppose there's an example anywhere of a very basic CEGui app with OGRE, that just uses mouse look with a basic window. Just the very basics, like moving around an object in space? If that makes sense.

Thanks

Re: Basic example of mouse look?

Posted: Sun Feb 06, 2005 11:44
by CrazyEddie
Not anything official like. I don't know what other people may have got lying around though :)

What kind of behaviour were you looking for? By this I mean under what conditions should the mouse change the camera view, and under what conditions would the window be active?

There's probably a few ways of doing this. Switching on a keypress (like escape to show/hide a menu), or something else where the mouse cursor is always present, though the camera only moves when the mouse is outside any windows are two popular approaches.

CE.

Re: Basic example of mouse look?

Posted: Thu Feb 10, 2005 01:28
by stodge
As an example, take the Terrain sample in OGRE. The player is moving around the terrain using the mouse and keys (WSAD as usual!). They see something on the terrain (say a person) and click on it; a GUI window pops up and displays the person's name and details.

The user closes the window and they continue to move around the terrain using the mouse and keys.

I think I was wondering how to switch between feeding the input events to CEGui and OGRE.

Thanks!

Re: Basic example of mouse look?

Posted: Thu Feb 10, 2005 02:41
by pjcast
In my application, I switch between usin buffered and unbuffered input... When I have a Gui up that needs input, I switch to buffered, and when it's gone, go back to unbuffered. Here's how I setup up my input:

Code: Select all

      m_EventProcessor = new Ogre::EventProcessor();
      m_EventProcessor->initialise( GraphicsSystem::getSingleton().getRenderWindow() );
      m_EventProcessor->startProcessingEvents();
      m_InputDevice = m_EventProcessor->getInputReader();
      m_UseBufferedKeyBoard = false;
      m_UseBufferedMouse = false;
      m_InputDevice->setBufferedInput(m_UseBufferedKeyBoard, m_UseBufferedMouse);


And here is how I switch between buffered/unbuffered:

Code: Select all

   void InputSystem::setBufferedInputMode( bool bMouse, bool bKeyBoard )
   {
      if( bMouse != m_UseBufferedMouse || bKeyBoard != m_UseBufferedKeyBoard)
      {
         m_UseBufferedMouse = bMouse;
         m_UseBufferedKeyBoard = bKeyBoard;
         m_InputDevice->setBufferedInput(m_UseBufferedKeyBoard, m_UseBufferedMouse);
      }      
   }


And wether or not I'm in buffered mode, I can still poll the keys with;

m_InputDevice->capture();
if( m_InputDevice->isKeyDown(Ogre::KC_ESCAPE) )
quit();

And to use buffered, you just have to add and remove mouseListeners/mouseMotionListeners/ and/or keylisteners as you need them using the methods provided in m_EventProcessor.

Hope this helps you out