HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RE_Texture2DArrayMap.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: Render Library (C++)
7  *
8  * COMMENTS:
9  * Handle to a 2D array texture stored in the texture cache. This class is
10  * primarily responsible for fetching images from various 2D sources and
11  * creating the texture for them.
12  * A 2D texture array is made up of multiple 2D texture sources. It can
13  * also support UDIM texturing.
14  *
15  */
16 #ifndef __RE_Texture2DArrayMap_h__
17 #define __RE_Texture2DArrayMap_h__
18 
19 #include <UT/UT_Rect.h>
20 #include <IMG/IMG_FileTypes.h>
21 
22 #include "RE_API.h"
23 #include "RE_TextureMap.h"
24 
26 {
27 public:
28  RE_Texture2DArrayMap(bool is_tiled_texture = false,
29  int u_stride = 10);
30  virtual ~RE_Texture2DArrayMap();
31 
32  virtual const char *className() const { return "RE_Texture2DArrayMap"; }
33 
34  /// This texture array represents a UDIM or UV tile sequence for a tiled
35  /// texture when this is enabled. The U stride is normally 10 for UDIM,
36  /// and ignored for UV tile textures.
37  void enableTileSource(bool e, int u_stride = 10);
38 
39  /// Returns the detected udim stride (not the u_stride above). This is the
40  /// number of images in the U direction for tiled textures.
41  int getTileStride() const { return myTileArea.w(); }
42 
43  /// Returns the bounding area of the populated tiles
44  UT_DimRect getTileArea() const { return myTileArea; }
45 
46  /// Sets a series of image files for the 2D array. They will appear in
47  /// the texture layers in the same order as passed. The resolution of the
48  /// array will be files.entries() layers, and the width and height will
49  /// be the maximum width and height of all images, up to max_width and
50  /// max_height if they are non-zero. An empty string can be passed to
51  /// fill that layer with (1,1,1,1).
52  void setImageList(const UT_StringArray &files,
53  int max_width = 0,
54  int max_height = 0);
55 
56  /// Returns the amount of main memory owned by this object.
57  /// GL Textures are shared in the texture cache itself.
58  virtual int64 getMemoryUsage(bool inclusive) const;
59 
61  virtual RE_TextureMap *clone() const;
62 
63  /// Returns true if the string is a tiled texture (UDIM or UV Tile) based
64  /// on the prescense of %(UDIM), %(U), %(V) or %(UVTILE) in the filename.
65  static bool isArrayMap(const char *map_filename);
66 
67  // Public interface is in RE_TextureMap
68 
69  typedef void (*RE_TextureHDAResolverCB)(const char *optable_optype,
70  const char *pattern,
71  UT_StringArray &files);
72 
73  static void installHDACallback(RE_TextureHDAResolverCB cb)
74  { theHDAFileResolver = cb; }
75 private:
76  virtual bool buildTexture(RE_Render *r, RE_Texture *tex, void *data);
77  virtual bool getNodeSource(const char *map, const char *rel,
78  void **mapptr,
79  RE_TextureDimension &textype,
80  RE_GPUType &datatype,
81  int &vectorsize,
82  int &w, int &h, int &d);
83  virtual bool getFileSource(const char *map,
84  void **mapptr,
85  RE_TextureDimension &textype,
86  RE_GPUType &datatype,
87  int &vectorsize,
88  int &w, int &h, int &d);
89 
90  virtual void cachedTextureFound(RE_Texture *tex);
91 
92  // UDIM-style tiled textures (1001+)
93  bool determineUDIMBounds(const char *map);
94 
95  // Mari-style u#v# textures
96  bool determineTileBounds(const char *map);
97 
98  // for %(U)d %(V)d syntax, mari-style texures
99  bool determineUVBounds(const char *map);
100  // for %(UVTILE)d syntax, mari-style texures
101  bool determineUVTileBounds(const char *map);
102 
103  bool findUVTileFiles(bool is_opdef,
104  const char *pattern,
105  const char *path,
106  int base_length,
107  int ext_length,
108  bool u_first);
109 
110  bool determineFileBounds();
111  void buildTiledTexture(RE_Render *r, RE_Texture *tex);
112  void buildArrayTexture(RE_Render *r, RE_Texture *tex);
113 
114  // TODO: for File COP support.
115  // fpreal myOpTime;
116  // unsigned long myOpVersion;
117 
118  bool myIsTiledTexture;
119 
120  // image file details, per file
121  IMG_DataType myDataType;
122  IMG_ColorModel myColorModel;
123  RE_GPUType myFormat;
124  int myVectorSize;
125  int myResW;
126  int myResH;
127  int myResD;
128 
129  // for non-UDIM 2D image collections
130  UT_StringArray myFiles;
131  int myMaxW, myMaxH;
132  bool myFilesDirty;
133 
134  // tiling information for UDIM
135  class re_TexArrayElement
136  {
137  public:
138  re_TexArrayElement(const char *file, int u, int v)
139  : myFile(file), myU(u), myV(v) {}
140 
141  UT_StringHolder myFile;
142  int myU;
143  int myV;
144  };
145 
146  int myTileStride;
147  UT_DimRect myTileArea;
148 
150  UT_StringHolder myLastMap;
151 
152  // For resolving files inside HDAs.
153  static RE_TextureHDAResolverCB theHDAFileResolver;
154 };
155 
156 #endif
virtual RE_TextureMap * clone() const =0
#define RE_API
Definition: RE_API.h:10
virtual RE_TextureDimension getMapType()
const GLdouble * v
Definition: glcorearb.h:836
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
virtual bool getFileSource(const char *map, void **mapptr, RE_TextureDimension &textype, RE_GPUType &datatype, int &vectorsize, int &w, int &h, int &d)
virtual bool getNodeSource(const char *map, const char *rel, void **mapptr, RE_TextureDimension &textype, RE_GPUType &datatype, int &vectorsize, int &w, int &h, int &d)
RE_TextureDimension
virtual const char * className() const
long long int64
Definition: SYS_Types.h:100
RE_GPUType
Definition: RE_Types.h:42
UT_DimRect getTileArea() const
Returns the bounding area of the populated tiles.
virtual void cachedTextureFound(RE_Texture *tex)
IMG_DataType
Definition: IMG_FileTypes.h:17
static void installHDACallback(RE_TextureHDAResolverCB cb)
virtual int64 getMemoryUsage(bool inclusive) const
GLboolean * data
Definition: glcorearb.h:130
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
IMG_ColorModel
Definition: IMG_FileTypes.h:53
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
GLboolean r
Definition: glcorearb.h:1221
virtual bool buildTexture(RE_Render *r, RE_Texture *tex, void *data)=0