Пример #1
0
void vtRoute::_StringWires(long ll, vtHeightField3d *pHeightField)
{
	// pick pole numbers i and i-1 and string a wire between them
	long numiterations = NUM_WIRE_SEGMENTS;

	FPoint3 fp0, fp1;

	vtUtilNode *n0 = m_Nodes[ll-1];
	vtUtilNode *n1 = m_Nodes[ll];

	vtUtilStruct *st0 = n0->m_struct;
	vtUtilStruct *st1 = n1->m_struct;

	// safety check
	if (!st0 || !st1)
		return;

	DPoint2 p0 = n0->m_Point;
	DPoint2 p1 = n1->m_Point;

	pHeightField->ConvertEarthToSurfacePoint(p0, fp0);
	pHeightField->ConvertEarthToSurfacePoint(p1, fp1);

	FMatrix4 rot;
	rot.Identity();
	FPoint3 axisY(0, 1, 0);
	FPoint3 offset, wire0, wire1;

	vtMesh *pWireMesh;
	for (int j = 0; j < st1->m_iNumWires; j++)
	{
		pWireMesh = new vtMesh(osg::PrimitiveSet::LINE_STRIP, 0, numiterations+1);

		offset = st0->m_fpWireAtt1[j];
		rot.AxisAngle(axisY, n0->dRadAzimuth);
		rot.Transform(offset, wire0);
		FPoint3 wire_start = fp0 + wire0;

		pWireMesh->AddVertex(wire_start);

		offset = st1->m_fpWireAtt2[j];
		rot.AxisAngle(axisY, n1->dRadAzimuth);
		rot.Transform(offset, wire1);
		FPoint3 wire_end = fp1 + wire1;

		_DrawCat(wire_start, wire_end, vtGetTS()->m_fCatenaryFactor, numiterations, pWireMesh);

		pWireMesh->AddVertex(wire_end);

		pWireMesh->AddStrip2(numiterations+1, 0);
		m_pWireGeom->AddMesh(pWireMesh, m_mi_wire);
	}
}
Пример #2
0
void vtLevel::GetEdgePlane(uint i, FPlane &plane)
{
	vtEdge *edge = m_Edges[i];
	int islope = edge->m_iSlope;
	float slope = (islope / 180.0f * PIf);

	int index = i;
	int ring = m_LocalFootprint.WhichRing(index);
	FLine3 &loop = m_LocalFootprint[ring];
	uint ring_edges = loop.GetSize();
	int next = (index+1 == ring_edges) ? 0 : index+1;

	// get edge vector
	FPoint3 vec = loop[next] - loop[index];
	vec.Normalize();

	// get perpendicular (upward pointing) vector
	FPoint3 perp;
	perp.Set(0, 1, 0);

	// create rotation matrix to rotate it upward
	FMatrix4 mat;
	mat.Identity();
	mat.AxisAngle(vec, slope);

	// create normal
	FPoint3 norm;
	mat.TransformVector(perp, norm);

	plane.Set(loop[index], norm);
}