Пример #1
0
//-----------------------------------------------------------------------------
// Purpose: Draws the measurements of a brush in the 2D view.
// Input  : pRender - 
//			pSolid - 
//			nFlags - 
//-----------------------------------------------------------------------------
void Clipper3D::DrawBrushExtents( CRender2D *pRender, CMapSolid *pSolid, int nFlags )
{
    //
    // get the bounds of the solid
    //
	Vector Mins, Maxs;
	pSolid->GetRender2DBox( Mins, Maxs );

	//
	// Determine which side of the clipping plane this solid is on in screen
	// space. This tells us where to draw the extents.
	//
    if( ( m_ClipPlane.normal[0] == 0 ) && ( m_ClipPlane.normal[1] == 0 ) && ( m_ClipPlane.normal[2] == 0 ) )
        return;

    Vector2D planeNormal;
    Vector normal = m_ClipPlane.normal;
    if( nFlags & DBT_BACK )
    {
       VectorNegate( normal );
    }
    pRender->TransformPoint3D( planeNormal, normal );

    if( planeNormal[0] <= 0 )
    {
        nFlags &= ~DBT_RIGHT;
        nFlags |= DBT_LEFT;
    }
    else if( planeNormal[0] > 0 )
    {
        nFlags &= ~DBT_LEFT;
        nFlags |= DBT_RIGHT;
    }

    if( planeNormal[1] <= 0 )
    {
        nFlags &= ~DBT_BOTTOM;
        nFlags |= DBT_TOP;
    }
    else if( planeNormal[1] > 0 )
    {
        nFlags &= ~DBT_TOP;
        nFlags |= DBT_BOTTOM;
    }

	DrawBoundsText(pRender, Mins, Maxs, nFlags);
}
Пример #2
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pDC - 
//			bounds - 
//-----------------------------------------------------------------------------
void Box3D::RenderTool2D(CRender2D *pRender)
{
	Vector mins = bmins;
	Vector maxs = bmaxs;
	CMapView2D *pView = (CMapView2D*)pRender->GetView();

	Assert( pRender );

	if ( IsTranslating() )
	{
		TranslateBox( mins, maxs );
	}
	else if ( IsEmpty() )
	{
		return;
	}


	if ( m_dwDrawFlags & boundstext)
	{
		DrawBoundsText(pRender, mins, maxs, DBT_TOP | DBT_LEFT);
	}

	if ( IsTranslating() )
	{
	    pRender->PushRenderMode( RENDER_MODE_DOTTED );
		pRender->SetDrawColor( GetRValue(Options.colors.clrToolDrag), GetGValue(Options.colors.clrToolDrag), GetBValue(Options.colors.clrToolDrag) );
	}
	else if (!(m_dwDrawFlags & thicklines))
	{
		pRender->PushRenderMode( RENDER_MODE_DOTTED );
		pRender->SetDrawColor( GetRValue(m_clrBox), GetGValue(m_clrBox), GetBValue(m_clrBox) );
	}
	else
	{
		pRender->PushRenderMode( RENDER_MODE_FLAT_NOZ );
		pRender->SetDrawColor( GetRValue(m_clrBox), GetGValue(m_clrBox), GetBValue(m_clrBox) );
	}

	// render bounds
	if ( !IsTranslating() || m_TranslateMode == modeScale || m_TranslateMode == modeMove )
	{
		// draw simple rectangle
		pRender->DrawRectangle( mins, maxs, false, 0 );
	}
	else
	{
		// during rotation or shearing, draw transformed bounding box

		Vector v[4];
		
		// init all points to center
		v[0] = v[1] = v[2] = v[3] = (bmins+bmaxs) / 2;

		int axis = pView->axHorz;

		v[0][axis] = v[1][axis] = bmins[axis];
		v[2][axis] = v[3][axis] = bmaxs[axis];

		axis = pView->axVert;

		v[1][axis] = v[2][axis] = bmins[axis];
		v[0][axis] = v[3][axis] = bmaxs[axis];

		for ( int i=0; i<4; i++)
		{
			TranslatePoint( v[i] );
		}
		
		pRender->DrawLine( v[0], v[1] );
		pRender->DrawLine( v[1], v[2] );
		pRender->DrawLine( v[2], v[3] );
		pRender->DrawLine( v[3], v[0] );
	}

	pRender->PopRenderMode();

	// draw a cross for translation origin in move or rotation mode
	if ( IsTranslating() )
	{
		if ( m_TranslateMode == modeMove || m_TranslateMode == modeRotate )
		{
			Vector vec = m_vTranslationFixPoint;

			if ( m_TranslateMode == modeMove  )
 			{
				TranslatePoint( vec );
			}

			// draw 'X'
			pRender->SetHandleStyle( 7, CRender::HANDLE_CROSS );
			pRender->SetHandleColor( GetRValue(Options.colors.clrToolDrag), GetGValue(Options.colors.clrToolDrag), GetBValue(Options.colors.clrToolDrag) );
			pRender->DrawHandle( vec );
			
		}
	}
	else if ( m_bEnableHandles )
	{
		RenderHandles2D( pRender, mins, maxs );
	}
}