예제 #1
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);
}