X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-scene3d%2Finternal%2Fcontrols%2Fmodel%2Fmodel-impl.h;h=d7924bfbbeb846b43a7e49e9312400e2dee52957;hb=c1236a21a2ddc2da56cb8d54b4ab7e7b1b6c2b50;hp=3db9c57c31bab6c10f9c939655714f211d7dfa97;hpb=cccb28e5edc58d4ebf98a4e91be09ac55064dd2d;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-scene3d/internal/controls/model/model-impl.h b/dali-scene3d/internal/controls/model/model-impl.h index 3db9c57..d7924bf 100644 --- a/dali-scene3d/internal/controls/model/model-impl.h +++ b/dali-scene3d/internal/controls/model/model-impl.h @@ -2,7 +2,7 @@ #define DALI_SCENE3D_INTERNAL_MODEL_H /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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,14 +20,21 @@ // EXTERNAL INCLUDES #include +#include #include #include +#include #include #include // INTERNAL INCLUDES +#include +#include +#include #include #include +#include +#include namespace Dali { @@ -40,22 +47,31 @@ namespace Internal /** * @brief Impl class for Model. */ -class Model : public Dali::Toolkit::Internal::Control +class Model : public Dali::Toolkit::Internal::Control, public ImageBasedLightObserver { public: using AnimationData = std::pair; + using CameraData = Loader::CameraParameters; /** - * @brief Creates a new Model. - * - * @return A public handle to the newly allocated Model. + * @copydoc Model::New() */ static Dali::Scene3D::Model New(const std::string& modelUrl, const std::string& resourceDirectoryUrl); /** * @copydoc Model::GetModelRoot() */ - const Actor GetModelRoot() const; + const Scene3D::ModelNode GetModelRoot() const; + + /** + * @copydoc Model::AddModelNode() + */ + void AddModelNode(Scene3D::ModelNode modelNode); + + /** + * @copydoc Model::RemoveModelNode() + */ + void RemoveModelNode(Scene3D::ModelNode modelNode); /** * @copydoc Model::SetChildrenSensitive() @@ -68,14 +84,19 @@ public: bool GetChildrenSensitive() const; /** - * @copydoc Model::SetImageBasedLightSource() + * @copydoc Model::SetChildrenFocusable() */ - void SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor); + void SetChildrenFocusable(bool enable); /** - * @copydoc Model::SetImageBasedLightTexture() + * @copydoc Model::GetChildrenFocusable() */ - void SetImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor); + bool GetChildrenFocusable() const; + + /** + * @copydoc Model::SetImageBasedLightSource() + */ + void SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor); /** * @copydoc Model::SetImageBasedLightScaleFactor() @@ -102,9 +123,31 @@ public: */ Dali::Animation GetAnimation(const std::string& name) const; + /** + * @copydoc Model::GetCameraCount() + */ + uint32_t GetCameraCount() const; + + /** + * @copydoc Model::GenerateCamera() + */ + Dali::CameraActor GenerateCamera(uint32_t index) const; + + /** + * @copydoc Model::ApplyCamera() + */ + bool ApplyCamera(uint32_t index, Dali::CameraActor camera) const; + + /** + * @copydoc Model::FindChildModelNodeByName() + */ + Scene3D::ModelNode FindChildModelNodeByName(std::string_view nodeName); + protected: /** * @brief Constructs a new Model. + * @param[in] modelUrl model file path.(e.g., glTF, and DLI). + * @param[in] resourceDirectoryUrl resource file path that includes binary, image etc. */ Model(const std::string& modelUrl, const std::string& resourceDirectoryUrl); @@ -115,6 +158,11 @@ protected: private: /** + * @copydoc Toolkit::Control::OnInitialize + */ + void OnInitialize(); + + /** * @copydoc CustomActorImpl::OnSceneConnection() */ void OnSceneConnection(int depth) override; @@ -125,6 +173,11 @@ private: void OnSceneDisconnection() override; /** + * @copydoc CustomActorImpl::OnSizeSet( const Vector3& size ) + */ + void OnSizeSet(const Vector3& size) override; + + /** * @copydoc Toolkit::Control::GetNaturalSize */ Vector3 GetNaturalSize() override; @@ -149,15 +202,16 @@ private: */ bool IsResourceReady() const override; +private: /** - * @brief Loads a model from file + * @brief Create Model Root of this Model class. */ - void LoadModel(); + void CreateModelRoot(); /** * @brief Scales the model to fit the control or to return to original size. */ - void ScaleModel(); + void ScaleModel(bool useCurrentSize); /** * @brief Changes model anchor point to set the model at center or returns to the original model pivot. @@ -167,7 +221,12 @@ private: /** * @brief Changes IBL information of the input node. */ - void CollectRenderableActor(Actor actor); + void UpdateImageBasedLightTextureRecursively(Scene3D::ModelNode node, Dali::Texture diffuseTexture, Dali::Texture specularTexture, float iblScaleFactor, uint32_t specularMipmapLevels); + + /** + * @brief Changes IBL factor of the input node. + */ + void UpdateImageBasedLightScaleFactorRecursively(Scene3D::ModelNode node, float iblScaleFactor); /** * @brief Changes IBL textures of the input node. @@ -179,22 +238,118 @@ private: */ void UpdateImageBasedLightScaleFactor(); + /** + * @brief Apply self transform into inputed camera. + * Inputed camera must be configured by CameraParameter. Mean, inputed camera coordinate depend on Model. + * After this API finished, CameraActor coordinate system converted as DALi coordinate system. + * + * @param[in,out] camera CameraActor who need to apply model itself's transform + */ + void ApplyCameraTransform(Dali::CameraActor camera) const; + +public: // Overrides ImageBasedLightObserver Methods. + /** + * @copydoc Dali::Scene3D::Internal::ImageBasedLightObserver::NotifyImageBasedLightTexture() + */ + void NotifyImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor, uint32_t specularMipmapLevels) override; + + /** + * @copydoc Dali::Scene3D::Internal::ImageBasedLightObserver::NotifyImageBasedLightScaleFactor() + */ + void NotifyImageBasedLightScaleFactor(float scaleFactor) override; + +private: + /** + * @brief Asynchronously model loading finished. + */ + void OnModelLoadComplete(); + + /** + * @brief Asynchronously ibl diffusel image loading finished. + */ + void OnIblDiffuseLoadComplete(); + + /** + * @brief Asynchronously ibl specular image loading finished. + */ + void OnIblSpecularLoadComplete(); + + /** + * @brief Asynchronously ibl loading finished. + */ + void OnIblLoadComplete(); + + /** + * @brief Update model root scale when Model size property is updated. + */ + void OnSizeNotification(Dali::PropertyNotification& source); + + /** + * @brief Reset Resource loading tasks. + */ + void ResetResourceTasks(); + + /** + * @brief Reset a Resource loading task. + */ + void ResetResourceTask(IntrusivePtr asyncTask); + + /** + * @brief Notify Resource Ready signal. + */ + void NotifyResourceReady(); + + /** + * @brief Create Model from loaded SceneDefinition. + */ + void CreateModel(); + + /** + * @brief Create Dali::Animation from loaded AnimationDefinitions. + */ + void CreateAnimations(Dali::Scene3D::Loader::SceneDefinition& scene); + + /** + * @brief Reset CameraData from loaded CameraParameters. + */ + void ResetCameraParameters(); + private: std::string mModelUrl; std::string mResourceDirectoryUrl; - Dali::Actor mModelRoot; + Scene3D::ModelNode mModelRoot; std::vector mAnimations; - std::vector> mRenderableActors; + std::vector mCameraParameters; WeakHandle mParentSceneView; + Dali::PropertyNotification mSizeNotification; + + // Asynchronous loading variable + ModelLoadTaskPtr mModelLoadTask; + EnvironmentMapLoadTaskPtr mIblDiffuseLoadTask; + EnvironmentMapLoadTaskPtr mIblSpecularLoadTask; + + std::string mDiffuseIblUrl; + std::string mSpecularIblUrl; + Dali::Texture mDefaultSpecularTexture; + Dali::Texture mDefaultDiffuseTexture; + Dali::Texture mSceneSpecularTexture; + Dali::Texture mSceneDiffuseTexture; Dali::Texture mSpecularTexture; Dali::Texture mDiffuseTexture; Vector3 mNaturalSize; Vector3 mModelPivot; + float mSceneIblScaleFactor; float mIblScaleFactor; + uint32_t mSceneSpecularMipmapLevels; + uint32_t mSpecularMipmapLevels; bool mModelChildrenSensitive; + bool mModelChildrenFocusable; bool mModelResourceReady; - bool mIBLResourceReady; + bool mIblDiffuseResourceReady; + bool mIblSpecularResourceReady; + bool mIblDiffuseDirty; + bool mIblSpecularDirty; }; } // namespace Internal