[Tizen] Use ShaderDefinitionFactory to ShaderManager 10/296910/3 accepted/tizen/7.0/unified/20230825.185059
authorseungho baek <sbsh.baek@samsung.com>
Thu, 29 Jun 2023 09:08:30 +0000 (18:08 +0900)
committerseungho baek <sbsh.baek@samsung.com>
Wed, 23 Aug 2023 04:52:27 +0000 (13:52 +0900)
Change-Id: I41979b1877067c85f64444e84bb3ee731305f8fa
Signed-off-by: seungho baek <sbsh.baek@samsung.com>
examples/scene3d-light/scene3d-light-example.cpp
examples/scene3d/scene3d-example.cpp
examples/scene3d/scene3d-example.h

index e38d146..4be4720 100644 (file)
  *
  */
 
+#include <dali-scene3d/dali-scene3d.h>
+#include <dali-scene3d/public-api/light/light.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
-#include <dali-scene3d/public-api/controls/model/model.h>
 #include <dali/devel-api/actors/actor-devel.h>
-#include <dali-scene3d/public-api/light/light.h>
 
 #include <dali/integration-api/debug.h>
 
@@ -152,7 +151,7 @@ public:
         sceneView.SetImageBasedLightSource("", "", 1.0f);
         light1.Enable(true);
         light2.Enable(true);
-        light6.Enable(false);  // to reset state of lights
+        light6.Enable(false); // to reset state of lights
         light6.Enable(true);
         light3.Enable(true);
       }
@@ -194,19 +193,19 @@ public:
   }
 
 private:
