Commit f5a4ccec7fbd222bce0455384b043fbf04a0ed5c
Committed by
Gerrit Code Review
Merge "Use ShaderDefinitionFactory to ShaderManager" into devel/master
Showing
3 changed files
with
34 additions
and
49 deletions
examples/scene3d-light/scene3d-light-example.cpp
| @@ -15,11 +15,10 @@ | @@ -15,11 +15,10 @@ | ||
| 15 | * | 15 | * |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | +#include <dali-scene3d/dali-scene3d.h> | ||
| 19 | +#include <dali-scene3d/public-api/light/light.h> | ||
| 18 | #include <dali-toolkit/dali-toolkit.h> | 20 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | -#include <dali-scene3d/public-api/controls/scene-view/scene-view.h> | ||
| 20 | -#include <dali-scene3d/public-api/controls/model/model.h> | ||
| 21 | #include <dali/devel-api/actors/actor-devel.h> | 21 | #include <dali/devel-api/actors/actor-devel.h> |
| 22 | -#include <dali-scene3d/public-api/light/light.h> | ||
| 23 | 22 | ||
| 24 | #include <dali/integration-api/debug.h> | 23 | #include <dali/integration-api/debug.h> |
| 25 | 24 | ||
| @@ -152,7 +151,7 @@ public: | @@ -152,7 +151,7 @@ public: | ||
| 152 | sceneView.SetImageBasedLightSource("", "", 1.0f); | 151 | sceneView.SetImageBasedLightSource("", "", 1.0f); |
| 153 | light1.Enable(true); | 152 | light1.Enable(true); |
| 154 | light2.Enable(true); | 153 | light2.Enable(true); |
| 155 | - light6.Enable(false); // to reset state of lights | 154 | + light6.Enable(false); // to reset state of lights |
| 156 | light6.Enable(true); | 155 | light6.Enable(true); |
| 157 | light3.Enable(true); | 156 | light3.Enable(true); |
| 158 | } | 157 | } |
| @@ -194,19 +193,19 @@ public: | @@ -194,19 +193,19 @@ public: | ||
| 194 | } | 193 | } |
| 195 | 194 | ||
| 196 | private: | 195 | private: |
| 197 | - Application& mApplication; | ||
| 198 | - Scene3D::Light light1; | ||
| 199 | - Scene3D::Light light2; | ||
| 200 | - Scene3D::Light light3; | ||
| 201 | - Scene3D::Light light4; | ||
| 202 | - Scene3D::Light light5; | ||
| 203 | - Scene3D::Light light6; | 196 | + Application& mApplication; |
| 197 | + Scene3D::Light light1; | ||
| 198 | + Scene3D::Light light2; | ||
| 199 | + Scene3D::Light light3; | ||
| 200 | + Scene3D::Light light4; | ||
| 201 | + Scene3D::Light light5; | ||
| 202 | + Scene3D::Light light6; | ||
| 204 | Scene3D::SceneView sceneView; | 203 | Scene3D::SceneView sceneView; |
| 205 | }; | 204 | }; |
| 206 | 205 | ||
| 207 | int DALI_EXPORT_API main(int argc, char** argv) | 206 | int DALI_EXPORT_API main(int argc, char** argv) |
| 208 | { | 207 | { |
| 209 | - Application application = Application::New(&argc, &argv); | 208 | + Application application = Application::New(&argc, &argv); |
| 210 | Scene3dLightController test(application); | 209 | Scene3dLightController test(application); |
| 211 | application.MainLoop(); | 210 | application.MainLoop(); |
| 212 | return 0; | 211 | return 0; |
examples/scene3d/scene3d-example.cpp
| @@ -15,23 +15,10 @@ | @@ -15,23 +15,10 @@ | ||
| 15 | * | 15 | * |
| 16 | */ | 16 | */ |
| 17 | #include "scene3d-example.h" | 17 | #include "scene3d-example.h" |
| 18 | -#include <dali-toolkit/dali-toolkit.h> | ||
| 19 | #include <dirent.h> | 18 | #include <dirent.h> |
| 20 | #include <cstring> | 19 | #include <cstring> |
| 20 | +#include <filesystem> | ||
| 21 | #include <string_view> | 21 | #include <string_view> |
| 22 | -#include "dali-scene3d/public-api/loader/model-loader.h" | ||
| 23 | -#include "dali-scene3d/public-api/loader/light-parameters.h" | ||
| 24 | -#include "dali-scene3d/public-api/loader/load-result.h" | ||
| 25 | -#include "dali-scene3d/public-api/loader/shader-definition-factory.h" | ||
| 26 | -#include "dali-toolkit/public-api/controls/scrollable/item-view/default-item-layout.h" | ||
| 27 | -#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h" | ||
| 28 | -#include "dali-toolkit/public-api/controls/text-controls/text-label.h" | ||
| 29 | -#include "dali-toolkit/public-api/visuals/gradient-visual-properties.h" | ||
| 30 | -#include "dali/public-api/actors/layer.h" | ||
| 31 | -#include "dali/public-api/adaptor-framework/key.h" | ||
| 32 | -#include "dali/public-api/events/key-event.h" | ||
| 33 | -#include "dali/public-api/object/property-array.h" | ||
| 34 | -#include "dali/public-api/render-tasks/render-task-list.h" | ||
| 35 | #include "scene3d-extension.h" | 22 | #include "scene3d-extension.h" |
| 36 | 23 | ||
| 37 | using namespace Dali; | 24 | using namespace Dali; |
| @@ -59,7 +46,8 @@ const std::string RESOURCE_TYPE_DIRS[]{ | @@ -59,7 +46,8 @@ const std::string RESOURCE_TYPE_DIRS[]{ | ||
| 59 | using StringVector = std::vector<std::string>; | 46 | using StringVector = std::vector<std::string>; |
| 60 | 47 | ||
| 61 | StringVector ListFiles( | 48 | StringVector ListFiles( |
| 62 | - const std::string& path, bool (*predicate)(const char*) = [](const char*) { return true; }) | 49 | + const std::string& path, bool (*predicate)(const char*) = [](const char*) |
| 50 | + { return true; }) | ||
| 63 | { | 51 | { |
| 64 | StringVector results; | 52 | StringVector results; |
| 65 | 53 | ||
| @@ -127,7 +115,8 @@ Actor CreateErrorMessage(std::string msg) | @@ -127,7 +115,8 @@ Actor CreateErrorMessage(std::string msg) | ||
| 127 | void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition& scene, Actor root, std::vector<BlendshapeShaderConfigurationRequest>&& requests) | 115 | void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition& scene, Actor root, std::vector<BlendshapeShaderConfigurationRequest>&& requests) |
| 128 | { | 116 | { |
| 129 | std::vector<std::string> errors; | 117 | std::vector<std::string> errors; |
| 130 | - auto onError = [&errors](const std::string& msg) { | 118 | + auto onError = [&errors](const std::string& msg) |
| 119 | + { | ||
| 131 | errors.push_back(msg); | 120 | errors.push_back(msg); |
| 132 | }; | 121 | }; |
| 133 | if(!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError)) | 122 | if(!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError)) |
| @@ -142,7 +131,8 @@ void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition | @@ -142,7 +131,8 @@ void ConfigureBlendShapeShaders(ResourceBundle& resources, const SceneDefinition | ||
| 142 | 131 | ||
| 143 | Actor LoadScene(std::string sceneName, CameraActor camera, std::vector<Dali::Animation>& generatedAnimations, Animation& animation) | 132 | Actor LoadScene(std::string sceneName, CameraActor camera, std::vector<Dali::Animation>& generatedAnimations, Animation& animation) |
| 144 | { | 133 | { |
| 145 | - ResourceBundle::PathProvider pathProvider = [](ResourceType::Value type) { | 134 | + ResourceBundle::PathProvider pathProvider = [](ResourceType::Value type) |
| 135 | + { | ||
| 146 | return Application::GetResourcePath() + RESOURCE_TYPE_DIRS[type]; | 136 | return Application::GetResourcePath() + RESOURCE_TYPE_DIRS[type]; |
| 147 | }; | 137 | }; |
| 148 | 138 | ||
| @@ -178,13 +168,19 @@ Actor LoadScene(std::string sceneName, CameraActor camera, std::vector<Dali::Ani | @@ -178,13 +168,19 @@ Actor LoadScene(std::string sceneName, CameraActor camera, std::vector<Dali::Ani | ||
| 178 | cameraParameters[0].ConfigureCamera(camera); | 168 | cameraParameters[0].ConfigureCamera(camera); |
| 179 | SetActorCentered(camera); | 169 | SetActorCentered(camera); |
| 180 | 170 | ||
| 181 | - ViewProjection viewProjection = cameraParameters[0].GetViewProjection(); | ||
| 182 | - Transforms xforms{ | 171 | + std::filesystem::path modelPath(path); |
| 172 | + std::string extension = modelPath.extension(); | ||
| 173 | + std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower); | ||
| 174 | + | ||
| 175 | + Scene3D::Loader::ShaderManagerPtr shaderManager = (extension == GLTF_EXTENSION) ? new Scene3D::Loader::ShaderManager() : nullptr; | ||
| 176 | + ViewProjection viewProjection = cameraParameters[0].GetViewProjection(); | ||
| 177 | + Transforms xforms{ | ||
| 183 | MatrixStack{}, | 178 | MatrixStack{}, |
| 184 | viewProjection}; | 179 | viewProjection}; |
| 185 | NodeDefinition::CreateParams nodeParams{ | 180 | NodeDefinition::CreateParams nodeParams{ |
| 186 | resources, | 181 | resources, |
| 187 | xforms, | 182 | xforms, |
| 183 | + shaderManager, | ||
| 188 | {}, | 184 | {}, |
| 189 | {}, | 185 | {}, |
| 190 | {}}; | 186 | {}}; |
| @@ -267,11 +263,11 @@ void Scene3DExample::OnInit(Application& app) | @@ -267,11 +263,11 @@ void Scene3DExample::OnInit(Application& app) | ||
| 267 | // get scenes | 263 | // get scenes |
| 268 | auto resPath = Application::GetResourcePath(); | 264 | auto resPath = Application::GetResourcePath(); |
| 269 | auto scenePath = resPath + RESOURCE_TYPE_DIRS[ResourceType::Mesh]; | 265 | auto scenePath = resPath + RESOURCE_TYPE_DIRS[ResourceType::Mesh]; |
| 270 | - auto sceneNames = ListFiles(scenePath, [](const char* name) { | 266 | + auto sceneNames = ListFiles(scenePath, [](const char* name) |
| 267 | + { | ||
| 271 | auto len = strlen(name); | 268 | auto len = strlen(name); |
| 272 | return (len > DLI_EXTENSION.size() && DLI_EXTENSION.compare(name + (len - DLI_EXTENSION.size())) == 0) || | 269 | return (len > DLI_EXTENSION.size() && DLI_EXTENSION.compare(name + (len - DLI_EXTENSION.size())) == 0) || |
| 273 | - (len > GLTF_EXTENSION.size() && GLTF_EXTENSION.compare(name + (len - GLTF_EXTENSION.size())) == 0); | ||
| 274 | - }); | 270 | + (len > GLTF_EXTENSION.size() && GLTF_EXTENSION.compare(name + (len - GLTF_EXTENSION.size())) == 0); }); |
| 275 | mSceneNames = sceneNames; | 271 | mSceneNames = sceneNames; |
| 276 | 272 | ||
| 277 | // create Dali objects | 273 | // create Dali objects |
examples/scene3d/scene3d-example.h
| @@ -17,21 +17,11 @@ | @@ -17,21 +17,11 @@ | ||
| 17 | * | 17 | * |
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | +#include <dali-scene3d/dali-scene3d.h> | ||
| 21 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 22 | +#include <dali-toolkit/devel-api/controls/navigation-view/navigation-view.h> | ||
| 23 | +#include <dali/dali.h> | ||
| 20 | #include <memory> | 24 | #include <memory> |
| 21 | -#include "dali-scene3d/public-api/loader/animation-definition.h" | ||
| 22 | -#include "dali-scene3d/public-api/loader/camera-parameters.h" | ||
| 23 | -#include "dali-scene3d/public-api/loader/node-definition.h" | ||
| 24 | -#include "dali-scene3d/public-api/loader/scene-definition.h" | ||
| 25 | -#include "dali-toolkit/devel-api/controls/navigation-view/navigation-view.h" | ||
| 26 | -#include "dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h" | ||
| 27 | -#include "dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h" | ||
| 28 | -#include "dali-toolkit/public-api/controls/scrollable/item-view/item-view.h" | ||
| 29 | -#include "dali/public-api/actors/camera-actor.h" | ||
| 30 | -#include "dali/public-api/adaptor-framework/application.h" | ||
| 31 | -#include "dali/public-api/common/vector-wrapper.h" | ||
| 32 | -#include "dali/public-api/events/pan-gesture-detector.h" | ||
| 33 | -#include "dali/public-api/render-tasks/render-task.h" | ||
| 34 | -#include "dali/public-api/signals/connection-tracker.h" | ||
| 35 | 25 | ||
| 36 | class Scene3DExtension; | 26 | class Scene3DExtension; |
| 37 | 27 | ||
| @@ -83,4 +73,4 @@ private: // methods | @@ -83,4 +73,4 @@ private: // methods | ||
| 83 | void OnKeyboardFocusChanged(Dali::Actor originalFocusedActor, Dali::Actor currentFocusedActor); | 73 | void OnKeyboardFocusChanged(Dali::Actor originalFocusedActor, Dali::Actor currentFocusedActor); |
| 84 | }; | 74 | }; |
| 85 | 75 | ||
| 86 | -#endif //SCENE_LAUNCHER_H_ | 76 | +#endif // SCENE_LAUNCHER_H_ |