Remove std::vector dependency for dali-signal.h
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scene3d-view / gltf-loader.h
index 42ee4dd..9672929 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_GLTF_LOADER_H\r
 \r
 /*\r
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
 \r
 // EXTERNAL INCLUDES\r
 #include <dali/public-api/actors/layer.h>\r
+#include <dali/public-api/animation/animation.h>\r
+#include <dali/public-api/common/vector-wrapper.h>\r
 #include <dali/public-api/rendering/renderer.h>\r
 #include <dali/public-api/rendering/shader.h>\r
-#include <dali/public-api/animation/animation.h>\r
 \r
 // INTERNAL INCLUDES\r
 #include <dali-toolkit/devel-api/builder/json-parser.h>\r
@@ -32,16 +33,12 @@ using namespace Dali;
 \r
 namespace Dali\r
 {\r
-\r
 namespace Toolkit\r
 {\r
-\r
 namespace Internal\r
 {\r
-\r
 namespace Gltf\r
 {\r
-\r
 enum ShaderType\r
 {\r
   NO_TEXTURE_SHADER,\r
@@ -114,9 +111,9 @@ enum ShaderType
 struct BufferInfo\r
 {\r
   BufferInfo()\r
-    : byteLength( -1 ),\r
-    uri( "" ),\r
-    name( "" )\r
+  : byteLength(-1),\r
+    uri(""),\r
+    name("")\r
   {\r
   }\r
 \r
@@ -124,7 +121,7 @@ struct BufferInfo
   {\r
   }\r
 \r
-  int32_t byteLength;\r
+  int32_t     byteLength;\r
   std::string uri;\r
   std::string name;\r
 };\r
@@ -132,12 +129,12 @@ struct BufferInfo
 struct BufferViewInfo\r
 {\r
   BufferViewInfo()\r
-    : buffer( -1 ),\r
-    byteOffset( 0 ),\r
-    byteLength( 0 ),\r
-    byteStride( 0 ),\r
-    target( 0 ),\r
-    name( "" )\r
+  : buffer(-1),\r
+    byteOffset(0),\r
+    byteLength(0),\r
+    byteStride(0),\r
+    target(0),\r
+    name("")\r
   {\r
   }\r
 \r
@@ -145,19 +142,19 @@ struct BufferViewInfo
   {\r
   }\r
 \r
-  int32_t buffer;\r
-  int32_t byteOffset;\r
-  int32_t byteLength;\r
-  int32_t byteStride;\r
-  int32_t target;\r
+  int32_t     buffer;\r
+  int32_t     byteOffset;\r
+  int32_t     byteLength;\r
+  int32_t     byteStride;\r
+  int32_t     target;\r
   std::string name;\r
 };\r
 \r
 struct TextureInfo\r
 {\r
   TextureInfo()\r
-    : sourceIdx( -1 ),\r
-    samplerIdx( -1 )\r
+  : sourceIdx(-1),\r
+    samplerIdx(-1)\r
   {\r
   }\r
 \r
@@ -171,9 +168,9 @@ struct TextureInfo
 struct PbrTextureInfo\r
 {\r
   PbrTextureInfo()\r
-    : index( -1 ),\r
-    texCoord( 0 ),\r
-    value( 0.0 )\r
+  : index(-1),\r
+    texCoord(0),\r
+    value(0.0)\r
   {\r
   }\r
   ~PbrTextureInfo()\r
@@ -182,20 +179,20 @@ struct PbrTextureInfo
 \r
   int32_t index;\r
   int32_t texCoord;\r
-  float value;\r
+  float   value;\r
 };\r
 \r
 struct MaterialInfo\r
 {\r
   MaterialInfo()\r
-    : baseColorFactor( 1, 1, 1, 1 ),\r
-    metallicFactor( 1.0 ),\r
-    roughnessFactor( 1.0 ),\r
-    emissiveFactor( 0.0, 0.0, 0.0 ),\r
-    alphaMode( "OPAQUE" ),\r
-    alphaCutoff( 0.5 ),\r
-    doubleSided( false ),\r
-    name( "" )\r
+  : baseColorFactor(1, 1, 1, 1),\r
+    metallicFactor(1.0),\r
+    roughnessFactor(1.0),\r
+    emissiveFactor(0.0, 0.0, 0.0),\r
+    alphaMode("OPAQUE"),\r
+    alphaCutoff(0.5),\r
+    doubleSided(false),\r
+    name("")\r
   {\r
   }\r
 \r
@@ -203,13 +200,13 @@ struct MaterialInfo
   {\r
   }\r
 \r
-  Vector4 baseColorFactor;\r
-  float metallicFactor;\r
-  float roughnessFactor;\r
-  Vector3 emissiveFactor;\r
+  Vector4     baseColorFactor;\r
+  float       metallicFactor;\r
+  float       roughnessFactor;\r
+  Vector3     emissiveFactor;\r
   std::string alphaMode;\r
-  float alphaCutoff;\r
-  bool doubleSided;\r
+  float       alphaCutoff;\r
+  bool        doubleSided;\r
 \r
   PbrTextureInfo baseColorTexture;\r
   PbrTextureInfo metallicRoughnessTexture;\r
@@ -224,15 +221,15 @@ struct MaterialInfo
 struct AccessorInfo\r
 {\r
   AccessorInfo()\r
-    : bufferView( -1 ),\r
-    byteOffset( 0 ),\r
-    componentType( -1 ),\r
-    normalized( false ),\r
-    count( 0 ),\r
-    type( "" ),\r
-    max( 0 ),\r
-    min( 0 ),\r
-    name( "" )\r
+  : bufferView(-1),\r
+    byteOffset(0),\r
+    componentType(-1),\r
+    normalized(false),\r
+    count(0),\r
+    type(""),\r
+    max(0),\r
+    min(0),\r
+    name("")\r
   {\r
   }\r
 \r
@@ -240,14 +237,14 @@ struct AccessorInfo
   {\r
   }\r
 \r
-  int32_t bufferView;\r
-  int32_t byteOffset;\r
-  int32_t componentType;\r
-  bool normalized;\r
-  int32_t count;\r
+  int32_t     bufferView;\r
+  int32_t     byteOffset;\r
+  int32_t     componentType;\r
+  bool        normalized;\r
+  int32_t     count;\r
   std::string type;\r
-  int32_t max;\r
-  int32_t min;\r
+  int32_t     max;\r
+  int32_t     min;\r
   std::string name;\r
   //need to add max, min\r
 };\r
@@ -255,9 +252,9 @@ struct AccessorInfo
 struct Attribute\r
 {\r
   Attribute()\r
-    : POSITION( -1 ),\r
-    NORMAL( -1 ),\r
-    TANGENT( -1 )\r
+  : POSITION(-1),\r
+    NORMAL(-1),\r
+    TANGENT(-1)\r
   {\r
   }\r
 \r
@@ -276,16 +273,16 @@ struct Attribute
 struct MeshInfo\r
 {\r
   MeshInfo()\r
-    : indicesIdx( -1 ),\r
-    materialsIdx( -1 ),\r
-    mode( 4 )\r
+  : indicesIdx(-1),\r
+    materialsIdx(-1),\r
+    mode(4)\r
   {\r
   }\r
 \r
   ~MeshInfo()\r
   {\r
   }\r
-  Geometry geometry;\r
+  Geometry    geometry;\r
   std::string name;\r
 \r
   int32_t indicesIdx;\r
@@ -302,9 +299,9 @@ struct MeshInfo
 struct AnimationChannelInfo\r
 {\r
   AnimationChannelInfo()\r
-    : sampler( -1 ),\r
-    targetNode( -1 ),\r
-    path( "" )\r
+  : sampler(-1),\r
+    targetNode(-1),\r
+    path("")\r
   {\r
   }\r
 \r
@@ -312,18 +309,17 @@ struct AnimationChannelInfo
   {\r
   }\r
 \r
-  int32_t sampler;\r
-  int32_t targetNode;\r
+  int32_t     sampler;\r
+  int32_t     targetNode;\r
   std::string path;\r
-\r
 };\r
 \r
 struct AnimationSamplerInfo\r
 {\r
   AnimationSamplerInfo()\r
-    : input( -1 ),\r
-    output( -1 ),\r
-    interpolation( "" )\r
+  : input(-1),\r
+    output(-1),\r
+    interpolation("")\r
   {\r
   }\r
 \r
@@ -331,15 +327,15 @@ struct AnimationSamplerInfo
   {\r
   }\r
 \r
-  int32_t input;\r
-  int32_t output;\r
+  int32_t     input;\r
+  int32_t     output;\r
   std::string interpolation;\r
 };\r
 \r
 struct AnimationInfo\r
 {\r
   AnimationInfo()\r
-    : name( "" )\r
+  : name("")\r
   {\r
   }\r
 \r
@@ -347,7 +343,7 @@ struct AnimationInfo
   {\r
   }\r
 \r
-  std::string name;\r
+  std::string                       name;\r
   std::vector<AnimationChannelInfo> channelArray;\r
   std::vector<AnimationSamplerInfo> samplerArray;\r
 };\r
@@ -355,10 +351,10 @@ struct AnimationInfo
 struct OrthographicInfo\r
 {\r
   OrthographicInfo()\r
-    : xmag( 0.0f ),\r
-    ymag( 0.0f ),\r
-    zfar( 0.0f ),\r
-    znear( 0.0f )\r
+  : xmag(0.0f),\r
+    ymag(0.0f),\r
+    zfar(0.0f),\r
+    znear(0.0f)\r
   {\r
   }\r
 \r
@@ -375,10 +371,10 @@ struct OrthographicInfo
 struct PerspectiveInfo\r
 {\r
   PerspectiveInfo()\r
-    : aspectRatio( 0.0f ),\r
-    yfov( 0.0f ),\r
-    zfar( 0.0f ),\r
-    znear( 0.0f )\r
+  : aspectRatio(0.0f),\r
+    yfov(0.0f),\r
+    zfar(0.0f),\r
+    znear(0.0f)\r
   {\r
   }\r
 \r
@@ -395,8 +391,8 @@ struct PerspectiveInfo
 struct CameraInfo\r
 {\r
   CameraInfo()\r
-    : name( "" ),\r
-    type( "" )\r
+  : name(""),\r
+    type("")\r
   {\r
   }\r
 \r
@@ -404,10 +400,10 @@ struct CameraInfo
   {\r
   }\r
 \r
-  std::string name;\r
-  std::string type;\r
+  std::string      name;\r
+  std::string      type;\r
   OrthographicInfo orthographic;\r
-  PerspectiveInfo perspective;\r
+  PerspectiveInfo  perspective;\r
 };\r
 \r
 /**\r
@@ -425,7 +421,6 @@ struct CameraInfo
 class Loader\r
 {\r
 public:\r
-\r
   /**\r
    * @brief Create an uninitialized Loader.\r
    */\r
