1 #ifndef DALI_SCENE_LOADER_INTERNAL_MODEL_VIEW_H
2 #define DALI_SCENE_LOADER_INTERNAL_MODEL_VIEW_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/actors/layer.h>
23 #include <dali/public-api/animation/animation.h>
24 #include <dali/public-api/rendering/texture.h>
25 #include <dali-toolkit/public-api/controls/control-impl.h>
28 #include <dali-scene-loader/public-api/controls/model-view/model-view.h>
39 * @brief Impl class for ModelView.
41 class ModelView : public Dali::Toolkit::Internal::Control
44 using AnimationData = std::pair<std::string, Dali::Animation>;
47 * @brief Creates a new ModelView.
49 * @return A public handle to the newly allocated ModelView.
51 static Dali::Scene3D::ModelView New(const std::string& modelPath, const std::string& resourcePath);
54 * @copydoc ModelView::GetModelRoot()
56 const Actor GetModelRoot();
59 * @copydoc ModelView::FitModel()
61 void FitSize(bool fit);
64 * @copydoc ModelView::FitCenter()
66 void FitCenter(bool fit);
69 * @copydoc ModelView::SetImageBasedLightSource()
71 void SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor);
74 * @copydoc ModelView::GetAnimationCount()
76 uint32_t GetAnimationCount();
79 * @copydoc ModelView::GetAnimation()
81 Dali::Animation GetAnimation(uint32_t index);
84 * @copydoc ModelView::GetAnimation()
86 Dali::Animation GetAnimation(const std::string& name);
90 * @brief Constructs a new ModelView.
92 ModelView(const std::string& modelPath, const std::string& resourcePath);
95 * A reference counted object may only be deleted by calling Unreference()
101 * @copydoc CustomActorImpl::OnSceneConnection()
103 void OnSceneConnection(int depth) override;
106 * @copydoc Toolkit::Control::OnInitialize()
108 void OnInitialize() override;
111 * @copydoc Toolkit::Control::GetNaturalSize
113 Vector3 GetNaturalSize() override;
116 * @copydoc Toolkit::Control::GetHeightForWidth()
118 float GetHeightForWidth(float width) override;
121 * @copydoc Toolkit::Control::GetWidthForHeight()
123 float GetWidthForHeight(float height) override;
126 * @copydoc Toolkit::Control::OnRelayout()
128 void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
131 * @brief Loads a model from file
136 * @brief Scales the model to fit the control or to return to original size.
141 * @brief Changes model anchor point to set the model at center or returns to the original model pivot.
143 void FitModelPosition();
146 * @brief Changes IBL information of the input node.
148 void SetImageBasedLight(Actor node);
151 std::string mModelPath;
152 std::string mResourcePath;
153 Dali::Layer mModelLayer;
154 Dali::Actor mModelRoot;
155 std::vector<AnimationData> mAnimations;
157 Dali::Texture mSpecularTexture;
158 Dali::Texture mDiffuseTexture;
159 Vector3 mNaturalSize;
161 float mIblScaleFactor;
166 } // namespace Internal
168 // Helpers for public-api forwarding methods
169 inline Dali::Scene3D::Internal::ModelView& GetImpl(Dali::Scene3D::ModelView& obj)
171 DALI_ASSERT_ALWAYS(obj);
172 Dali::RefObject& handle = obj.GetImplementation();
173 return static_cast<Dali::Scene3D::Internal::ModelView&>(handle);
176 inline const Dali::Scene3D::Internal::ModelView& GetImpl(const Dali::Scene3D::ModelView& obj)
178 DALI_ASSERT_ALWAYS(obj);
179 const Dali::RefObject& handle = obj.GetImplementation();
180 return static_cast<const Dali::Scene3D::Internal::ModelView&>(handle);
183 } // namespace Toolkit
187 #endif // DALI_SCENE_LOADER_INTERNAL_MODEL_VIEW_H