License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / dali / public-api / geometry / animatable-mesh.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18
19 #include <dali/public-api/geometry/animatable-mesh.h>
20 #include <dali/internal/event/modeling/animatable-mesh-impl.h>
21
22 namespace Dali
23 {
24
25 AnimatableMesh::AnimatableMesh()
26 {
27 }
28
29 AnimatableMesh AnimatableMesh::New(
30   unsigned int numVertices,
31   const AnimatableMesh::Faces& faceIndices,
32   Dali::Material material )
33 {
34   Internal::AnimatableMeshPtr internal = Internal::AnimatableMesh::New( numVertices,
35                                                                         faceIndices,
36                                                                         material );
37   return AnimatableMesh(internal.Get());
38 }
39
40 AnimatableMesh AnimatableMesh::New( unsigned int numVertices,
41                                     const Faces& faceIndices )
42 {
43
44   Internal::AnimatableMeshPtr internal = Internal::AnimatableMesh::New( numVertices, faceIndices );
45   return AnimatableMesh(internal.Get());
46 }
47
48 AnimatableMesh AnimatableMesh::DownCast( BaseHandle handle )
49 {
50   return AnimatableMesh( dynamic_cast<Dali::Internal::AnimatableMesh*>(handle.GetObjectPtr()) );
51 }
52
53 AnimatableMesh::~AnimatableMesh()
54 {
55 }
56
57 unsigned int AnimatableMesh::GetNumberOfVertices() const
58 {
59   return GetImplementation(*this).GetNumberOfVertices();
60 }
61
62 AnimatableVertex AnimatableMesh::operator[](const unsigned int index) const
63 {
64   DALI_ASSERT_ALWAYS( index < GetNumberOfVertices() && "Index out of bounds" );
65
66   return AnimatableVertex(index, *this);
67 }
68
69 Property::Index AnimatableMesh::GetPropertyIndex(
70   unsigned int index,
71   Property::Index property ) const
72 {
73   DALI_ASSERT_ALWAYS( index < GetNumberOfVertices() && "Index out of bounds" );
74
75   return GetImplementation(*this).GetVertexPropertyIndex( index, property );
76 }
77
78 Property AnimatableMesh::GetVertexProperty( unsigned int vertex, Property::Index property)
79 {
80   return Property( *this, GetPropertyIndex( vertex, property ) );
81 }
82
83
84 AnimatableMesh::AnimatableMesh( Internal::AnimatableMesh* internal )
85 : Constrainable(internal)
86 {
87 }
88
89 } // Dali