@@ -442,55 +437,55 @@ public:
    * @param[in] scene3dView Scene3dView data loaded from file.\r
    * @return true if scene is successfully loaded\r
    */\r
-  bool LoadScene( const std::string& filePath, Internal::Scene3dView& scene3dView );\r
+  bool LoadScene(const std::string& filePath, Internal::Scene3dView& scene3dView);\r
 \r
 private:\r
-  bool ParseGltf( const std::string& filePath );\r
+  bool ParseGltf(const std::string& filePath);\r
   bool LoadAssets();\r
 \r
-  bool CreateScene( Internal::Scene3dView& scene3dView );\r
+  bool CreateScene(Internal::Scene3dView& scene3dView);\r
 \r
-  void LoadCamera( Scene3dView& scene3dView );\r
-  bool LoadOrthoGraphic( const TreeNode& camera, CameraInfo& cameraInfo );\r
-  bool LoadPerspective( const TreeNode& camera, CameraInfo& cameraInfo );\r
+  void LoadCamera(Scene3dView& scene3dView);\r
+  bool LoadOrthoGraphic(const TreeNode& camera, CameraInfo& cameraInfo);\r
+  bool LoadPerspective(const TreeNode& camera, CameraInfo& cameraInfo);\r
 \r
-  bool LoadSceneNodes( Scene3dView& scene3dView );\r
-  Actor AddNode( Scene3dView& scene3dView, uint32_t index );\r
-  void SetActorCache( Actor& actor, uint32_t index );\r
-  bool SetTextureAndSampler( TextureSet& textureSet, int32_t textureIdx, std::string& toShader, std::string shader, int32_t& addIdx );\r
+  bool  LoadSceneNodes(Scene3dView& scene3dView);\r
+  Actor AddNode(Scene3dView& scene3dView, uint32_t index);\r
+  void  SetActorCache(Actor& actor, uint32_t index);\r
+  bool  SetTextureAndSampler(TextureSet& textureSet, int32_t textureIdx, std::string& toShader, std::string shader, int32_t& addIdx);\r
 \r
