Ejemplo n.º 1
0
//-----------------------------------------------
// makeUp :
// \param face : pointer on the face to make up (must not be null).
// \param idMakeUp : index of the make-up to apply.
// \warning This function does not check if 'face'  is valid.
//-----------------------------------------------
void makeUp(NL3D::UInstance face, sint idMakeUp)
{
	static const char *tattooStr = "visage_makeup";

	// look for tattoo texture
	uint numMat = face.getNumMaterials();
	std::string texFilename;
	for(uint k = 0; k < numMat; ++k)
	{
		UInstanceMaterial im = face.getMaterial(k);
		sint numTex = im.getLastTextureStage();
		for(sint l = 0; l <= numTex; ++l)
		{
			if (im.isTextureFile(l)) // one texture from a file ?
			{
				// see if it is the texture used for tattoos
				texFilename = im.getTextureFileName(l);
				// nlinfo("visage tex = %s", texFilename.c_str());
				std::string::size_type pos = texFilename.find(tattooStr, 0);
				if (pos != std::string::npos)
				{
					uint charIndex = (uint)(pos + strlen(tattooStr));
					if (texFilename.length() >= charIndex + 2)
					{
						texFilename[charIndex] = '0' + (unsigned char) (idMakeUp / 10);
						texFilename[charIndex + 1] = '0' + (unsigned char) (idMakeUp % 10);
						im.setTextureFileName(texFilename, l);
					}
				}
			}
		}
	}
}// makeUp //
Ejemplo n.º 2
0
// *************************************************************************************************
void setEmissive(NL3D::UInstance instance, const NLMISC::CRGBA &color)
{
	if (instance.empty()) return;
	for(uint k = 0; k < instance.getNumMaterials(); ++k)
	{
		NL3D::UInstanceMaterial mat = instance.getMaterial(k);
		mat.setEmissive(color);
	}
}
Ejemplo n.º 3
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);
		}
	}
}