コード例 #1
0
ファイル: prim_render.cpp プロジェクト: AzyxWare/ryzom
// *********************************************************
void CPrimRender::updateEdgeDecal(CDecal &edgeDecal, const NLMISC::CVector &start, const NLMISC::CVector &end, float distToStartVertex, float distToEndVertex)
{
	//H_AUTO(R2_CPrimRender_updateEdgeDecal)
	CVector2f start2f(start.x, start.y);
	CVector2f end2f(end.x, end.y);
	// compute real start coordinate that is at 'startRadius' dist from the 'start' pos
	float length = (end2f - start2f).norm();
	if ((distToStartVertex + distToEndVertex) >= length)
	{
		CMatrix nullMat;
		nullMat.setScale(0.f);
		// decal not visible
		edgeDecal.setWorldMatrix(nullMat);
		return;
	}
	CVector dirNormed = (end2f - start2f) / length;
	start2f = start2f + distToStartVertex * dirNormed;
	end2f = end2f - distToEndVertex * dirNormed;
	edgeDecal.setWorldMatrixForArrow(start2f, end2f, _Look.EdgeLook.DecalWidth);
	CMatrix uvMatrix;
	float uScale = _Look.EdgeLook.DecalUScale * (length  - (distToStartVertex + distToEndVertex));
	uvMatrix.setScale(CVector(uScale, 1.f, 1.f));
	switch(_Look.EdgeLook.DecalWrapMode)
	{
		case CEdgeLook::Scaled:
		case CEdgeLook::Repeat:
		break;
		case CEdgeLook::Centered:
			uvMatrix.setPos(CVector(0.5f * (1.f - uScale), 0.f, 0.f));
		break;
		default:
			nlassert(0);
		break;
	}
	edgeDecal.setTextureMatrix(uvMatrix);
}