Exemplo n.º 1
0
void vtRoadMap3d::DetermineSurfaceAppearance()
{
	// Pre-process some link attributes
	for (LinkGeom *pL = GetFirstLink(); pL; pL = pL->GetNext())
	{
		// set material index based on surface type, number of lanes, and direction
		bool two_way = (pL->m_iFlags & RF_FORWARD) &&
					   (pL->m_iFlags & RF_REVERSE);
		switch (pL->m_Surface)
		{
		case SURFT_NONE:
//			pL->m_vti = 3;
			pL->m_vti = 0;
			break;
		case SURFT_GRAVEL:
			pL->m_vti = VTI_GRAVEL;
			break;
		case SURFT_TRAIL:
			pL->m_vti = VTI_TRAIL;
			break;
		case SURFT_2TRACK:
		case SURFT_DIRT:
			pL->m_vti = VTI_4WD;
			break;
		case SURFT_PAVED:
			switch (pL->m_iLanes)
			{
			case 1:
				pL->m_vti = VTI_1LANE;
				break;
			case 2:
				pL->m_vti = two_way ? VTI_2LANE2WAY : VTI_2LANE1WAY;
				break;
			case 3:
				pL->m_vti = two_way ? VTI_3LANE2WAY : VTI_3LANE1WAY;
				break;
			case 4:
			case 5:
			case 6:
				pL->m_vti = two_way ? VTI_4LANE2WAY : VTI_4LANE1WAY;
				break;
			default:
				// Catch any freakish roads with >6 lanes.
				pL->m_vti = two_way ? VTI_4LANE2WAY : VTI_4LANE1WAY;
				break;
			}
			break;
		case SURFT_RAILROAD:
			pL->m_vti = VTI_RAIL;
			break;
		case SURFT_STONE:
			pL->m_vti = VTI_STONE;
			break;
		default:
			pL->m_vti = 0;
			break;
		}
	}
}
//!	see	CMultiXApp::OnPrepareForShutdown
void CISO8583AuthorizerApp::OnPrepareForShutdown(int32_t WaitTime)
{
	//	if we have listeners we close all of them so no new connections will be accepted
	for(CMultiXLink	*Link	=	GetFirstLink();Link;Link=Link->ID().Next())
	{
		if(Link->IsRaw()	&&	Link->OpenMode()	==	MultiXOpenModeServer)
			Link->Close();
	}
	if(WaitTime	<	2000)
		End();
}
Exemplo n.º 3
0
void vtRoadMap3d::_GatherExtents()
{
	// Find extents of area covered by links
	m_extents.InsideOut();

	// Examine the range of the roadmap area
	for (LinkGeom *pL = GetFirstLink(); pL; pL = pL->GetNext())
		m_extents.GrowToContainLine(pL->m_centerline);

	// Expand slightly for safety - in case we allow dragging link nodes
	//  interactively in the future.
	FPoint3 diff = m_extents.max - m_extents.min;
	m_extents.min -= (diff / 20.0f);
	m_extents.max += (diff / 20.0f);
	m_extent_range = m_extents.max - m_extents.min;
}
Exemplo n.º 4
0
vtTransform *vtRoadMap3d::GenerateGeometry(bool do_texture,
	bool bHwy, bool bPaved, bool bDirt, bool progress_callback(int))
{
	VTLOG("   vtRoadMap3d::GenerateGeometry\n");
	VTLOG("   Nodes %d, Links %d\n", NumNodes(), NumLinks());

	_CreateMaterials(do_texture);

	m_pGroup = new vtGroup;
	m_pGroup->setName("Roads");

	m_pTransform = new vtTransform;
	m_pTransform->addChild(m_pGroup);
	m_pTransform->SetTrans(FPoint3(0, m_fGroundOffset, 0));

	// We wrap the roads' geometry with an array of simple LOD nodes
	int a, b;
	for (a = 0; a < ROAD_CLUSTER; a++)
		for (b = 0; b < ROAD_CLUSTER; b++)
		{
			m_pRoads[a][b] = NULL;
		}

	_GatherExtents();

#if 0
	vtGeode *pGeode = CreateLineGridGeom(m_pMats, 0,
						   m_extents.min, m_extents.max, ROAD_CLUSTER);
	m_pGroup->addChild(pGeode);
#endif

	vtMesh *pMesh;
	int count = 0, total = NumLinks() + NumNodes();
	for (LinkGeom *pL = GetFirstLink(); pL; pL = pL->GetNext())
	{
		// Decide whether to construct this link
		bool include = false;
		if (bHwy && bPaved && bDirt)
			include = true;
		else
		{
			bool bIsDirt = (pL->m_Surface == SURFT_2TRACK || pL->m_Surface == SURFT_DIRT);
			if (bHwy && pL->m_iHwy != -1)
				include = true;
			if (bPaved && !bIsDirt)
				include = true;
			if (bDirt && bIsDirt)
				include = true;
		}
		if (include)
			pL->GenerateGeometry(this);
		count++;
		if (progress_callback != NULL)
			progress_callback(count * 100 / total);
	}
	count = 0;
	for (NodeGeom *pN = GetFirstNode(); pN; pN = pN->GetNext())
	{
		// What material to use?  We used to simply use "pavement", but that is
		// bad when they are e.g. trail or stone.  Now, we will try to guess
		// what to use by looking at the links here.
		int node_vti = VTI_PAVEMENT;
		for (int i = 0; i < pN->NumLinks(); i++)
		{
			LinkGeom *pL = pN->GetLink(i);
			switch (pL->m_vti)
			{
			case VTI_RAIL:
			case VTI_4WD:
			case VTI_TRAIL:
			case VTI_GRAVEL:
			case VTI_STONE:
				node_vti = pL->m_vti;
			}
		}
		VirtualTexture &vt = m_vt[node_vti];

		pMesh = pN->GenerateGeometry(vt);
		if (pMesh)
			AddMeshToGrid(pMesh, vt.m_idx);
		count++;
		if (progress_callback != NULL)
			progress_callback(count * 100 / total);
	}

	// return the top group, ready to be added to scene graph
	return m_pTransform;
}
Exemplo n.º 5
0
void vtRoadMap3d::DrapeOnTerrain(vtHeightField3d *pHeightField)
{
	FPoint3 p;
	NodeGeom *pN;

#if 0
	// This code attempts to identify cases where a node actually
	// represents something like an overpass: two links that don't
	// actually connect.  However, it's better to take care of this
	// as a preprocess, rather than at runtime.
	float height;
	for (pN = GetFirstNode(); pN; pN = (NodeGeom *)pN->m_pNext)
	{
		bool all_same_height = true;
		height = pN->GetLink(0)->GetHeightAt(pN);
		for (int r = 1; r < pN->NumLinks(); r++)
		{
			if (pN->GetLink(r)->GetHeightAt(pN) != height)
			{
				all_same_height = false;
				break;
			}
		}
		if (!all_same_height)
		{
			pNew = new NodeGeom;
			for (r = 1; r < pN->NumLinks(); r++)
			{
				LinkGeom *pL = pN->GetLink(r);
				if (pL->GetHeightAt(pN) != height)
				{
					pN->DetachRoad(pL);
					pNew->AddRoad(pL);
				}
			}
		}
	}
#endif
	for (pN = GetFirstNode(); pN; pN = pN->GetNext())
	{
		pHeightField->ConvertEarthToSurfacePoint(pN->Pos(), pN->m_p3);
#if 0
		if (pN->NumLinks() > 0)
		{
			height = pN->GetLink(0)->GetHeightAt(pN);
			pN->m_p3.y += height;
		}
#endif
	}
	for (LinkGeom *pL = GetFirstLink(); pL; pL = pL->GetNext())
	{
		pL->m_centerline.SetSize(pL->GetSize());
		for (uint j = 0; j < pL->GetSize(); j++)
		{
			pHeightField->ConvertEarthToSurfacePoint(pL->GetAt(j), p);
			pL->m_centerline[j] = p;
		}
		// ignore width from file - imply from properties
		pL->EstimateWidth();
	}
}