Dali 3D User Interface Engine
path-constrainer-impl.h
Go to the documentation of this file.
1 #ifndef __DALI_INTERNAL_PATH_CONSTRAINER_H__
2 #define __DALI_INTERNAL_PATH_CONSTRAINER_H__
3 
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20 
21 // INTERNAL INCLUDES
26 
27 namespace Dali
28 {
29 
30 namespace Internal
31 {
32 
34 
43 {
51  PathConstraintFunctor(PathPtr path, const Vector2& range, const Vector2& wrap ):mPath(path),mRange(range),mWrap(wrap){}
52 
61  PathConstraintFunctor(PathPtr path, const Vector2& range,const Vector3& forward, const Vector2& wrap ):mPath(path),mForward(forward),mRange(range),mWrap(wrap){}
62 
71  void operator()( Vector3& position,
72  const PropertyInputContainer& inputs)
73  {
74  float inputWrapped = inputs[0]->GetFloat();
75  if( inputWrapped < mWrap.x || inputWrapped > mWrap.y )
76  {
77  inputWrapped = WrapInDomain(inputWrapped, mWrap.x, mWrap.y);
78  }
79 
80  float t = ( inputWrapped - mRange.x ) / ( mRange.y-mRange.x );
81 
82  Vector3 tangent;
83  mPath->Sample( t, position, tangent );
84  }
85 
94  void operator()( Quaternion& current,
95  const PropertyInputContainer& inputs)
96  {
97  float inputWrapped = inputs[0]->GetFloat();
98  if( inputWrapped < mWrap.x || inputWrapped > mWrap.y )
99  {
100  inputWrapped = WrapInDomain(inputWrapped, mWrap.x, mWrap.y);
101  }
102 
103  float t = ( inputWrapped - mRange.x ) / ( mRange.y-mRange.x );
104 
105  Vector3 position, tangent;
106  mPath->Sample( t, position, tangent );
107  current = Quaternion( mForward, tangent );
108  }
109 
114 };
115 
120 {
121 public:
122 
127  static PathConstrainer* New();
128 
129 protected:
130 
134  virtual ~PathConstrainer();
135 
136 private:
137 
141  virtual unsigned int GetDefaultPropertyCount() const;
142 
146  virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
147 
151  virtual const char* GetDefaultPropertyName(Property::Index index) const;
152 
156  virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
157 
161  virtual bool IsDefaultPropertyWritable(Property::Index index) const;
162 
166  virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
167 
171  virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
172 
177 
181  virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
182 
186  virtual Property::Value GetDefaultProperty( Property::Index index ) const;
187 
188 public:
189 
193  void Apply( Property target, Property source, const Vector2& range, const Vector2& wrap );
194 
195 private:
196 
197  //Constructor
198  PathConstrainer();
199 
200  // Undefined
202 
203  // Undefined
205 
208 };
209 
210 } // Internal
211 
212 // Get impl of handle
214 {
215  DALI_ASSERT_ALWAYS( pathConstrainer && "PathConstrainer handle is empty" );
216  Dali::RefObject& object = pathConstrainer.GetBaseObject();
217  return static_cast<Internal::PathConstrainer&>(object);
218 }
219 
221 {
222  DALI_ASSERT_ALWAYS( pathConstrainer && "PathConstrainer handle is empty" );
223  const Dali::RefObject& object = pathConstrainer.GetBaseObject();
224  return static_cast<const Internal::PathConstrainer&>(object);
225 }
226 
227 } // Dali
228 
229 #endif //__DALI_INTERNAL_PATH_CONSTRAINER_H__
Dali Docs Home
Read more about Dali