Property refactor in dali-core: Core changes
[platform/core/uifw/dali-core.git] / dali / public-api / geometry / animatable-vertex.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 #include <dali/public-api/geometry/animatable-vertex.h>
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 AnimatableVertex::AnimatableVertex( unsigned int vertex, AnimatableMesh mesh)
26   : mVertex(vertex),
27     mMesh(GetImplementation(mesh))
28 {
29   DALI_ASSERT_ALWAYS( mesh && "Mesh handle is empty" );
30   DALI_ASSERT_ALWAYS( vertex < mesh.GetNumberOfVertices() && "vertex is out of bounds" );
31 }
32
33 AnimatableVertex::~AnimatableVertex()
34 {
35 }
36
37 void AnimatableVertex::SetPosition(const Vector3& position)
38 {
39   mMesh.SetProperty( mMesh.GetVertexPropertyIndex(mVertex, Property::Position), Dali::Property::Value(position) );
40 }
41
42 void AnimatableVertex::SetColor(const Vector4& color)
43 {
44   mMesh.SetProperty( mMesh.GetVertexPropertyIndex(mVertex, Property::Color), Dali::Property::Value(color) );
45 }
46
47 void AnimatableVertex::SetTextureCoords(const Vector2& textureCoords)
48 {
49   mMesh.SetProperty( mMesh.GetVertexPropertyIndex(mVertex, Property::TextureCoords), Dali::Property::Value(textureCoords) );
50 }
51
52 Vector3 AnimatableVertex::GetCurrentPosition()
53 {
54   Vector3 position;
55   mMesh.GetProperty( mMesh.GetVertexPropertyIndex(mVertex, Property::Position) ).Get(position);
56   return position;
57 }
58
59 Vector4 AnimatableVertex::GetCurrentColor()
60 {
61   Vector4 color;
62   mMesh.GetProperty( mMesh.GetVertexPropertyIndex(mVertex, Property::Color) ).Get(color);
63   return color;
64 }
65
66 Vector2 AnimatableVertex::GetCurrentTextureCoords()
67 {
68   Vector2 textureCoords;
69   mMesh.GetProperty( mMesh.GetVertexPropertyIndex(mVertex, Property::TextureCoords) ).Get(textureCoords);
70   return textureCoords;
71 }
72
73 }//Dali