Skip to content

Commit

Permalink
support to build for ue4
Browse files Browse the repository at this point in the history
  • Loading branch information
alexchicn committed Jan 29, 2018
1 parent 373f111 commit f30e0ba
Show file tree
Hide file tree
Showing 8 changed files with 275 additions and 287 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ set(LIBGLTF_PLATFORM_LINUX FALSE)
set(LIBGLTF_PLATFORM_MACOS FALSE)

option(LIBGLTF_COVERAGE_GCOV "Coverage gcov (debug, Linux builds only)" OFF)
option(LIBGLTF_BUILD_DEBUG_FOR_UE4 "Build for UE4" OFF)
option(LIBGLTF_BUILD_FOR_UE4 "Build for UE4" OFF)

if(LIBGLTF_BUILD_FOR_UE4)
add_definitions(-DLIBGLTF_USE_WCHAR)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(LIBGLTF_PLATFORM_WINDOWS TRUE)
add_definitions(-DLIBGLTF_PLATFORM_WINDOWS)
set(DYNAMIC_LIBRARY_EXTENSION ".dll")
set(STATIC_LIBRARY_EXTENSION ".lib")
if(LIBGLTF_BUILD_DEBUG_FOR_UE4)
if(LIBGLTF_BUILD_FOR_UE4)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MD")
endif()
if((CMAKE_EXE_LINKER_FLAGS STREQUAL "/machine:X86") OR (CMAKE_EXE_LINKER_FLAGS STREQUAL " /machine:X86"))
Expand Down Expand Up @@ -101,3 +105,4 @@ add_subdirectory(source)
add_subdirectory(tools)

set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT libgltf)

120 changes: 57 additions & 63 deletions include/libgltf/libgltf.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@

namespace libgltf
{
#if defined(LIBGLTF_PLATFORM_WINDOWS)
# if defined(UNICODE)
#if defined(LIBGLTF_USE_WCHAR)
typedef std::wstring GLTFString;
# else
typedef std::string GLTFString;
# endif
#elif defined(LIBGLTF_PLATFORM_LINUX) || defined(LIBGLTF_PLATFORM_MACOS) || defined(PLATFORM_ANDROID) || defined(PLATFORM_IOS)
typedef std::string GLTFString;
#else
#error Sorry, not support your platform.
typedef std::string GLTFString;
#endif

struct SGlTF;
Expand All @@ -38,6 +32,49 @@ namespace libgltf
std::shared_ptr<struct SExtension> extensions;
};

/*!
* struct: SGlTFChildofRootProperty
*/
struct SGlTFChildofRootProperty : SGlTFProperty
{
SGlTFChildofRootProperty();

// Check valid
operator bool() const;

// The user-defined name of this object.
GLTFString name;
};

/*!
* struct: SMaterial
* The material appearance of a primitive.
*/
struct SMaterial : SGlTFChildofRootProperty
{
SMaterial();

// Check valid
operator bool() const;

// The alpha cutoff value of the material.
float alphaCutoff;
// The emissive map texture.
std::shared_ptr<struct STextureInfo> emissiveTexture;
// 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.
std::shared_ptr<struct SMaterialPBRMetallicRoughness> pbrMetallicRoughness;
// The occlusion map texture.
std::shared_ptr<struct SMaterialOcclusionTextureInfo> occlusionTexture;
// The alpha rendering mode of the material.
GLTFString alphaMode;
// Specifies whether the material is double sided.
bool doubleSided;
// The normal map texture.
std::shared_ptr<struct SMaterialNormalTextureInfo> normalTexture;
// The emissive color of the material.
std::vector<float> emissiveFactor;
};

/*!
* struct: SAsset
* Metadata about the glTF asset.
Expand All @@ -59,20 +96,6 @@ namespace libgltf
GLTFString copyright;
};

/*!
* struct: SGlTFChildofRootProperty
*/
struct SGlTFChildofRootProperty : SGlTFProperty
{
SGlTFChildofRootProperty();

// Check valid
operator bool() const;

// The user-defined name of this object.
GLTFString name;
};

