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_Options.h>
35 
36 namespace GLTF_NAMESPACE
37 {
39 {
40 public:
41  bool myCopySourceTextures = false;
42  bool myFlipGreenChannel = false;
43  bool myRoundUpPowerOfTwo = false;
44  int myQuality = 100;
45  exint myMaxResolution = 0;
46  UT_StringHolder myImageFormat = "png";
47 };
48 
49 // Contains functions for exporting materials and texture to a GLTF_ExportRoot
51 {
52 public:
54  GLTF_ExportRoot& root,
55  GLTF_BaseErrorManager& error_manager,
56  UT_String& base_path,
57  bool glb);
58  ~GLTF_MaterialExport() = default;
59 
60  // Translation of Houdini principled shader parameters -> GLTF material
61  // Parameters
62  uint32 TranslatePrincipledShader(
63  const OP_Context& context,
64  const OP_Node* ps_node,
65  const UT_Options& mat_overrides,
66  const GLTF_TextureParms& tex_parms);
67 
68  // For handling textures with input from only a single channel
69  bool TranslateTexture(
70  const UT_StringHolder& mat_path,
71  const OP_Context& context,
73  const GLTF_TextureParms& tex_parms,
74  const OP_Node* ps_node = nullptr);
75 
76  // For handling textures with input from multiple channels
77  bool TranslateTexture(
79  const OP_Context& context,
81  const GLTF_TextureParms& tex_parms);
82 
83  bool CopySourceTexture(
84  const UT_StringHolder& source_path,
86  const GLTF_TextureParms& tex_parms);
87 
88  bool CopySourceTexture(
91  const GLTF_TextureParms& tex_parms);
92 
93  uint32 OutputTexture(
94  const UT_String& output_path,
95  const GLTF_TextureParms& parms,
96  std::function<
97  bool(std::ostream&,
98  const IMG_Format*,
100  output_function,
102  const OP_Context& context,
103  const IMG_Format* format);
104 
105  // As we are pulling from multiple directories and outputting
106  // the images in a single directory, there is a possiblity of
107  // name collisions. This numbers files with the same name
108  // in an arbitrary order.
109  void GetNonCollidingName(const UT_String& s, UT_String& o);
110 
114  bool myGlb;
115 };
116 
117 } // namespace GLTF_NAMESPACE
118 
119 #endif // __GLTF_MATERIAL_EXPORT_H__
int64 exint
Definition: SYS_Types.h:125
#define GLTF_NAMESPACE
Definition: GLTF_API.h:42
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:107
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
GLdouble s
Definition: glew.h:1395