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 
25 typedef void (*RE_TextureHDAResolverCB)(const char *optable_optype,
26  const char *pattern,
27  UT_StringArray &files);
28 
29 
30 
31 namespace RE_Utils
32 {
33 // Returns true if <UDIM> or %(UDIM)d is in the filename.
34 extern RE_API bool isUDIMTexture(const UT_StringHolder &map_name);
35 
36 // Given a filepath with <UDIM> or %(UDIM)d in it, determine the UDIM extent,
37 // the filenames and their coordinate
38 extern RE_API bool determineUDIMBounds(
39  const UT_StringHolder &filepath,
40  UT_DimRect &udim_area,
41  int &max_tile,
42  UT_Array<std::pair<UT_StringHolder,UT_Vector2i>> &tiles,
43  int tile_stride,
44  RE_TextureHDAResolverCB hda_resolver);
45 
46 /// Given an oppath + a channel name (op:/path/to/node/parmname) to a ramp parm,
47 /// generate a ramp in ramp_data. Presize the array to the precision you require.
48 /// parm_path can also be op:parmname if rel_path is the path to the node.
49 extern RE_API bool createRampFromParm(const UT_StringHolder &parm_path,
50  const UT_StringHolder &rel_path,
51  UT_Vector4FArray &ramp_data,
52  int &op_id, int &op_version,
53  bool &is_rgb);
54 // Given a polar map, create a 6-face map in 'output_pixels', which must be
55 // large enough to hold 6 images of cube_size X cube_size with the bit depth of
56 // 'data_type' and the tuple size of the polar_image.
57 // order: +X, -X, +Y, -Y, +Z, -Z
58 extern RE_API bool createSphereMap(const PXL_Raster *polar_image,
59  int cube_size,
60  void *output_pixels,
61  RE_GPUType dest_type);
62 // Scale a polar raster to a lower mip, 1/2 size. Must be FP32.
63 extern RE_API void scalePolarFromRaster(PXL_Raster *dest,
64  const PXL_Raster *src,
65  bool wrap_y);
66 // Load a six-plane cubemap file (with planes Right, Left, Top,Bottom,Front,Back
67 // into a block of memory big enough for 6 x W x H x depth(type) x vsize
68 extern RE_API bool loadCubeMap(IMG_File *fp, int w, int h,
69  RE_GPUType type, int vsize, void *output_pixels);
70 
71 // Given an oppath (op:/path/to/node/parmname) to a cubemap (with planes
72 // Right, Left, Top, Bottom, Front, Back) loads it into a block of memory
73 // big enough for 6 x W x H x depth(type) x vsize, and also returns the
74 // size, format, and op id of the pixel through output parameters.
75 // If ptr to data is null, still sets the output parameters
76 extern RE_API bool resolveCopCubeMap(const UT_StringHolder &op_path,
77  int &op_id,
78  int &w, int &h,
79  RE_GPUType &datatype, int &vsize,
80  void *output_pixels, exint output_size);
81 
83  fpreal b, fpreal t,
84  fpreal n, fpreal f,
85  bool reverse_depth = false);
87  fpreal b, fpreal t,
88  fpreal n, fpreal f);
90  const UT_Vector3D &target,
91  const UT_Vector3D &up);
92 }
93 
94 #endif
95 
96 
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_GPUType
Definition: RE_Types.h:44
GLdouble n
Definition: glcorearb.h:2008
GLfloat f
Definition: glcorearb.h:1926
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
fpreal64 fpreal
Definition: SYS_Types.h:277
void(* RE_TextureHDAResolverCB)(const char *optable_optype, const char *pattern, UT_StringArray &files)
Definition: RE_Utils.h:25
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
type
Definition: core.h:1059
GLenum src
Definition: glcorearb.h:1793