Exemplo n.º 1
0
bool FEdModeGeometry::GetCustomDrawingCoordinateSystem( FMatrix& InMatrix, void* InData )
{
	if( GetSelectionState() == GSS_None )
	{
		return 0;
	}

	if( InData )
	{
		InMatrix = FRotationMatrix( ((FGeomBase*)InData)->GetNormal().Rotation() );
	}
	else
	{
		// If we don't have a specific geometry object to get the normal from
		// use the one that was last selected.

		for( int32 o = 0 ; o < GeomObjects.Num() ; ++o )
		{
			FGeomObject* go = GeomObjects[o];
			go->CompileSelectionOrder();

			if( go->SelectionOrder.Num() )
			{
				InMatrix = FRotationMatrix( go->SelectionOrder[ go->SelectionOrder.Num()-1 ]->GetWidgetRotation() );
				return 1;
			}
		}
	}

	return 0;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pRender - 
//-----------------------------------------------------------------------------
void CMapPointHandle::Render2D(CRender2D *pRender)
{
	SelectionState_t eState = GetSelectionState();

	if (eState == SELECT_NONE )
		return;
	
	if (eState == SELECT_MODIFY)
	{
		pRender->PushRenderMode( RENDER_MODE_DOTTED );
		pRender->SetDrawColor( GetRValue(Options.colors.clrSelection), GetGValue(Options.colors.clrSelection), GetBValue(Options.colors.clrSelection) );
	}
	else
	{
		pRender->PushRenderMode( RENDER_MODE_FLAT );
		pRender->SetDrawColor( GetRValue(Options.colors.clrToolHandle), GetGValue(Options.colors.clrToolHandle), GetBValue(Options.colors.clrToolHandle) );
	}

	pRender->SetHandleStyle( HANDLE_RADIUS, CRender::HANDLE_CIRCLE );
	pRender->DrawHandle( m_Origin );
	
	// Draw a line from origin helpers to their parent while they are being dragged.
	if ((m_pParent != NULL) && (m_bDrawLineToParent || (eState == SELECT_MODIFY)))
	{
		if (eState == SELECT_MODIFY)
		{
			pRender->SetDrawColor( GetRValue(Options.colors.clrSelection), GetGValue(Options.colors.clrSelection), GetBValue(Options.colors.clrSelection) );
		}
		else
		{
			pRender->SetDrawColor( GetRValue(Options.colors.clrToolHandle), GetGValue(Options.colors.clrToolHandle), GetBValue(Options.colors.clrToolHandle) );
		}

		Vector vecOrigin;
		GetParent()->GetOrigin(vecOrigin);
		pRender->DrawLine(m_Origin, vecOrigin);
	}

	pRender->PopRenderMode();

	if (eState == SELECT_MODIFY)
	{
		Vector2D ptText;
		pRender->TransformPoint(ptText, m_Origin);

		ptText.y += HANDLE_RADIUS + 4;

		pRender->SetTextColor(GetRValue(Options.colors.clrToolHandle), GetGValue(Options.colors.clrToolHandle), GetBValue(Options.colors.clrToolHandle) );
		
		char szText[100];
		sprintf(szText, "(%0.f, %0.f, %0.f)", m_Origin.x, m_Origin.y, m_Origin.z);
		pRender->DrawText(szText, ptText.x, ptText.y, CRender2D::TEXT_JUSTIFY_LEFT);
	}

}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pRender - 
//-----------------------------------------------------------------------------
void CMapPointHandle::Render3D(CRender3D *pRender)
{
	if (GetSelectionState() != SELECT_NONE)
	{
		Vector vecViewPoint;
		pRender->GetCamera()->GetViewPoint(vecViewPoint);
		float flDist = (m_Origin - vecViewPoint).Length();

		pRender->RenderSphere(m_Origin, 0.04 * flDist, 12, 12, 128, 128, 255);

		if ((m_pParent != NULL) && (m_bDrawLineToParent))
		{
			Vector vecOrigin;
			GetParent()->GetOrigin(vecOrigin);
			pRender->SetDrawColor( 255, 255, 255 );
			pRender->DrawLine( m_Origin, vecOrigin );
		}
	}
}
Exemplo n.º 4
0
bool FEdModeGeometry::GetCustomDrawingCoordinateSystem( FMatrix& InMatrix, void* InData )
{
	if( GetSelectionState() == GSS_None )
	{
		return 0;
	}

	if( InData )
	{
		FGeomBase* GeomBase = static_cast<FGeomBase*>(InData);
		FGeomObjectPtr GeomObject = GeomBase->GetParentObject();
		check(GeomObject.IsValid());
		ABrush* Brush = GeomObject->GetActualBrush();
		InMatrix = FRotationMatrix(GeomBase->GetNormal().Rotation()) * FQuatRotationMatrix(Brush->GetActorQuat());
	}
	else
	{
		// If we don't have a specific geometry object to get the normal from
		// use the one that was last selected.

		for( int32 o = 0 ; o < GeomObjects.Num() ; ++o )
		{
			FGeomObjectPtr go = GeomObjects[o];
			go->CompileSelectionOrder();

			if( go->SelectionOrder.Num() )
			{
				FGeomBase* GeomBase = go->SelectionOrder[go->SelectionOrder.Num() - 1];
				check(GeomBase != nullptr);
				FGeomObjectPtr GeomObject = GeomBase->GetParentObject();
				check(GeomObject.IsValid());
				ABrush* Brush = GeomObject->GetActualBrush();
				InMatrix = FRotationMatrix( go->SelectionOrder[ go->SelectionOrder.Num()-1 ]->GetWidgetRotation() ) * FQuatRotationMatrix(Brush->GetActorQuat());
				return 1;
			}
		}
	}

	return 0;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pRender - 
//-----------------------------------------------------------------------------
void CMapSweptPlayerHull::Render3D(CRender3D *pRender)
{
	for (int i = 0; i < 2; i++)
	{	
		m_Point[i]->Render3D(pRender);
	}	

	if (GetSelectionState() == SELECT_NONE)
	{
		pRender->SetDrawColor( 200,180,0 );
	}
	else
	{
		pRender->SetDrawColor( 255,0,0 );
	}

	Vector vec1;
	Vector vec2;
	m_Point[0]->GetOrigin(vec1);
	m_Point[1]->GetOrigin(vec2);
	
	pRender->DrawLine(vec1, vec2);
	
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pRender - 
//-----------------------------------------------------------------------------
void CMapSweptPlayerHull::Render2D(CRender2D *pRender)
{
	SelectionState_t eState = GetSelectionState();

	CMapView2D *pView = (CMapView2D*)pRender->GetView();

	m_Point[0]->Render2D(pRender);
	m_Point[1]->Render2D(pRender);

	Vector vecOrigin1;
	Vector vecOrigin2;
	m_Point[0]->GetOrigin(vecOrigin1);
	m_Point[1]->GetOrigin(vecOrigin2);

	Vector mins1, maxs1;
	Vector mins2, maxs2;
	m_Point[0]->m_CullBox.GetBounds( mins1, maxs1 );
	m_Point[1]->m_CullBox.GetBounds( mins2, maxs2 );

	// Draw swept volume
	Vector dir = vecOrigin2 - vecOrigin1;

	int nHorz = pView->axHorz;
	int nVert = pView->axVert;
	int nThird = pView->axThird;

	dir[ nThird ] = 0;

	VectorNormalize( dir );

	float dx = dir[ nHorz ];
	float dy = dir[ nVert ];

	if ( dx == 0 && dy == 0 )
		return;

	if (eState == SELECT_MODIFY)
	{
		pRender->PushRenderMode( RENDER_MODE_DOTTED );
		pRender->SetDrawColor( GetRValue(Options.colors.clrSelection), GetGValue(Options.colors.clrSelection), GetBValue(Options.colors.clrSelection) );

	}
	else
	{
		pRender->PushRenderMode( RENDER_MODE_FLAT );
		pRender->SetDrawColor( GetRValue(Options.colors.clrToolHandle), GetGValue(Options.colors.clrToolHandle), GetBValue(Options.colors.clrToolHandle) );
	}

	Vector line1[2];
	Vector line2[2];
	
	line1[0].Init();
	line1[1].Init();
	line2[0].Init();
	line2[1].Init();

	if ( dx > 0 )
	{
		if ( dy > 0 )
		{
			line1[0][nHorz] = mins1[ nHorz ];
			line1[0][nVert] = maxs1[ nVert ];
			line1[1][nHorz] = mins2[ nHorz ];
			line1[1][nVert] = maxs2[ nVert ];

			line2[0][nHorz] = maxs1[ nHorz ];
			line2[0][nVert] = mins1[ nVert ];
			line2[1][nHorz] = maxs2[ nHorz ];
			line2[1][nVert] = mins2[ nVert ];
		}
		else
		{
			line1[0][nHorz] = maxs1[ nHorz ];
			line1[0][nVert] = maxs1[ nVert ];
			line1[1][nHorz] = maxs2[ nHorz ];
			line1[1][nVert] = maxs2[ nVert ];

			line2[0][nHorz] = mins1[ nHorz ];
			line2[0][nVert] = mins1[ nVert ];
			line2[1][nHorz] = mins2[ nHorz ];
			line2[1][nVert] = mins2[ nVert ];
		}
	}
	else
	{
		if ( dy > 0 )
		{
			line1[0][nHorz] = maxs1[ nHorz ];
			line1[0][nVert] = maxs1[ nVert ];
			line1[1][nHorz] = maxs2[ nHorz ];
			line1[1][nVert] = maxs2[ nVert ];

			line2[0][nHorz] = mins1[ nHorz ];
			line2[0][nVert] = mins1[ nVert ];
			line2[1][nHorz] = mins2[ nHorz ];
			line2[1][nVert] = mins2[ nVert ];
		}
		else
		{
			line1[0][nHorz] = mins1[ nHorz ];
			line1[0][nVert] = maxs1[ nVert ];
			line1[1][nHorz] = mins2[ nHorz ];
			line1[1][nVert] = maxs2[ nVert ];

			line2[0][nHorz] = maxs1[ nHorz ];
			line2[0][nVert] = mins1[ nVert ];
			line2[1][nHorz] = maxs2[ nHorz ];
			line2[1][nVert] = mins2[ nVert ];
		}
	}

	pRender->DrawLine( line1[0], line1[1] );
	pRender->DrawLine( line2[0], line2[1] );

	pRender->PopRenderMode();
}