ArcGIS Procedural Runtime  3.2.10650
Material.h
1 /*
2  COPYRIGHT (c) 2012-2024 Esri R&D Center Zurich
3  TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
4  Unpublished material - all rights reserved under the
5  Copyright Laws of the United States and applicable international
6  laws, treaties, and conventions.
7 
8  For additional information, contact:
9  Environmental Systems Research Institute, Inc.
10  Attn: Contracts and Legal Services Department
11  380 New York Street
12  Redlands, California, 92373
13  USA
14 
15  email: contracts@esri.com
16 */
17 
18 #ifndef PRTX_MATERIAL_H_
19 #define PRTX_MATERIAL_H_
20 
21 #include "prtx/prtx.h"
22 #include "prtx/Types.h"
23 #include "prtx/Attributable.h"
24 #include "prtx/Builder.h"
25 #include "prtx/Content.h"
26 #include "prtx/Shader.h"
27 #include "prtx/Texture.h"
28 #include "prtx/generated/BuiltinMaterialAttributes.h"
29 
30 #include <vector>
31 #include <memory>
32 
33 #ifdef _MSC_VER
34 # pragma warning(push)
35 # pragma warning(disable : 4275)
36 #endif
37 
38 
39 class MaterialImpl;
40 
41 
42 namespace prtx {
43 
44 
45 class Material;
46 typedef std::shared_ptr<Material> MaterialPtr;
47 typedef std::vector<MaterialPtr> MaterialPtrVector;
48 
202 class PRTX_EXPORTS_API Material : public Attributable, public ComparableContent, public BuiltinMaterialAttributes {
203 public:
207  static constexpr PrimitiveType PT_TEXTURE = PT_BLIND_DATA_ARRAY + 1;
208  static constexpr PrimitiveType PT_TEXTURE_ARRAY = PT_TEXTURE + 1;
209  static constexpr PrimitiveType PT_COUNT = prtx::Attributable::PT_COUNT + 2;
210 
211  virtual ~Material();
212 
216  virtual const WStringVector& getKeys() const = 0;
217  virtual bool hasKey (const std::wstring& key) const = 0;
218  virtual PrimitiveType getType (const std::wstring& key) const = 0;
219  virtual Bool getBool (const std::wstring& key) const = 0;
220  virtual int32_t getInt (const std::wstring& key) const = 0;
221  virtual double getFloat (const std::wstring& key) const = 0;
222  virtual const std::wstring& getString (const std::wstring& key) const = 0;
223  virtual const BoolVector& getBoolArray (const std::wstring& key) const = 0;
224  virtual const Int32Vector& getIntArray (const std::wstring& key) const = 0;
225  virtual const DoubleVector& getFloatArray (const std::wstring& key) const = 0;
226  virtual const WStringVector& getStringArray (const std::wstring& key) const = 0;
227  virtual void* getBlindData (const std::wstring& key) const = 0;
233  virtual ShaderPtr getShader() const = 0;
234 
243  virtual TexturePtr getTexture(const std::wstring& key) const = 0;
244 
254  virtual const TexturePtrVector& getTextureArray(const std::wstring& key) const = 0;
255 
269  virtual TexturePtr getTextureArrayItem(const std::wstring& key, size_t index) const = 0;
270 
275  virtual const WStringVector& getBlindDataKeys() const = 0;
276 
277 
286  static std::pair<std::wstring, size_t> getShaderTextureArrayKeyAndIndexFromCGAMapName(const std::wstring& cgaMapName);
287 
288 protected:
289  // @cond
290  Material();
291  // @endcond
292 };
293 
294 
295 class MaterialBuilder;
296 typedef std::shared_ptr<MaterialBuilder> MaterialBuilderPtr;
297 
306 class PRTX_EXPORTS_API MaterialBuilder : public SharedPtrBuilder<Material>, public AttributableSetter, public BuiltinMaterialAttributesBuilder {
307 public:
311  MaterialBuilder();
312 
317  MaterialBuilder(const ShaderPtr& shader);
318 
323  MaterialBuilder(const MaterialPtr& material);
324 
325  virtual ~MaterialBuilder();
326 
327  // SharedPtrBuilder interface implementation
328  virtual MaterialPtr createSharedAndReset(std::wstring* warnings = 0);
329  virtual MaterialPtr createShared(std::wstring* warnings = 0) const;
330 
331 
335  virtual void setBool (const std::wstring& key, Bool val);
336  virtual void setInt (const std::wstring& key, int32_t val);
337  virtual void setFloat (const std::wstring& key, double val);
338  virtual void setString (const std::wstring& key, const std::wstring& val);
339  virtual void setBoolArray (const std::wstring& key, const BoolVector& val);
340  virtual void setIntArray (const std::wstring& key, const Int32Vector& val);
341  virtual void setFloatArray (const std::wstring& key, const DoubleVector& val);
342  virtual void setStringArray (const std::wstring& key, const WStringVector& val);
343  virtual void setBlindData (const std::wstring& key, void* val);
355  virtual void setTexture(const std::wstring& key, const TexturePtr& val, const std::wstring& resolveMapKey);
356 
368  virtual void setTextureArray(const std::wstring& key, const TexturePtrVector& val, const WStringVector& resolveMapKeys);
369 
381  virtual void setTextureArrayItem(const std::wstring& key, size_t index, const TexturePtr& val, const std::wstring& resolveMapKey);
382 
383 private:
384  #include "prtx/generated/BuiltinMaterialAttributesBuilder_impl_decl.h"
385 
386 private:
387  MaterialImpl* mMaterial;
388 };
389 
390 
391 } // namespace prtx
392 
393 
394 #ifdef _MSC_VER
395 # pragma warning(pop)
396 #endif
397 
398 
399 #endif /* PRTX_MATERIAL_H_ */
Definition: BuiltinMaterialAttributes.h:161
Definition: Builder.h:65
uint8_t Bool
uint8_t based Bool type
Definition: Types.h:30
std::shared_ptr< Texture > TexturePtr
shared Texture pointer
Definition: Texture.h:37
std::vector< prtx::Bool > BoolVector
vector of uint8_t based Bool type
Definition: Types.h:31
std::shared_ptr< Shader > ShaderPtr
shared Shader pointer
Definition: Shader.h:40
Definition: /Attributable.h:37
std::vector< double > DoubleVector
vector of double
Definition: Types.h:32
std::vector< TexturePtr > TexturePtrVector
vector of shared Texture pointers
Definition: Texture.h:39
std::shared_ptr< Material > MaterialPtr
shared Material pointer
Definition: DataBackend.h:45
Definition: /Attributable.h:139
Definition: Material.h:202
The Procedural Runtime eXtension namespace. The prtx namespace contains the tools to extend the Proce...
Definition: AnnotationBuilder.h:35
Definition: BuiltinMaterialAttributes.h:39
Definition: Content.h:88
std::vector< MaterialPtr > MaterialPtrVector
vector of shared Material pointers
Definition: DataBackend.h:46
std::vector< int32_t > Int32Vector
vector of int32_t
Definition: Types.h:33
std::vector< std::wstring > WStringVector
vector of std::wstring
Definition: Types.h:35
Definition: Material.h:306