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-toolkit/internal/controls/cluster/cluster-style-impl.h>
22 #include <dali/public-api/animation/animation.h>
24 #include <dali-toolkit/public-api/controls/cluster/cluster.h>
29 namespace // unnamed namespace
33 const unsigned int STYLE_1_CHILDREN_NUMBER = 8;
35 const float STYLE_1_BACKGROUND_IMAGE_OFFSET_Z = 1.0f;
37 const float STYLE_1_CHILD_OFFSET_Z = 2.0f;
38 const float STYLE_1_CHILD_GAP_FACTOR = 0.03f;
39 const float STYLE_1_CHILD_SIZE_FACTOR[] = { 0.4f, 0.15f, 0.25f, 0.15f, 0.4f, 0.15f, 0.25f, 0.15f };
40 const Vector3 STYLE_1_CHILD_POSITION_FACTOR[] = { Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[0] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
41 0.5f - STYLE_1_CHILD_SIZE_FACTOR[0] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
42 STYLE_1_CHILD_OFFSET_Z),
43 Vector3(0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f,
44 0.5f - STYLE_1_CHILD_SIZE_FACTOR[1] - STYLE_1_CHILD_SIZE_FACTOR[2] - STYLE_1_CHILD_GAP_FACTOR * 1.5f,
45 STYLE_1_CHILD_OFFSET_Z + 0.5f),
46 Vector3(0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f,
47 0.5f - STYLE_1_CHILD_SIZE_FACTOR[2] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
48 STYLE_1_CHILD_OFFSET_Z + 1.0f),
49 Vector3(0.5f + STYLE_1_CHILD_SIZE_FACTOR[2] + STYLE_1_CHILD_GAP_FACTOR * 1.5f,
50 0.5f - STYLE_1_CHILD_SIZE_FACTOR[3] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
51 STYLE_1_CHILD_OFFSET_Z + 1.5f),
52 Vector3(0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f,
53 0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f,
54 STYLE_1_CHILD_OFFSET_Z + 2.0f),
55 Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[5] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
56 0.5f + STYLE_1_CHILD_SIZE_FACTOR[6] + STYLE_1_CHILD_GAP_FACTOR * 1.5f,
57 STYLE_1_CHILD_OFFSET_Z + 2.5f),
58 Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[6] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
59 0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f,
60 STYLE_1_CHILD_OFFSET_Z + 3.0f),
61 Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[6] - STYLE_1_CHILD_SIZE_FACTOR[7] - STYLE_1_CHILD_GAP_FACTOR * 1.5f,
62 0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f,
63 STYLE_1_CHILD_OFFSET_Z + 3.5f) };
65 const Vector3 STYLE_1_TITLE_SIZE_FACTOR = Vector3(0.3f, 0.11f, 1.0f);
66 const Vector3 STYLE_1_TITLE_POSITION_FACTOR = Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[0] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
67 0.5f - STYLE_1_CHILD_SIZE_FACTOR[0] - STYLE_1_CHILD_GAP_FACTOR * 0.5f - STYLE_1_TITLE_SIZE_FACTOR.height + 0.02f,
69 const Vector3 STYLE_1_TITLE_POSITION_OFFSET = Vector3(0.0f, 0.0f, 8.0f);
73 const unsigned int STYLE_2_CHILDREN_NUMBER = 6;
75 const float STYLE_2_BACKGROUND_IMAGE_OFFSET_Z = 1.0f;
77 const float STYLE_2_CHILD_OFFSET_Z = 2.0f;
78 const float STYLE_2_CHILD_GAP_FACTOR = 0.03f;
79 const float STYLE_2_CHILD_SIZE_FACTOR[] = { 0.4f, 0.25f, 0.15f, 0.4f, 0.25f, 0.15f };
80 const Vector3 STYLE_2_CHILD_POSITION_FACTOR[] = { Vector3(0.5f - STYLE_2_CHILD_SIZE_FACTOR[0] - STYLE_2_CHILD_GAP_FACTOR * 0.5f,
81 0.5f - STYLE_2_CHILD_SIZE_FACTOR[0] * 0.75f,
82 STYLE_2_CHILD_OFFSET_Z),
83 Vector3(0.5f + STYLE_2_CHILD_GAP_FACTOR * 0.5f,
84 0.5f - STYLE_2_CHILD_SIZE_FACTOR[1] - STYLE_2_CHILD_SIZE_FACTOR[3] * 0.25f - STYLE_2_CHILD_GAP_FACTOR,
85 STYLE_2_CHILD_OFFSET_Z + 0.5f),
86 Vector3(0.5f + STYLE_2_CHILD_SIZE_FACTOR[1] + STYLE_2_CHILD_GAP_FACTOR * 1.5f,
87 0.5f - STYLE_2_CHILD_SIZE_FACTOR[2] - STYLE_2_CHILD_SIZE_FACTOR[3] * 0.25f - STYLE_2_CHILD_GAP_FACTOR,
88 STYLE_2_CHILD_OFFSET_Z + 1.0f),
89 Vector3(0.5f + STYLE_2_CHILD_GAP_FACTOR * 0.5f,
90 0.5f - STYLE_2_CHILD_SIZE_FACTOR[3] * 0.25f,
91 STYLE_2_CHILD_OFFSET_Z + 1.5f),
92 Vector3(0.5f - STYLE_2_CHILD_SIZE_FACTOR[4] - STYLE_2_CHILD_GAP_FACTOR * 0.5f,
93 0.5f + STYLE_2_CHILD_SIZE_FACTOR[0] * 0.25f + STYLE_2_CHILD_GAP_FACTOR,
94 STYLE_2_CHILD_OFFSET_Z + 2.0f),
95 Vector3(0.5f - STYLE_2_CHILD_SIZE_FACTOR[4] - STYLE_2_CHILD_SIZE_FACTOR[5] - STYLE_2_CHILD_GAP_FACTOR * 1.5f,
96 0.5f + STYLE_2_CHILD_SIZE_FACTOR[0] * 0.25f + STYLE_2_CHILD_GAP_FACTOR,
97 STYLE_2_CHILD_OFFSET_Z + 2.5f) };
99 const Vector3 STYLE_2_TITLE_SIZE_FACTOR = Vector3(0.3f, 0.11f, 1.0f);
100 const Vector3 STYLE_2_TITLE_POSITION_FACTOR = Vector3(0.5f - STYLE_2_CHILD_SIZE_FACTOR[0] - STYLE_2_CHILD_GAP_FACTOR * 0.5f,
101 0.5f - STYLE_2_CHILD_SIZE_FACTOR[0] * 0.75f - STYLE_2_TITLE_SIZE_FACTOR.height + 0.02f,
103 const Vector3 STYLE_2_TITLE_POSITION_OFFSET = Vector3(0.0f, 0.0f, 8.0f);
105 // Cluster style three
107 const unsigned int STYLE_3_CHILDREN_NUMBER = 6;
109 const Vector3 STYLE_3_TITLE_SIZE_FACTOR = Vector3(0.4f, 0.15f, 1.0f);
111 const float STYLE_3_BACKGROUND_IMAGE_OFFSET_Z = 1.0f;
113 const float STYLE_3_CHILD_OFFSET_Z = 2.0f;
114 const float STYLE_3_CHILD_GAP_FACTOR = 0.03f;
115 const float STYLE_3_CHILD_SIZE_FACTOR[] = { 0.4f, 0.4f, 0.15f, 0.25f, 0.25f, 0.15f };
116 const float STYLE_3_CHILD_POSITION_OFFSET_Y = (1.0f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_SIZE_FACTOR[3] - STYLE_3_CHILD_GAP_FACTOR - STYLE_3_TITLE_SIZE_FACTOR.height) * 0.5f;
117 const Vector3 STYLE_3_CHILD_POSITION_FACTOR[] = { Vector3(0.5f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_GAP_FACTOR * 0.5f,
118 0.5f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y,
119 STYLE_3_CHILD_OFFSET_Z),
120 Vector3(0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f,
121 0.5f - STYLE_3_CHILD_SIZE_FACTOR[1] - STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y,
122 STYLE_3_CHILD_OFFSET_Z + 0.5f),
123 Vector3(0.5f + STYLE_3_CHILD_SIZE_FACTOR[3] + STYLE_3_CHILD_GAP_FACTOR * 1.5f,
124 0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y,
125 STYLE_3_CHILD_OFFSET_Z + 1.0f),
126 Vector3(0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f,
127 0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y,
128 STYLE_3_CHILD_OFFSET_Z + 1.5f),
129 Vector3(0.5f - STYLE_3_CHILD_SIZE_FACTOR[4] - STYLE_3_CHILD_GAP_FACTOR * 0.5f,
130 0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y,
131 STYLE_3_CHILD_OFFSET_Z + 2.0f),
132 Vector3(0.5f - STYLE_3_CHILD_SIZE_FACTOR[4] - STYLE_3_CHILD_SIZE_FACTOR[5] - STYLE_3_CHILD_GAP_FACTOR * 1.5f,
133 0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y,
134 STYLE_3_CHILD_OFFSET_Z + 2.5f) };
136 const Vector3 STYLE_3_TITLE_POSITION_FACTOR = Vector3(0.5f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_GAP_FACTOR * 0.5f,
137 0.5f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y - STYLE_3_TITLE_SIZE_FACTOR.height + 0.02f,
139 const Vector3 STYLE_3_TITLE_POSITION_OFFSET = Vector3(0.0f, 0.0f, 8.0f);
141 // Cluster style four
143 const unsigned int STYLE_4_CHILDREN_NUMBER = 6;
145 const float STYLE_4_BACKGROUND_IMAGE_OFFSET_Z = 1.0f;
147 const float STYLE_4_CHILD_OFFSET_Z = 2.0f;
148 const float STYLE_4_CHILD_GAP_FACTOR = 0.03f;
149 const float STYLE_4_CHILD_SIZE_FACTOR[] = { 0.4f, 0.22f, 0.13f, 0.4f, 0.22f, 0.13f };
150 const Vector3 STYLE_4_CHILD_POSITION_FACTOR[] = { Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[0] * 0.9f,
151 0.5f - STYLE_4_CHILD_SIZE_FACTOR[0] - STYLE_4_CHILD_GAP_FACTOR * 0.5f,
152 STYLE_4_CHILD_OFFSET_Z),
153 Vector3(0.5f + STYLE_4_CHILD_SIZE_FACTOR[0] * 0.1f + STYLE_4_CHILD_GAP_FACTOR,
154 0.5f - STYLE_4_CHILD_SIZE_FACTOR[1] - STYLE_4_CHILD_GAP_FACTOR * 0.5f,
155 STYLE_4_CHILD_OFFSET_Z + 0.5f),
156 Vector3(0.5f + STYLE_4_CHILD_SIZE_FACTOR[0] * 0.1f + STYLE_4_CHILD_SIZE_FACTOR[1] + STYLE_4_CHILD_GAP_FACTOR * 2.0f,
157 0.5f - STYLE_4_CHILD_SIZE_FACTOR[2] - STYLE_4_CHILD_GAP_FACTOR * 0.5f,
158 STYLE_4_CHILD_OFFSET_Z + 1.0f),
159 Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[3] * 0.1f,
160 0.5f + STYLE_4_CHILD_GAP_FACTOR * 0.5f,
161 STYLE_4_CHILD_OFFSET_Z + 1.5f),
162 Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[3] * 0.1f - STYLE_4_CHILD_SIZE_FACTOR[4] - STYLE_4_CHILD_GAP_FACTOR,
163 0.5f + STYLE_4_CHILD_GAP_FACTOR * 0.5f,
164 STYLE_4_CHILD_OFFSET_Z + 2.0f),
165 Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[3] * 0.1f - STYLE_4_CHILD_SIZE_FACTOR[4] - STYLE_4_CHILD_SIZE_FACTOR[5] - STYLE_4_CHILD_GAP_FACTOR * 2.0f,
166 0.5f + STYLE_4_CHILD_GAP_FACTOR * 0.5f,
167 STYLE_4_CHILD_OFFSET_Z + 2.5f) };
169 const Vector3 STYLE_4_TITLE_SIZE_FACTOR = Vector3(0.3f, 0.11f, 1.0f);
170 const Vector3 STYLE_4_TITLE_POSITION_FACTOR = Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[0] * 0.9f,
171 0.5f - STYLE_4_CHILD_SIZE_FACTOR[0] - STYLE_4_CHILD_GAP_FACTOR * 0.5f - STYLE_4_TITLE_SIZE_FACTOR.height + 0.02f,
173 const Vector3 STYLE_4_TITLE_POSITION_OFFSET = Vector3(0.0f, 0.0f, 8.0f);
174 const unsigned int CLUSTER_RANDOM_SEED(0x17eac9f3); ///< Random seed for cluster data.
176 const int STYLE_RANDOM_CHILDREN_NUMBER = 16;
178 Vector3 FirstOrderEquation( const Vector3& source, const Vector3& relative, const Vector3& offset = Vector3::ZERO )
180 return source * relative + offset;
183 // random data generator //////////////////////////////////////////////////////
185 const unsigned int GEN_RAND_CONST = 0x15d9a373;
187 unsigned int genRandom(unsigned int& seed, unsigned int offset)
189 unsigned int shft = offset&31;
193 seed^= (seed << (shft) | seed >> (32 - shft)) * (offset * GEN_RAND_CONST);
198 float genRandomFloat(unsigned int& seed, unsigned int offset, float min, float max)
200 const float f = static_cast<float>(genRandom(seed, offset)) / 0xffffffff;
201 return f * (max - min) + min;
204 } // unnamed namespace
212 // ClusterStyle ///////////////////////////////////////////////////////////////
214 ClusterStyle::ClusterStyle()
216 mTitlePositionRelative(Vector3::ONE),
217 mTitlePositionOffset(Vector3::ZERO),
218 mTitleSize(Vector3::ONE),
219 mBackgroundPositionRelative(Vector3::ONE),
220 mBackgroundPositionOffset(Vector3::ZERO),
221 mBackgroundSize(Vector3::ONE),
222 mClusterSize( Vector3::ZERO )
226 ClusterStyle::~ClusterStyle()
231 void ClusterStyle::SetMaximumNumberOfChildren(unsigned int maxChildren)
233 mMaxChildren = maxChildren;
236 unsigned int ClusterStyle::GetMaximumNumberOfChildren() const
241 void ClusterStyle::ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds)
244 FirstOrderEquation( GetClusterSize(), mBackgroundPositionRelative, mBackgroundPositionOffset ),
245 FirstOrderEquation( GetClusterSize(), mBackgroundSize ),
250 void ClusterStyle::ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds)
253 FirstOrderEquation( GetClusterSize(), mTitlePositionRelative, mTitlePositionOffset ),
254 FirstOrderEquation( GetClusterSize(), mTitleSize ),
259 void ClusterStyle::SetTitleProperties(const Vector3& relativePosition,
260 const Vector3& offsetPosition,
263 mTitlePositionRelative = relativePosition;
264 mTitlePositionOffset = offsetPosition;
268 void ClusterStyle::SetBackgroundProperties(const Vector3& relativePosition,
269 const Vector3& offsetPosition,
272 mBackgroundPositionRelative = relativePosition;
273 mBackgroundPositionOffset = offsetPosition;
274 mBackgroundSize = size;
277 void ClusterStyle::SetClusterSize( const Vector3& clusterSize )
279 mClusterSize = clusterSize;
282 Vector3 ClusterStyle::GetClusterSize() const
287 void ClusterStyle::Apply( Actor actor,
288 const Vector3& position,
291 const TimePeriod& durationSeconds)
293 float animationDuration = durationSeconds.delaySeconds + durationSeconds.durationSeconds;
294 if( animationDuration > 0.f )
296 Animation animation = Animation::New(animationDuration);
297 animation.MoveTo( actor, position, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
298 animation.Resize( actor, size, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
303 actor.SetPosition( position );
304 actor.SetSize( size );
308 void ClusterStyle::Apply( Actor actor,
309 const Vector3& position,
311 const Quaternion& rotation,
312 const Vector3& scale,
314 const TimePeriod& durationSeconds)
316 float animationDuration = durationSeconds.delaySeconds + durationSeconds.durationSeconds;
317 if( animationDuration > 0.f )
319 Animation animation = Animation::New(animationDuration);
320 animation.MoveTo( actor, position, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
321 animation.Resize( actor, size, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
322 animation.RotateTo( actor, rotation, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
323 animation.ScaleTo( actor, scale, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
328 actor.SetPosition( position );
329 actor.SetSize( size );
330 actor.SetRotation( rotation );
331 actor.SetScale( scale );
335 // ClusterStyleStandard ///////////////////////////////////////////////////////
337 ClusterStylePtr ClusterStyleStandard::New(StyleType style)
339 ClusterStylePtr impl( new ClusterStyleStandard(style) );
344 ClusterStyleStandard::ClusterStyleStandard(StyleType style)
351 case Toolkit::ClusterStyleStandard::ClusterStyle1:
353 SetMaximumNumberOfChildren(STYLE_1_CHILDREN_NUMBER);
354 SetSizes(STYLE_1_CHILD_SIZE_FACTOR);
355 SetPositions(STYLE_1_CHILD_POSITION_FACTOR);
356 SetTitleProperties(STYLE_1_TITLE_POSITION_FACTOR,
357 STYLE_1_TITLE_POSITION_OFFSET,
358 STYLE_1_TITLE_SIZE_FACTOR);
359 SetBackgroundProperties(Vector3::ZERO,
360 Vector3(0.0f, 0.0f, STYLE_1_BACKGROUND_IMAGE_OFFSET_Z),
364 case Toolkit::ClusterStyleStandard::ClusterStyle2:
366 SetMaximumNumberOfChildren(STYLE_2_CHILDREN_NUMBER);
367 SetSizes(STYLE_2_CHILD_SIZE_FACTOR);
368 SetPositions(STYLE_2_CHILD_POSITION_FACTOR);
369 SetTitleProperties(STYLE_2_TITLE_POSITION_FACTOR,
370 STYLE_2_TITLE_POSITION_OFFSET,
371 STYLE_2_TITLE_SIZE_FACTOR);
372 SetBackgroundProperties(Vector3::ZERO,
373 Vector3(0.0f, 0.0f, STYLE_2_BACKGROUND_IMAGE_OFFSET_Z),
377 case Toolkit::ClusterStyleStandard::ClusterStyle3:
379 SetMaximumNumberOfChildren(STYLE_3_CHILDREN_NUMBER);
380 SetSizes(STYLE_3_CHILD_SIZE_FACTOR);
381 SetPositions(STYLE_3_CHILD_POSITION_FACTOR);
382 SetTitleProperties(STYLE_3_TITLE_POSITION_FACTOR,
383 STYLE_3_TITLE_POSITION_OFFSET,
384 STYLE_3_TITLE_SIZE_FACTOR);
385 SetBackgroundProperties(Vector3::ZERO,
386 Vector3(0.0f, 0.0f, STYLE_3_BACKGROUND_IMAGE_OFFSET_Z),
390 case Toolkit::ClusterStyleStandard::ClusterStyle4:
392 SetMaximumNumberOfChildren(STYLE_4_CHILDREN_NUMBER);
393 SetSizes(STYLE_4_CHILD_SIZE_FACTOR);
394 SetPositions(STYLE_4_CHILD_POSITION_FACTOR);
395 SetTitleProperties(STYLE_4_TITLE_POSITION_FACTOR,
396 STYLE_4_TITLE_POSITION_OFFSET,
397 STYLE_4_TITLE_SIZE_FACTOR);
398 SetBackgroundProperties(Vector3::ZERO,
399 Vector3(0.0f, 0.0f, STYLE_4_BACKGROUND_IMAGE_OFFSET_Z),
405 DALI_ASSERT_ALWAYS(false && "Invalid Style");
411 void ClusterStyleStandard::SetSizes(const float *sizes)
416 void ClusterStyleStandard::SetPositions(const Vector3 *positions)
418 mPositions = positions;
421 void ClusterStyleStandard::ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds)
425 const float& size = mSizes[index];
426 // counter top-left parent origin and top-left anchor point.
427 const Vector3 position = mPositions[index] - Vector3(0.5f, 0.5f, 0.0f) + Vector3(size, size, 0.0f) * 0.5f;
430 FirstOrderEquation( GetClusterSize(), Vector3(position.x, position.y, 0.0f), Vector3(0.0f, 0.0f, position.z) ),
431 FirstOrderEquation( GetClusterSize(), Vector3::ONE * size ),
439 // ClusterStyleRandom /////////////////////////////////////////////////////////
441 ClusterStylePtr ClusterStyleRandom::New()
443 ClusterStylePtr impl( new ClusterStyleRandom() );
448 ClusterStyleRandom::ClusterStyleRandom()
451 SetMaximumNumberOfChildren(STYLE_RANDOM_CHILDREN_NUMBER);
452 SetTitleProperties(Vector3::ZERO,
455 SetBackgroundProperties(Vector3::ZERO,
456 Vector3(0.0f, 0.0f, 0.0f),
460 void ClusterStyleRandom::ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds)
462 unsigned int seed = CLUSTER_RANDOM_SEED;
463 const float size = 0.5f;
464 const float rotation = genRandomFloat(seed, index, -1.0f, 1.0f) * Math::PI * 0.1; // +/- 18 degrees
465 const Vector3 position(genRandomFloat(seed, index, -0.1f, 0.1f),
466 genRandomFloat(seed, index, -0.1f, 0.1f),
469 Property::Index depthProperty = child.GetPropertyIndex(Toolkit::Cluster::CLUSTER_ACTOR_DEPTH);
470 float depthPropertyValue = child.GetProperty<float>( depthProperty );
474 FirstOrderEquation( GetClusterSize(), Vector3(position.x, position.y, 0.0f), Vector3(0.0f, 0.0f, depthPropertyValue) ),
475 FirstOrderEquation( GetClusterSize(), Vector3::ONE * size),
476 Quaternion(rotation, Vector3::ZAXIS),
482 } // namespace Internal
484 } // namespace Toolkit