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 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.
25 #include <dali/public-api/object/handle.h>
26 #include <dali/public-api/actors/mesh-actor.h>
27 #include <dali/public-api/geometry/mesh.h>
28 #include <dali/public-api/modeling/entity.h>
29 #include <dali/internal/event/actors/actor-impl.h>
30 #include <dali/internal/event/actors/actor-declarations.h>
31 #include <dali/internal/event/modeling/material-impl.h>
32 #include <dali/internal/event/modeling/model-data-impl.h>
33 #include <dali/internal/event/actor-attachments/mesh-attachment-impl.h>
34 #include <dali/internal/event/actors/renderable-actor-impl.h>
45 class MeshActor : public RenderableActor
50 * Create an un-intialised mesh actor
51 * @return A smart-pointer to a newly allocated mesh actor
53 static MeshActorPtr New();
56 * Create an intialised mesh actor from the given mesh
57 * @param[in] mesh An object containing mesh data
58 * @return A smart-pointer to a newly allocated mesh actor
60 static MeshActorPtr New(Dali::Mesh mesh);
63 * Create an intialised mesh actor from the given mesh
64 * @param[in] mesh An object containing mesh data
65 * @return A smart-pointer to a newly allocated mesh actor
67 static MeshActorPtr New(Dali::AnimatableMesh mesh);
70 * Create an intialised mesh actor from a model entity
71 * @param[in] modelData Scene graph object
72 * @param[in] entity in a model
73 * @return A smart-pointer to a newly allocated mesh actor
75 static MeshActorPtr New(ModelDataPtr modelData, Dali::Entity entity);
80 * Add a mesh to this actor.
81 * @param[in] mesh A mesh structure
83 void SetMesh(Dali::Mesh mesh);
86 * Add an animated mesh to this actor
87 * @param[in] mesh An animatable mesh
89 void SetMesh(Dali::AnimatableMesh mesh);
92 * Add a mesh resource to this actor
93 * @param[in] mesh A mesh resource
95 void SetMesh(MeshIPtr meshPtr);
98 * Set the given mesh to this actor
99 * @param[in] modelData The model data
100 * @param[in] meshIndex The mesh index from the model
102 void SetMesh(ModelDataPtr modelData, unsigned int meshIndex);
105 * @copydoc Dali::MeshActor::SetMaterial(Material material)
107 void SetMaterial(const Dali::Material material);
110 * Get a material for a given mesh.
111 * @return The material
113 Dali::Material GetMaterial() const;
116 * Set whether this mesh actor should be affected by lights in the
117 * scene. If it set to false, then the mesh will be unaffected by
118 * lighting, and will be evenly lit without any shading.
119 * This property is not inherited.
120 * @param[in] affectedByLighting Whether the actor should be lit by the scene lighting.
122 void SetAffectedByLighting(bool affectedByLighting);
125 * Get whether the actor is lit by scene or evenly lit
126 * @return true if lit by scene, false if evenly lit
128 bool IsAffectedByLighting();
131 * Search the actor tree for all named bones in the mesh array and connect them.
132 * @param[in] rootActor - the root actor of the actor tree.
134 void BindBonesToMesh(Internal::ActorPtr rootActor);
136 private: // From RenderableActor
139 * @copydoc RenderableActor::GetRenderableAttachment
141 virtual RenderableAttachment& GetRenderableAttachment() const
143 DALI_ASSERT_DEBUG( mMeshAttachment );
144 return *mMeshAttachment;
149 * Protected constructor; see also MeshActor::New()
154 * A reference counted object may only be deleted by calling Unreference()
156 virtual ~MeshActor();
159 Internal::MeshAttachmentPtr mMeshAttachment;
160 // To keep a reference to the AnimatableMesh so it would not be destroyed before the MeshActor object
161 Dali::Handle mAnimatableMeshHandle;
164 } // namespace Internal
166 // Helpers for public-api forwarding methods
168 inline Internal::MeshActor& GetImplementation(Dali::MeshActor& meshActor)
170 DALI_ASSERT_ALWAYS( meshActor && "MeshActor handle is empty" );
172 BaseObject& handle = meshActor.GetBaseObject();
174 return static_cast<Internal::MeshActor&>(handle);
177 inline const Internal::MeshActor& GetImplementation(const Dali::MeshActor& meshActor)
179 DALI_ASSERT_ALWAYS( meshActor && "MeshActor handle is empty" );
181 const BaseObject& handle = meshActor.GetBaseObject();
183 return static_cast<const Internal::MeshActor&>(handle);
186 } // namespace Internal
188 #endif // __DALI_INTERNAL_MESH_ACTOR_H__