Пример #1
0
	void Material::buildDefaultTextures()
	{
		if(!hasDiffuseTexture())
		{
			this->diffuseTexture = new Image(1, 1, Image::IMAGE_RGB, std::vector<unsigned char>({255, 20, 147}));
			this->diffuseTexture->toTexture(false, false, true);
		}

		if(!hasNormalTexture())
		{
			this->normalTexture = new Image(1, 1, Image::IMAGE_RGB, std::vector<unsigned char>({127, 127, 255}));
			this->normalTexture->toTexture(false, false, true);
		}
	}
Пример #2
0
bool Material::isCompatible(const Material& other) const
{
    if (this == &other)
        return true;

    // compatible, if using the same textures, or one uses textures and the
    // other doesn't, or both don't use any textures at all
    if (hasDiffuseTexture() && other.hasDiffuseTexture()) {
        if (getDiffuseTexture() != other.getDiffuseTexture())
            return false;
    }
    if (hasSpecularTexture() && other.hasSpecularTexture()) {
        if (getSpecularTexture() != other.getSpecularTexture())
            return false;
    }
    if (hasEmissiveTexture() && other.hasEmissiveTexture()) {
        if (getEmissiveTexture() != other.getEmissiveTexture())
            return false;

    }
    if (hasGlossyTexture() && other.hasGlossyTexture()) {
        if (getGlossyTexture() != other.getGlossyTexture())
            return false;
    }
    if (hasAlphaTexture() && other.hasAlphaTexture()) {
        if (getAlphaTexture() != other.getAlphaTexture())
            return false;
    }
    if (hasNormalTexture() && other.hasNormalTexture()) {
        if (getNormalTexture() != other.getNormalTexture())
            return false;
    }
    if (hasAmbientTexture() && other.hasAmbientTexture()) {
        if (getAmbientTexture() != other.getAmbientTexture())
            return false;
    }

    return true;
}