Type of field XCAFPrs_Texture::myImageSource was changed from Image_Texture to Handle(Image_Texture)
Handle(Graphic3d_TextureSet) aTextureSet = new Graphic3d_TextureSet (aNbTexUnits);
if (!aColorTexture.IsNull())
{
- aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*aColorTexture, Graphic3d_TextureUnit_BaseColor));
+ aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (aColorTexture, Graphic3d_TextureUnit_BaseColor));
}
if (!myPbrMat.EmissiveTexture.IsNull())
{
- aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*myPbrMat.EmissiveTexture, Graphic3d_TextureUnit_Emissive));
+ aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (myPbrMat.EmissiveTexture, Graphic3d_TextureUnit_Emissive));
}
if (!myPbrMat.OcclusionTexture.IsNull())
{
- aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*myPbrMat.OcclusionTexture, Graphic3d_TextureUnit_Occlusion));
+ aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (myPbrMat.OcclusionTexture, Graphic3d_TextureUnit_Occlusion));
}
if (!myPbrMat.NormalTexture.IsNull())
{
- aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*myPbrMat.NormalTexture, Graphic3d_TextureUnit_Normal));
+ aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (myPbrMat.NormalTexture, Graphic3d_TextureUnit_Normal));
}
if (!myPbrMat.MetallicRoughnessTexture.IsNull())
{
- aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (*myPbrMat.MetallicRoughnessTexture, Graphic3d_TextureUnit_MetallicRoughness));
+ aTextureSet->SetValue (aTexIter++, new XCAFPrs_Texture (myPbrMat.MetallicRoughnessTexture, Graphic3d_TextureUnit_MetallicRoughness));
}
theAspect->SetTextureSet (aTextureSet);
//function : XCAFPrs_Texture
//purpose :
//=======================================================================
-XCAFPrs_Texture::XCAFPrs_Texture (const Image_Texture& theImageSource,
+XCAFPrs_Texture::XCAFPrs_Texture (const Handle(Image_Texture)& theImageSource,
const Graphic3d_TextureUnit theUnit)
: Graphic3d_Texture2D (""),
myImageSource (theImageSource)
{
- if (!myImageSource.TextureId().IsEmpty())
+ if (!myImageSource.IsNull() && !myImageSource->TextureId().IsEmpty())
{
- myTexId = myImageSource.TextureId();
+ myTexId = myImageSource->TextureId();
}
myParams->SetTextureUnit (theUnit);
myIsColorMap = theUnit == Graphic3d_TextureUnit_BaseColor
//=======================================================================
Handle(Image_CompressedPixMap) XCAFPrs_Texture::GetCompressedImage (const Handle(Image_SupportedFormats)& theSupported)
{
- return myImageSource.ReadCompressedImage (theSupported);
+ return !myImageSource.IsNull() ? myImageSource->ReadCompressedImage (theSupported) : Handle(Image_CompressedPixMap)();
}
//=======================================================================
//=======================================================================
Handle(Image_PixMap) XCAFPrs_Texture::GetImage (const Handle(Image_SupportedFormats)& theSupported)
{
- Handle(Image_PixMap) anImage = myImageSource.ReadImage (theSupported);
- convertToCompatible (theSupported, anImage);
+ Handle(Image_PixMap) anImage;
+ if (!myImageSource.IsNull())
+ {
+ anImage = myImageSource->ReadImage(theSupported);
+ convertToCompatible(theSupported, anImage);
+ }
return anImage;
}
public:
//! Constructor.
- Standard_EXPORT explicit XCAFPrs_Texture (const Image_Texture& theImageSource,
- const Graphic3d_TextureUnit theUnit);
+ Standard_EXPORT XCAFPrs_Texture (const Handle(Image_Texture)& theImageSource,
+ const Graphic3d_TextureUnit theUnit);
//! Image reader.
Standard_EXPORT virtual Handle(Image_CompressedPixMap) GetCompressedImage (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
Standard_EXPORT virtual Handle(Image_PixMap) GetImage (const Handle(Image_SupportedFormats)& theSupported) Standard_OVERRIDE;
//! Return image source.
- const Image_Texture& GetImageSource() const { return myImageSource; }
+ const Handle(Image_Texture)& GetImageSource() const { return myImageSource; }
protected:
- Image_Texture myImageSource;
-
+ Handle(Image_Texture) myImageSource;
};
#endif // _XCAFPrs_Texture_HeaderFile