Material Definition Language API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bsdf_isotropic_data.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright 2020 NVIDIA Corporation. All rights reserved.
3  **************************************************************************************************/
7 
8 #ifndef MI_NEURAYLIB_BSDF_ISOTROPIC_DATA_H
9 #define MI_NEURAYLIB_BSDF_ISOTROPIC_DATA_H
10 
11 #include <mi/base/handle.h>
14 
15 namespace mi {
16 
17 namespace neuraylib {
18 
23 class Bsdf_buffer : public mi::base::Interface_implement<neuraylib::IBsdf_buffer>
30 {
31 public:
35  Bsdf_buffer( Size size) : m_buffer( new Float32[size]()) { }
36 
38  ~Bsdf_buffer() { delete[] m_buffer; }
39 
41  const Float32* get_data() const { return m_buffer; }
42 
44  Float32* get_data() { return m_buffer; }
45 
46 private:
47  Float32* m_buffer;
48 };
49 
59 class Bsdf_isotropic_data : public mi::base::Interface_implement<neuraylib::IBsdf_isotropic_data>
60 {
61 public:
63  Bsdf_isotropic_data( Uint32 resolution_theta, Uint32 resolution_phi, Bsdf_type type)
64  : m_resolution_theta( resolution_theta),
65  m_resolution_phi( resolution_phi),
66  m_type( type)
67  {
68  Size size = resolution_theta * resolution_theta * resolution_phi;
69  if( type == BSDF_RGB)
70  size *= 3;
71  m_bsdf_buffer = new Bsdf_buffer( size);
72  }
73 
75  Uint32 get_resolution_theta() const { return m_resolution_theta; }
76 
78  Uint32 get_resolution_phi() const { return m_resolution_phi; }
79 
81  Bsdf_type get_type() const { return m_type; }
82 
85  { m_bsdf_buffer->retain(); return m_bsdf_buffer.get(); }
86 
89  { m_bsdf_buffer->retain(); return m_bsdf_buffer.get(); }
90 
91 private:
92  Uint32 m_resolution_theta;
93  Uint32 m_resolution_phi;
94  Bsdf_type m_type;
95  base::Handle<Bsdf_buffer> m_bsdf_buffer;
96 };
97  // end group mi_neuray_misc
99 
100 } // namespace neuraylib
101 
102 } // namespace mi
103 
104 #endif // MI_NEURAYLIB_BSDF_ISOTROPIC_DATA_H