HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_Utils.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: RE_Utils.h ( RE Library, C++)
7  *
8  * COMMENTS:
9  * Utility functions for RE and RV.
10  */
11 #ifndef RE_Utils_h
12 #define RE_Utils_h
13 
14 #include "RE_API.h"
15 #include "RE_Types.h"
16 #include <UT/UT_Array.h>
17 #include <UT/UT_Rect.h>
18 #include <UT/UT_VectorTypes.h>
19 
20 class UT_StringHolder;
21 class UT_StringArray;
22 class PXL_Raster;
23 class IMG_File;
24 class RE_Render;
25 class RE_OGLTexture;
26 
27 typedef void (*RE_TextureHDAResolverCB)(const char *optable_optype,
28  const char *pattern,
29  UT_StringArray &files);
30 
31 
32 
33 namespace RE_Utils
34 {
35 // Returns true if <UDIM> or %(UDIM)d is in the filename.
36 extern RE_API bool isUDIMTexture(const UT_StringHolder &map_name);
37 
38 // Given a filepath with <UDIM> or %(UDIM)d in it, determine the UDIM extent,
39 // the filenames and their coordinate
40 extern RE_API bool determineUDIMBounds(
41  const UT_StringHolder &filepath,
42  UT_DimRect &udim_area,
43  int &max_tile,
44  UT_Array<std::pair<UT_StringHolder,UT_Vector2i>> &tiles,
45  int tile_stride,
46  RE_TextureHDAResolverCB hda_resolver);
47 
48 /// Given an oppath + a channel name (op:/path/to/node/parmname) to a ramp parm,
49 /// generate a ramp in ramp_data. Presize the array to the precision you require.
50 /// parm_path can also be op:parmname if rel_path is the path to the node.
51 extern RE_API bool createRampFromParm(const UT_StringHolder &parm_path,
52  const UT_StringHolder &rel_path,
53  UT_Vector4FArray &ramp_data,
54  int &op_id, int &op_version,
55  bool &is_rgb);
56 // Given a polar map, create a 6-face map in 'output_pixels', which must be
57 // large enough to hold 6 images of cube_size X cube_size with the bit depth of
58 // 'data_type' and the tuple size of the polar_image.
59 // order: +X, -X, +Y, -Y, +Z, -Z
60 extern RE_API bool createSphereMap(const PXL_Raster *polar_image,
61  int cube_size,
62  void *output_pixels,
63  RE_GPUType dest_type);
64 // Scale a polar raster to a lower mip, 1/2 size. Must be FP32.
65 extern RE_API void scalePolarFromRaster(PXL_Raster *dest,
66  const PXL_Raster *src,
67  bool wrap_y);
68 // Load a six-plane cubemap file (with planes Right, Left, Top,Bottom,Front,Back
69 // into a block of memory big enough for 6 x W x H x depth(type) x vsize
70 extern RE_API bool loadCubeMap(IMG_File *fp, int w, int h,
71  RE_GPUType type, int vsize, void *output_pixels);
72 
73 // Given an oppath (op:/path/to/node/parmname) to a cubemap (with planes
74 // Right, Left, Top, Bottom, Front, Back) loads it into a block of memory
75 // big enough for 6 x W x H x depth(type) x vsize, and also returns the
76 // size, format, and op id of the pixel through output parameters.
77 // If ptr to data is null, still sets the output parameters
78 extern RE_API bool resolveCopCubeMap(const UT_StringHolder &op_path,
79  int &op_id,
80  int &w, int &h,
81  RE_GPUType &datatype, int &vsize,
82  void *output_pixels, exint output_size);
83 
85  fpreal b, fpreal t,
86  fpreal n, fpreal f,
87  bool reverse_depth = false);
89  fpreal b, fpreal t,
90  fpreal n, fpreal f);
92  const UT_Vector3D &target,
93  const UT_Vector3D &up);
94 
95 extern RE_API void copyDepth(RE_Render *r,
97  RE_OGLTexture *src);
98 
99 extern RE_API void copyDepthRaw2DSrc(RE_Render *r,
100  RE_OGLTexture *dst,
101  exint src_id);
102 }
103 
104 #endif
105 
106 
RE_API bool loadCubeMap(IMG_File *fp, int w, int h, RE_GPUType type, int vsize, void *output_pixels)
RE_API bool createSphereMap(const PXL_Raster *polar_image, int cube_size, void *output_pixels, RE_GPUType dest_type)
#define RE_API
Definition: RE_API.h:10
void
Definition: png.h:1083
int64 exint
Definition: SYS_Types.h:125
RE_API bool isUDIMTexture(const UT_StringHolder &map_name)
RE_API bool resolveCopCubeMap(const UT_StringHolder &op_path, int &op_id, int &w, int &h, RE_GPUType &datatype, int &vsize, void *output_pixels, exint output_size)
RE_API void copyDepthRaw2DSrc(RE_Render *r, RE_OGLTexture *dst, exint src_id)
RE_API void copyDepth(RE_Render *r, RE_OGLTexture *dst, RE_OGLTexture *src)
RE_GPUType
Definition: RE_Types.h:52
GLdouble n
Definition: glcorearb.h:2008
GLfloat f
Definition: glcorearb.h:1926
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
GLenum target
Definition: glcorearb.h:1667
RE_API UT_Matrix4D getOrthoProjection(fpreal l, fpreal r, fpreal b, fpreal t, fpreal n, fpreal f)
RE_API UT_Matrix4D getLookatTransform(const UT_Vector3D &eye, const UT_Vector3D &target, const UT_Vector3D &up)
GLushort pattern
Definition: glad.h:2583
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
RE_API bool determineUDIMBounds(const UT_StringHolder &filepath, UT_DimRect &udim_area, int &max_tile, UT_Array< std::pair< UT_StringHolder, UT_Vector2i >> &tiles, int tile_stride, RE_TextureHDAResolverCB hda_resolver)
GLdouble t
Definition: glad.h:2397
RE_API bool createRampFromParm(const UT_StringHolder &parm_path, const UT_StringHolder &rel_path, UT_Vector4FArray &ramp_data, int &op_id, int &op_version, bool &is_rgb)
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
GLenum GLenum dst
Definition: glcorearb.h:1793
fpreal64 fpreal
Definition: SYS_Types.h:283
void(* RE_TextureHDAResolverCB)(const char *optable_optype, const char *pattern, UT_StringArray &files)
Definition: RE_Utils.h:27
RE_API void scalePolarFromRaster(PXL_Raster *dest, const PXL_Raster *src, bool wrap_y)
RE_API UT_Matrix4D getPerspectiveProjection(fpreal l, fpreal r, fpreal b, fpreal t, fpreal n, fpreal f, bool reverse_depth=false)
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
GLboolean r
Definition: glcorearb.h:1222
GLenum src
Definition: glcorearb.h:1793