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;
42 return Dali::MeshActor::New();
45 TypeRegistration mType( typeid(Dali::MeshActor), typeid(Dali::RenderableActor), Create );
49 MeshActorPtr MeshActor::New()
51 MeshActorPtr actor(new MeshActor());
53 // Second-phase construction
56 // Create the attachment
57 actor->mMeshAttachment = MeshAttachment::New( *actor->mStage, *actor->mNode );
58 actor->Attach(*actor->mMeshAttachment);
59 actor->SetCullFace( Dali::CullBack );
64 MeshActorPtr MeshActor::New(Dali::Mesh mesh)
66 MeshActorPtr actor = MeshActor::New();
76 MeshActorPtr MeshActor::New(Dali::AnimatableMesh mesh)
78 MeshActorPtr actor = MeshActor::New();
88 MeshActor::MeshActor()
93 MeshActor::~MeshActor()
97 void MeshActor::SetMesh(Dali::Mesh mesh)
99 SetMesh( &GetImplementation(mesh) );
102 void MeshActor::SetMesh(Dali::AnimatableMesh mesh)
104 mAnimatableMeshHandle = mesh;
105 SetMesh( GetImplementation(mesh).GetMesh() );
107 SetInitialVolume(Vector3(1.0f, 1.0f, 1.0f));
110 void MeshActor::SetMesh( MeshIPtr meshPtr )
112 mMeshAttachment->SetMesh( meshPtr, meshPtr->GetResourceId(), meshPtr->GetBones(), meshPtr->GetMaterial() );
115 void MeshActor::SetMaterial(const Dali::Material material)
117 MaterialIPtr materialPtr = const_cast<Internal::Material*>(&GetImplementation(material));
118 mMeshAttachment->SetMaterial(materialPtr);
121 Dali::Material MeshActor::GetMaterial() const
123 Dali::Material material;
125 Internal::MaterialIPtr internalPtr = mMeshAttachment->GetMaterial( );
129 material = Dali::Material(internalPtr.Get());
135 void MeshActor::BindBonesToMesh(Internal::ActorPtr rootActor)
137 mMeshAttachment->BindBonesToMesh(rootActor);
140 } // namespace Internal