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 "cluster-style-impl.h"
22 #include <dali/public-api/animation/animation.h>
30 namespace // unnamed namespace
34 const unsigned int STYLE_1_CHILDREN_NUMBER = 8;
36 const float STYLE_1_BACKGROUND_IMAGE_OFFSET_Z = 1.0f;
38 const float STYLE_1_CHILD_OFFSET_Z = 2.0f;
39 const float STYLE_1_CHILD_GAP_FACTOR = 0.03f;
40 const float STYLE_1_CHILD_SIZE_FACTOR[] = { 0.4f, 0.15f, 0.25f, 0.15f, 0.4f, 0.15f, 0.25f, 0.15f };
41 const Vector3 STYLE_1_CHILD_POSITION_FACTOR[] = { Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[0] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
42 0.5f - STYLE_1_CHILD_SIZE_FACTOR[0] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
43 STYLE_1_CHILD_OFFSET_Z),
44 Vector3(0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f,
45 0.5f - STYLE_1_CHILD_SIZE_FACTOR[1] - STYLE_1_CHILD_SIZE_FACTOR[2] - STYLE_1_CHILD_GAP_FACTOR * 1.5f,
46 STYLE_1_CHILD_OFFSET_Z + 0.5f),
47 Vector3(0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f,
48 0.5f - STYLE_1_CHILD_SIZE_FACTOR[2] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
49 STYLE_1_CHILD_OFFSET_Z + 1.0f),
50 Vector3(0.5f + STYLE_1_CHILD_SIZE_FACTOR[2] + STYLE_1_CHILD_GAP_FACTOR * 1.5f,
51 0.5f - STYLE_1_CHILD_SIZE_FACTOR[3] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
52 STYLE_1_CHILD_OFFSET_Z + 1.5f),
53 Vector3(0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f,
54 0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f,
55 STYLE_1_CHILD_OFFSET_Z + 2.0f),
56 Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[5] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
57 0.5f + STYLE_1_CHILD_SIZE_FACTOR[6] + STYLE_1_CHILD_GAP_FACTOR * 1.5f,
58 STYLE_1_CHILD_OFFSET_Z + 2.5f),
59 Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[6] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
60 0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f,
61 STYLE_1_CHILD_OFFSET_Z + 3.0f),
62 Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[6] - STYLE_1_CHILD_SIZE_FACTOR[7] - STYLE_1_CHILD_GAP_FACTOR * 1.5f,
63 0.5f + STYLE_1_CHILD_GAP_FACTOR * 0.5f,
64 STYLE_1_CHILD_OFFSET_Z + 3.5f) };
66 const Vector3 STYLE_1_TITLE_SIZE_FACTOR = Vector3(0.3f, 0.11f, 1.0f);
67 const Vector3 STYLE_1_TITLE_POSITION_FACTOR = Vector3(0.5f - STYLE_1_CHILD_SIZE_FACTOR[0] - STYLE_1_CHILD_GAP_FACTOR * 0.5f,
68 0.5f - STYLE_1_CHILD_SIZE_FACTOR[0] - STYLE_1_CHILD_GAP_FACTOR * 0.5f - STYLE_1_TITLE_SIZE_FACTOR.height + 0.02f,
70 const Vector3 STYLE_1_TITLE_POSITION_OFFSET = Vector3(0.0f, 0.0f, 8.0f);
74 const unsigned int STYLE_2_CHILDREN_NUMBER = 6;
76 const float STYLE_2_BACKGROUND_IMAGE_OFFSET_Z = 1.0f;
78 const float STYLE_2_CHILD_OFFSET_Z = 2.0f;
79 const float STYLE_2_CHILD_GAP_FACTOR = 0.03f;
80 const float STYLE_2_CHILD_SIZE_FACTOR[] = { 0.4f, 0.25f, 0.15f, 0.4f, 0.25f, 0.15f };
81 const Vector3 STYLE_2_CHILD_POSITION_FACTOR[] = { Vector3(0.5f - STYLE_2_CHILD_SIZE_FACTOR[0] - STYLE_2_CHILD_GAP_FACTOR * 0.5f,
82 0.5f - STYLE_2_CHILD_SIZE_FACTOR[0] * 0.75f,
83 STYLE_2_CHILD_OFFSET_Z),
84 Vector3(0.5f + STYLE_2_CHILD_GAP_FACTOR * 0.5f,
85 0.5f - STYLE_2_CHILD_SIZE_FACTOR[1] - STYLE_2_CHILD_SIZE_FACTOR[3] * 0.25f - STYLE_2_CHILD_GAP_FACTOR,
86 STYLE_2_CHILD_OFFSET_Z + 0.5f),
87 Vector3(0.5f + STYLE_2_CHILD_SIZE_FACTOR[1] + STYLE_2_CHILD_GAP_FACTOR * 1.5f,
88 0.5f - STYLE_2_CHILD_SIZE_FACTOR[2] - STYLE_2_CHILD_SIZE_FACTOR[3] * 0.25f - STYLE_2_CHILD_GAP_FACTOR,
89 STYLE_2_CHILD_OFFSET_Z + 1.0f),
90 Vector3(0.5f + STYLE_2_CHILD_GAP_FACTOR * 0.5f,
91 0.5f - STYLE_2_CHILD_SIZE_FACTOR[3] * 0.25f,
92 STYLE_2_CHILD_OFFSET_Z + 1.5f),
93 Vector3(0.5f - STYLE_2_CHILD_SIZE_FACTOR[4] - STYLE_2_CHILD_GAP_FACTOR * 0.5f,
94 0.5f + STYLE_2_CHILD_SIZE_FACTOR[0] * 0.25f + STYLE_2_CHILD_GAP_FACTOR,
95 STYLE_2_CHILD_OFFSET_Z + 2.0f),
96 Vector3(0.5f - STYLE_2_CHILD_SIZE_FACTOR[4] - STYLE_2_CHILD_SIZE_FACTOR[5] - STYLE_2_CHILD_GAP_FACTOR * 1.5f,
97 0.5f + STYLE_2_CHILD_SIZE_FACTOR[0] * 0.25f + STYLE_2_CHILD_GAP_FACTOR,
98 STYLE_2_CHILD_OFFSET_Z + 2.5f) };
100 const Vector3 STYLE_2_TITLE_SIZE_FACTOR = Vector3(0.3f, 0.11f, 1.0f);
101 const Vector3 STYLE_2_TITLE_POSITION_FACTOR = Vector3(0.5f - STYLE_2_CHILD_SIZE_FACTOR[0] - STYLE_2_CHILD_GAP_FACTOR * 0.5f,
102 0.5f - STYLE_2_CHILD_SIZE_FACTOR[0] * 0.75f - STYLE_2_TITLE_SIZE_FACTOR.height + 0.02f,
104 const Vector3 STYLE_2_TITLE_POSITION_OFFSET = Vector3(0.0f, 0.0f, 8.0f);
106 // Cluster style three
108 const unsigned int STYLE_3_CHILDREN_NUMBER = 6;
110 const Vector3 STYLE_3_TITLE_SIZE_FACTOR = Vector3(0.4f, 0.15f, 1.0f);
112 const float STYLE_3_BACKGROUND_IMAGE_OFFSET_Z = 1.0f;
114 const float STYLE_3_CHILD_OFFSET_Z = 2.0f;
115 const float STYLE_3_CHILD_GAP_FACTOR = 0.03f;
116 const float STYLE_3_CHILD_SIZE_FACTOR[] = { 0.4f, 0.4f, 0.15f, 0.25f, 0.25f, 0.15f };
117 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;
118 const Vector3 STYLE_3_CHILD_POSITION_FACTOR[] = { Vector3(0.5f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_GAP_FACTOR * 0.5f,
119 0.5f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y,
120 STYLE_3_CHILD_OFFSET_Z),
121 Vector3(0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f,
122 0.5f - STYLE_3_CHILD_SIZE_FACTOR[1] - STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y,
123 STYLE_3_CHILD_OFFSET_Z + 0.5f),
124 Vector3(0.5f + STYLE_3_CHILD_SIZE_FACTOR[3] + STYLE_3_CHILD_GAP_FACTOR * 1.5f,
125 0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y,
126 STYLE_3_CHILD_OFFSET_Z + 1.0f),
127 Vector3(0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f,
128 0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y,
129 STYLE_3_CHILD_OFFSET_Z + 1.5f),
130 Vector3(0.5f - STYLE_3_CHILD_SIZE_FACTOR[4] - STYLE_3_CHILD_GAP_FACTOR * 0.5f,
131 0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y,
132 STYLE_3_CHILD_OFFSET_Z + 2.0f),
133 Vector3(0.5f - STYLE_3_CHILD_SIZE_FACTOR[4] - STYLE_3_CHILD_SIZE_FACTOR[5] - STYLE_3_CHILD_GAP_FACTOR * 1.5f,
134 0.5f + STYLE_3_CHILD_GAP_FACTOR * 0.5f + STYLE_3_CHILD_POSITION_OFFSET_Y,
135 STYLE_3_CHILD_OFFSET_Z + 2.5f) };
137 const Vector3 STYLE_3_TITLE_POSITION_FACTOR = Vector3(0.5f - STYLE_3_CHILD_SIZE_FACTOR[0] - STYLE_3_CHILD_GAP_FACTOR * 0.5f,
138 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,
140 const Vector3 STYLE_3_TITLE_POSITION_OFFSET = Vector3(0.0f, 0.0f, 8.0f);
142 // Cluster style four
144 const unsigned int STYLE_4_CHILDREN_NUMBER = 6;
146 const float STYLE_4_BACKGROUND_IMAGE_OFFSET_Z = 1.0f;
148 const float STYLE_4_CHILD_OFFSET_Z = 2.0f;
149 const float STYLE_4_CHILD_GAP_FACTOR = 0.03f;
150 const float STYLE_4_CHILD_SIZE_FACTOR[] = { 0.4f, 0.22f, 0.13f, 0.4f, 0.22f, 0.13f };
151 const Vector3 STYLE_4_CHILD_POSITION_FACTOR[] = { Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[0] * 0.9f,
152 0.5f - STYLE_4_CHILD_SIZE_FACTOR[0] - STYLE_4_CHILD_GAP_FACTOR * 0.5f,
153 STYLE_4_CHILD_OFFSET_Z),
154 Vector3(0.5f + STYLE_4_CHILD_SIZE_FACTOR[0] * 0.1f + STYLE_4_CHILD_GAP_FACTOR,
155 0.5f - STYLE_4_CHILD_SIZE_FACTOR[1] - STYLE_4_CHILD_GAP_FACTOR * 0.5f,
156 STYLE_4_CHILD_OFFSET_Z + 0.5f),
157 Vector3(0.5f + STYLE_4_CHILD_SIZE_FACTOR[0] * 0.1f + STYLE_4_CHILD_SIZE_FACTOR[1] + STYLE_4_CHILD_GAP_FACTOR * 2.0f,
158 0.5f - STYLE_4_CHILD_SIZE_FACTOR[2] - STYLE_4_CHILD_GAP_FACTOR * 0.5f,
159 STYLE_4_CHILD_OFFSET_Z + 1.0f),
160 Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[3] * 0.1f,
161 0.5f + STYLE_4_CHILD_GAP_FACTOR * 0.5f,
162 STYLE_4_CHILD_OFFSET_Z + 1.5f),
163 Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[3] * 0.1f - STYLE_4_CHILD_SIZE_FACTOR[4] - STYLE_4_CHILD_GAP_FACTOR,
164 0.5f + STYLE_4_CHILD_GAP_FACTOR * 0.5f,
165 STYLE_4_CHILD_OFFSET_Z + 2.0f),
166 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,
167 0.5f + STYLE_4_CHILD_GAP_FACTOR * 0.5f,
168 STYLE_4_CHILD_OFFSET_Z + 2.5f) };
170 const Vector3 STYLE_4_TITLE_SIZE_FACTOR = Vector3(0.3f, 0.11f, 1.0f);
171 const Vector3 STYLE_4_TITLE_POSITION_FACTOR = Vector3(0.5f - STYLE_4_CHILD_SIZE_FACTOR[0] * 0.9f,
172 0.5f - STYLE_4_CHILD_SIZE_FACTOR[0] - STYLE_4_CHILD_GAP_FACTOR * 0.5f - STYLE_4_TITLE_SIZE_FACTOR.height + 0.02f,
174 const Vector3 STYLE_4_TITLE_POSITION_OFFSET = Vector3(0.0f, 0.0f, 8.0f);
175 const unsigned int CLUSTER_RANDOM_SEED(0x17eac9f3); ///< Random seed for cluster data.
177 const int STYLE_RANDOM_CHILDREN_NUMBER = 16;
179 Vector3 FirstOrderEquation( const Vector3& source, const Vector3& relative, const Vector3& offset = Vector3::ZERO )
181 return source * relative + offset;
184 // random data generator //////////////////////////////////////////////////////
186 const unsigned int GEN_RAND_CONST = 0x15d9a373;
188 unsigned int genRandom(unsigned int& seed, unsigned int offset)
190 unsigned int shft = offset&31;
194 seed^= (seed << (shft) | seed >> (32 - shft)) * (offset * GEN_RAND_CONST);
199 float genRandomFloat(unsigned int& seed, unsigned int offset, float min, float max)
201 const float f = static_cast<float>(genRandom(seed, offset)) / 0xffffffff;
202 return f * (max - min) + min;
205 } // unnamed namespace
213 // ClusterStyle ///////////////////////////////////////////////////////////////
215 ClusterStyle::ClusterStyle()
217 mTitlePositionRelative(Vector3::ONE),
218 mTitlePositionOffset(Vector3::ZERO),
219 mTitleSize(Vector3::ONE),
220 mBackgroundPositionRelative(Vector3::ONE),
221 mBackgroundPositionOffset(Vector3::ZERO),
222 mBackgroundSize(Vector3::ONE),
223 mClusterSize( Vector3::ZERO )
227 ClusterStyle::~ClusterStyle()
232 void ClusterStyle::SetMaximumNumberOfChildren(unsigned int maxChildren)
234 mMaxChildren = maxChildren;
237 unsigned int ClusterStyle::GetMaximumNumberOfChildren() const
242 void ClusterStyle::ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds)
245 FirstOrderEquation( GetClusterSize(), mBackgroundPositionRelative, mBackgroundPositionOffset ),
246 FirstOrderEquation( GetClusterSize(), mBackgroundSize ),
251 void ClusterStyle::ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds)
254 FirstOrderEquation( GetClusterSize(), mTitlePositionRelative, mTitlePositionOffset ),
255 FirstOrderEquation( GetClusterSize(), mTitleSize ),
260 void ClusterStyle::SetTitleProperties(const Vector3& relativePosition,
261 const Vector3& offsetPosition,
264 mTitlePositionRelative = relativePosition;
265 mTitlePositionOffset = offsetPosition;
269 void ClusterStyle::SetBackgroundProperties(const Vector3& relativePosition,
270 const Vector3& offsetPosition,
273 mBackgroundPositionRelative = relativePosition;
274 mBackgroundPositionOffset = offsetPosition;
275 mBackgroundSize = size;
278 void ClusterStyle::SetClusterSize( const Vector3& clusterSize )
280 mClusterSize = clusterSize;
283 Vector3 ClusterStyle::GetClusterSize() const
288 void ClusterStyle::Apply( Actor actor,
289 const Vector3& position,
292 const TimePeriod& durationSeconds)
294 float animationDuration = durationSeconds.delaySeconds + durationSeconds.durationSeconds;
295 if( animationDuration > 0.f )
297 Animation animation = Animation::New(animationDuration);
298 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), position, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) );
299 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), size, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) );
304 actor.SetPosition( position );
305 actor.SetSize( size );
309 void ClusterStyle::Apply( Actor actor,
310 const Vector3& position,
312 const Quaternion& rotation,
313 const Vector3& scale,
315 const TimePeriod& durationSeconds)
317 float animationDuration = durationSeconds.delaySeconds + durationSeconds.durationSeconds;
318 if( animationDuration > 0.f )
320 Animation animation = Animation::New(animationDuration);
321 animation.AnimateTo( Property( actor, Actor::Property::POSITION ), position, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) );
322 animation.AnimateTo( Property( actor, Actor::Property::SIZE ), size, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) );
323 animation.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), rotation, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) );
324 animation.AnimateTo( Property( actor, Actor::Property::SCALE ), scale, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) );
329 actor.SetPosition( position );
330 actor.SetSize( size );
331 actor.SetOrientation( rotation );
332 actor.SetScale( scale );
336 // ClusterStyleStandard ///////////////////////////////////////////////////////
338 ClusterStylePtr ClusterStyleStandard::New(StyleType style)
340 ClusterStylePtr impl( new ClusterStyleStandard(style) );
345 ClusterStyleStandard::ClusterStyleStandard(StyleType style)
352 case Demo::ClusterStyleStandard::ClusterStyle1:
354 SetMaximumNumberOfChildren(STYLE_1_CHILDREN_NUMBER);
355 SetSizes(STYLE_1_CHILD_SIZE_FACTOR);
356 SetPositions(STYLE_1_CHILD_POSITION_FACTOR);
357 SetTitleProperties(STYLE_1_TITLE_POSITION_FACTOR,
358 STYLE_1_TITLE_POSITION_OFFSET,
359 STYLE_1_TITLE_SIZE_FACTOR);
360 SetBackgroundProperties(Vector3::ZERO,
361 Vector3(0.0f, 0.0f, STYLE_1_BACKGROUND_IMAGE_OFFSET_Z),
365 case Demo::ClusterStyleStandard::ClusterStyle2:
367 SetMaximumNumberOfChildren(STYLE_2_CHILDREN_NUMBER);
368 SetSizes(STYLE_2_CHILD_SIZE_FACTOR);
369 SetPositions(STYLE_2_CHILD_POSITION_FACTOR);
370 SetTitleProperties(STYLE_2_TITLE_POSITION_FACTOR,
371 STYLE_2_TITLE_POSITION_OFFSET,
372 STYLE_2_TITLE_SIZE_FACTOR);
373 SetBackgroundProperties(Vector3::ZERO,
374 Vector3(0.0f, 0.0f, STYLE_2_BACKGROUND_IMAGE_OFFSET_Z),
378 case Demo::ClusterStyleStandard::ClusterStyle3:
380 SetMaximumNumberOfChildren(STYLE_3_CHILDREN_NUMBER);
381 SetSizes(STYLE_3_CHILD_SIZE_FACTOR);
382 SetPositions(STYLE_3_CHILD_POSITION_FACTOR);
383 SetTitleProperties(STYLE_3_TITLE_POSITION_FACTOR,
384 STYLE_3_TITLE_POSITION_OFFSET,
385 STYLE_3_TITLE_SIZE_FACTOR);
386 SetBackgroundProperties(Vector3::ZERO,
387 Vector3(0.0f, 0.0f, STYLE_3_BACKGROUND_IMAGE_OFFSET_Z),
391 case Demo::ClusterStyleStandard::ClusterStyle4:
393 SetMaximumNumberOfChildren(STYLE_4_CHILDREN_NUMBER);
394 SetSizes(STYLE_4_CHILD_SIZE_FACTOR);
395 SetPositions(STYLE_4_CHILD_POSITION_FACTOR);
396 SetTitleProperties(STYLE_4_TITLE_POSITION_FACTOR,
397 STYLE_4_TITLE_POSITION_OFFSET,
398 STYLE_4_TITLE_SIZE_FACTOR);
399 SetBackgroundProperties(Vector3::ZERO,
400 Vector3(0.0f, 0.0f, STYLE_4_BACKGROUND_IMAGE_OFFSET_Z),
406 DALI_ASSERT_ALWAYS(false && "Invalid Style");
412 void ClusterStyleStandard::SetSizes(const float *sizes)
417 void ClusterStyleStandard::SetPositions(const Vector3 *positions)
419 mPositions = positions;
422 void ClusterStyleStandard::ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds)
426 const float& size = mSizes[index];
427 // counter top-left parent origin and top-left anchor point.
428 const Vector3 position = mPositions[index] - Vector3(0.5f, 0.5f, 0.0f) + Vector3(size, size, 0.0f) * 0.5f;
431 FirstOrderEquation( GetClusterSize(), Vector3(position.x, position.y, 0.0f), Vector3(0.0f, 0.0f, position.z) ),
432 FirstOrderEquation( GetClusterSize(), Vector3::ONE * size ),
440 // ClusterStyleRandom /////////////////////////////////////////////////////////
442 ClusterStylePtr ClusterStyleRandom::New()
444 ClusterStylePtr impl( new ClusterStyleRandom() );
449 ClusterStyleRandom::ClusterStyleRandom()
452 SetMaximumNumberOfChildren(STYLE_RANDOM_CHILDREN_NUMBER);
453 SetTitleProperties(Vector3::ZERO,
456 SetBackgroundProperties(Vector3::ZERO,
457 Vector3(0.0f, 0.0f, 0.0f),
461 void ClusterStyleRandom::ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds)
463 unsigned int seed = CLUSTER_RANDOM_SEED;
464 const float size = 0.5f;
465 const float rotation = genRandomFloat(seed, index, -1.0f, 1.0f) * Math::PI * 0.1; // +/- 18 degrees
466 const Vector3 position(genRandomFloat(seed, index, -0.1f, 0.1f),
467 genRandomFloat(seed, index, -0.1f, 0.1f),
470 Property::Index depthProperty = child.GetPropertyIndex(Demo::Cluster::CLUSTER_ACTOR_DEPTH);
471 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( Radian( rotation ), Vector3::ZAXIS ),
482 } // namespace Internal