1 #ifndef __DALI_TOOLKIT_INTERNAL_MESH_RENDERER_H__
2 #define __DALI_TOOLKIT_INTERNAL_MESH_RENDERER_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.
26 #include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
27 #include <dali-toolkit/internal/controls/model3d-view/obj-loader.h>
39 * The renderer which renders a 3D object to the control's quad
41 * The following Property::Map keys are required to create a MeshRender
43 * | %Property Name | Type | Representing |
44 * |-----------------|-------------|-----------------------------------------------------------------------|
45 * | objectUrl | STRING | A URL to the .obj file |
46 * | materialUrl | STRING | A URL to the .mtl file |
47 * | texturesPath | STRING | A URL of the path to the texture images |
48 * | shaderType | STRING | An enum of shader types |
49 * | useMipmapping | BOOLEAN | If true, use mipmaps for textures. Default true. |
50 * | useSoftNormals | BOOLEAN | If true, average normals at points for smooth textures. Default true. |
52 class MeshRenderer: public ControlRenderer
59 * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
61 MeshRenderer( RendererFactoryCache& factoryCache );
64 * @brief A reference counted object may only be deleted by calling Unreference().
66 virtual ~MeshRenderer();
68 public: // from ControlRenderer
71 * @copydoc ControlRenderer::SetSize
73 virtual void SetSize( const Vector2& size );
76 * @copydoc ControlRenderer::SetClipRect
78 virtual void SetClipRect( const Rect<int>& clipRect );
81 * @copydoc ControlRenderer::SetOffset
83 virtual void SetOffset( const Vector2& offset );
86 * @copydoc ControlRenderer::CreatePropertyMap
88 virtual void DoCreatePropertyMap( Property::Map& map ) const;
93 * @copydoc ControlRenderer::DoInitialize
95 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
98 * @copydoc ControlRenderer::DoSetOnStage
100 virtual void DoSetOnStage( Actor& actor );
105 * Declare whether a texture map should be used for the object, if it's present. Defaults to true.
106 * @param[in] useTexture boolean declaration.
108 void SetUseTexture( bool useTexture );
111 * Declare whether a normal map should be used for the object, if it's present. Defaults to true.
112 * @param[in] useNormalMap boolean declaration.
114 void SetUseNormalMap( bool useNormalMap );
118 //Corresponds to the shader that will be used by the mesh renderer.
127 * @brief Provide an empty geometry for the renderer to use.
128 * @details For use in error cases where the initialisation has failed for varying reasons.
130 void SupplyEmptyGeometry();
133 * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
135 void InitializeRenderer();
138 * @brief Create a shader for the object to use.
143 * @brief Update shader related info, uniforms, etc. for the new shader.
145 void UpdateShaderUniforms();
148 * @brief Use the object URL stored in the renderer to load and create the geometry of the object.
149 * @return Boolean of success of operation.
151 bool CreateGeometry();
154 * @brief Use the object URL stored in the renderer to load the geometry of the object.
155 * @return Boolean of success of operation.
160 * @brief Use the material URL stored in the renderer to load the material of the object.
161 * @return Boolean of success of operation.
166 * @brief Use the image and texture URL components to load the different types of texture.
167 * @return Boolean of success of operation. Returns false if any texture fails to load from a url.
174 MeshRenderer( const MeshRenderer& meshRenderer );
177 MeshRenderer& operator=( const MeshRenderer& meshRenderer );
181 std::string mObjectUrl;
182 std::string mMaterialUrl;
184 std::string mDiffuseTextureUrl;
185 std::string mNormalTextureUrl;
186 std::string mGlossTextureUrl;
187 std::string mTexturesPath;
191 TextureSet mTextureSet;
193 ObjLoader mObjLoader;
194 Vector3 mSceneCenter;
196 ShaderType mShaderType;
200 bool mUseSoftNormals;
203 } // namespace Internal
205 } // namespace Toolkit
209 #endif /* __DALI_TOOLKIT_INTERNAL_MESH_RENDERER_H__ */