Exemple #1
0
Material& Material::setTexture(unsigned int textureUnit, const char* textureFile)
{
	ESL_ASSERT(textureUnit>=1 && textureUnit<=k_maxTextureUnitNum);

	if(textureUnit<=m_textures.size())
	{	
		m_textures[textureUnit-1] = new Texture();
		m_textures[textureUnit-1]->create(textureFile);
	}
	else
	{
		TexturePtr tex = new Texture();
		tex->create(textureFile);
		m_textures.push_back(tex);
	}
	return *this;
}
Exemple #2
0
Material& Material::setTextureProperty(const std::string& propertyName, const char* textureFile)
{
	PropertyMapIter iter = m_properties.find(propertyName);
	if(iter==m_properties.end())
	{
		int unit = m_textures.size()+1;
		TexturePtr tex = new Texture();
		tex->create(textureFile);
		m_textures.push_back(tex);
		
		MaterialProperty texP;
		texP.mName = propertyName;
		texP.mType = MPT_TEXTURE_UNIT;
		texP.iValue = unit;
		setProperty(propertyName, texP);
	}
	else
	{
		MaterialProperty& texP = iter->second;
		setTexture(texP.iValue, textureFile);
	}

	return *this;
}