2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/event/actors/mesh-actor-impl.h>
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/internal/event/modeling/animatable-mesh-impl.h>
24 #include <dali/internal/event/modeling/mesh-impl.h>
29 using Internal::MeshIter;
30 using Internal::MeshIPtr;
31 using Internal::MaterialIPtr;
41 return Dali::MeshActor::New();
44 TypeRegistration mType( typeid(Dali::MeshActor), typeid(Dali::RenderableActor), Create );
48 MeshActorPtr MeshActor::New()
50 MeshActorPtr actor(new MeshActor());
52 // Second-phase construction
55 // Create the attachment
56 actor->mMeshAttachment = MeshAttachment::New( *actor->mStage, *actor->mNode );
57 actor->Attach(*actor->mMeshAttachment);
58 actor->SetCullFace( Dali::CullBack );
63 MeshActorPtr MeshActor::New(Dali::Mesh mesh)
65 MeshActorPtr actor = MeshActor::New();
75 MeshActorPtr MeshActor::New(Dali::AnimatableMesh mesh)
77 MeshActorPtr actor = MeshActor::New();
87 MeshActor::MeshActor()
92 MeshActor::~MeshActor()
96 void MeshActor::SetMesh(Dali::Mesh mesh)
98 SetMesh( &GetImplementation(mesh) );
101 void MeshActor::SetMesh(Dali::AnimatableMesh mesh)
103 mAnimatableMeshHandle = mesh;
104 SetMesh( GetImplementation(mesh).GetMesh() );
106 SetInitialVolume(Vector3(1.0f, 1.0f, 1.0f));
109 void MeshActor::SetMesh( MeshIPtr meshPtr )
111 mMeshAttachment->SetMesh( meshPtr, meshPtr->GetResourceId(), meshPtr->GetBones(), meshPtr->GetMaterial() );
114 void MeshActor::SetMaterial(const Dali::Material material)
116 MaterialIPtr materialPtr = const_cast<Internal::Material*>(&GetImplementation(material));
117 mMeshAttachment->SetMaterial(materialPtr);
120 Dali::Material MeshActor::GetMaterial() const
122 Dali::Material material;
124 Internal::MaterialIPtr internalPtr = mMeshAttachment->GetMaterial( );
128 material = Dali::Material(internalPtr.Get());
134 void MeshActor::BindBonesToMesh(Internal::ActorPtr rootActor)
136 mMeshAttachment->BindBonesToMesh(rootActor);
139 } // namespace Internal