HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GLTF_MaterialExport.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef __GLTF_MATERIAL_EXPORT_H__
27 #define __GLTF_MATERIAL_EXPORT_H__
28 
29 #include "GLTFZ_API.h"
30 
31 #include <GLTF/GLTF_Types.h>
32 #include <GLTFZ/GLTF_ExportRoot.h>
33 #include <OP/OP_Node.h>
34 #include <UT/UT_Function.h>
35 #include <UT/UT_Options.h>
36 
37 namespace GLTF_NAMESPACE
38 {
40 {
41 public:
42  bool myCopySourceTextures = false;
43  bool myFlipGreenChannel = false;
44  bool myRoundUpPowerOfTwo = false;
45  int myQuality = 100;
46  exint myMaxResolution = 0;
47  UT_StringHolder myImageFormat = "png";
48 };
49 
50 // Contains functions for exporting materials and texture to a GLTF_ExportRoot
52 {
53 public:
55  GLTF_ExportRoot& root,
56  GLTF_BaseErrorManager& error_manager,
57  UT_String& base_path,
58  bool glb);
59  ~GLTF_MaterialExport() = default;
60 
61  // Translation of Houdini principled shader parameters -> GLTF material
62  // Parameters
63  uint32 TranslatePrincipledShader(
64  const OP_Context& context,
65  const OP_Node* ps_node,
66  const UT_Options& mat_overrides,
67  const GLTF_TextureParms& tex_parms);
68 
69  // For handling textures with input from only a single channel
70  bool TranslateTexture(
71  const UT_StringHolder& mat_path,
72  const OP_Context& context,
74  const GLTF_TextureParms& tex_parms,
75  const UT_StringHolder *tex_name = nullptr,
76  const OP_Node* ps_node = nullptr);
77 
78  // For handling textures with input from multiple channels
79  bool TranslateTexture(
81  const OP_Context& context,
83  const GLTF_TextureParms& tex_parms,
84  const UT_StringHolder *tex_name = nullptr);
85 
86  bool CopySourceTexture(
87  const UT_StringHolder& source_path,
89  const GLTF_TextureParms& tex_parms,
90  const UT_StringHolder *tex_name = nullptr);
91 
92  bool CopySourceTexture(
95  const GLTF_TextureParms& tex_parms,
96  const UT_StringHolder *tex_name = nullptr);
97 
98  uint32 OutputTexture(
99  const UT_String& output_path,
100  const GLTF_TextureParms& parms,
101  UT_Function<
102  bool(std::ostream&,
103  const IMG_Format*,
105  output_function,
107  const OP_Context& context,
108  const IMG_Format* format,
109  const UT_StringHolder *tex_name = nullptr);
110 
111  // As we are pulling from multiple directories and outputting
112  // the images in a single directory, there is a possiblity of
113  // name collisions. This numbers files with the same name
114  // in an arbitrary order.
115  void GetNonCollidingName(const UT_String& s, UT_String& o);
116 
120  bool myGlb;
121 };
122 
123 } // namespace GLTF_NAMESPACE
124 
125 #endif // __GLTF_MATERIAL_EXPORT_H__
int64 exint
Definition: SYS_Types.h:125
GLdouble s
Definition: glad.h:3009
#define GLTF_NAMESPACE
Definition: GLTF_API.h:42
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
std::function< T > UT_Function
Definition: UT_Function.h:37
A map of string to various well defined value types.
Definition: UT_Options.h:84
unsigned int uint32
Definition: SYS_Types.h:40
#define GLTFZ_API
Definition: GLTFZ_API.h:37