mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-06-06 08:42:35 +00:00
GLTF loader now has support for the punctual lights extension
This commit is contained in:
@@ -18,6 +18,74 @@ namespace gltf
|
|||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonAsset, version, generator);
|
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonAsset, version, generator);
|
||||||
|
|
||||||
|
class JsonPunctualSpotLightProperties
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::optional<float> innerConeAngle;
|
||||||
|
std::optional<float> outerConeAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonPunctualSpotLightProperties, innerConeAngle, outerConeAngle);
|
||||||
|
|
||||||
|
enum class JsonPunctualLightType
|
||||||
|
{
|
||||||
|
DIRECTIONAL,
|
||||||
|
POINT,
|
||||||
|
SPOT
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_JSON_SERIALIZE_ENUM(JsonPunctualLightType,
|
||||||
|
{
|
||||||
|
{JsonPunctualLightType::DIRECTIONAL, "directional"},
|
||||||
|
{JsonPunctualLightType::POINT, "point" },
|
||||||
|
{JsonPunctualLightType::SPOT, "spot" },
|
||||||
|
});
|
||||||
|
|
||||||
|
class JsonPunctualLight
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::optional<std::array<float, 3>> color;
|
||||||
|
std::optional<float> intensity;
|
||||||
|
std::optional<std::string> name;
|
||||||
|
std::optional<float> range;
|
||||||
|
std::optional<JsonPunctualSpotLightProperties> spot;
|
||||||
|
JsonPunctualLightType type;
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonPunctualLight, color, intensity, name, range, spot, type);
|
||||||
|
|
||||||
|
class JsonPunctualLightsExt
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::optional<std::vector<JsonPunctualLight>> lights;
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonPunctualLightsExt, lights);
|
||||||
|
|
||||||
|
class JsonExtension
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::optional<JsonPunctualLightsExt> KHR_lights_punctual;
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonExtension, KHR_lights_punctual);
|
||||||
|
|
||||||
|
class JsonPunctualLightIndex
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int light;
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonPunctualLightIndex, light);
|
||||||
|
|
||||||
|
class JsonNodeExt
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::optional<JsonPunctualLightIndex> KHR_lights_punctual;
|
||||||
|
};
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonNodeExt, KHR_lights_punctual);
|
||||||
|
|
||||||
class JsonNode
|
class JsonNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -29,9 +97,11 @@ namespace gltf
|
|||||||
std::optional<std::vector<unsigned>> children;
|
std::optional<std::vector<unsigned>> children;
|
||||||
std::optional<unsigned> skin;
|
std::optional<unsigned> skin;
|
||||||
std::optional<unsigned> mesh;
|
std::optional<unsigned> mesh;
|
||||||
|
|
||||||
|
std::optional<JsonNodeExt> extensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonNode, name, translation, rotation, scale, matrix, children, skin, mesh);
|
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonNode, name, translation, rotation, scale, matrix, children, skin, mesh, extensions);
|
||||||
|
|
||||||
class JsonBuffer
|
class JsonBuffer
|
||||||
{
|
{
|
||||||
@@ -326,6 +396,7 @@ namespace gltf
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
JsonAsset asset;
|
JsonAsset asset;
|
||||||
|
std::optional<JsonExtension> extensions;
|
||||||
std::optional<unsigned> scene;
|
std::optional<unsigned> scene;
|
||||||
std::optional<std::vector<JsonScene>> scenes;
|
std::optional<std::vector<JsonScene>> scenes;
|
||||||
std::optional<std::vector<JsonNode>> nodes;
|
std::optional<std::vector<JsonNode>> nodes;
|
||||||
@@ -341,5 +412,5 @@ namespace gltf
|
|||||||
};
|
};
|
||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_EXTENSION(
|
NLOHMANN_DEFINE_TYPE_EXTENSION(
|
||||||
JsonRoot, asset, scene, scenes, nodes, animations, materials, meshes, textures, images, skins, accessors, bufferViews, buffers);
|
JsonRoot, asset, extensions, scene, scenes, nodes, animations, materials, meshes, textures, images, skins, accessors, bufferViews, buffers);
|
||||||
} // namespace gltf
|
} // namespace gltf
|
||||||
|
|||||||
Reference in New Issue
Block a user