HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMG_FileIES.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: IMG_FileIES.h ( IMG Library, C++)
7  *
8  * COMMENTS: Class to read/write IES format. Images loaded from IES
9  * format will show only the candela values, not the angles.
10  * To map from a direction vector to an image pixel
11  * coordinate, use the getEnvCoord() method. Specification
12  * for this file format are located here:
13  *
14  * http://www.ltblight.com/English.lproj/LTBLhelp/pages/iesformat.html
15  */
16 
17 #ifndef __IMG_FileIES__
18 #define __IMG_FileIES__
19 
20 #include "IMG_API.h"
21 #include "IMG_File.h"
22 #include <UT/UT_NonCopyable.h>
23 
24 class IMG_API IMG_FileIES : public IMG_File
25 {
26 public:
27  IMG_FileIES();
28  ~IMG_FileIES() override;
29 
31 
32  static void registerFormat();
33 
34  int open() override;
35  int readScanline(int y, void *buf) override;
36  int writeScanline(int y, const void *buf) override;
37 
38  int closeFile() override;
39 
40  // This operation converts a direction vector to the IES image
41  // coordinates based on the angles specified in the file.
42  // The angscale scales the direction vector vertical angle.
43  void getEnvCoord(
44  const UT_Vector3 &r,
45  float &u,
46  float &v,
47  float angscale) const;
48 
49  // mode 1: normalize using maximum value in the table (mantra-style)
50  // mode 2: normalize to preserve light's energy output
51  float getNormalization(int mode) const { return myScaler[mode]; }
52 
53  int getPhotometricType() const { return myHeader.myPhotometricType; }
54 
55  int getXResolution() const { return myXRes; }
56  int getYResolution() const { return myYRes; }
57  const float* getXAngles() const { return myXAngles.data(); }
58  const float* getYAngles() const { return myYAngles.data(); }
59  const float* getImageData() const { return myImageData.data(); }
60 
61 private:
62  // Helper to construct the actual pixel data for filtering. This
63  // method handles the different symmetry types at load time so that
64  // image filtering can be performed without seams.
65  void buildImageData();
66 
67 private:
68  struct Header {
69  // Line 10
70  int myNLamps;
71  float myLumensPerLamp;
72  float myCandelaMultiplier;
73  int myVerticalAngles;
74  int myHorizontalAngles;
75  int myPhotometricType;
76  int myUnitsType;
77  float myWidth;
78  float myLength;
79  float myHeight;
80 
81  // Line 11
82  float myBallastFactor;
83  float myBallastPhotometricFactor;
84  float myInputWatts;
85  };
86 
87  UT_String myFormat;
88  UT_String myTilt;
89  Header myHeader;
90  UT_FloatArray myVerticalAngles;
91  UT_FloatArray myHorizontalAngles;
92  UT_FloatArray myData;
93 
94  // IES file data processed into an angle-parameterized sphere map
95  UT_FloatArray myXAngles;
96  UT_FloatArray myYAngles;
97  UT_FloatArray myImageData;
98  int myXRes;
99  int myYRes;
100  float myScaler[3];
101 };
102 
103 #endif
104 
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
int getPhotometricType() const
Definition: IMG_FileIES.h:53
const GLdouble * v
Definition: glcorearb.h:837
float getNormalization(int mode) const
Definition: IMG_FileIES.h:51
GLint y
Definition: glcorearb.h:103
const float * getImageData() const
Definition: IMG_FileIES.h:59
#define IMG_API
Definition: IMG_API.h:10
int open(float queuesize) override
const float * getYAngles() const
Definition: IMG_FileIES.h:58
int getXResolution() const
Definition: IMG_FileIES.h:55
int getYResolution() const
Definition: IMG_FileIES.h:56
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
GLenum mode
Definition: glcorearb.h:99
const float * getXAngles() const
Definition: IMG_FileIES.h:57
GLboolean r
Definition: glcorearb.h:1222