Advertisement
bombillo

Dead Camera Test

Feb 22nd, 2020
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. bool check_cam_collision = true;
  2. {
  3. static r3dPoint3D oldPlayerPos(0,0,0);
  4. static r3dPoint3D camPosOffset(0,0,0);
  5. // death camera
  6. 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
  7.  
  8. // find a cam position
  9. if(!oldPlayerPos.AlmostEqual(pl->GetPosition())) // make sure to do that check only once
  10. {
  11. oldPlayerPos = pl->GetPosition();
  12. camPosOffset = r3dPoint3D(0.0f, 0, 0.0f);
  13. }
  14.  
  15. int mMX=Mouse->m_MouseMoveX, mMY=Mouse->m_MouseMoveY;
  16. if(g_vertical_look->GetBool()) // invert mouse
  17. mMY = -mMY;
  18. float glb_MouseSensAdj = CurrentRig.MouseSensetivity * g_mouse_sensitivity->GetFloat();
  19. // Mouse controls are here
  20.  
  21. float mmoveX = float(-mMX) * glb_MouseSensAdj;
  22. float mmoveY = float(-mMY) * glb_MouseSensAdj;
  23.  
  24. if(hudPause && !hudPause->isActive() && Keyboard->IsPressed(kbsLeftShift))
  25. {
  26. camPosOffset.x += mmoveX;
  27. camPosOffset.y += mmoveY;
  28. }
  29.  
  30. if(camPosOffset.x > 360.0f ) camPosOffset.x = camPosOffset.x - 360.0f;
  31. if(camPosOffset.x < 0.0f ) camPosOffset.x = camPosOffset.x + 360.0f;
  32. if(camPosOffset.y > 85 ) camPosOffset.y = 85;
  33. if(camPosOffset.y < -85) camPosOffset.y = -85;
  34.  
  35.  
  36. D3DXMATRIX mr;
  37. D3DXMatrixRotationYawPitchRoll(&mr, R3D_DEG2RAD(-camPosOffset.x), R3D_DEG2RAD(-camPosOffset.y), 0);
  38. camDir = r3dVector(mr._31, mr._32, mr._33);
  39.  
  40. camPos = pl->GetPosition() - camDir*10.0f;
  41. do_camera = true;
  42. check_cam_collision = true;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement