コード例 #1
0
//-----------------------------------------------------------------------------
// Purpose: Renders us in the 3D view.
// Input  : pRender - Interface to use for rendering.
//-----------------------------------------------------------------------------
void CMapSideList::Render3D(CRender3D *pRender)
{
	if (Parent->IsSelected())
	{
		//
		// Draw lines from us to the center of all faces in the list.
		//
		pRender->SetRenderMode(RENDER_MODE_WIREFRAME);

		CMeshBuilder meshBuilder;
		IMesh *pMesh = MaterialSystemInterface()->GetDynamicMesh();

		meshBuilder.Begin(pMesh, MATERIAL_LINES, m_Faces.Count());

		for (int i = 0; i < m_Faces.Count(); i++)
		{
			CMapFace *pFace = m_Faces.Element(i);

			Vector Center;
			pFace->GetCenter(Center);

			unsigned char color[3];
			color[0] = SELECT_EDGE_RED; 
			color[1] = SELECT_EDGE_GREEN;
			color[2] = SELECT_EDGE_BLUE;

			meshBuilder.Color3ubv( color );
			meshBuilder.Position3f(m_Origin.x, m_Origin.y, m_Origin.z);
			meshBuilder.AdvanceVertex();

			meshBuilder.Color3ubv( color );
			meshBuilder.Position3f(Center.x, Center.y, Center.z);
			meshBuilder.AdvanceVertex();
		}

		meshBuilder.End();
		pMesh->Draw();
	}
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Purpose: Calculates our bounds.
// Input  : bFullUpdate - 
//-----------------------------------------------------------------------------
void CMapSideList::CalcBounds(BOOL bFullUpdate)
{
	//
	// We're just a point in the 2D view because we don't render there.
	//
	m_Render2DBox.ResetBounds();
	m_Render2DBox.UpdateBounds(m_Origin);

	//
	// Our culling bounds includes the endpoints of all the lines we draw when
	// our parent entity is selected.
	//
	m_CullBox.ResetBounds();
	m_CullBox.UpdateBounds(m_Origin);

	for (int i = 0; i < m_Faces.Count(); i++)
	{
		CMapFace *pFace = m_Faces.Element(i);

		Vector Center;
		pFace->GetCenter(Center);
		m_CullBox.UpdateBounds(Center);
	}
}