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 |
50 class MeshRenderer: public ControlRenderer
57 * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
59 MeshRenderer( RendererFactoryCache& factoryCache );
62 * @brief A reference counted object may only be deleted by calling Unreference().
64 virtual ~MeshRenderer();
66 public: // from ControlRenderer
69 * @copydoc ControlRenderer::SetSize
71 virtual void SetSize( const Vector2& size );
74 * @copydoc ControlRenderer::SetClipRect
76 virtual void SetClipRect( const Rect<int>& clipRect );
79 * @copydoc ControlRenderer::SetOffset
81 virtual void SetOffset( const Vector2& offset );
84 * @copydoc ControlRenderer::CreatePropertyMap
86 virtual void DoCreatePropertyMap( Property::Map& map ) const;
91 * @copydoc ControlRenderer::DoInitialize
93 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
96 * @copydoc ControlRenderer::DoSetOnStage
98 virtual void DoSetOnStage( Actor& actor );
103 * Declare whether a texture map should be used for the object, if it's present. Defaults to true.
104 * @param[in] useTexture boolean declaration.
106 void SetUseTexture( bool useTexture );
109 * Declare whether a normal map should be used for the object, if it's present. Defaults to true.
110 * @param[in] useNormalMap boolean declaration.
112 void SetUseNormalMap( bool useNormalMap );
116 //Corresponds to the shader that will be used by the mesh renderer.
125 * @brief Provide an empty geometry for the renderer to use.
126 * @details For use in error cases where the initialisation has failed for varying reasons.
128 void SupplyEmptyGeometry();
131 * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
133 void InitializeRenderer();
136 * @brief Create a shader for the object to use.
141 * @brief Update shader related info, uniforms, etc. for the new shader.
143 void UpdateShaderUniforms();
146 * @brief Use the object URL stored in the renderer to load and create the geometry of the object.
147 * @return Boolean of success of operation.
149 bool CreateGeometry();
152 * @brief Use the object URL stored in the renderer to load the geometry of the object.
153 * @return Boolean of success of operation.
158 * @brief Use the material URL stored in the renderer to load the material of the object.
159 * @return Boolean of success of operation.
164 * @brief Use the image and texture URL components to load the different types of texture.
165 * @return Boolean of success of operation. Returns false if any texture fails to load from a url.
172 MeshRenderer( const MeshRenderer& meshRenderer );
175 MeshRenderer& operator=( const MeshRenderer& meshRenderer );
179 std::string mObjectUrl;
180 std::string mMaterialUrl;
182 std::string mDiffuseTextureUrl;
183 std::string mNormalTextureUrl;
184 std::string mGlossTextureUrl;
185 std::string mTexturesPath;
187 std::string mShaderTypeString;
191 TextureSet mTextureSet;
193 ObjLoader mObjLoader;
194 Vector3 mSceneCenter;
196 ShaderType mShaderType;
202 } // namespace Internal
204 } // namespace Toolkit
208 #endif /* __DALI_TOOLKIT_INTERNAL_MESH_RENDERER_H__ */