Skip to content

Commit f30e0ba

Browse files
committed
support to build for ue4
1 parent 373f111 commit f30e0ba

8 files changed

Lines changed: 275 additions & 287 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ set(LIBGLTF_PLATFORM_LINUX FALSE)
1414
set(LIBGLTF_PLATFORM_MACOS FALSE)
1515

1616
option(LIBGLTF_COVERAGE_GCOV "Coverage gcov (debug, Linux builds only)" OFF)
17-
option(LIBGLTF_BUILD_DEBUG_FOR_UE4 "Build for UE4" OFF)
17+
option(LIBGLTF_BUILD_FOR_UE4 "Build for UE4" OFF)
18+
19+
if(LIBGLTF_BUILD_FOR_UE4)
20+
add_definitions(-DLIBGLTF_USE_WCHAR)
21+
endif()
1822

1923
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
2024
set(LIBGLTF_PLATFORM_WINDOWS TRUE)
2125
add_definitions(-DLIBGLTF_PLATFORM_WINDOWS)
2226
set(DYNAMIC_LIBRARY_EXTENSION ".dll")
2327
set(STATIC_LIBRARY_EXTENSION ".lib")
24-
if(LIBGLTF_BUILD_DEBUG_FOR_UE4)
28+
if(LIBGLTF_BUILD_FOR_UE4)
2529
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MD")
2630
endif()
2731
if((CMAKE_EXE_LINKER_FLAGS STREQUAL "/machine:X86") OR (CMAKE_EXE_LINKER_FLAGS STREQUAL " /machine:X86"))
@@ -101,3 +105,4 @@ add_subdirectory(source)
101105
add_subdirectory(tools)
102106

103107
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT libgltf)
108+

include/libgltf/libgltf.h

Lines changed: 57 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,10 @@
88

99
namespace libgltf
1010
{
11-
#if defined(LIBGLTF_PLATFORM_WINDOWS)
12-
# if defined(UNICODE)
11+
#if defined(LIBGLTF_USE_WCHAR)
1312
typedef std::wstring GLTFString;
14-
# else
15-
typedef std::string GLTFString;
16-
# endif
17-
#elif defined(LIBGLTF_PLATFORM_LINUX) || defined(LIBGLTF_PLATFORM_MACOS) || defined(PLATFORM_ANDROID) || defined(PLATFORM_IOS)
18-
typedef std::string GLTFString;
1913
#else
20-
#error Sorry, not support your platform.
14+
typedef std::string GLTFString;
2115
#endif
2216

2317
struct SGlTF;
@@ -38,6 +32,49 @@ namespace libgltf
3832
std::shared_ptr<struct SExtension> extensions;
3933
};
4034

35+
/*!
36+
* struct: SGlTFChildofRootProperty
37+
*/
38+
struct SGlTFChildofRootProperty : SGlTFProperty
39+
{
40+
SGlTFChildofRootProperty();
41+
42+
// Check valid
43+
operator bool() const;
44+
45+
// The user-defined name of this object.
46+
GLTFString name;
47+
};
48+
49+
/*!
50+
* struct: SMaterial
51+
* The material appearance of a primitive.
52+
*/
53+
struct SMaterial : SGlTFChildofRootProperty
54+
{
55+
SMaterial();
56+
57+
// Check valid
58+
operator bool() const;
59+
60+
// The alpha cutoff value of the material.
61+
float alphaCutoff;
62+
// The emissive map texture.
63+
std::shared_ptr<struct STextureInfo> emissiveTexture;
64+
// A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of `pbrMetallicRoughness` apply.
65+
std::shared_ptr<struct SMaterialPBRMetallicRoughness> pbrMetallicRoughness;
66+
// The occlusion map texture.
67+
std::shared_ptr<struct SMaterialOcclusionTextureInfo> occlusionTexture;
68+
// The alpha rendering mode of the material.
69+
GLTFString alphaMode;
70+
// Specifies whether the material is double sided.
71+
bool doubleSided;
72+
// The normal map texture.
73+
std::shared_ptr<struct SMaterialNormalTextureInfo> normalTexture;
74+
// The emissive color of the material.
75+
std::vector<float> emissiveFactor;
76+
};
77+
4178
/*!
4279
* struct: SAsset
4380
* Metadata about the glTF asset.
@@ -59,20 +96,6 @@ namespace libgltf
5996
GLTFString copyright;
6097
};
6198

62-
/*!
63-
* struct: SGlTFChildofRootProperty
64-
*/
65-
struct SGlTFChildofRootProperty : SGlTFProperty
66-
{
67-
SGlTFChildofRootProperty();
68-
69-
// Check valid
70-
operator bool() const;
71-
72-
// The user-defined name of this object.
73-
GLTFString name;
74-
};
75-
7699
/*!
77100
* struct: SSampler
78101
* Texture sampler properties for filtering and wrapping modes.
@@ -114,32 +137,16 @@ namespace libgltf
114137
};
115138

116139
/*!
117-
* struct: SMaterial
118-
* The material appearance of a primitive.
140+
* struct: SExtras
141+
* Application-specific data.
119142
*/
120-
struct SMaterial : SGlTFChildofRootProperty
143+
struct SExtras
121144
{
122-
SMaterial();
145+
SExtras();
123146

124147
// Check valid
125148
operator bool() const;
126149

127-
// The alpha cutoff value of the material.
128-
float alphaCutoff;
129-
// The emissive map texture.
130-
std::shared_ptr<struct STextureInfo> emissiveTexture;
131-
// A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of `pbrMetallicRoughness` apply.
132-
std::shared_ptr<struct SMaterialPBRMetallicRoughness> pbrMetallicRoughness;
133-
// The occlusion map texture.
134-
std::shared_ptr<struct SMaterialOcclusionTextureInfo> occlusionTexture;
135-
// The alpha rendering mode of the material.
136-
GLTFString alphaMode;
137-
// Specifies whether the material is double sided.
138-
bool doubleSided;
139-
// The normal map texture.
140-
std::shared_ptr<struct SMaterialNormalTextureInfo> normalTexture;
141-
// The emissive color of the material.
142-
std::vector<float> emissiveFactor;
143150
};
144151

