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 OP_Node* ps_node = nullptr);
76 
77  // For handling textures with input from multiple channels
78  bool TranslateTexture(
80  const OP_Context& context,
82  const GLTF_TextureParms& tex_parms);
83 
84  bool CopySourceTexture(
85  const UT_StringHolder& source_path,
87  const GLTF_TextureParms& tex_parms);
88 
89  bool CopySourceTexture(
92  const GLTF_TextureParms& tex_parms);
93 
94  uint32 OutputTexture(
95  const UT_String& output_path,
96  const GLTF_TextureParms& parms,
98  bool(std::ostream&,
99  const IMG_Format*,
101  output_function,
103  const OP_Context& context,
104  const IMG_Format* format);
105 
106  // As we are pulling from multiple directories and outputting
107  // the images in a single directory, there is a possiblity of
108  // name collisions. This numbers files with the same name
109  // in an arbitrary order.
110  void GetNonCollidingName(const UT_String& s, UT_String& o);
111 
115  bool myGlb;
116 };
117 
118 } // namespace GLTF_NAMESPACE
119 
120 #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