Increasing camera forces dynamically

Rasengan

16-07-2008 09:44:03

Hello,

my camera fps is a "CakeSmartCamera" based code. I'have added a "TURBO" variable that is 5 times faster than the normal speed. (i.e the value of the force). This value is used when user click on the right button of the mouse and when we release the button, the normal speed is applied.

Here is the problem: when the turbo mode is applied, sometimes the camera can "penetrate" the walls.



...
#define DEFAULT_CAM_SPEED 20.0
#define TURBO 100.0
...


bool frameStarted(const Ogre::FrameEvent &evt)
{
...

if (mMouse->getMouseState().buttonDown( OIS::MB_Right ))
{
gCamSpeed = TURBO;
}
else
{
gCamSpeed = DEFAULT_CAM_SPEED;
}

...

if (mKeyboard->isKeyDown(OIS::KC_W))
{
translate(-gCamSpeed);
}

...

mCamera->setPosition(gCameraActor->getGlobalPositionAsOgreVector3());
...
}


I'have to change some camera actorsParams when the turbo mode is used and revert to normal params with normal speed?

betajaen

16-07-2008 13:11:53

It's because the Camera is going so fast that it misses the collision with the wall; thus going through it. CCD is required, or you can just slow down. ;)