/*!
* struct: SSampler
* Texture sampler properties for filtering and wrapping modes.
Expand Down Expand Up @@ -114,32 +137,16 @@ namespace libgltf
};

/*!
* struct: SMaterial
* The material appearance of a primitive.
* struct: SExtras
* Application-specific data.
*/
struct SMaterial : SGlTFChildofRootProperty
struct SExtras
{
SMaterial();
SExtras();

// Check valid
operator bool() const;

// The alpha cutoff value of the material.
float alphaCutoff;
// The emissive map texture.
std::shared_ptr<struct STextureInfo> emissiveTexture;
// 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.
std::shared_ptr<struct SMaterialPBRMetallicRoughness> pbrMetallicRoughness;
// The occlusion map texture.
std::shared_ptr<struct SMaterialOcclusionTextureInfo> occlusionTexture;
// The alpha rendering mode of the material.
GLTFString alphaMode;
// Specifies whether the material is double sided.
bool doubleSided;
// The normal map texture.
std::shared_ptr<struct SMaterialNormalTextureInfo> normalTexture;
// The emissive color of the material.
std::vector<float> emissiveFactor;
};

/*!
Expand Down Expand Up @@ -281,16 +288,20 @@ namespace libgltf
};

/*!
* struct: SExtras
* Application-specific data.
* struct: SMesh
* A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene.
*/
struct SExtras
struct SMesh : SGlTFChildofRootProperty
{
SExtras();
SMesh();

// Check valid
operator bool() const;

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

/*!
Expand Down Expand Up @@ -528,23 +539,6 @@ namespace libgltf
GLTFString uri;
};

/*!
* struct: SMesh
* A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene.
*/
struct SMesh : SGlTFChildofRootProperty
{
SMesh();

// Check valid
operator bool() const;

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

/*!
* struct: STexture
* A texture and its sampler.
Expand Down
72 changes: 36 additions & 36 deletions source/libgltf/libgltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,50 @@ namespace libgltf
return true;
}

SAsset::SAsset()
SGlTFChildofRootProperty::SGlTFChildofRootProperty()
: SGlTFProperty()
, minVersion(GLTFTEXT(""))
, version(GLTFTEXT(""))
, generator(GLTFTEXT(""))
, copyright(GLTFTEXT(""))
, name(GLTFTEXT(""))
{
//
}

SAsset::operator bool() const
SGlTFChildofRootProperty::operator bool() const
{
//TODO:
return true;
}

SGlTFChildofRootProperty::SGlTFChildofRootProperty()
SMaterial::SMaterial()
: SGlTFChildofRootProperty()
, alphaCutoff(0.500000f)
, emissiveTexture(nullptr)
, pbrMetallicRoughness(nullptr)
, occlusionTexture(nullptr)
, alphaMode(GLTFTEXT("OPAQUE"))
, doubleSided(false)
, normalTexture(nullptr)
, emissiveFactor({ 0.000000f, 0.000000f, 0.000000f })
{
//
}

SMaterial::operator bool() const
{
//TODO:
return true;
}

SAsset::SAsset()
: SGlTFProperty()
, name(GLTFTEXT(""))
, minVersion(GLTFTEXT(""))
, version(GLTFTEXT(""))
, generator(GLTFTEXT(""))
, copyright(GLTFTEXT(""))
{
//
}

SGlTFChildofRootProperty::operator bool() const
SAsset::operator bool() const
{
//TODO:
return true;
Expand Down Expand Up @@ -76,21 +96,12 @@ namespace libgltf
return true;
}

SMaterial::SMaterial()
: SGlTFChildofRootProperty()
, alphaCutoff(0.500000f)
, emissiveTexture(nullptr)
, pbrMetallicRoughness(nullptr)
, occlusionTexture(nullptr)
, alphaMode(GLTFTEXT("OPAQUE"))
, doubleSided(false)
, normalTexture(nullptr)
, emissiveFactor({ 0.000000f, 0.000000f, 0.000000f })
SExtras::SExtras()
{
//
}

SMaterial::operator bool() const
SExtras::operator bool() const
{
//TODO:
return true;
Expand Down Expand Up @@ -210,12 +221,15 @@ namespace libgltf
return true;
}

SExtras::SExtras()
SMesh::SMesh()
: SGlTFChildofRootProperty()
, primitives()
, weights()
{
//
}

SExtras::operator bool() const
SMesh::operator bool() const
{
//TODO:
return true;
Expand Down Expand Up @@ -407,20 +421,6 @@ namespace libgltf
return true;
}

SMesh::SMesh()
: SGlTFChildofRootProperty()
, primitives()
, weights()
{
//
}

SMesh::operator bool() const
{
//TODO:
return true;
}

STexture::STexture()
: SGlTFChildofRootProperty()
, source(nullptr)
Expand Down
Loading

0 comments on commit f30e0ba

Please sign in to comment.