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/public-api/visuals/mesh-visual-properties.h>
27 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
28 #include <dali-toolkit/internal/controls/model3d-view/obj-loader.h>
40 * The visual which renders a 3D object to the control's quad
42 * The following Property::Map keys are required to create a MeshVisual
44 * | %Property Name | Type | Representing |
45 * |-----------------|-------------|-----------------------------------------------------------------------|
46 * | objectUrl | STRING | A URL to the .obj file |
47 * | materialUrl | STRING | A URL to the .mtl file |
48 * | texturesPath | STRING | A URL of the path to the texture images |
49 * | shadingMode | STRING | An enum of shading modes |
50 * | useMipmapping | BOOLEAN | If true, use mipmaps for textures. Default true. |
51 * | useSoftNormals | BOOLEAN | If true, average normals at points for smooth textures. Default true. |
52 * | lightPosition | VECTOR3 | The position (on stage) of the light |
54 class MeshVisual: public Visual::Base
61 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
63 MeshVisual( VisualFactoryCache& factoryCache );
66 * @brief A reference counted object may only be deleted by calling Unreference().
68 virtual ~MeshVisual();
70 public: // from Visual
73 * @copydoc Visual::SetSize
75 virtual void SetSize( const Vector2& size );
78 * @copydoc Visual::CreatePropertyMap
80 virtual void DoCreatePropertyMap( Property::Map& map ) const;
85 * @copydoc Visual::DoInitialize
87 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
90 * @copydoc Visual::DoSetOnStage
92 virtual void DoSetOnStage( Actor& actor );
97 * Declare whether a texture map should be used for the object, if it's present. Defaults to true.
98 * @param[in] useTexture boolean declaration.
100 void SetUseTexture( bool useTexture );
103 * Declare whether a normal map should be used for the object, if it's present. Defaults to true.
104 * @param[in] useNormalMap boolean declaration.
106 void SetUseNormalMap( bool useNormalMap );
111 * @brief Provide an empty geometry for the visual to use.
112 * @details For use in error cases where the initialisation has failed for varying reasons.
114 void SupplyEmptyGeometry();
117 * @brief Initialize the visual with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
119 void InitializeRenderer();
122 * @brief Create a shader for the object to use.
127 * @brief Update shader related info, uniforms, etc. for the new shader.
129 void UpdateShaderUniforms();
132 * @brief Use the object URL stored in the mesh visual to load and create the geometry of the object.
133 * @return Boolean of success of operation.
135 bool CreateGeometry();
138 * @brief Use the object URL stored in the visual to load the geometry of the object.
139 * @return Boolean of success of operation.
144 * @brief Use the material URL stored in the mesh visual to load the material of the object.
145 * @return Boolean of success of operation.
150 * @brief Use the image and texture URL components to load the different types of texture.
151 * @return Boolean of success of operation. Returns false if any texture fails to load from a url.
158 MeshVisual( const MeshVisual& meshVisual );
161 MeshVisual& operator=( const MeshVisual& meshVisual );
165 std::string mObjectUrl;
166 std::string mMaterialUrl;
168 std::string mDiffuseTextureUrl;
169 std::string mNormalTextureUrl;
170 std::string mGlossTextureUrl;
171 std::string mTexturesPath;
175 TextureSet mTextureSet;
177 ObjLoader mObjLoader;
178 Vector3 mSceneCenter;
181 Vector3 mLightPosition;
182 Toolkit::MeshVisual::ShadingMode::Value mShadingMode;
186 bool mUseSoftNormals;
189 } // namespace Internal
191 } // namespace Toolkit
195 #endif /* DALI_TOOLKIT_INTERNAL_MESH_VISUAL_H */