1 #ifndef DALI_TOOLKIT_INTERNAL_MODEL3D_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_MODEL3D_VIEW_H
5 * Copyright (c) 2021 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/rendering/renderer.h>
25 #include <dali-toolkit/internal/controls/model3d-view/obj-loader.h>
26 #include <dali-toolkit/public-api/controls/control-impl.h>
27 #include <dali-toolkit/public-api/controls/model3d-view/model3d-view.h>
38 * @brief Impl class for Model3dView.
40 * All the geometry loaded with the control is automatically centered and scaled to fit
41 * the size of all the other controls. So the max is (0.5,0.5) and the min is (-0.5,-0.5)
43 class Model3dView : public Control
47 * @brief Create a new Model3dView.
49 * @return A public handle to the newly allocated Model3dView.
51 static Toolkit::Model3dView New();
56 * @brief Called when a property of an object of this type is set.
58 * @param[in] object The object whose property is set.
59 * @param[in] index The property index.
60 * @param[in] value The new property value.
62 static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
65 * @brief Called to retrieve a property of an object of this type.
67 * @param[in] object The object whose property is to be retrieved.
68 * @param[in] index The property index.
69 * @return The current value of the property.
71 static Property::Value GetProperty(BaseObject* object, Property::Index index);
74 * @copydoc Control::OnRelayout
76 void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
79 * @brief Called to load both geometry (.obj) and material (.mtl) files
86 * @brief Construct a new Model3dView.
91 * A reference counted object may only be deleted by calling Unreference()
93 virtual ~Model3dView();
97 * @copydoc Toolkit::Control::OnInitialize()
99 void OnInitialize() override;
102 * @copydoc CustomActorImpl::OnSceneConnection()
104 void OnSceneConnection(int depth) override;
108 * @brief Load geometry (.obj) from file
113 * @brief Load material (.mtl) from file
118 * @brief Create Geometry class from the loaded geometry
120 void CreateGeometry();
123 * @brief Create Material and Shader classes from the loaded material
125 void CreateMaterial();
128 * @brief Load samplers and add them to Material
133 * @brief Set matrix to shader to orientate geometry
138 * @brief Update shader uniforms
140 void UpdateShaderUniforms();
143 * @brief Given a specific shader type, find out which properties are necessary for it.
145 * @param[in] illuminationType The type of shader we intend to use.
146 * @return A bitmask of the properties we require to be loaded to use the given shader.
148 int GetShaderProperties(Toolkit::Model3dView::IlluminationType illuminationType);
150 ObjLoader mObjLoader;
154 std::string mTextureSetUrl;
155 std::string mImagesUrl;
156 std::string mTexture0Url;
157 std::string mTexture1Url;
158 std::string mTexture2Url;
159 Vector3 mLightPosition;
161 Toolkit::Model3dView::IlluminationType mIlluminationType;
164 Vector2 mControlSize;
165 Vector3 mSceneCenter;
170 TextureSet mTextureSet;
175 } // namespace Internal
177 // Helpers for public-api forwarding methods
178 inline Toolkit::Internal::Model3dView& GetImpl(Toolkit::Model3dView& obj)
180 DALI_ASSERT_ALWAYS(obj);
181 Dali::RefObject& handle = obj.GetImplementation();
182 return static_cast<Toolkit::Internal::Model3dView&>(handle);
185 inline const Toolkit::Internal::Model3dView& GetImpl(const Toolkit::Model3dView& obj)
187 DALI_ASSERT_ALWAYS(obj);
188 const Dali::RefObject& handle = obj.GetImplementation();
189 return static_cast<const Toolkit::Internal::Model3dView&>(handle);
192 } // namespace Toolkit
196 #endif // DALI_TOOLKIT_INTERNAL_MODEL_VIEW_H