Merge pull request #983 from roshanch/master
adding support to store all the layered texturespull/986/head
commit
cc16d4a0db
|
@ -1916,18 +1916,26 @@ void Converter::TrySetTextureProperties( aiMaterial* out_mat, const LayeredTextu
|
|||
return;
|
||||
}
|
||||
|
||||
const Texture* const tex = ( *it ).second->getTexture();
|
||||
int texCount = (*it).second->textureCount();
|
||||
|
||||
// Set the blend mode for layered textures
|
||||
int blendmode= (*it).second->GetBlendMode();
|
||||
out_mat->AddProperty(&blendmode,1,_AI_MATKEY_TEXOP_BASE,target,0);
|
||||
|
||||
for(int texIndex = 0; texIndex < texCount; texIndex++){
|
||||
|
||||
const Texture* const tex = ( *it ).second->getTexture(texIndex);
|
||||
|
||||
aiString path;
|
||||
path.Set( tex->RelativeFilename() );
|
||||
|
||||
out_mat->AddProperty( &path, _AI_MATKEY_TEXTURE_BASE, target, 0 );
|
||||
out_mat->AddProperty( &path, _AI_MATKEY_TEXTURE_BASE, target, texIndex );
|
||||
|
||||
aiUVTransform uvTrafo;
|
||||
// XXX handle all kinds of UV transformations
|
||||
uvTrafo.mScaling = tex->UVScaling();
|
||||
uvTrafo.mTranslation = tex->UVTranslation();
|
||||
out_mat->AddProperty( &uvTrafo, 1, _AI_MATKEY_UVTRANSFORM_BASE, target, 0 );
|
||||
out_mat->AddProperty( &uvTrafo, 1, _AI_MATKEY_UVTRANSFORM_BASE, target, texIndex );
|
||||
|
||||
const PropertyTable& props = tex->Props();
|
||||
|
||||
|
@ -2021,7 +2029,8 @@ void Converter::TrySetTextureProperties( aiMaterial* out_mat, const LayeredTextu
|
|||
}
|
||||
}
|
||||
|
||||
out_mat->AddProperty( &uvIndex, 1, _AI_MATKEY_UVWSRC_BASE, target, 0 );
|
||||
out_mat->AddProperty( &uvIndex, 1, _AI_MATKEY_UVWSRC_BASE, target, texIndex );
|
||||
}
|
||||
}
|
||||
|
||||
void Converter::SetTextureProperties( aiMaterial* out_mat, const TextureMap& textures, const MeshGeometry* const mesh )
|
||||
|
@ -2030,6 +2039,7 @@ void Converter::SetTextureProperties( aiMaterial* out_mat, const TextureMap& tex
|
|||
TrySetTextureProperties( out_mat, textures, "AmbientColor", aiTextureType_AMBIENT, mesh );
|
||||
TrySetTextureProperties( out_mat, textures, "EmissiveColor", aiTextureType_EMISSIVE, mesh );
|
||||
TrySetTextureProperties( out_mat, textures, "SpecularColor", aiTextureType_SPECULAR, mesh );
|
||||
TrySetTextureProperties( out_mat, textures, "SpecularFactor", aiTextureType_SPECULAR, mesh);
|
||||
TrySetTextureProperties( out_mat, textures, "TransparentColor", aiTextureType_OPACITY, mesh );
|
||||
TrySetTextureProperties( out_mat, textures, "ReflectionColor", aiTextureType_REFLECTION, mesh );
|
||||
TrySetTextureProperties( out_mat, textures, "DisplacementColor", aiTextureType_DISPLACEMENT, mesh );
|
||||
|
@ -2044,6 +2054,7 @@ void Converter::SetTextureProperties( aiMaterial* out_mat, const LayeredTextureM
|
|||
TrySetTextureProperties( out_mat, layeredTextures, "AmbientColor", aiTextureType_AMBIENT, mesh );
|
||||
TrySetTextureProperties( out_mat, layeredTextures, "EmissiveColor", aiTextureType_EMISSIVE, mesh );
|
||||
TrySetTextureProperties( out_mat, layeredTextures, "SpecularColor", aiTextureType_SPECULAR, mesh );
|
||||
TrySetTextureProperties( out_mat, layeredTextures, "SpecularFactor", aiTextureType_SPECULAR, mesh);
|
||||
TrySetTextureProperties( out_mat, layeredTextures, "TransparentColor", aiTextureType_OPACITY, mesh );
|
||||
TrySetTextureProperties( out_mat, layeredTextures, "ReflectionColor", aiTextureType_REFLECTION, mesh );
|
||||
TrySetTextureProperties( out_mat, layeredTextures, "DisplacementColor", aiTextureType_DISPLACEMENT, mesh );
|
||||
|
|
|
@ -594,23 +594,24 @@ public:
|
|||
BlendMode_BlendModeCount
|
||||
};
|
||||
|
||||
const Texture* getTexture() const
|
||||
const Texture* getTexture(int index=0) const
|
||||
{
|
||||
return texture;
|
||||
}
|
||||
return textures[index];
|
||||
|
||||
BlendMode GetBlendMode()
|
||||
}
|
||||
const int textureCount() const {
|
||||
return textures.size();
|
||||
}
|
||||
const BlendMode GetBlendMode() const
|
||||
{
|
||||
return blendMode;
|
||||
}
|
||||
|
||||
float Alpha()
|
||||
{
|
||||
return alpha;
|
||||
}
|
||||
|
||||
private:
|
||||
const Texture* texture;
|
||||
std::vector<const Texture*> textures;
|
||||
BlendMode blendMode;
|
||||
float alpha;
|
||||
};
|
||||
|
|
|
@ -227,7 +227,6 @@ Texture::~Texture()
|
|||
|
||||
LayeredTexture::LayeredTexture(uint64_t id, const Element& element, const Document& /*doc*/, const std::string& name)
|
||||
: Object(id,element,name)
|
||||
,texture(0)
|
||||
,blendMode(BlendMode_Modulate)
|
||||
,alpha(1)
|
||||
{
|
||||
|
@ -267,7 +266,7 @@ void LayeredTexture::fillTexture(const Document& doc)
|
|||
|
||||
const Texture* const tex = dynamic_cast<const Texture*>(ob);
|
||||
|
||||
texture = tex;
|
||||
textures.push_back(tex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue