void DiInputManager::captureInput() { if (mMouse) { mMouse->capture(); DiRenderWindow* rw = Driver->GetMainRenderWindow(); setInputViewSize(rw->GetWidth(), rw->GetHeight()); } if(mKeyboard) mKeyboard->capture(); #if OIS_WITH_MULTITOUCH if(mMultiTouch) mMultiTouch->capture(); #endif if(mAccelerometer) mAccelerometer->capture(); }
bool DiCameraHelper::Update( float elapsed ) { if (!mEnabled) { return false; } if (mStyle == CS_FREELOOK) { DiVec3 accel = DiVec3::ZERO; if (mGoingForward) { accel += mCamera->GetDirection(); } if (mGoingBack) accel -= mCamera->GetDirection(); if (mGoingRight) accel += mCamera->GetRight(); if (mGoingLeft) accel -= mCamera->GetRight(); if (mGoingUp) accel += mCamera->GetUp(); if (mGoingDown) accel -= mCamera->GetUp(); float topSpeed = mFastMove ? mTopSpeed * 20 : mTopSpeed; if (accel.squaredLength() != 0) { accel.normalise(); mVelocity += accel * topSpeed * elapsed * 10; } else { mVelocity -= mVelocity * elapsed * 10; } float tooSmall = std::numeric_limits<float>::epsilon(); if (mVelocity.squaredLength() > topSpeed * topSpeed) { mVelocity.normalise(); mVelocity *= topSpeed; } else if (mVelocity.squaredLength() < tooSmall * tooSmall) { mVelocity = DiVec3::ZERO; } if (mVelocity != DiVec3::ZERO) { mCamera->Move(mVelocity * elapsed); } } else if (mStyle == CS_SMOOTH) { if (Driver && mMousePos.x >= 0 && mMousePos.y >= 0) { DiRenderWindow* window = Driver->GetMainRenderWindow(); int x = (mMousePos.x - window->GetWidth() / 2); int y = (mMousePos.y - window->GetHeight() / 2); DiVec3 pos = mCamera->GetPosition(); pos.x += (x - pos.x) * 0.01f; pos.y += (-y - pos.y) * 0.01f; mCamera->SetPosition(pos); mCamera->LookAt(0, 0, 0); } } return true; }