CFx SDK Documentation  2022 SP0
GiMaterialItem.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 // Material data entry for Gs material cache and textures processing.
25 
26 #ifndef __ODGIMATERIALITEM_H__
27 #define __ODGIMATERIALITEM_H__
28 
29 #include "GiExport.h"
30 #include "GiImage.h"
31 #include "GiMaterial.h"
32 #include "GiCommonDraw.h"
33 
34 #include "RxObject.h"
35 
36 #include "TD_PackPush.h"
37 
38 class OdDbStub;
39 
49 {
50  public:
51  // Simple variant type for external device information
52 
57  {
59  {
60  DevDataVariantType_Void = 0,
62  DevDataVariantType_RxObject
63  };
64 
65  DevDataVariant() : m_ddvType(DevDataVariantType_Void), m_pVoid(NULL)
66  {
67  }
68  DevDataVariant(void *ptr) : m_ddvType(DevDataVariantType_Ptr), m_pVoid(ptr)
69  {
70  if (m_pVoid == NULL)
71  m_ddvType = DevDataVariantType_Void;
72  }
73  DevDataVariant(OdRxObjectPtr ptr) : m_ddvType(DevDataVariantType_RxObject), m_pVoid(NULL)
74  {
75  m_pRxObject = ptr;
76  }
77 
79  {
80  return m_ddvType;
81  }
82  void *getPtr() const
83  {
84  return m_pVoid;
85  }
87  {
88  return m_pRxObject;
89  }
90 
91  DevDataVariant &operator =(void *ptr)
92  {
93  return setPtr(ptr);
94  }
95  DevDataVariant &operator =(OdRxObjectPtr ptr)
96  {
97  return setRxObject(ptr);
98  }
99 
100  DevDataVariant &setPtr(void *ptr)
101  {
102  clear();
103  if (ptr != NULL)
104  {
105  m_ddvType = DevDataVariantType_Ptr;
106  m_pVoid = ptr;
107  }
108  return *this;
109  }
111  {
112  clear();
113  m_ddvType = DevDataVariantType_RxObject;
114  m_pRxObject = ptr;
115  return *this;
116  }
117 
118  void clear()
119  {
120  m_ddvType = DevDataVariantType_Void;
121  m_pVoid = NULL;
122  if (m_pRxObject.isNull())
123  m_pRxObject.release();
124  }
125 
126  protected:
128  void *m_pVoid;
130  };
131 
132  public:
134  friend class OdGiModuleObject;
135 
141  virtual void setTextureData(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, const OdGiImageBGRA32 &image) = 0;
149 
153  virtual bool haveData() const = 0;
154 
163 
164  private:
166  static void rxInitDefaultTextureDataImplementation();
168  static void rxUninitDefaultTextureDataImplementation();
169 };
170 
177 
186 {
187  public:
189 
191 
196  virtual void startTextureLoading(OdString &fileName, OdDbBaseDatabase* pDb) = 0;
197 
201  virtual void textureLoaded(const OdString &fileName, OdDbBaseDatabase* pDb) = 0;
205  virtual void textureLoadingFailed(const OdString &fileName, OdDbBaseDatabase* pDb) = 0;
206 };
207 
214 
216 
226 {
227  public:
229 
234  virtual bool allowTextureLoading(OdGiMaterialTexturePtr pTexture) = 0;
235 
245 };
246 
253 
263 {
264  public:
266 
271  {
272  kFileTexturesOnly = 0, // @def
273  kFileAndProceduralTextures, // not efficient for search
274  kDisable // only loading from LoaderExt will be active
275  };
276 
281  virtual void setManageType(ManageType type) = 0;
285  virtual ManageType manageType() const = 0;
286 
296 
311  virtual OdGiMaterialTextureDataPtr searchTexture(const OdString &fileName) = 0;
312 
339  virtual OdGiMaterialTextureDataPtr tryToLoad(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, OdGiMaterialTextureEntry *pEntry, const OdString &fileName) = 0;
340 
346  virtual void linkTexture(const OdGiMaterialMap &matMap, OdGiMaterialTextureDataPtr pData) = 0;
358  virtual void linkTexture(const OdString &fileName, OdGiMaterialTextureDataPtr pData) = 0;
359 
364  virtual bool isAvailable(const OdGiMaterialTextureData *pData) const = 0;
365 
370  virtual void unlinkTexture(OdGiMaterialTextureData *pData) = 0;
371 
375  virtual void clear() = 0;
376 
380  virtual OdUInt32 numTextureEntries() const = 0;
381 
387 
393 };
394 
401 
411 {
412  public:
414 
422  virtual bool isTextureInitialized() const = 0;
423 
427  virtual OdUInt32 proceduralTextureWidth() const = 0;
435  virtual OdUInt32 proceduralTextureHeight() const = 0;
444 
448  virtual double proceduralTextureQuality() const = 0;
452  virtual void setProceduralTextureQuality(double coef) = 0;
453 
462  virtual bool setGiMaterialTexture(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, const OdGiMaterialMap &matMap, OdGiMaterialTextureManager *pManager = NULL) = 0;
463 
472  virtual bool setGiMaterialTexture(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, OdGiMaterialTexturePtr pTexture, OdGiMaterialTextureManager *pManager = NULL) = 0;
473  // Load texture from raster file
482  virtual bool setGiMaterialTexture(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, const OdString &fileName, OdGiMaterialTextureManager *pManager = NULL) = 0;
491  virtual bool setGiMaterialTexture(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, double opacity, OdGiMaterialTextureManager *pManager = NULL) = 0;
492 
498  virtual void setTextureData(OdGiMaterialTextureData *pTextureData, OdGiMaterialTextureManager *pManager = NULL) = 0;
499 };
500 
507 
517 {
518  public:
520 
536  virtual void removeDiffuseTexture() = 0;
540  virtual bool haveDiffuseTexture() const = 0;
541 
542  // Container data
543 
547  virtual OdRxObjectPtr cachedData() const = 0;
551  virtual void setCachedData(OdRxObjectPtr data) = 0;
552 
556  virtual const OdDbStub *materialId() const = 0;
560  virtual void setMaterialId(const OdDbStub *matId = NULL) = 0;
564  virtual bool isMaterialIdValid(const OdDbStub *matId) = 0;
565 };
566 
573 
583 {
584  public:
586 
602  virtual void removeSpecularTexture() = 0;
606  virtual bool haveSpecularTexture() const = 0;
607 
623  virtual void removeReflectionTexture() = 0;
627  virtual bool haveReflectionTexture() const = 0;
628 
644  virtual void removeOpacityTexture() = 0;
648  virtual bool haveOpacityTexture() const = 0;
649 
665  virtual void removeBumpTexture() = 0;
669  virtual bool haveBumpTexture() const = 0;
670 
686  virtual void removeRefractionTexture() = 0;
690  virtual bool haveRefractionTexture() const = 0;
691 
707  virtual void removeNormalMapTexture() = 0;
711  virtual bool haveNormalMapTexture() const = 0;
712 
728  virtual void removeEmissionTexture() = 0;
732  virtual bool haveEmissionTexture() const = 0;
733 };
734 
741 
742 #include "TD_PackPop.h"
743 
744 #endif // __ODGIMATERIALITEM_H__
#define ODGI_EXPORT
Definition: GiExport.h:35
OdSmartPtr< OdGiMaterialRenderItem > OdGiMaterialRenderItemPtr
OdSmartPtr< OdGiMaterialItem > OdGiMaterialItemPtr
OdSmartPtr< OdGiMaterialTextureManager > OdGiMaterialTextureManagerPtr
OdSmartPtr< OdGiMaterialTextureEntry > OdGiMaterialTextureEntryPtr
OdSmartPtr< OdGiMaterialTextureLoadPE > OdGiMaterialTextureLoadPEPtr
OdSmartPtr< OdGiMaterialTextureLoaderExt > OdGiMaterialTextureLoaderExtPtr
OdSmartPtr< OdGiMaterialTextureData > OdGiMaterialTextureDataPtr
#define NULL
Definition: GsProperties.h:177
unsigned int OdUInt32
virtual const OdDbStub * materialId() const =0
virtual void setMaterialId(const OdDbStub *matId=NULL)=0
virtual void setCachedData(OdRxObjectPtr data)=0
ODRX_DECLARE_MEMBERS(OdGiMaterialItem)
virtual OdGiMaterialTextureEntryPtr diffuseTexture() const =0
virtual bool haveDiffuseTexture() const =0
virtual OdRxObjectPtr cachedData() const =0
virtual OdGiMaterialTextureEntryPtr diffuseTexture()=0
virtual OdGiMaterialTextureEntryPtr createDiffuseTexture()=0
virtual void removeDiffuseTexture()=0
virtual bool isMaterialIdValid(const OdDbStub *matId)=0
ODRX_DECLARE_MEMBERS(OdGiMaterialRenderItem)
virtual bool haveSpecularTexture() const =0
virtual bool haveOpacityTexture() const =0
virtual OdGiMaterialTextureEntryPtr createRefractionTexture()=0
virtual OdGiMaterialTextureEntryPtr reflectionTexture() const =0
virtual OdGiMaterialTextureEntryPtr reflectionTexture()=0
virtual void removeBumpTexture()=0
virtual void removeEmissionTexture()=0
virtual bool haveNormalMapTexture() const =0
virtual OdGiMaterialTextureEntryPtr normalMapTexture()=0
virtual OdGiMaterialTextureEntryPtr createOpacityTexture()=0
virtual OdGiMaterialTextureEntryPtr bumpTexture()=0
virtual void removeNormalMapTexture()=0
virtual OdGiMaterialTextureEntryPtr bumpTexture() const =0
virtual OdGiMaterialTextureEntryPtr refractionTexture()=0
virtual bool haveEmissionTexture() const =0
virtual OdGiMaterialTextureEntryPtr createBumpTexture()=0
virtual OdGiMaterialTextureEntryPtr createSpecularTexture()=0
virtual void removeRefractionTexture()=0
virtual OdGiMaterialTextureEntryPtr emissionTexture()=0
virtual OdGiMaterialTextureEntryPtr specularTexture() const =0
virtual OdGiMaterialTextureEntryPtr createReflectionTexture()=0
virtual OdGiMaterialTextureEntryPtr refractionTexture() const =0
virtual bool haveBumpTexture() const =0
virtual void removeSpecularTexture()=0
virtual OdGiMaterialTextureEntryPtr emissionTexture() const =0
virtual OdGiMaterialTextureEntryPtr normalMapTexture() const =0
virtual void removeReflectionTexture()=0
virtual OdGiMaterialTextureEntryPtr opacityTexture()=0
virtual OdGiMaterialTextureEntryPtr createNormalMapTexture()=0
virtual bool haveRefractionTexture() const =0
virtual OdGiMaterialTextureEntryPtr createEmissionTexture()=0
virtual OdGiMaterialTextureEntryPtr specularTexture()=0
virtual bool haveReflectionTexture() const =0
virtual OdGiMaterialTextureEntryPtr opacityTexture() const =0
virtual void removeOpacityTexture()=0
virtual void setTextureData(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, const OdGiImageBGRA32 &image)=0
static OdSmartPtr< OdGiMaterialTextureData > createDefaultTextureDataImplementation()
static OdRxClass * defaultTextureDataImplementationDesc()
virtual bool haveData() const =0
virtual void textureData(OdGiPixelBGRA32Array &data, OdUInt32 &width, OdUInt32 &height) const =0
ODRX_DECLARE_MEMBERS(OdGiMaterialTextureData)
virtual OdUInt32 proceduralTextureWidth() const =0
virtual OdGiMaterialTextureDataPtr textureData() const =0
virtual bool setGiMaterialTexture(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, OdGiMaterialTexturePtr pTexture, OdGiMaterialTextureManager *pManager=NULL)=0
virtual OdUInt32 proceduralTextureHeight() const =0
virtual void setTextureData(OdGiMaterialTextureData *pTextureData, OdGiMaterialTextureManager *pManager=NULL)=0
virtual void setProceduralTextureHeight(OdUInt32 height)=0
virtual void setProceduralTextureResolution(OdUInt32 width, OdUInt32 height)=0
virtual bool setGiMaterialTexture(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, const OdString &fileName, OdGiMaterialTextureManager *pManager=NULL)=0
virtual bool isTextureInitialized() const =0
virtual void setProceduralTextureWidth(OdUInt32 width)=0
ODRX_DECLARE_MEMBERS(OdGiMaterialTextureEntry)
virtual double proceduralTextureQuality() const =0
virtual bool setGiMaterialTexture(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, const OdGiMaterialMap &matMap, OdGiMaterialTextureManager *pManager=NULL)=0
virtual void setProceduralTextureQuality(double coef)=0
virtual bool setGiMaterialTexture(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, double opacity, OdGiMaterialTextureManager *pManager=NULL)=0
virtual void textureLoadingFailed(const OdString &fileName, OdDbBaseDatabase *pDb)=0
ODRX_DECLARE_MEMBERS(OdGiMaterialTextureLoadPE)
virtual void startTextureLoading(OdString &fileName, OdDbBaseDatabase *pDb)=0
virtual void textureLoaded(const OdString &fileName, OdDbBaseDatabase *pDb)=0
virtual OdGiMaterialTextureDataPtr loadTexture(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, OdGiMaterialTextureEntry *pEntry, OdGiMaterialTexturePtr pTexture)=0
virtual bool allowTextureLoading(OdGiMaterialTexturePtr pTexture)=0
ODRX_DECLARE_MEMBERS(OdGiMaterialTextureLoaderExt)
virtual OdUInt32 numTextureEntries() const =0
virtual OdGiMaterialTextureDataPtr searchTexture(OdGiMaterialTexturePtr pTexture)=0
virtual OdGiMaterialTexturePtr textureEntryKey(OdUInt32 nIndex) const =0
virtual ManageType manageType() const =0
virtual void clear()=0
virtual void setManageType(ManageType type)=0
virtual void linkTexture(const OdGiMaterialMap &matMap, OdGiMaterialTextureDataPtr pData)=0
virtual OdGiMaterialTextureDataPtr searchTexture(const OdString &fileName)=0
virtual OdGiMaterialTextureDataPtr tryToLoad(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, OdGiMaterialTextureEntry *pEntry, OdGiMaterialTexturePtr pTexture)=0
virtual void linkTexture(const OdString &fileName, OdGiMaterialTextureDataPtr pData)=0
ODRX_DECLARE_MEMBERS(OdGiMaterialTextureManager)
virtual OdGiMaterialTextureLoaderExtPtr materialLoaderExt() const =0
virtual OdGiMaterialTextureDataPtr tryToLoad(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, OdGiMaterialTextureEntry *pEntry, const OdGiMaterialMap &matMap)=0
virtual OdGiMaterialTextureDataPtr searchTexture(const OdGiMaterialMap &matMap)=0
virtual void unlinkTexture(OdGiMaterialTextureData *pData)=0
virtual void linkTexture(OdGiMaterialTexturePtr pTexture, OdGiMaterialTextureDataPtr pData)=0
virtual void setMaterialLoaderExt(OdGiMaterialTextureLoaderExt *pExt)=0
virtual OdGiMaterialTextureDataPtr tryToLoad(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, OdRxClass *pTexDataImpl, const OdGiContext &giCtx, OdGiMaterialTextureEntry *pEntry, const OdString &fileName)=0
virtual OdGiMaterialTextureDataPtr textureEntryData(OdUInt32 nIndex) const =0
virtual bool isAvailable(const OdGiMaterialTextureData *pData) const =0
GLint GLenum GLsizei width
Definition: gles2_ext.h:110
GLint GLenum GLsizei GLsizei GLint GLsizei const void * data
Definition: gles2_ext.h:110
GLuint GLsizei GLsizei GLint GLenum * type
Definition: gles2_ext.h:274
GLint GLenum GLsizei GLsizei height
Definition: gles2_ext.h:110
DevDataVariantType type() const
DevDataVariant & setPtr(void *ptr)
DevDataVariant & setRxObject(OdRxObjectPtr ptr)