-  bool LoadAnimation( Scene3dView& scene3dView );\r
-  bool LoadAnimationChannels( const TreeNode& animation, AnimationInfo& animationInfo );\r
-  bool LoadAnimationSamplers( const TreeNode& animation, AnimationInfo& animationInfo );\r
+  bool LoadAnimation(Scene3dView& scene3dView);\r
+  bool LoadAnimationChannels(const TreeNode& animation, AnimationInfo& animationInfo);\r
+  bool LoadAnimationSamplers(const TreeNode& animation, AnimationInfo& animationInfo);\r
 \r
 private:\r
   Dali::Toolkit::JsonParser mParser;\r
-  const TreeNode* mNodes;\r
-  const TreeNode* mRoot;\r
+  const TreeNode*           mNodes;\r
+  const TreeNode*           mRoot;\r
 \r
   std::string mPath;\r
 \r
   std::vector<Actor> mActorCache;\r
-  Shader mShaderCache[ShaderType::SHADER_TYPE_MAX + 1];\r
+  Shader             mShaderCache[ShaderType::SHADER_TYPE_MAX + 1];\r
 \r
-  std::vector<BufferInfo> mBufferArray;\r
+  std::vector<BufferInfo>     mBufferArray;\r
   std::vector<BufferViewInfo> mBufferViewArray;\r
-  std::vector<AccessorInfo> mAccessorArray;\r
+  std::vector<AccessorInfo>   mAccessorArray;\r
 \r
-  std::vector<MeshInfo> mMeshArray;\r
+  std::vector<MeshInfo>     mMeshArray;\r
   std::vector<MaterialInfo> mMaterialArray;\r
-  std::vector<TextureInfo> mTextureArray;\r
+  std::vector<TextureInfo>  mTextureArray;\r
 \r
   std::vector<Texture> mSourceArray;\r
   std::vector<Sampler> mSamplerArray;\r
 };\r
 \r
-}//namespace Gltf\r
+} //namespace Gltf\r
 \r
-}//namespace Internal\r
+} //namespace Internal\r
 \r
-}//namespace Toolkit\r
+} //namespace Toolkit\r
 \r
-}//namespace Dali\r
+} //namespace Dali\r
 \r
 #endif // DALI_TOOLKIT_INTERNAL_GLTF_LOADER_H\r