1 #ifndef __DALI_INTERNAL_MESH_ACTOR_H__
2 #define __DALI_INTERNAL_MESH_ACTOR_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
24 #include <dali/public-api/object/ref-object.h>
25 #include <dali/public-api/actors/mesh-actor.h>
26 #include <dali/public-api/geometry/mesh.h>
27 #include <dali/public-api/modeling/entity.h>
28 #include <dali/internal/event/actors/actor-impl.h>
29 #include <dali/internal/event/actors/actor-declarations.h>
30 #include <dali/internal/event/modeling/material-impl.h>
31 #include <dali/internal/event/modeling/model-data-impl.h>
32 #include <dali/internal/event/actor-attachments/mesh-attachment-impl.h>
33 #include <dali/internal/event/actors/renderable-actor-impl.h>
44 class MeshActor : public RenderableActor
49 * Create an un-intialised mesh actor
50 * @return A smart-pointer to a newly allocated mesh actor
52 static MeshActorPtr New();
55 * Create an intialised mesh actor from the given mesh
56 * @param[in] mesh An object containing mesh data
57 * @return A smart-pointer to a newly allocated mesh actor
59 static MeshActorPtr New(Dali::Mesh mesh);
62 * Create an intialised mesh actor from the given mesh
63 * @param[in] mesh An object containing mesh data
64 * @return A smart-pointer to a newly allocated mesh actor
66 static MeshActorPtr New(Dali::AnimatableMesh mesh);
69 * Create an intialised mesh actor from a model entity
70 * @param[in] modelData Scene graph object
71 * @param[in] entity in a model
72 * @return A smart-pointer to a newly allocated mesh actor
74 static MeshActorPtr New(ModelDataPtr modelData, Dali::Entity entity);
79 * Add a mesh to this actor.
80 * @param[in] mesh A mesh structure
82 void SetMesh(Dali::Mesh mesh);
85 * Add an animated mesh to this actor
86 * @param[in] mesh An animatable mesh
88 void SetMesh(Dali::AnimatableMesh mesh);
91 * Add a mesh resource to this actor
92 * @param[in] mesh A mesh resource
94 void SetMesh(MeshIPtr meshPtr);
97 * Set the given mesh to this actor
98 * @param[in] modelData The model data
99 * @param[in] meshIndex The mesh index from the model
101 void SetMesh(ModelDataPtr modelData, unsigned int meshIndex);
104 * @copydoc Dali::MeshActor::SetMaterial(Material material)
106 void SetMaterial(const Dali::Material material);
109 * Get a material for a given mesh.
110 * @return The material
112 Dali::Material GetMaterial() const;
115 * Set whether this mesh actor should be affected by lights in the
116 * scene. If it set to false, then the mesh will be unaffected by
117 * lighting, and will be evenly lit without any shading.
118 * This property is not inherited.
119 * @param[in] affectedByLighting Whether the actor should be lit by the scene lighting.
121 void SetAffectedByLighting(bool affectedByLighting);
124 * Get whether the actor is lit by scene or evenly lit
125 * @return true if lit by scene, false if evenly lit
127 bool IsAffectedByLighting();
130 * Search the actor tree for all named bones in the mesh array and connect them.
131 * @param[in] rootActor - the root actor of the actor tree.
133 void BindBonesToMesh(Internal::ActorPtr rootActor);
135 private: // From RenderableActor
138 * @copydoc RenderableActor::GetRenderableAttachment
140 virtual RenderableAttachment& GetRenderableAttachment() const
142 DALI_ASSERT_DEBUG( mMeshAttachment );
143 return *mMeshAttachment;
148 * Protected constructor; see also MeshActor::New()
153 * A reference counted object may only be deleted by calling Unreference()
155 virtual ~MeshActor();
158 Internal::MeshAttachmentPtr mMeshAttachment;
161 } // namespace Internal
163 // Helpers for public-api forwarding methods
165 inline Internal::MeshActor& GetImplementation(Dali::MeshActor& meshActor)
167 DALI_ASSERT_ALWAYS( meshActor && "MeshActor handle is empty" );
169 BaseObject& handle = meshActor.GetBaseObject();
171 return static_cast<Internal::MeshActor&>(handle);
174 inline const Internal::MeshActor& GetImplementation(const Dali::MeshActor& meshActor)
176 DALI_ASSERT_ALWAYS( meshActor && "MeshActor handle is empty" );
178 const BaseObject& handle = meshActor.GetBaseObject();
180 return static_cast<const Internal::MeshActor&>(handle);
183 } // namespace Internal
185 #endif // __DALI_INTERNAL_MESH_ACTOR_H__