HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
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
{
39
struct
GLTFZ_API
GLTF_TextureParms
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
51
class
GLTFZ_API
GLTF_MaterialExport
52
{
53
public
:
54
GLTF_MaterialExport
(
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,
73
GLTF_NAMESPACE::GLTF_TextureInfo
& tex_info,
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(
80
const
UT_Array<GLTF_NAMESPACE::GLTF_ChannelMapping>
& mappings,
81
const
OP_Context
& context,
82
GLTF_NAMESPACE::GLTF_TextureInfo
& tex_info,
83
const
GLTF_TextureParms
& tex_parms,
84
const
UT_StringHolder
*tex_name =
nullptr
);
85
86
bool
CopySourceTexture(
87
const
UT_StringHolder
& source_path,
88
GLTF_NAMESPACE::GLTF_TextureInfo
& tex_info,
89
const
GLTF_TextureParms
& tex_parms,
90
const
UT_StringHolder
*tex_name =
nullptr
);
91
92
bool
CopySourceTexture(
93
const
UT_Array<GLTF_NAMESPACE::GLTF_ChannelMapping>
& mappings,
94
GLTF_NAMESPACE::GLTF_TextureInfo
& tex_info,
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
*,
104
const
GLTF_NAMESPACE::GLTF_ImgExportParms
&)>
105
output_function,
106
GLTF_NAMESPACE::GLTF_TextureInfo
& tex_info,
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
117
GLTF_ExportRoot
&
myRoot
;
118
GLTF_BaseErrorManager
&
myErrorManager
;
119
UT_String
&
myBasePath
;
120
bool
myGlb
;
121
};
122
123
}
// namespace GLTF_NAMESPACE
124
125
#endif // __GLTF_MATERIAL_EXPORT_H__
GLTF_ExportRoot.h
GLTF_NAMESPACE::GLTF_ImgExportParms
Definition:
GLTF_ImageExport.h:60
GLTF_NAMESPACE::GLTF_MaterialExport::myGlb
bool myGlb
Definition:
GLTF_MaterialExport.h:120
IMG_Format
Definition:
IMG_Format.h:45
GLTF_NAMESPACE::GLTF_TextureInfo
Definition:
GLTF_Types.h:194
exint
int64 exint
Definition:
SYS_Types.h:125
s
GLdouble s
Definition:
glad.h:3009
GLTF_NAMESPACE::GLTF_MaterialExport::myRoot
GLTF_ExportRoot & myRoot
Definition:
GLTF_MaterialExport.h:117
GLTF_NAMESPACE::GLTF_BaseErrorManager
Definition:
GLTF_Types.h:523
GLTF_NAMESPACE::GLTF_MaterialExport::myErrorManager
GLTF_BaseErrorManager & myErrorManager
Definition:
GLTF_MaterialExport.h:118
UT_Array
Definition:
BV_KDOPTree.h:18
UT_Options.h
OP_Context
Definition:
OP_Context.h:44
GLTF_Types.h
GLTF_NAMESPACE::GLTF_TextureParms
Definition:
GLTF_MaterialExport.h:39
UT_StringHolder
Definition:
UT_StringHolder.h:999
GLTF_NAMESPACE
#define GLTF_NAMESPACE
Definition:
GLTF_API.h:42
OP_Node.h
OP_Node
Definition:
OP_Node.h:503
format
GLint GLint GLsizei GLint GLenum format
Definition:
glcorearb.h:108
GLTF_NAMESPACE::GLTF_MaterialExport::myBasePath
UT_String & myBasePath
Definition:
GLTF_MaterialExport.h:119
UT_Function.h
UT_Function
std::function< T > UT_Function
Definition:
UT_Function.h:37
UT_Options
A map of string to various well defined value types.
Definition:
UT_Options.h:84
uint32
unsigned int uint32
Definition:
SYS_Types.h:40
GLTF_NAMESPACE::GLTF_ExportRoot
Definition:
GLTF_ExportRoot.h:52
UT_String
Definition:
UT_String.h:73
GLTFZ_API.h
GLTFZ_API
#define GLTFZ_API
Definition:
GLTFZ_API.h:37
GLTF_NAMESPACE::GLTF_MaterialExport
Definition:
GLTF_MaterialExport.h:51
GLTFZ
GLTF_MaterialExport.h
Generated on Sun Nov 17 2024 03:01:14 for HDK by
1.8.6