1 #ifndef DALI_TOOLKIT_INTERNAL_MODEL3D_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_MODEL3D_VIEW_H
5 * Copyright (c) 2016 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/public-api/controls/control-impl.h>
26 #include <dali-toolkit/public-api/controls/model3d-view/model3d-view.h>
27 #include <dali-toolkit/internal/controls/model3d-view/obj-loader.h>
40 * @brief Impl class for Model3dView.
42 * All the geometry loaded with the control is automatically centered and scaled to fit
43 * the size of all the other controls. So the max is (0.5,0.5) and the min is (-0.5,-0.5)
45 class Model3dView : public Control
50 * @brief Create a new Model3dView.
52 * @return A public handle to the newly allocated Model3dView.
54 static Toolkit::Model3dView New();
59 * @brief Called when a property of an object of this type is set.
61 * @param[in] object The object whose property is set.
62 * @param[in] index The property index.
63 * @param[in] value The new property value.
65 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
68 * @brief Called to retrieve a property of an object of this type.
70 * @param[in] object The object whose property is to be retrieved.
71 * @param[in] index The property index.
72 * @return The current value of the property.
74 static Property::Value GetProperty( BaseObject* object, Property::Index index );
77 * @copydoc Control::OnRelayout
79 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
82 * @brief Called to load both geometry (.obj) and material (.mtl) files
90 * @brief Construct a new Model3dView.
95 * A reference counted object may only be deleted by calling Unreference()
97 virtual ~Model3dView();
102 * @copydoc Toolkit::Control::OnInitialize()
104 virtual void OnInitialize();
107 * @copydoc CustomActorImpl::OnStageConnection()
109 virtual void OnStageConnection( int depth );
114 * @brief Load geometry (.obj) from file
119 * @brief Load material (.mtl) from file
124 * @brief Create Geometry class from the loaded geometry
126 void CreateGeometry();
129 * @brief Create Material and Shader classes from the loaded material
131 void CreateMaterial();
134 * @brief Load samplers and add them to Material
139 * @brief Set matrix to shader to orientate geometry
144 * @brief Update shader uniforms
146 void UpdateShaderUniforms();
150 * @brief Given a specific shader type, find out which properties are necessary for it.
152 * @param[in] illuminationType The type of shader we intend to use.
153 * @return A bitmask of the properties we require to be loaded to use the given shader.
155 int GetShaderProperties( Toolkit::Model3dView::IlluminationType illuminationType );
158 ObjLoader mObjLoader;
162 std::string mTextureSetUrl;
163 std::string mImagesUrl;
164 std::string mTexture0Url;
165 std::string mTexture1Url;
166 std::string mTexture2Url;
167 Vector3 mLightPosition;
169 Toolkit::Model3dView::IlluminationType mIlluminationType;
172 Vector2 mControlSize;
173 Vector3 mSceneCenter;
178 TextureSet mTextureSet;
183 } // namespace Internal
185 // Helpers for public-api forwarding methods
186 inline Toolkit::Internal::Model3dView& GetImpl( Toolkit::Model3dView& obj )
188 DALI_ASSERT_ALWAYS(obj);
189 Dali::RefObject& handle = obj.GetImplementation();
190 return static_cast<Toolkit::Internal::Model3dView&>(handle);
193 inline const Toolkit::Internal::Model3dView& GetImpl( const Toolkit::Model3dView& obj )
195 DALI_ASSERT_ALWAYS(obj);
196 const Dali::RefObject& handle = obj.GetImplementation();
197 return static_cast<const Toolkit::Internal::Model3dView&>(handle);
200 } // namespace Toolkit
204 #endif // DALI_TOOLKIT_INTERNAL_MODEL_VIEW_H