(ImageSize) Add natural image size handling
[platform/core/uifw/dali-core.git] / capi / dali / public-api / actors / mesh-actor.h
1 #ifndef __DALI_MESH_ACTOR_H__
2 #define __DALI_MESH_ACTOR_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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
10 //
11 //     http://floralicense.org/license/
12 //
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.
18 //
19
20
21 /**
22  * @addtogroup CAPI_DALI_FRAMEWORK
23  * @{
24  */
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/actors/renderable-actor.h>
28
29 namespace Dali DALI_IMPORT_API
30 {
31 class Material;
32 class Mesh;
33 class Model;
34 class AnimatableMesh;
35
36 namespace Internal DALI_INTERNAL
37 {
38 class MeshActor;
39 }
40
41 /**
42  * This actor is used to draw one or more mesh geometries, passed in on creation. It allows
43  * for a custom material to be drawn on the mesh.
44  *
45  * By default CullFaceMode is set to CullBack to enable back face culling.
46  */
47 class DALI_IMPORT_API MeshActor : public RenderableActor
48 {
49 public:
50
51   /**
52    * Create an uninitialized MeshActor handle. This can be initialised with MeshActor::New().
53    * Calling member functions with an uninitialized Dali::Object is not allowed.
54    */
55   MeshActor();
56
57   /**
58    * Create a MeshActor object.
59    * @return the newly allocated MeshActor object
60    */
61   static MeshActor New();
62
63   /**
64    * Create a MeshActor object.
65    * @param[in] mesh the Mesh the actor will use.
66    * @return the newly allocated MeshActor object
67    */
68   static MeshActor New( Mesh mesh );
69
70   /**
71    * Create a MeshActor object
72    * @param[in] mesh the Animated Mesh the actor will use.
73    * @return the newly allocated MeshActor object
74    */
75   static MeshActor New( AnimatableMesh mesh );
76
77   /**
78    * Downcast an Object handle to MeshActor. If handle points to a MeshActor the
79    * downcast produces a valid handle. If not the returned handle is left uninitialized.
80    * @param[in] handle to an object
81    * @return handle to a MeshActor or an uninitialized handle
82    */
83   static MeshActor DownCast( BaseHandle handle );
84
85   /**
86    * Virtual destructor.
87    * Dali::Object derived classes typically do not contain member data.
88    */
89   virtual ~MeshActor();
90
91   /**
92    * @copydoc Dali::BaseHandle::operator=
93    */
94   using BaseHandle::operator=;
95
96   /**
97    * Set a custom material on the given actor or one of it's children.
98    * @pre the mesh is loaded
99    * @param[in] actor      The first actor in the tree of model actors
100    * @param[in] actorName  The name of the actor to search for.
101    * @param[in] material   The custom material.<br>Pass NULL to revert to the
102    *                       original material.
103    */
104   static void SetMaterial(Actor actor, const std::string& actorName, Material material);
105
106   /**
107    * Set a custom material on this actor
108    * @pre the mesh is loaded
109    * @param[in] material   The custom material.@n
110    *                       Pass an uninitialised Material to revert to the original material.
111    */
112   void SetMaterial(Material material);
113
114   /**
115    * Get the material for this mesh actor
116    * @pre the mesh is loaded
117    * @return The material
118    */
119   Material GetMaterial() const;
120
121   /**
122    * Set whether this mesh actor should be affected by lights in the
123    * scene.  If it set to false, then the mesh will be unaffected by
124    * lighting, and will be drawn with flat lighting, applying
125    * the material's diffuse & ambient colors and the actor's color to the
126    * material texture. If it is set to true, and there are no lights in the
127    * scene, the mesh will not be drawn.
128    *
129    * @note This property is not inherited.
130    * @note The default value is true.
131    * @param[in] affectedByLighting Whether the actor should be lit by the scene lighting.
132    */
133   void SetAffectedByLighting(bool affectedByLighting);
134
135   /**
136    * Get the lighting status
137    * @return true if the actor is affected by the scene lighting, or false if its evenly lit.
138    */
139   bool IsAffectedByLighting();
140
141   /**
142    * Search the actor tree for all named bones in the mesh and connect them.
143    * @param[in] rootActor The root actor of the actor tree.
144    */
145   void BindBonesToMesh(Actor rootActor);
146
147 public: // Not intended for application developers
148
149   /**
150    * This constructor is used by Dali New() methods
151    * @param [in] actor A pointer to a newly allocated Dali resource
152    */
153   explicit DALI_INTERNAL MeshActor(Internal::MeshActor* actor);
154 };
155
156 } // namespace Dali
157
158 /**
159  * @}
160  */
161 #endif /* _MESH_ACTOR_H_ */