Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. const float Pitch_Factor = 90.0f / 16000.0f; //теперь при выводе, умнож питч на эту хрень. И яв на ниэнюю. Что выведет
  2. const float Yaw_Factor = 180.0f / 32768.0f;
  3. const float AIMPitch_Factor = 16000.0f / 90.0f; //Так? да.
  4. const float AIMYaw_Factor = 32768.0f / 180.0f;
  5.  
  6. D3DXVECTOR3 vpos = { actor->PlayerCamera->Location.X, actor->PlayerCamera->Location.Y, actor->PlayerCamera->Location.Z };
  7. static float posTest[3];
  8.  
  9. if (GetAsyncKeyState(VK_F1) & 0x8000)
  10. {
  11. posTest[0] = actor->PlayerCamera->Location.X;
  12. posTest[1] = actor->PlayerCamera->Location.Y;
  13. posTest[2] = actor->PlayerCamera->Location.Z;
  14. };
  15.  
  16. float pitch = (float)actor->Pawn->Owner->Rotation.Pitch * Pitch_Factor;
  17. float yaw = (float)actor->Pawn->Owner->Rotation.Yaw * Yaw_Factor;
  18.  
  19. float aim_yaw = BMATH::XAngle(vpos[0], vpos[1], posTest[0], posTest[1], yaw);
  20. float aim_pitch = BMATH::YAngle(vpos[0], vpos[1], vpos[2], posTest[0], posTest[1], posTest[2], pitch);
  21.  
  22. sprintf(str, "yaw: %f pitch: %f\naim_yaw: %f aim_pitch: %f", yaw, pitch, aim_yaw, aim_pitch);
  23. BGUI::Text.DrawEx(str, 0, 20, 40, BGUI::color_gold, 0, 0, 0, 1, *BGUI::color_black);
  24.  
  25. D3DXMATRIX mproj;
  26. mproj = *Matrix->ViewState()->GetViewMatrix() * *Matrix->ViewState()->GetProjMatrix();
  27. float w[2];
  28. BOOL FOV = BMATH::DXProection(w, posTest, &mproj, BGUI::viewport.Width, BGUI::viewport.Height, 0, 1);
  29.  
  30. if (FOV)
  31. {
  32. BGUI::DrawTexture(0, 0, w[0] - 10, w[1] - 10, 20, 20, BGUI::color_gold);
  33. }
  34. D3DXVECTOR3 Screen;
  35. bool AIMFOV = WorldToScreen((D3DXVECTOR3*)&posTest, (D3DXVECTOR3*)&Screen, *device, Matrix->ViewState()->GetProjMatrix(), Matrix->ViewState()->GetViewMatrix());
  36.  
  37. if (AIMFOV)
  38. {
  39. BGUI::DrawTexture(0, 0, Screen.x - 10, Screen.y - 10, 20, 20, BGUI::color_gold);
  40. }
  41.  
  42. if(GetAsyncKeyState(VK_NUMPAD1)&0x8000)actor->Pawn->Owner->Rotation.Yaw += (int)(0.5*aim_yaw * AIMYaw_Factor);
  43. if(GetAsyncKeyState(VK_NUMPAD2) & 0x8000)actor->Pawn->Owner->Rotation.Pitch += (int)(0.5*aim_pitch* AIMPitch_Factor);
  44.  
  45. if (GetKeyState(VK_NUMPAD3))
  46. {
  47. actor->Pawn->Owner->Rotation.Yaw += (int)(0.5*aim_yaw * AIMYaw_Factor);
  48. actor->Pawn->Owner->Rotation.Pitch += (int)(0.5*aim_pitch* AIMPitch_Factor);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement