Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

On the water demo supplied with Ogre3D's SDK, controls are set to actually control the camera and environment, but not actually the ogre head that generates the disturbances. I tried digging into the SDK code but couldn't find the actual pieces of code that allow customization of the controls (keyboard input). Maybe that's coming from the SampleBrowser application?

I intend to use that demo to generate the same Pygame/OpenGL water ripple effect I seek here: Pygame water ripple effect with the added benefit of the 3D engine. This is also targetted at a multitouch library that tries to stay away from Flash in support of harder reverse-engineering of the output binaries.

Bottom line, my question is, where are the keyboard controls bound to the scene on Ogre's SDK Water Demo? I am just starting in C/C++.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

I think you need to override the keyPressed virtual method inherited by the Sample_Water class (in Water.h) from SdkSample class.

Adding something like the following code in Sample_Water class (Water.h) should help you

bool keyPressed( const OIS::KeyEvent &arg )
{
    //-- Don't process any more keys if dialog is up
    if (mTrayMgr->isDialogVisible()) return true;

    //-- keyPressed actions
    switch (arg.key)
    {
        case OIS::KC_UP:
        case OIS::KC_W:
            // up action
            break;

        case OIS::KC_DOWN:
        case OIS::KC_S:
            // down action
            break;

        case OIS::KC_LEFT:
        case OIS::KC_A:
            // left action
            break;

        case OIS::KC_RIGHT:
        case OIS::KC_D:
            // right action
            break;

        default:
            break;
    }

    // Call the keyPressed method of the inherited class SdkSample for others keys...
    return SdkSample::keyPressed( arg );
}

It will probably not be enough by itself, so if it doesn't works try to edit the SdkSample.h (Samples/Common folder) in order to remove/deactivate the following lines:

  • mCameraMan->injectKeyDown(evt); at the end of the keyPressed method.
  • mCameraMan->injectKeyUp(arg); at the end of the keyReleased method.

Those two lines propagate the key actions to the camera controller mCameraMan.

I didn't tried it, but it should be ok, or at least not that far from what you are looking for.

share|improve this answer
    
great info for a C++ virgin –  leon Oct 24 '11 at 21:28
add comment

In my previous company (Touchscape), I did exactly this. The code for the water demo is part of the multitouch sdk sample. we used Ogre3D for graphics. but what specifically will help you is to understand multi-touch interaction with water and how water is simulated (plus the rendering if you are interested). You can download it for free from http://touchscape.org/v2/products/.

share|improve this answer
    
thanks, excellent resource –  leon Oct 24 '11 at 21:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.