cBoxInfo cEngine::DrawBoundingBox( Vector vHead, Vector vFoot, DWORD color, int edge, bool CalcOnly )//edge == 1 edge only, edge == 2 box + edge box[/FONT][/B][/LEFT]
[B][FONT=Arial][LEFT]{
CVector2i iHead, iFoot;
cBoxInfo m_Box = {0};
//center boxes & add correction's
vFoot.x = vHead.x;
vFoot.z = vHead.z;
if( WorldToScreen( vHead, iHead ) && WorldToScreen( vFoot, iFoot ) )
{
m_Box.iHead = iHead;
m_Box.iFoot = iFoot;
iFoot.y += 5;//some corrections
iHead.y -= 7;//some corrections
int w = ( iFoot.y - iHead.y ) / 4;
if( CalcOnly == false )
{
if( edge == 1 )
{
DrawEdgeBoundingBox( ( iHead.x - w ), iHead.y, ( w * 2 ), ( iFoot.y - iHead.y ), color, 8 );
} else if( edge == 2 ) {
m_pDx11Renderer.DrawBorder( ( iHead.x - w ), iHead.y, ( w * 2 ), ( iFoot.y - iHead.y ), 1, color );
DrawEdgeBoundingBox( ( iHead.x - w - 3 ), iHead.y - 3, ( w * 2 ) + 6, ( iFoot.y - iHead.y ) + 6, txtYellow, 6 );//draw 3 px bigger
} else {
m_pDx11Renderer.DrawBorder( ( iHead.x - w ), iHead.y, ( w * 2 ), ( iFoot.y - iHead.y ), 1, color );
}
}
m_Box.x = ( iHead.x - w );
m_Box.y = iHead.y;
m_Box.w = ( w * 2 );
m_Box.h = ( iFoot.y - iHead.y );
m_Box.middle_x = iHead.x;
}
return m_Box;
}
void cEngine::DrawEdgeBoundingBox( int x, int y, int w, int h, DWORD BorderColor, int override_le, bool midpoint, bool center )
{
//draw circle on center of box
if( midpoint )
m_pDx11Renderer.DrawCircle( x, y, 2, txtGreen );
//center x y in the box
if( center )
{
x -= ( w / 2 );
y -= ( h / 2 );
}
int le = w / 4;
if( le > ( h / 4 ) )
le = ( h / 4 );
if( override_le > 0 )
le = override_le;
m_pDx11Renderer.DrawLine( x, y, x + le, y, BorderColor );
m_pDx11Renderer.DrawLine( x, y, x, y + le, BorderColor );
m_pDx11Renderer.DrawLine( x + w, y, x + w - le, y, BorderColor );
m_pDx11Renderer.DrawLine( x + w, y, x + w, y + le, BorderColor );
m_pDx11Renderer.DrawLine( x, y + h, x, y + h - le, BorderColor );
m_pDx11Renderer.DrawLine( x, y + h, x + le, y + h, BorderColor );
m_pDx11Renderer.DrawLine( x + w, y + h, x +w - le, y + h, BorderColor );
m_pDx11Renderer.DrawLine( x + w, y + h, x + w, y + h - le, BorderColor );
}