X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Freflection-demo%2Fgltf-scene.h;h=e1b4e307c7da59786827d573dad517973bbce234;hb=0d99f20446b7c9a0ea9d4c47ffe776338953ea06;hp=faecea8d45983a0239bf484184ed5f72c86f9cc1;hpb=94b12f95897032fe73182ed01e1061f7f7f36aad;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/reflection-demo/gltf-scene.h b/examples/reflection-demo/gltf-scene.h index faecea8..e1b4e30 100644 --- a/examples/reflection-demo/gltf-scene.h +++ b/examples/reflection-demo/gltf-scene.h @@ -1,5 +1,8 @@ +#ifndef GLTF_SCENE_H +#define GLTF_SCENE_H + /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,21 +18,22 @@ * */ -#ifndef GLTF_SCENE_H -#define GLTF_SCENE_H - +// EXTERNAL INCLUDES #include - #include -#include "pico-json.h" +// INTERNAL INCLUDES +#include "third-party/pico-json.h" -#define GLTF_LOG(...) {DALI_LOG_ERROR( __VA_ARGS__ );} +#define GLTF_LOG(...) \ + { \ + Dali::Integration::Log::LogMessage(Dali::Integration::Log::INFO, __VA_ARGS__); \ + } enum class glTFAttributeType { - POSITION = 0, - NORMAL = 1, + POSITION = 0, + NORMAL = 1, TEXCOORD_0 = 2, UNDEFINED, }; @@ -56,19 +60,19 @@ struct glTF_BufferView struct glTF_Accessor { - uint32_t bufferView; - uint32_t componentType; - uint32_t count; - uint32_t componentSize; + uint32_t bufferView; + uint32_t componentType; + uint32_t count; + uint32_t componentSize; std::string type; }; struct glTF_Mesh { - std::string name; + std::string name; std::vector> attributes; - uint32_t indices; - uint32_t material; + uint32_t indices; + uint32_t material; }; struct glTF_Texture @@ -79,11 +83,11 @@ struct glTF_Texture struct glTF_Material { - bool doubleSided; + bool doubleSided; std::string name; struct pbrMetallicRoughness { - bool enabled {false}; + bool enabled{false}; struct baseTextureColor { uint32_t index; @@ -94,17 +98,17 @@ struct glTF_Material struct glTF_Node { - uint32_t index{0u}; - std::string name{}; - uint32_t meshId { 0xffffffff }; - uint32_t cameraId{ 0xffffffff }; - glTF_Node* parent { nullptr }; - std::vector children {}; + uint32_t index{0u}; + std::string name{}; + uint32_t meshId{0xffffffff}; + uint32_t cameraId{0xffffffff}; + glTF_Node* parent{nullptr}; + std::vector children{}; // Transform - float rotationQuaternion[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; - float translation[3] = { 0.0f, 0.0f, 0.0f }; - float scale[3] = { 1.0f, 1.0f, 1.0f }; + float rotationQuaternion[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + float translation[3] = {0.0f, 0.0f, 0.0f}; + float scale[3] = {1.0f, 1.0f, 1.0f}; }; using glTF_Buffer = std::vector; @@ -116,8 +120,7 @@ using glTF_Buffer = std::vector; */ struct glTF { - - glTF( const std::string& filename ); + glTF(const std::string& filename); ~glTF() = default; std::vector GetMeshes() const; @@ -140,39 +143,37 @@ struct glTF * Returns a copy of attribute buffer * @return */ - std::vector GetMeshAttributeBuffer( const glTF_Mesh& mesh, const std::vector& attrTypes ); - uint32_t GetMeshAttributeCount( const glTF_Mesh* mesh ) const; - const glTF_Mesh* FindMeshByName( const std::string& name ) const; + std::vector GetMeshAttributeBuffer(const glTF_Mesh& mesh, const std::vector& attrTypes); + uint32_t GetMeshAttributeCount(const glTF_Mesh* mesh) const; + const glTF_Mesh* FindMeshByName(const std::string& name) const; /** * Returns a copy of index buffer * @return */ - std::vector GetMeshIndexBuffer( const glTF_Mesh* mesh ) const; + std::vector GetMeshIndexBuffer(const glTF_Mesh* mesh) const; - const glTF_Node* FindNodeByName( const std::string& name ) const; + const glTF_Node* FindNodeByName(const std::string& name) const; private: + void LoadFromFile(const std::string& filename); - void LoadFromFile( const std::string& filename ); - - glTF_Buffer LoadFile( const std::string& filename ); + glTF_Buffer LoadFile(const std::string& filename); bool ParseJSON(); - std::vector mMeshes; - std::vector mCameras; - std::vector mBufferViews; - std::vector mAccessors; - std::vector mNodes; - std::vector mMaterials; - std::vector mTextures; - glTF_Buffer mBuffer; - glTF_Buffer jsonBuffer; + std::vector mMeshes; + std::vector mCameras; + std::vector mBufferViews; + std::vector mAccessors; + std::vector mNodes; + std::vector mMaterials; + std::vector mTextures; + glTF_Buffer mBuffer; + glTF_Buffer jsonBuffer; // json nodes picojson::value jsonNode; }; - #endif //DALI_CMAKE_GLTF_SCENE_H