0
\$\begingroup\$

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++.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ great info for a C++ virgin \$\endgroup\$ Commented Oct 24, 2011 at 21:28
1
\$\begingroup\$

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/.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .