1 #ifndef DALI_TOOLKIT_INTERNAL_MESH_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_MESH_VISUAL_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/visuals/visual-base-impl.h>
27 #include <dali-toolkit/internal/controls/model3d-view/obj-loader.h>
39 * The visual which renders a 3D object to the control's quad
41 * The following Property::Map keys are required to create a MeshVisual
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. |
51 * | lightPosition | VECTOR3 | The position (on stage) of the light |
53 class MeshVisual: public Visual::Base
60 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
62 MeshVisual( VisualFactoryCache& factoryCache );
65 * @brief A reference counted object may only be deleted by calling Unreference().
67 virtual ~MeshVisual();
69 public: // from Visual
72 * @copydoc Visual::SetSize
74 virtual void SetSize( const Vector2& size );
77 * @copydoc Visual::SetClipRect
79 virtual void SetClipRect( const Rect<int>& clipRect );
82 * @copydoc Visual::SetOffset
84 virtual void SetOffset( const Vector2& offset );
87 * @copydoc Visual::CreatePropertyMap
89 virtual void DoCreatePropertyMap( Property::Map& map ) const;
94 * @copydoc Visual::DoInitialize
96 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
99 * @copydoc Visual::DoSetOnStage
101 virtual void DoSetOnStage( Actor& actor );
106 * Declare whether a texture map should be used for the object, if it's present. Defaults to true.
107 * @param[in] useTexture boolean declaration.
109 void SetUseTexture( bool useTexture );
112 * Declare whether a normal map should be used for the object, if it's present. Defaults to true.
113 * @param[in] useNormalMap boolean declaration.
115 void SetUseNormalMap( bool useNormalMap );
119 //Corresponds to the shader that will be used by the mesh visual.
128 * @brief Provide an empty geometry for the visual to use.
129 * @details For use in error cases where the initialisation has failed for varying reasons.
131 void SupplyEmptyGeometry();
134 * @brief Initialize the visual with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
136 void InitializeRenderer();
139 * @brief Create a shader for the object to use.
144 * @brief Update shader related info, uniforms, etc. for the new shader.
146 void UpdateShaderUniforms();
149 * @brief Use the object URL stored in the mesh visual to load and create the geometry of the object.
150 * @return Boolean of success of operation.
152 bool CreateGeometry();
155 * @brief Use the object URL stored in the visual to load the geometry of the object.
156 * @return Boolean of success of operation.
161 * @brief Use the material URL stored in the mesh visual to load the material of the object.
162 * @return Boolean of success of operation.
167 * @brief Use the image and texture URL components to load the different types of texture.
168 * @return Boolean of success of operation. Returns false if any texture fails to load from a url.
175 MeshVisual( const MeshVisual& meshVisual );
178 MeshVisual& operator=( const MeshVisual& meshVisual );
182 std::string mObjectUrl;
183 std::string mMaterialUrl;
185 std::string mDiffuseTextureUrl;
186 std::string mNormalTextureUrl;
187 std::string mGlossTextureUrl;
188 std::string mTexturesPath;
192 TextureSet mTextureSet;
194 ObjLoader mObjLoader;
195 Vector3 mSceneCenter;
198 Vector3 mLightPosition;
199 ShaderType mShaderType;
203 bool mUseSoftNormals;
206 } // namespace Internal
208 } // namespace Toolkit
212 #endif /* DALI_TOOLKIT_INTERNAL_MESH_VISUAL_H */