Guest User

Untitled

a guest
Mar 11th, 2017
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. cBoxInfo cEngine::DrawBoundingBox( Vector vHead, Vector vFoot, DWORD color, int edge, bool CalcOnly )//edge == 1 edge only, edge == 2 box + edge box
  2. {
  3. CVector2i iHead, iFoot;
  4. cBoxInfo m_Box = {0};
  5.  
  6. //center boxes & add correction's
  7. vFoot.x = vHead.x;
  8. vFoot.z = vHead.z;
  9.  
  10. if( WorldToScreen( vHead, iHead ) && WorldToScreen( vFoot, iFoot ) )
  11. {
  12. m_Box.iHead = iHead;
  13. m_Box.iFoot = iFoot;
  14.  
  15. iFoot.y += 5;//some corrections
  16. iHead.y -= 7;//some corrections
  17. int w = ( iFoot.y - iHead.y ) / 4;
  18.  
  19. if( CalcOnly == false )
  20. {
  21. if( edge == 1 )
  22. {
  23. DrawEdgeBoundingBox( ( iHead.x - w ), iHead.y, ( w * 2 ), ( iFoot.y - iHead.y ), color, 8 );
  24. } else if( edge == 2 ) {
  25. m_pDx11Renderer.DrawBorder( ( iHead.x - w ), iHead.y, ( w * 2 ), ( iFoot.y - iHead.y ), 1, color );
  26. DrawEdgeBoundingBox( ( iHead.x - w - 3 ), iHead.y - 3, ( w * 2 ) + 6, ( iFoot.y - iHead.y ) + 6, txtYellow, 6 );//draw 3 px bigger
  27. } else {
  28. m_pDx11Renderer.DrawBorder( ( iHead.x - w ), iHead.y, ( w * 2 ), ( iFoot.y - iHead.y ), 1, color );
  29. }
  30.  
  31. }
  32.  
  33. m_Box.x = ( iHead.x - w );
  34. m_Box.y = iHead.y;
  35. m_Box.w = ( w * 2 );
  36. m_Box.h = ( iFoot.y - iHead.y );
  37. m_Box.middle_x = iHead.x;
  38. }
  39. return m_Box;
  40. }
  41.  
  42. void cEngine::DrawEdgeBoundingBox( int x, int y, int w, int h, DWORD BorderColor, int override_le, bool midpoint, bool center )
  43. {
  44. //draw circle on center of box
  45. if( midpoint )
  46. m_pDx11Renderer.DrawCircle( x, y, 2, txtGreen );
  47.  
  48. //center x y in the box
  49. if( center )
  50. {
  51. x -= ( w / 2 );
  52. y -= ( h / 2 );
  53. }
  54.  
  55. int le = w / 4;
  56.  
  57. if( le > ( h / 4 ) )
  58. le = ( h / 4 );
  59.  
  60. if( override_le > 0 )
  61. le = override_le;
  62.  
  63. m_pDx11Renderer.DrawLine( x, y, x + le, y, BorderColor );
  64. m_pDx11Renderer.DrawLine( x, y, x, y + le, BorderColor );
  65. m_pDx11Renderer.DrawLine( x + w, y, x + w - le, y, BorderColor );
  66. m_pDx11Renderer.DrawLine( x + w, y, x + w, y + le, BorderColor );
  67. m_pDx11Renderer.DrawLine( x, y + h, x, y + h - le, BorderColor );
  68. m_pDx11Renderer.DrawLine( x, y + h, x + le, y + h, BorderColor );
  69. m_pDx11Renderer.DrawLine( x + w, y + h, x +w - le, y + h, BorderColor );
  70. m_pDx11Renderer.DrawLine( x + w, y + h, x + w, y + h - le, BorderColor );
  71. }
Advertisement
Add Comment
Please, Sign In to add comment