{
}
- Vector3 operator()( const Vector3& current, const PropertyInput& scrollProperty, const PropertyInput& parentSize )
+ void operator()( Vector3& position, const PropertyInputContainer& inputs )
{
- Vector3 pos( current );
- const float parentHeight = parentSize.GetVector3().height;
+ const Vector3& parentSize = inputs[1]->GetVector3();
- // Wrap bubbles vertically
- if( pos.y + mShapeSize * 0.5f < -parentHeight * 0.5f )
+ // Wrap bubbles verically.
+ if( position.y + mShapeSize * 0.5f < -parentSize.y * 0.5f )
{
- pos.y = parentHeight * 0.5f + mShapeSize * 0.5f;
+ position.y = parentSize.y * 0.5f + mShapeSize * 0.5f;
}
- // Bubbles X position moves parallax to horizontal panning by a scale factor unique to each bubble
- pos.x = mInitialX + ( scrollProperty.GetVector3().x * mScale );
- return pos;
+ // Bubbles X position moves parallax to horizontal
+ // panning by a scale factor unique to each bubble.
+ position.x = mInitialX + ( inputs[0]->GetVector3().x * mScale );
}
private:
child.SetPosition( childPos );
// Define bubble horizontal parallax and vertical wrapping
- Constraint animConstraint = Constraint::New < Vector3 > ( Actor::Property::POSITION,
- Source( mScrollView, ScrollView::Property::SCROLL_POSITION ),
- Dali::ParentSource( Dali::Actor::Property::SIZE ),
- AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ), childSize.height ) );
- child.ApplyConstraint( animConstraint );
+ Constraint animConstraint = Constraint::New < Vector3 > ( child, Actor::Property::POSITION, AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ), childSize.height ) );
+ animConstraint.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) );
+ animConstraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) );
+ animConstraint.Apply();
// Kickoff animation
Animation animation = Animation::New( Random::Range( 40.0f, 80.0f ) );
// constraints ////////////////////////////////////////////////////////////////
/**
- * CollisionConstraint generates a collision vector
- * between two actors a and b, assuming they're rectangular
- * based on their size.
- */
-struct CollisionConstraint
-{
- /**
- * Collision Constraint constructor
- * The adjust (optional) parameter can be used to add a margin
- * to the actors. A +ve size will result in larger collisions,
- * while a -ve size will result in tighter collisions.
- *
- * @param[in] adjust (optional) Adjusts the rectangular size detection
- */
- CollisionConstraint(Vector3 adjust = Vector3::ZERO)
- : mAdjust(adjust)
- {
- }
-
- /**
- * Generates collision vector indicating whether Actor's A and B
- * have overlapped eachother, and the relative position of Actor B to A.
- *
- * @param[in] current The current collision-property (ignored)
- * @param[in] propertyA Actor A's Position property.
- * @param[in] propertyB Actor B's Position property.
- * @param[in] propertySizeA Actor A's Size property.
- * @param[in] propertySizeB Actor B's Size property.
- * @return The collision vector is returned.
- */
- Vector3 operator()(const Vector3& current,
- const PropertyInput& propertyA,
- const PropertyInput& propertyB,
- const PropertyInput& propertySizeA,
- const PropertyInput& propertySizeB)
- {
- const Vector3& a = propertyA.GetVector3();
- const Vector3& b = propertyB.GetVector3();
- const Vector3& sizeA = propertySizeA.GetVector3();
- const Vector3& sizeB = propertySizeB.GetVector3();
- const Vector3 sizeComb = (sizeA + sizeB + mAdjust) * 0.5f;
-
- // get collision relative to a.
- Vector3 delta = b - a;
-
- // Check if not overlapping Actors.
- if( (fabsf(delta.x) > sizeComb.width) ||
- (fabsf(delta.y) > sizeComb.height) )
- {
- delta = Vector3::ZERO; // not overlapping
- }
-
- return delta; // overlapping, return overlap vector relative to actor a.
- }
-
- const Vector3 mAdjust; ///< Size Adjustment value
-};
-
-/**
* CollisionCircleRectangleConstraint generates a collision vector
* between two actors a (circle) and b (rectangle)
*/
* Generates collision vector indicating whether Actor's A and B
* have overlapped eachother, and the relative position of Actor B to A.
*
- * @param[in] current The current collision-property (ignored)
- * @param[in] propertyA Actor A's Position property.
- * @param[in] propertyB Actor B's Position property.
- * @param[in] propertySizeA Actor A's Size property.
- * @param[in] propertySizeB Actor B's Size property.
+ * @param[in,out] current The current collision-property
+ * @param[in] inputs Contains:
+ * Actor A's Position property.
+ * Actor B's Position property.
+ * Actor A's Size property.
+ * Actor B's Size property.
* @return The collision vector is returned.
*/
- Vector3 operator()(const Vector3& current,
- const PropertyInput& propertyA,
- const PropertyInput& propertyB,
- const PropertyInput& propertySizeA,
- const PropertyInput& propertySizeB)
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& a = propertyA.GetVector3();
- const Vector3 b = propertyB.GetVector3() + mAdjustPosition;
- const Vector3& sizeA = propertySizeA.GetVector3();
- const Vector3& sizeB = propertySizeB.GetVector3();
+ const Vector3& a = inputs[0]->GetVector3();
+ const Vector3 b = inputs[1]->GetVector3() + mAdjustPosition;
+ const Vector3& sizeA = inputs[2]->GetVector3();
+ const Vector3& sizeB = inputs[3]->GetVector3();
const Vector3 sizeA2 = sizeA * 0.5f; // circle radius
const Vector3 sizeB2 = (sizeB + mAdjustSize) * 0.5f; // rectangle half rectangle.
if(delta.Length() < sizeA2.x)
{
delta.Normalize();
- return delta;
+ current = delta;
+ }
+ else
+ {
+ current = Vector3::ZERO;
}
-
- return Vector3::ZERO;
}
const Vector3 mAdjustPosition; ///< Position Adjustment value
}
/**
- * @param[in] current The current rotation property (ignored)
- * @param[in] propertyWobble The wobble property (value from 0.0f to 1.0f)
+ * @param[in,out] current The current rotation property
+ * @param[in] inputs Contains the wobble property (value from 0.0f to 1.0f)
* @return The rotation (quaternion) is generated.
*/
- Quaternion operator()(const Quaternion& current,
- const PropertyInput& propertyWobble)
+ void operator()( Quaternion& current, const PropertyInputContainer& inputs )
{
- const float& wobble = propertyWobble.GetFloat();
+ const float& wobble = inputs[0]->GetFloat();
float f = sinf(wobble * 10.0f) * (1.0f-wobble);
- Quaternion q(mDeviation * f, Vector3::ZAXIS);
-
- return q;
+ current = Quaternion(mDeviation * f, Vector3::ZAXIS);
}
const float mDeviation; ///< Deviation factor in radians.
mPaddleImage.SetSize( mPaddleFullSize );
mWobbleProperty = mPaddle.RegisterProperty(WOBBLE_PROPERTY_NAME, 0.0f);
- Constraint wobbleConstraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
- LocalSource(mWobbleProperty),
- WobbleConstraint(10.0f));
- mPaddle.ApplyConstraint(wobbleConstraint);
+ Constraint wobbleConstraint = Constraint::New<Quaternion>( mPaddle, Actor::Property::ORIENTATION, WobbleConstraint(10.0f));
+ wobbleConstraint.AddSource( LocalSource(mWobbleProperty) );
+ wobbleConstraint.Apply();
mPaddle.SetPosition( stageSize * Vector3( PADDLE_START_POSITION ) );
mContentLayer.Add(mPaddle);
Actor delegate = Actor::New();
stage.Add(delegate);
Property::Index property = delegate.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO);
- Constraint constraint = Constraint::New<Vector3>( property,
- Source(mBall, Actor::Property::POSITION),
- Source(mPaddle, Actor::Property::POSITION),
- Source(mBall, Actor::Property::SIZE),
- Source(mPaddle, Actor::Property::SIZE),
- CollisionCircleRectangleConstraint( -Vector3(0.0f, mPaddleHitMargin.height * 0.575f, 0.0f),-Vector3(mPaddleHitMargin) ));
- delegate.ApplyConstraint(constraint);
+ Constraint constraint = Constraint::New<Vector3>( delegate, property, CollisionCircleRectangleConstraint( -Vector3(0.0f, mPaddleHitMargin.height * 0.575f, 0.0f),-Vector3(mPaddleHitMargin) ) );
+ constraint.AddSource( Source(mBall, Actor::Property::POSITION) );
+ constraint.AddSource( Source(mPaddle, Actor::Property::POSITION) );
+ constraint.AddSource( Source(mBall, Actor::Property::SIZE) );
+ constraint.AddSource( Source(mPaddle, Actor::Property::SIZE) );
+ constraint.Apply();
PropertyNotification paddleNotification = delegate.AddPropertyNotification( property, GreaterThanCondition(0.0f) );
paddleNotification.NotifySignal().Connect( this, &ExampleController::OnHitPaddle );
// Add a constraint on the brick between it and the ball generating a collision-property
Property::Index property = brick.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO);
- Constraint constraint = Constraint::New<Vector3>( property,
- Source(mBall, Actor::Property::POSITION),
- Source(brick, Actor::Property::POSITION),
- Source(mBall, Actor::Property::SIZE),
- Source(brick, Actor::Property::SIZE),
- CollisionCircleRectangleConstraint(BRICK_COLLISION_MARGIN));
- brick.ApplyConstraint(constraint);
+ Constraint constraint = Constraint::New<Vector3>( brick, property, CollisionCircleRectangleConstraint(BRICK_COLLISION_MARGIN) );
+ constraint.AddSource( Source(mBall, Actor::Property::POSITION) );
+ constraint.AddSource( Source(brick, Actor::Property::POSITION) );
+ constraint.AddSource( Source(mBall, Actor::Property::SIZE) );
+ constraint.AddSource( Source(brick, Actor::Property::SIZE) );
+ constraint.Apply();
// Now add a notification on this collision-property
* @param[in] current The object's current property value
* @return The object's new property value
*/
- Vector2 operator()(const Vector2& current,
- const PropertyInput& propertyOrientation)
+ void operator()( Vector2& current, const PropertyInputContainer& inputs )
{
Vector3 axis;
float angle;
- propertyOrientation.GetQuaternion().ToAxisAngle( axis, angle );
- Vector2 direction( cosf(angle), sinf(angle) );
+ inputs[0]->GetQuaternion().ToAxisAngle( axis, angle );
+
+ current.x = cosf(angle);
+ current.y = sinf(angle);
- return mAngleSweep * direction;
+ current *= mAngleSweep;
}
Vector2 mAngleSweep;
}
/**
- * @param[in] current The current shear effect Angle.
- * @param[in] scrollOvershootProperty The overshoot property from ScrollView
- * @param[in] propertyViewOrientation The orientation of the view e.g. Portrait, Landscape.
+ * @param[in,out] current The current shear effect Angle.
+ * @param[in] inputs Contains the overshoot property from ScrollView and the orientation of the view e.g. Portrait, Landscape.
* @return angle to provide ShearShaderEffect
*/
- float operator()(const float& current,
- const PropertyInput& scrollOvershootProperty,
- const PropertyInput& propertyViewOrientation)
+ void operator()( float& current, const PropertyInputContainer& inputs )
{
- float f = scrollOvershootProperty.GetVector3().x;
+ float f = inputs[0]->GetVector3().x;
float mag = fabsf(f);
float halfWidth = mStageSize.x * 0.5f;
// the component mask passed in.
Vector3 axis;
float angle;
- propertyViewOrientation.GetQuaternion().ToAxisAngle( axis, angle );
+ inputs[1]->GetQuaternion().ToAxisAngle( axis, angle );
Vector2 direction( cosf(angle), sinf(angle) );
float yield = direction.x * mComponentMask.x + direction.y * mComponentMask.y;
- return overshoot * mMaxOvershoot * yield;
+ current = overshoot * mMaxOvershoot * yield;
}
Vector2 mStageSize;
}
/**
- * @param[in] current The current center
- * @param[in] propertyViewSize The current view size
+ * @param[in,out] current The current center
+ * @param[in] inputs Contains the current view size
* @return vector to provide ShearShaderEffect
*/
- Vector2 operator()(const Vector2& current,
- const PropertyInput& propertyViewSize)
+ void operator()( Vector2& current, const PropertyInputContainer& inputs )
{
- float f = propertyViewSize.GetVector3().width / mStageSize.width;
- return Vector2( f * mCenter.x, mCenter.y );
+ float f = inputs[0]->GetVector3().width / mStageSize.width;
+ current.x = f * mCenter.x;
+ current.y = mCenter.y;
}
Vector2 mStageSize;
* @param[in] propertyViewSize The current view size
* @return vector to provide SphereShaderEffect
*/
- float operator()(const float& current)
+ void operator()( float& current, const PropertyInputContainer& /* inputs */ )
{
- return current + mOffset;
+ current += mOffset;
}
float mOffset;
}
- Cluster mCluster; ///< Cluster instance
- int mIndex; ///< Cluster index
- Vector3 mPosition; ///< Cluster original position
- Vector3 mSize; ///< Cluster original size
- ActiveConstraint mEffectConstraint; ///< Cluster constraint
+ Cluster mCluster; ///< Cluster instance
+ int mIndex; ///< Cluster index
+ Vector3 mPosition; ///< Cluster original position
+ Vector3 mSize; ///< Cluster original size
+ Constraint mEffectConstraint; ///< Cluster constraint
};
/**
RemoveShaderEffectRecursively( cluster );
if( i->mEffectConstraint )
{
- cluster.RemoveConstraint(i->mEffectConstraint);
+ i->mEffectConstraint.Remove();
i->mEffectConstraint.Reset();
}
}
Vector2 shearCenter( Vector2(position.x + size.width * shearAnchor.x, position.y + size.height * shearAnchor.y) );
Property::Index centerProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetCenterPropertyName());
- Constraint constraint = Constraint::New<Vector2>( centerProperty,
- Source(mView, Actor::Property::SIZE),
- ShearEffectCenterConstraint(stageSize, shearCenter) );
- shaderEffect.ApplyConstraint(constraint);
+ Constraint constraint = Constraint::New<Vector2>( shaderEffect, centerProperty, ShearEffectCenterConstraint(stageSize, shearCenter) );
+ constraint.AddSource( Source(mView, Actor::Property::SIZE) );
+
+ constraint.Apply();
SetShaderEffectRecursively( cluster,shaderEffect );
Property::Index angleXAxisProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetAngleXAxisPropertyName());
Property::Index angleYAxisProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetAngleYAxisPropertyName());
- constraint = Constraint::New<float>( angleXAxisProperty,
- Source(mScrollView, scrollOvershootProperty),
- Source(mView, Actor::Property::ORIENTATION),
- ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::XAXIS) );
- shaderEffect.ApplyConstraint(constraint);
- constraint = Constraint::New<float>( angleYAxisProperty,
- Source(mScrollView, scrollOvershootProperty),
- Source(mView, Actor::Property::ORIENTATION),
- ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::YAXIS) );
- shaderEffect.ApplyConstraint(constraint);
+ constraint = Constraint::New<float>( shaderEffect, angleXAxisProperty, ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::XAXIS) );
+ constraint.AddSource( Source(mScrollView, scrollOvershootProperty) );
+ constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) );
+ constraint.Apply();
+
+ constraint = Constraint::New<float>( shaderEffect, angleYAxisProperty, ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::YAXIS ) );
+ constraint.AddSource( Source(mScrollView, scrollOvershootProperty) );
+ constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) );
+ constraint.Apply();
}
CAROUSEL_EFFECT_ANGLE_SWEEP / stageSize.width );
Property::Index anglePerUnit = shaderEffect.GetPropertyIndex( shaderEffect.GetAnglePerUnitPropertyName() );
- shaderEffect.ApplyConstraint( Constraint::New<Vector2>( anglePerUnit,
- Source(mView, Actor::Property::ORIENTATION),
- CarouselEffectOrientationConstraint( angleSweep ) ) );
+ Constraint constraint = Constraint::New<Vector2>( shaderEffect, anglePerUnit, CarouselEffectOrientationConstraint( angleSweep ) );
+ constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) );
+ constraint.Apply();
break;
}
// dont apply shader effect to scrollview as it might override internal shaders for bounce effect etc
for( std::vector<ClusterInfo>::iterator i = mClusterInfo.begin(); i != mClusterInfo.end(); ++i )
{
- Constraint constraint = Constraint::New<float>(Actor::Property::POSITION_Z, SphereEffectOffsetConstraint(SPHERE_EFFECT_POSITION_Z));
- constraint.SetRemoveAction(Constraint::Discard);
Cluster cluster = i->mCluster;
+ i->mEffectConstraint = Constraint::New<float>( cluster, Actor::Property::POSITION_Z, SphereEffectOffsetConstraint( SPHERE_EFFECT_POSITION_Z ) );
+ i->mEffectConstraint.SetRemoveAction(Constraint::Discard);
SetShaderEffectRecursively( cluster, shaderEffect );
- i->mEffectConstraint = cluster.ApplyConstraint(constraint);
+ i->mEffectConstraint.Apply();
}
break;
}
{
}
- Vector3 operator()(const Vector3& current,
- const PropertyInput& sizeProperty,
- const PropertyInput& animationTimeProperty)
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- float time = animationTimeProperty.GetFloat();
- const Vector3& size = sizeProperty.GetVector3();
+ float time = inputs[1]->GetFloat();
+ const Vector3& size = inputs[0]->GetVector3();
- Vector3 range(mStageSize - size - Vector3::ONE * MAGNIFIER_INDENT * 2.0f);
- Vector3 position(mOffset);
+ current = mOffset;
- position.x += 0.5f * sinf(time * 0.471f) * range.width;
- position.y += 0.5f * sinf(time * 0.8739f) * range.height;
-
- return position;
+ Vector3 range( mStageSize - size - Vector3::ONE * MAGNIFIER_INDENT * 2.0f );
+ current.x += 0.5f * sinf(time * 0.471f) * range.width;
+ current.y += 0.5f * sinf(time * 0.8739f) * range.height;
}
Vector3 mStageSize; ///< Keep track of the stage size for determining path within stage bounds
{
}
- Vector3 operator()(const Vector3& constPosition,
- const PropertyInput& sizeProperty,
- const PropertyInput& parentOriginProperty,
- const PropertyInput& anchorPointProperty,
- const PropertyInput& referenceSizeProperty)
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& size = sizeProperty.GetVector3();
- const Vector3 origin = parentOriginProperty.GetVector3();
- const Vector3& anchor = anchorPointProperty.GetVector3();
- const Vector3& referenceSize = referenceSizeProperty.GetVector3();
+ const Vector3& size = inputs[0]->GetVector3();
+ const Vector3 origin = inputs[1]->GetVector3();
+ const Vector3& anchor = inputs[2]->GetVector3();
+ const Vector3& referenceSize = inputs[3]->GetVector3();
Vector3 offset(mOffsetOrigin * referenceSize);
- Vector3 newPosition( constPosition + offset );
-
// Get actual position of Actor relative to parent's Top-Left.
- Vector3 position(constPosition + offset + origin * referenceSize);
+ Vector3 position(current + offset + origin * referenceSize);
+
+ current += offset;
// if top-left corner is outside of Top-Left bounds, then push back in screen.
Vector3 corner(position - size * anchor - mMinIndent);
if(mFlipHorizontal && corner.x < 0.0f)
{
corner.x = 0.0f;
- newPosition.x += size.width;
+ current.x += size.width;
}
if(mFlipVertical && corner.y < 0.0f)
{
corner.y = 0.0f;
- newPosition.y += size.height;
+ current.y += size.height;
}
- newPosition.x -= std::min(corner.x, 0.0f);
- newPosition.y -= std::min(corner.y, 0.0f);
+ current.x -= std::min(corner.x, 0.0f);
+ current.y -= std::min(corner.y, 0.0f);
// if bottom-right corner is outside of Bottom-Right bounds, then push back in screen.
corner += size - referenceSize + mMinIndent + mMaxIndent;
if(mFlipHorizontal && corner.x > 0.0f)
{
corner.x = 0.0f;
- newPosition.x -= size.width;
+ current.x -= size.width;
}
if(mFlipVertical && corner.y > 0.0f)
{
corner.y = 0.0f;
- newPosition.y -= size.height;
+ current.y -= size.height;
}
- newPosition.x -= std::max(corner.x, 0.0f);
- newPosition.y -= std::max(corner.y, 0.0f);
-
- return newPosition;
+ current.x -= std::max(corner.x, 0.0f);
+ current.y -= std::max(corner.y, 0.0f);
}
Vector3 mOffsetOrigin; ///< Manual Parent Offset Origin.
overlay.Add( mMagnifier );
// Apply constraint to animate the position of the magnifier.
- Constraint constraint = Constraint::New<Vector3>(Actor::Property::POSITION,
- LocalSource(Actor::Property::SIZE),
- LocalSource(Actor::Property::PARENT_ORIGIN),
- LocalSource(Actor::Property::ANCHOR_POINT),
- ParentSource(Actor::Property::SIZE),
- ConfinementConstraint(ParentOrigin::CENTER, Vector2::ONE * MAGNIFIER_INDENT, Vector2::ONE * MAGNIFIER_INDENT));
+ Constraint constraint = Constraint::New<Vector3>( mMagnifier, Actor::Property::POSITION, ConfinementConstraint(ParentOrigin::CENTER, Vector2::ONE * MAGNIFIER_INDENT, Vector2::ONE * MAGNIFIER_INDENT) );
+ constraint.AddSource( LocalSource(Actor::Property::SIZE) );
+ constraint.AddSource( LocalSource(Actor::Property::PARENT_ORIGIN) );
+ constraint.AddSource( LocalSource(Actor::Property::ANCHOR_POINT) );
+ constraint.AddSource( ParentSource(Actor::Property::SIZE) );
constraint.SetRemoveAction(Constraint::Discard);
- mMagnifier.ApplyConstraint( constraint );
+ constraint.Apply();
// Create bouncing magnifier automatically bounces around screen.
mBouncingMagnifier = Toolkit::Magnifier::New();
ContinueAnimation();
// Apply constraint to animate the position of the magnifier.
- constraint = Constraint::New<Vector3>(Actor::Property::POSITION,
- LocalSource(Actor::Property::SIZE),
- LocalSource(mAnimationTimeProperty),
- MagnifierPathConstraint(mStageSize, mStageSize * 0.5f));
- mBouncingMagnifier.ApplyConstraint( constraint );
+ constraint = Constraint::New<Vector3>( mBouncingMagnifier, Actor::Property::POSITION, MagnifierPathConstraint(mStageSize, mStageSize * 0.5f) );
+ constraint.AddSource( LocalSource(Actor::Property::SIZE) );
+ constraint.AddSource( LocalSource(mAnimationTimeProperty) );
+ constraint.Apply();
// Apply constraint to animate the source of the magnifier.
- constraint = Constraint::New<Vector3>(mBouncingMagnifier.GetPropertyIndex( Toolkit::Magnifier::SOURCE_POSITION_PROPERTY_NAME ),
- LocalSource(Actor::Property::SIZE),
- LocalSource(mAnimationTimeProperty),
- MagnifierPathConstraint(mStageSize));
- mBouncingMagnifier.ApplyConstraint( constraint );
+ constraint = Constraint::New<Vector3>( mBouncingMagnifier, mBouncingMagnifier.GetPropertyIndex( Toolkit::Magnifier::SOURCE_POSITION_PROPERTY_NAME ), MagnifierPathConstraint(mStageSize) );
+ constraint.AddSource( LocalSource(Actor::Property::SIZE) );
+ constraint.AddSource( LocalSource(mAnimationTimeProperty) );
+ constraint.Apply();
}
/**
* Method to project a point on a circle of radius halfSide at given
* angle onto a square of side 2 * halfSide
*/
-Vector3 CircleSquareProjection( Degree angle, float halfSide )
+void CircleSquareProjection( Vector3& position, Degree angle, float halfSide )
{
- Vector3 position(0.0f, 0.0f, 0.0f);
Radian angleInRadians(angle);
// 135 90 45
position.x = halfSide;
position.y = -halfSide * sinf(angleInRadians) / cosf(angleInRadians);
}
- return position;
+
+ position.z = 0.0f;
}
float HoldZeroFastEaseInOutHoldOne(float progress)
{
}
- Vector3 operator()( const Vector3& current, const PropertyInput& start, const PropertyInput& rotation )
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- float degree = fmodf((start.GetFloat() + rotation.GetFloat()), 360.0f);
+ float degree = fmodf((inputs[0]->GetFloat() + inputs[1]->GetFloat()), 360.0f);
if(degree < 0.0f)
{
degree += 360.0f;
float endAngle = (90.0f*mSideIndex)+45.0f;
if(degree < startAngle)
{
- return Vector3::ZERO;
+ current = Vector3::ZERO;
}
- else if( degree >= endAngle )
+ else
{
- degree = endAngle;
+ if( degree >= endAngle )
+ {
+ degree = endAngle;
+ }
+ CircleSquareProjection( current, Degree(degree), 0.5f );
+ current.x = -current.x; // Inverting X makes the animation go anti clockwise from left center
}
- Vector3 pos = CircleSquareProjection(Degree(degree), 0.5f);
- pos.x = -pos.x; // Inverting X makes the animation go anti clockwise from left center
- return pos;
}
int mSideIndex;
// Constrain the vertices of the square mesh to sweep out a sector as the
// rotation angle is animated.
- mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(1, AnimatableVertex::Property::POSITION),
- srcStart, srcStart, SquareFanConstraint(0)));
- mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(2, AnimatableVertex::Property::POSITION),
- srcStart, srcRot, SquareFanConstraint(0)));
- mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(3, AnimatableVertex::Property::POSITION),
- srcStart, srcRot, SquareFanConstraint(1)));
- mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(4, AnimatableVertex::Property::POSITION),
- srcStart, srcRot, SquareFanConstraint(2)));
- mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(5, AnimatableVertex::Property::POSITION),
- srcStart, srcRot, SquareFanConstraint(3)));
- mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(6, AnimatableVertex::Property::POSITION),
- srcStart, srcRot, SquareFanConstraint(4)));
+ Constraint constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(1, AnimatableVertex::Property::POSITION), SquareFanConstraint(0) );
+ constraint.AddSource( srcStart );
+ constraint.AddSource( srcStart );
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(2, AnimatableVertex::Property::POSITION), SquareFanConstraint(0) );
+ constraint.AddSource( srcStart );
+ constraint.AddSource( srcRot );
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(3, AnimatableVertex::Property::POSITION), SquareFanConstraint(1) );
+ constraint.AddSource( srcStart );
+ constraint.AddSource( srcRot );
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(4, AnimatableVertex::Property::POSITION), SquareFanConstraint(2) );
+ constraint.AddSource( srcStart );
+ constraint.AddSource( srcRot );
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(5, AnimatableVertex::Property::POSITION), SquareFanConstraint(3) );
+ constraint.AddSource( srcStart );
+ constraint.AddSource( srcRot );
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(6, AnimatableVertex::Property::POSITION), SquareFanConstraint(4) );
+ constraint.AddSource( srcStart );
+ constraint.AddSource( srcRot );
+ constraint.Apply();
mStencilActor.SetDrawMode( DrawMode::STENCIL );
mStencilActor.SetPositionInheritanceMode(USE_PARENT_POSITION);
{
}
- Vector2 operator()( const Vector2& current, const PropertyInput& spinAngleProperty)
+ void operator()( Vector2& current, const PropertyInputContainer& inputs )
{
- float spinAngle = spinAngleProperty.GetFloat();
- return Vector2( cos(spinAngle ), sin( spinAngle ) ) * mRadius;
+ float spinAngle = inputs[0]->GetFloat();
+ current.x = cos( spinAngle );
+ current.y = sin( spinAngle );
+
+ current *= mRadius;
}
float mRadius;
handle.SetUniform( "uLightIntensity", 2.5f );
Dali::Property::Index index = handle.RegisterProperty( "uSpinAngle", 0.f );
- Constraint constraint = Constraint::New<Vector2>( handle.GetPropertyIndex("uLightSpinOffset"),
- LocalSource(index),
- LightOffsetConstraint(stageSize.x*0.1f));
- handle.ApplyConstraint( constraint );
+ Constraint constraint = Constraint::New<Vector2>( handle, handle.GetPropertyIndex("uLightSpinOffset"), LightOffsetConstraint(stageSize.x*0.1f) );
+ constraint.AddSource( LocalSource(index) );
+ constraint.Apply();
return handle;
}
{
}
- Vector3 operator()( const Vector3& current, const PropertyInput& property )
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- Vector3 position = property.GetVector3();
- position.z += 1.0f;
- return position;
- }
- };
-
- struct QuaternionEqualToConstraint
- {
- QuaternionEqualToConstraint()
- {
- }
-
- Quaternion operator()( const Quaternion& current, const PropertyInput& property )
- {
- return property.GetQuaternion();
+ current = inputs[0]->GetVector3();
+ current.z += 1.0f;
}
};
{
}
- Quaternion operator()( const Quaternion& current, const PropertyInput& property )
+ void operator()( Quaternion& current, const PropertyInputContainer& inputs )
{
- Degree angle(property.GetFloat());
- return Quaternion( Radian(angle) * mSign, Vector3::YAXIS );
+ Degree angle( inputs[0]->GetFloat() );
+ current = Quaternion( Radian(angle) * mSign, Vector3::YAXIS );
}
float mSign;
Property::Index angleIndex = mImageActor2.RegisterProperty("angle", Property::Value(30.0f));
Source angleSrc( mImageActor2, angleIndex );
- mImageActor1.ApplyConstraint(Constraint::New<Quaternion>( Actor::Property::ORIENTATION, angleSrc,
- RotationConstraint(-1.0f)));
- mImageActor3.ApplyConstraint(Constraint::New<Quaternion>( Actor::Property::ORIENTATION, angleSrc,
- RotationConstraint(+1.0f)));
+
+ Constraint constraint = Constraint::New<Quaternion>( mImageActor1, Actor::Property::ORIENTATION, RotationConstraint(-1.0f) );
+ constraint.AddSource( angleSrc );
+ constraint.Apply();
+
+ constraint = Constraint::New<Quaternion>( mImageActor3, Actor::Property::ORIENTATION, RotationConstraint(+1.0f) );
+ constraint.AddSource( angleSrc );
+ constraint.Apply();
mSceneAnimation = Animation::New(2.5f);