X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscene3d-view%2Fgltf-loader.h;h=967292920915b8b785c95b0589e1f3dbc6f1cfe7;hp=42ee4dd75c0c290a550fd7852e3537771f5a1d95;hb=e7fe800178ddd41877c18c3dea629f321d7dee19;hpb=77f26df9824d174eda53dce2fc5440faddcf9f9b diff --git a/dali-toolkit/internal/controls/scene3d-view/gltf-loader.h b/dali-toolkit/internal/controls/scene3d-view/gltf-loader.h index 42ee4dd..9672929 100644 --- a/dali-toolkit/internal/controls/scene3d-view/gltf-loader.h +++ b/dali-toolkit/internal/controls/scene3d-view/gltf-loader.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_GLTF_LOADER_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -20,9 +20,10 @@ // EXTERNAL INCLUDES #include +#include +#include #include #include -#include // INTERNAL INCLUDES #include @@ -32,16 +33,12 @@ using namespace Dali; namespace Dali { - namespace Toolkit { - namespace Internal { - namespace Gltf { - enum ShaderType { NO_TEXTURE_SHADER, @@ -114,9 +111,9 @@ enum ShaderType struct BufferInfo { BufferInfo() - : byteLength( -1 ), - uri( "" ), - name( "" ) + : byteLength(-1), + uri(""), + name("") { } @@ -124,7 +121,7 @@ struct BufferInfo { } - int32_t byteLength; + int32_t byteLength; std::string uri; std::string name; }; @@ -132,12 +129,12 @@ struct BufferInfo struct BufferViewInfo { BufferViewInfo() - : buffer( -1 ), - byteOffset( 0 ), - byteLength( 0 ), - byteStride( 0 ), - target( 0 ), - name( "" ) + : buffer(-1), + byteOffset(0), + byteLength(0), + byteStride(0), + target(0), + name("") { } @@ -145,19 +142,19 @@ struct BufferViewInfo { } - int32_t buffer; - int32_t byteOffset; - int32_t byteLength; - int32_t byteStride; - int32_t target; + int32_t buffer; + int32_t byteOffset; + int32_t byteLength; + int32_t byteStride; + int32_t target; std::string name; }; struct TextureInfo { TextureInfo() - : sourceIdx( -1 ), - samplerIdx( -1 ) + : sourceIdx(-1), + samplerIdx(-1) { } @@ -171,9 +168,9 @@ struct TextureInfo struct PbrTextureInfo { PbrTextureInfo() - : index( -1 ), - texCoord( 0 ), - value( 0.0 ) + : index(-1), + texCoord(0), + value(0.0) { } ~PbrTextureInfo() @@ -182,20 +179,20 @@ struct PbrTextureInfo int32_t index; int32_t texCoord; - float value; + float value; }; struct MaterialInfo { MaterialInfo() - : baseColorFactor( 1, 1, 1, 1 ), - metallicFactor( 1.0 ), - roughnessFactor( 1.0 ), - emissiveFactor( 0.0, 0.0, 0.0 ), - alphaMode( "OPAQUE" ), - alphaCutoff( 0.5 ), - doubleSided( false ), - name( "" ) + : baseColorFactor(1, 1, 1, 1), + metallicFactor(1.0), + roughnessFactor(1.0), + emissiveFactor(0.0, 0.0, 0.0), + alphaMode("OPAQUE"), + alphaCutoff(0.5), + doubleSided(false), + name("") { } @@ -203,13 +200,13 @@ struct MaterialInfo { } - Vector4 baseColorFactor; - float metallicFactor; - float roughnessFactor; - Vector3 emissiveFactor; + Vector4 baseColorFactor; + float metallicFactor; + float roughnessFactor; + Vector3 emissiveFactor; std::string alphaMode; - float alphaCutoff; - bool doubleSided; + float alphaCutoff; + bool doubleSided; PbrTextureInfo baseColorTexture; PbrTextureInfo metallicRoughnessTexture; @@ -224,15 +221,15 @@ struct MaterialInfo struct AccessorInfo { AccessorInfo() - : bufferView( -1 ), - byteOffset( 0 ), - componentType( -1 ), - normalized( false ), - count( 0 ), - type( "" ), - max( 0 ), - min( 0 ), - name( "" ) + : bufferView(-1), + byteOffset(0), + componentType(-1), + normalized(false), + count(0), + type(""), + max(0), + min(0), + name("") { } @@ -240,14 +237,14 @@ struct AccessorInfo { } - int32_t bufferView; - int32_t byteOffset; - int32_t componentType; - bool normalized; - int32_t count; + int32_t bufferView; + int32_t byteOffset; + int32_t componentType; + bool normalized; + int32_t count; std::string type; - int32_t max; - int32_t min; + int32_t max; + int32_t min; std::string name; //need to add max, min }; @@ -255,9 +252,9 @@ struct AccessorInfo struct Attribute { Attribute() - : POSITION( -1 ), - NORMAL( -1 ), - TANGENT( -1 ) + : POSITION(-1), + NORMAL(-1), + TANGENT(-1) { } @@ -276,16 +273,16 @@ struct Attribute struct MeshInfo { MeshInfo() - : indicesIdx( -1 ), - materialsIdx( -1 ), - mode( 4 ) + : indicesIdx(-1), + materialsIdx(-1), + mode(4) { } ~MeshInfo() { } - Geometry geometry; + Geometry geometry; std::string name; int32_t indicesIdx; @@ -302,9 +299,9 @@ struct MeshInfo struct AnimationChannelInfo { AnimationChannelInfo() - : sampler( -1 ), - targetNode( -1 ), - path( "" ) + : sampler(-1), + targetNode(-1), + path("") { } @@ -312,18 +309,17 @@ struct AnimationChannelInfo { } - int32_t sampler; - int32_t targetNode; + int32_t sampler; + int32_t targetNode; std::string path; - }; struct AnimationSamplerInfo { AnimationSamplerInfo() - : input( -1 ), - output( -1 ), - interpolation( "" ) + : input(-1), + output(-1), + interpolation("") { } @@ -331,15 +327,15 @@ struct AnimationSamplerInfo { } - int32_t input; - int32_t output; + int32_t input; + int32_t output; std::string interpolation; }; struct AnimationInfo { AnimationInfo() - : name( "" ) + : name("") { } @@ -347,7 +343,7 @@ struct AnimationInfo { } - std::string name; + std::string name; std::vector channelArray; std::vector samplerArray; }; @@ -355,10 +351,10 @@ struct AnimationInfo struct OrthographicInfo { OrthographicInfo() - : xmag( 0.0f ), - ymag( 0.0f ), - zfar( 0.0f ), - znear( 0.0f ) + : xmag(0.0f), + ymag(0.0f), + zfar(0.0f), + znear(0.0f) { } @@ -375,10 +371,10 @@ struct OrthographicInfo struct PerspectiveInfo { PerspectiveInfo() - : aspectRatio( 0.0f ), - yfov( 0.0f ), - zfar( 0.0f ), - znear( 0.0f ) + : aspectRatio(0.0f), + yfov(0.0f), + zfar(0.0f), + znear(0.0f) { } @@ -395,8 +391,8 @@ struct PerspectiveInfo struct CameraInfo { CameraInfo() - : name( "" ), - type( "" ) + : name(""), + type("") { } @@ -404,10 +400,10 @@ struct CameraInfo { } - std::string name; - std::string type; + std::string name; + std::string type; OrthographicInfo orthographic; - PerspectiveInfo perspective; + PerspectiveInfo perspective; }; /** @@ -425,7 +421,6 @@ struct CameraInfo class Loader { public: - /** * @brief Create an uninitialized Loader. */ @@ -442,55 +437,55 @@ public: * @param[in] scene3dView Scene3dView data loaded from file. * @return true if scene is successfully loaded */ - bool LoadScene( const std::string& filePath, Internal::Scene3dView& scene3dView ); + bool LoadScene(const std::string& filePath, Internal::Scene3dView& scene3dView); private: - bool ParseGltf( const std::string& filePath ); + bool ParseGltf(const std::string& filePath); bool LoadAssets(); - bool CreateScene( Internal::Scene3dView& scene3dView ); + bool CreateScene(Internal::Scene3dView& scene3dView); - void LoadCamera( Scene3dView& scene3dView ); - bool LoadOrthoGraphic( const TreeNode& camera, CameraInfo& cameraInfo ); - bool LoadPerspective( const TreeNode& camera, CameraInfo& cameraInfo ); + void LoadCamera(Scene3dView& scene3dView); + bool LoadOrthoGraphic(const TreeNode& camera, CameraInfo& cameraInfo); + bool LoadPerspective(const TreeNode& camera, CameraInfo& cameraInfo); - bool LoadSceneNodes( Scene3dView& scene3dView ); - Actor AddNode( Scene3dView& scene3dView, uint32_t index ); - void SetActorCache( Actor& actor, uint32_t index ); - bool SetTextureAndSampler( TextureSet& textureSet, int32_t textureIdx, std::string& toShader, std::string shader, int32_t& addIdx ); + bool LoadSceneNodes(Scene3dView& scene3dView); + Actor AddNode(Scene3dView& scene3dView, uint32_t index); + void SetActorCache(Actor& actor, uint32_t index); + bool SetTextureAndSampler(TextureSet& textureSet, int32_t textureIdx, std::string& toShader, std::string shader, int32_t& addIdx); - bool LoadAnimation( Scene3dView& scene3dView ); - bool LoadAnimationChannels( const TreeNode& animation, AnimationInfo& animationInfo ); - bool LoadAnimationSamplers( const TreeNode& animation, AnimationInfo& animationInfo ); + bool LoadAnimation(Scene3dView& scene3dView); + bool LoadAnimationChannels(const TreeNode& animation, AnimationInfo& animationInfo); + bool LoadAnimationSamplers(const TreeNode& animation, AnimationInfo& animationInfo); private: Dali::Toolkit::JsonParser mParser; - const TreeNode* mNodes; - const TreeNode* mRoot; + const TreeNode* mNodes; + const TreeNode* mRoot; std::string mPath; std::vector mActorCache; - Shader mShaderCache[ShaderType::SHADER_TYPE_MAX + 1]; + Shader mShaderCache[ShaderType::SHADER_TYPE_MAX + 1]; - std::vector mBufferArray; + std::vector mBufferArray; std::vector mBufferViewArray; - std::vector mAccessorArray; + std::vector mAccessorArray; - std::vector mMeshArray; + std::vector mMeshArray; std::vector mMaterialArray; - std::vector mTextureArray; + std::vector mTextureArray; std::vector mSourceArray; std::vector mSamplerArray; }; -}//namespace Gltf +} //namespace Gltf -}//namespace Internal +} //namespace Internal -}//namespace Toolkit +} //namespace Toolkit -}//namespace Dali +} //namespace Dali #endif // DALI_TOOLKIT_INTERNAL_GLTF_LOADER_H