145152
/*!
@@ -281,16 +288,20 @@ namespace libgltf
281288
};
282289

283290
/*!
284-
* struct: SExtras
285-
* Application-specific data.
291+
* struct: SMesh
292+
* A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene.
286293
*/
287-
struct SExtras
294+
struct SMesh : SGlTFChildofRootProperty
288295
{
289-
SExtras();
296+
SMesh();
290297

291298
// Check valid
292299
operator bool() const;
293300

301+
// An array of primitives, each defining geometry to be rendered with a material.
302+
std::vector<std::shared_ptr<struct SMeshPrimitive>> primitives;
303+
// Array of weights to be applied to the Morph Targets.
304+
std::vector<float> weights;
294305
};
295306

296307
/*!
@@ -528,23 +539,6 @@ namespace libgltf
528539
GLTFString uri;
529540
};
530541

531-
/*!
532-
* struct: SMesh
533-
* A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene.
534-
*/
535-
struct SMesh : SGlTFChildofRootProperty
536-
{
537-
SMesh();
538-
539-
// Check valid
540-
operator bool() const;
541-
542-
// An array of primitives, each defining geometry to be rendered with a material.
543-
std::vector<std::shared_ptr<struct SMeshPrimitive>> primitives;
544-
// Array of weights to be applied to the Morph Targets.
545-
std::vector<float> weights;
546-
};
547-
548542
/*!
549543
* struct: STexture
550544
* A texture and its sampler.

source/libgltf/libgltf.cpp

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,50 @@ namespace libgltf
1616
return true;
1717
}
1818

19-
SAsset::SAsset()
19+
SGlTFChildofRootProperty::SGlTFChildofRootProperty()
2020
: SGlTFProperty()
21-
, minVersion(GLTFTEXT(""))
22-
, version(GLTFTEXT(""))
23-
, generator(GLTFTEXT(""))
24-
, copyright(GLTFTEXT(""))
21+
, name(GLTFTEXT(""))
2522
{
2623
//
2724
}
2825

29-
SAsset::operator bool() const
26+
SGlTFChildofRootProperty::operator bool() const
3027
{
3128
//TODO:
3229
return true;
3330
}
3431

35-
SGlTFChildofRootProperty::SGlTFChildofRootProperty()
32+
SMaterial::SMaterial()
33+
: SGlTFChildofRootProperty()
34+
, alphaCutoff(0.500000f)
35+
, emissiveTexture(nullptr)
36+
, pbrMetallicRoughness(nullptr)
37+
, occlusionTexture(nullptr)
38+
, alphaMode(GLTFTEXT("OPAQUE"))
39+
, doubleSided(false)
40+
, normalTexture(nullptr)
41+
, emissiveFactor({ 0.000000f, 0.000000f, 0.000000f })
42+
{
43+
//
44+
}
45+
46+
SMaterial::operator bool() const
47+
{
48+
//TODO:
49+
return true;
50+
}
51+
52+
SAsset::SAsset()
3653
: SGlTFProperty()
37-
, name(GLTFTEXT(""))
54+
, minVersion(GLTFTEXT(""))
55+
, version(GLTFTEXT(""))
56+
, generator(GLTFTEXT(""))
57+
, copyright(GLTFTEXT(""))
3858
{
3959
//
4060
}
4161

42-
SGlTFChildofRootProperty::operator bool() const
62+
SAsset::operator bool() const
4363
{
4464
//TODO:
4565
return true;
@@ -76,21 +96,12 @@ namespace libgltf
7696
return true;
7797
}
7898

79-
SMaterial::SMaterial()
80-
: SGlTFChildofRootProperty()
81-
, alphaCutoff(0.500000f)
82-
, emissiveTexture(nullptr)
83-
, pbrMetallicRoughness(nullptr)
84-
, occlusionTexture(nullptr)
85-
, alphaMode(GLTFTEXT("OPAQUE"))
86-
, doubleSided(false)
87-
, normalTexture(nullptr)
88-
, emissiveFactor({ 0.000000f, 0.000000f, 0.000000f })
99+
SExtras::SExtras()
89100
{
90101
//
91102
}
92103

93-
SMaterial::operator bool() const
104+
SExtras::operator bool() const
94105
{
95106
//TODO:
96107
return true;
@@ -210,12 +221,15 @@ namespace libgltf
210221
return true;
211222
}
212223

213-
SExtras::SExtras()
224+
SMesh::SMesh()
225+
: SGlTFChildofRootProperty()
226+
, primitives()
227+
, weights()
214228
{
215229
//
216230
}
217231

218-
SExtras::operator bool() const
232+
SMesh::operator bool() const
219233
{
220234
//TODO:
221235
return true;
@@ -407,20 +421,6 @@ namespace libgltf
407421
return true;
408422
}
409423

410-
SMesh::SMesh()
411-
: SGlTFChildofRootProperty()
412-
, primitives()
413-
, weights()
414-
{
415-
//
416-
}
417-
418-
SMesh::operator bool() const
419-
{
420-
//TODO:
421-
return true;
422-
}
423-
424424
STexture::STexture()
425425
: SGlTFChildofRootProperty()
426426
, source(nullptr)

0 commit comments

Comments
 (0)