Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool check_cam_collision = true;
- {
- static r3dPoint3D oldPlayerPos(0,0,0);
- static r3dPoint3D camPosOffset(0,0,0);
- // death camera
- camPointTo = pl->GetPosition() + r3dPoint3D(0, 1.3f, 0); // add a bit of offset, as sometimes player's pos is just a bit under ground and because of that physics will show collision and our camera will be moved under ground
- // find a cam position
- if(!oldPlayerPos.AlmostEqual(pl->GetPosition())) // make sure to do that check only once
- {
- oldPlayerPos = pl->GetPosition();
- camPosOffset = r3dPoint3D(0.0f, 0, 0.0f);
- }
- int mMX=Mouse->m_MouseMoveX, mMY=Mouse->m_MouseMoveY;
- if(g_vertical_look->GetBool()) // invert mouse
- mMY = -mMY;
- float glb_MouseSensAdj = CurrentRig.MouseSensetivity * g_mouse_sensitivity->GetFloat();
- // Mouse controls are here
- float mmoveX = float(-mMX) * glb_MouseSensAdj;
- float mmoveY = float(-mMY) * glb_MouseSensAdj;
- if(hudPause && !hudPause->isActive() && Keyboard->IsPressed(kbsLeftShift))
- {
- camPosOffset.x += mmoveX;
- camPosOffset.y += mmoveY;
- }
- if(camPosOffset.x > 360.0f ) camPosOffset.x = camPosOffset.x - 360.0f;
- if(camPosOffset.x < 0.0f ) camPosOffset.x = camPosOffset.x + 360.0f;
- if(camPosOffset.y > 85 ) camPosOffset.y = 85;
- if(camPosOffset.y < -85) camPosOffset.y = -85;
- D3DXMATRIX mr;
- D3DXMatrixRotationYawPitchRoll(&mr, R3D_DEG2RAD(-camPosOffset.x), R3D_DEG2RAD(-camPosOffset.y), 0);
- camDir = r3dVector(mr._31, mr._32, mr._33);
- camPos = pl->GetPosition() - camDir*10.0f;
- do_camera = true;
- check_cam_collision = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement