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/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/actor-attachments/mesh-attachment-impl.h>
32 #include <dali/internal/event/actors/renderable-actor-impl.h>
42 class MeshActor : public RenderableActor
47 * Create an un-intialised mesh actor
48 * @return A smart-pointer to a newly allocated mesh actor
50 static MeshActorPtr New();
53 * Create an intialised mesh actor from the given mesh
54 * @param[in] mesh An object containing mesh data
55 * @return A smart-pointer to a newly allocated mesh actor
57 static MeshActorPtr New(Dali::Mesh mesh);
60 * Create an intialised mesh actor from the given mesh
61 * @param[in] mesh An object containing mesh data
62 * @return A smart-pointer to a newly allocated mesh actor
64 static MeshActorPtr New(Dali::AnimatableMesh mesh);
69 * Add a mesh to this actor.
70 * @param[in] mesh A mesh structure
72 void SetMesh(Dali::Mesh mesh);
75 * Add an animated mesh to this actor
76 * @param[in] mesh An animatable mesh
78 void SetMesh(Dali::AnimatableMesh mesh);
81 * Add a mesh resource to this actor
82 * @param[in] mesh A mesh resource
84 void SetMesh(MeshIPtr meshPtr);
87 * @copydoc Dali::MeshActor::SetMaterial(Material material)
89 void SetMaterial(const Dali::Material material);
92 * Get a material for a given mesh.
93 * @return The material
95 Dali::Material GetMaterial() const;
98 * Search the actor tree for all named bones in the mesh array and connect them.
99 * @param[in] rootActor - the root actor of the actor tree.
101 void BindBonesToMesh(Internal::ActorPtr rootActor);
103 private: // From RenderableActor
106 * @copydoc RenderableActor::GetRenderableAttachment
108 virtual RenderableAttachment& GetRenderableAttachment() const
110 DALI_ASSERT_DEBUG( mMeshAttachment );
111 return *mMeshAttachment;
116 * Protected constructor; see also MeshActor::New()
121 * A reference counted object may only be deleted by calling Unreference()
123 virtual ~MeshActor();
126 Internal::MeshAttachmentPtr mMeshAttachment;
127 // To keep a reference to the AnimatableMesh so it would not be destroyed before the MeshActor object
128 Dali::Handle mAnimatableMeshHandle;
131 } // namespace Internal
133 // Helpers for public-api forwarding methods
135 inline Internal::MeshActor& GetImplementation(Dali::MeshActor& meshActor)
137 DALI_ASSERT_ALWAYS( meshActor && "MeshActor handle is empty" );
139 BaseObject& handle = meshActor.GetBaseObject();
141 return static_cast<Internal::MeshActor&>(handle);
144 inline const Internal::MeshActor& GetImplementation(const Dali::MeshActor& meshActor)
146 DALI_ASSERT_ALWAYS( meshActor && "MeshActor handle is empty" );
148 const BaseObject& handle = meshActor.GetBaseObject();
150 return static_cast<const Internal::MeshActor&>(handle);
153 } // namespace Internal
155 #endif // __DALI_INTERNAL_MESH_ACTOR_H__