Ejemplo n.º 1
0
// *************************************************************************************************
void setDiffuse(NL3D::UInstance instance, bool onOff, const NLMISC::CRGBA &color)
{
	if (instance.empty()) return;
	for(uint k = 0; k < instance.getNumMaterials(); ++k)
	{
		NL3D::UInstanceMaterial mat = instance.getMaterial(k);
		if (mat.isLighted())
		{
			CRGBA src;
			if (onOff)
			{
				src = mat.getDiffuse();
				src.R = color.R;
				src.G = color.G;
				src.B = color.B;
			}
			else
			{
				NL3D::UMaterial			matShape = instance.getShape().getMaterial(k);
				src = matShape.getDiffuse();
				src.A = mat.getDiffuse().A;
			}
			mat.setDiffuse(src);
		}
		else
		{
			CRGBA src;
			if (onOff)
			{
				src = mat.getColor();
				src.R = color.R;
				src.G = color.G;
				src.B = color.B;
			}
			else
			{
				NL3D::UMaterial			matShape = instance.getShape().getMaterial(k);
				src = matShape.getColor();
				src.A = mat.getColor().A;
			}
			mat.setColor(src);
		}
	}
}