NVIDIA Iray API
 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 1986, 2014 NVIDIA Corporation. All rights reserved.
3 //*****************************************************************************
7 //*****************************************************************************
8 
9 #ifndef MI_NEURAYLIB_BSDF_ISOTROPIC_DATA_H
10 #define MI_NEURAYLIB_BSDF_ISOTROPIC_DATA_H
11 
12 #include <mi/base/handle.h>
15 
16 namespace mi {
17 
24 class Bsdf_buffer : public mi::base::Interface_implement<IBsdf_buffer>
25 {
26 public:
30  Bsdf_buffer( Size size) : m_buffer( new Float32[size]()) { }
31 
33  ~Bsdf_buffer() { delete[] m_buffer; }
34 
36  const Float32* get_data() const { return m_buffer; }
37 
39  Float32* get_data() { return m_buffer; }
40 
41 private:
42  Float32* m_buffer;
43 };
44 
54 class Bsdf_isotropic_data : public mi::base::Interface_implement<IBsdf_isotropic_data>
55 {
56 public:
58  Bsdf_isotropic_data( Uint32 resolution_theta, Uint32 resolution_phi, Bsdf_type type)
59  : m_resolution_theta( resolution_theta),
60  m_resolution_phi( resolution_phi),
61  m_type( type)
62  {
63  Size size = resolution_theta * resolution_theta * resolution_phi;
64  if( type == BSDF_RGB)
65  size *= 3;
66  m_bsdf_buffer = new Bsdf_buffer( size);
67  }
68 
70  Uint32 get_resolution_theta() const { return m_resolution_theta; }
71 
73  Uint32 get_resolution_phi() const { return m_resolution_phi; }
74 
76  Bsdf_type get_type() const { return m_type; }
77 
79  const Bsdf_buffer* get_bsdf_buffer() const
80  { m_bsdf_buffer->retain(); return m_bsdf_buffer.get(); }
81 
84  { m_bsdf_buffer->retain(); return m_bsdf_buffer.get(); }
85 
86 private:
87  Uint32 m_resolution_theta;
88  Uint32 m_resolution_phi;
89  Bsdf_type m_type;
90  base::Handle<Bsdf_buffer> m_bsdf_buffer;
91 };
92  // end group mi_neuray_misc
94 
95 } // namespace mi
96 
97 #endif // MI_NEURAYLIB_BSDF_ISOTROPIC_DATA_H