-  Application& mApplication;
-  Scene3D::Light light1;
-  Scene3D::Light light2;
-  Scene3D::Light light3;
-  Scene3D::Light light4;
-  Scene3D::Light light5;
-  Scene3D::Light light6;
+  Application&       mApplication;
+  Scene3D::Light     light1;
+  Scene3D::Light     light2;
+  Scene3D::Light     light3;
+  Scene3D::Light     light4;
+  Scene3D::Light     light5;
+  Scene3D::Light     light6;
   Scene3D::SceneView sceneView;
 };
 
 int DALI_EXPORT_API main(int argc, char** argv)
 {
-  Application          application = Application::New(&argc, &argv);
+  Application            application = Application::New(&argc, &argv);
   Scene3dLightController test(application);
   application.MainLoop();
   return 0;
index a1639aa..7323bb1 100644 (file)
  *\r
  */\r
 #include "scene3d-example.h"\r
-#include <dali-toolkit/dali-toolkit.h>\r
 #include <dirent.h>\r
 #include <cstring>\r
+#include <filesystem>\r
 #include <string_view>\r
-#include "dali-scene3d/public-api/loader/model-loader.h"\r
-#include "dali-scene3d/public-api/loader/light-parameters.h"\r
-#include "dali-scene3d/public-api/loader/load-result.h"\r
-#include "dali-scene3d/public-api/loader/shader-definition-factory.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/default-item-layout.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h"\r
-#include "dali-toolkit/public-api/controls/text-controls/text-label.h"\r
-#include "dali-toolkit/public-api/visuals/gradient-visual-properties.h"\r
-#include "dali/public-api/actors/layer.h"\r
-#include "dali/public-api/adaptor-framework/key.h"\r
-#include "dali/public-api/events/key-event.h"\r
-#include "dali/public-api/object/property-array.h"\r
-#include "dali/public-api/render-tasks/render-task-list.h"\r
 #include "scene3d-extension.h"\r
 \r
 using namespace Dali;\r
@@ -59,7 +46,8 @@ const std::string RESOURCE_TYPE_DIRS[]{
 using StringVector = std::vector<std::string>;\r
 \r
 StringVector ListFiles(\r
-  const std::string& path, bool (*predicate)(const char*) = [](const char*) { return true; })\r
+  const std::string& path, bool (*predicate)(const char*) = [](const char*)\r
+                           { return true; })\r
 {\r
   StringVector results;\r
 \r
@@ -127,7 +115,8 @@ Actor CreateErrorMessage(std::string msg)
 void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition& scene, Actor root, std::vector<BlendshapeShaderConfigurationRequest>&& requests)\r
 {\r
   std::vector<std::string> errors;\r
-  auto                     onError = [&errors](const std::string& msg) {\r
+  auto                     onError = [&errors](const std::string& msg)\r
+  {\r
     errors.push_back(msg);\r
   };\r
   if(!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError))\r
@@ -142,7 +131,8 @@ void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition
 \r
 Actor LoadScene(std::string sceneName, CameraActor camera, std::vector<Dali::Animation>& generatedAnimations, Animation& animation)\r
 {\r
-  ResourceBundle::PathProvider pathProvider = [](ResourceType::Value type) {\r
+  ResourceBundle::PathProvider pathProvider = [](ResourceType::Value type)\r
+  {\r
     return Application::GetResourcePath() + RESOURCE_TYPE_DIRS[type];\r
   };\r
 \r
@@ -178,13 +168,19 @@ Actor LoadScene(std::string sceneName, CameraActor camera, std::vector<Dali::Ani
   cameraParameters[0].ConfigureCamera(camera);\r
   SetActorCentered(camera);\r
 \r
-  ViewProjection viewProjection = cameraParameters[0].GetViewProjection();\r
-  Transforms     xforms{\r
+  std::filesystem::path modelPath(path);\r
+  std::string           extension = modelPath.extension();\r
+  std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);\r
+\r
+  Scene3D::Loader::ShaderManagerPtr shaderManager  = (extension == GLTF_EXTENSION) ? new Scene3D::Loader::ShaderManager() : nullptr;\r
+  ViewProjection                    viewProjection = cameraParameters[0].GetViewProjection();\r
+  Transforms                        xforms{\r
     MatrixStack{},\r
     viewProjection};\r
   NodeDefinition::CreateParams nodeParams{\r
     resources,\r
     xforms,\r
+    shaderManager,\r
     {},\r
     {},\r
     {}};\r
@@ -267,11 +263,11 @@ void Scene3DExample::OnInit(Application& app)
   // get scenes\r
   auto resPath    = Application::GetResourcePath();\r
   auto scenePath  = resPath + RESOURCE_TYPE_DIRS[ResourceType::Mesh];\r
-  auto sceneNames = ListFiles(scenePath, [](const char* name) {\r
+  auto sceneNames = ListFiles(scenePath, [](const char* name)\r
+                              {\r
     auto len = strlen(name);\r
     return (len > DLI_EXTENSION.size() && DLI_EXTENSION.compare(name + (len - DLI_EXTENSION.size())) == 0) ||\r
-           (len > GLTF_EXTENSION.size() && GLTF_EXTENSION.compare(name + (len - GLTF_EXTENSION.size())) == 0);\r
-  });\r
+           (len > GLTF_EXTENSION.size() && GLTF_EXTENSION.compare(name + (len - GLTF_EXTENSION.size())) == 0); });\r
   mSceneNames     = sceneNames;\r
 \r
   // create Dali objects\r
index 3f56eba..0139104 100644 (file)
  *\r
  */\r
 \r
+#include <dali-scene3d/dali-scene3d.h>\r
+#include <dali-toolkit/dali-toolkit.h>\r
+#include <dali-toolkit/devel-api/controls/navigation-view/navigation-view.h>\r
+#include <dali/dali.h>\r
 #include <memory>\r
-#include "dali-scene3d/public-api/loader/animation-definition.h"\r
-#include "dali-scene3d/public-api/loader/camera-parameters.h"\r
-#include "dali-scene3d/public-api/loader/node-definition.h"\r
-#include "dali-scene3d/public-api/loader/scene-definition.h"\r
-#include "dali-toolkit/devel-api/controls/navigation-view/navigation-view.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h"\r
-#include "dali-toolkit/public-api/controls/scrollable/item-view/item-view.h"\r
-#include "dali/public-api/actors/camera-actor.h"\r
-#include "dali/public-api/adaptor-framework/application.h"\r
-#include "dali/public-api/common/vector-wrapper.h"\r
-#include "dali/public-api/events/pan-gesture-detector.h"\r
-#include "dali/public-api/render-tasks/render-task.h"\r
-#include "dali/public-api/signals/connection-tracker.h"\r
 \r
 class Scene3DExtension;\r
 \r
@@ -83,4 +73,4 @@ private: // methods
   void        OnKeyboardFocusChanged(Dali::Actor originalFocusedActor, Dali::Actor currentFocusedActor);\r
 };\r
 \r
-#endif //SCENE_LAUNCHER_H_\r
+#endif // SCENE_LAUNCHER_H_\r