-Matrix TransitionBase::GetWorldTransform(Dali::Actor actor)
-{
- enum InheritanceMode
- {
- DONT_INHERIT_TRANSFORM = 0,
- INHERIT_POSITION = 1,
- INHERIT_SCALE = 2,
- INHERIT_ORIENTATION = 4,
- INHERIT_ALL = INHERIT_POSITION | INHERIT_SCALE | INHERIT_ORIENTATION,
- };
-
- std::vector<Dali::Actor> descentList;
- std::vector<InheritanceMode> inheritanceModeList;
- Dali::Actor currentActor = actor;
- int inheritance = 0;
- do
- {
- inheritance = (static_cast<int>(currentActor.GetProperty<bool>(Dali::Actor::Property::INHERIT_ORIENTATION)) << 2) +
- (static_cast<int>(currentActor.GetProperty<bool>(Dali::Actor::Property::INHERIT_SCALE)) << 1) +
- static_cast<int>(currentActor.GetProperty<bool>(Dali::Actor::Property::INHERIT_POSITION));
- inheritanceModeList.push_back(static_cast<InheritanceMode>(inheritance));
- descentList.push_back(currentActor);
- currentActor = currentActor.GetParent();
- } while(inheritance != DONT_INHERIT_TRANSFORM && currentActor);
-
- Matrix worldMatrix;
- Vector3 localPosition;
- for(unsigned int i(descentList.size() - 1); i < descentList.size(); --i)
- {
- Vector3 anchorPoint = descentList[i].GetProperty<Vector3>(Dali::Actor::Property::ANCHOR_POINT);
- Vector3 parentOrigin = descentList[i].GetProperty<Vector3>(Dali::Actor::Property::PARENT_ORIGIN);
- bool positionUsesAnchorPoint = descentList[i].GetProperty<bool>(Dali::Actor::Property::POSITION_USES_ANCHOR_POINT);
- Vector3 size = descentList[i].GetProperty<Vector3>(Dali::Actor::Property::SIZE);
- Vector3 actorPosition = descentList[i].GetProperty<Vector3>(Dali::Actor::Property::POSITION);
- Quaternion localOrientation = descentList[i].GetProperty<Quaternion>(Dali::Actor::Property::ORIENTATION);
- Vector3 localScale = descentList[i].GetProperty<Vector3>(Dali::Actor::Property::SCALE);
-
- Vector3 centerPosition = CalculateCenterPosition(anchorPoint, positionUsesAnchorPoint, size, localScale, localOrientation);
- if(inheritanceModeList[i] != DONT_INHERIT_TRANSFORM && descentList[i].GetParent())
- {
- Matrix localMatrix;
- Vector3 parentSize = descentList[i + 1].GetProperty<Vector3>(Dali::Actor::Property::SIZE);
- if(inheritanceModeList[i] == INHERIT_ALL)
- {
- localPosition = actorPosition + centerPosition + (parentOrigin - Vector3(0.5f, 0.5f, 0.5f)) * parentSize;
- localMatrix.SetTransformComponents(localScale, localOrientation, localPosition);
-
- //Update the world matrix
- Matrix tempMatrix;
- Matrix::Multiply(tempMatrix, localMatrix, worldMatrix);
- worldMatrix = tempMatrix;
- }
- else
- {
- Vector3 parentPosition, parentScale;
- Quaternion parentOrientation;
- worldMatrix.GetTransformComponents(parentPosition, parentOrientation, parentScale);
-
- if((inheritanceModeList[i] & INHERIT_SCALE) == 0)
- {
- //Don't inherit scale
- localScale /= parentScale;
- }
-
- if((inheritanceModeList[i] & INHERIT_ORIENTATION) == 0)
- {
- //Don't inherit orientation
- parentOrientation.Invert();
- localOrientation = parentOrientation * localOrientation;
- }
-
- if((inheritanceModeList[i] & INHERIT_POSITION) == 0)
- {
- localMatrix.SetTransformComponents(localScale, localOrientation, Vector3::ZERO);
- Matrix tempMatrix;
- Matrix::Multiply(tempMatrix, localMatrix, worldMatrix);
- worldMatrix = tempMatrix;
- worldMatrix.SetTranslation(actorPosition + centerPosition);
- }
- else
- {
- localPosition = actorPosition + centerPosition + (parentOrigin - Vector3(0.5f, 0.5f, 0.5f)) * parentSize;
- localMatrix.SetTransformComponents(localScale, localOrientation, localPosition);
- Matrix tempMatrix;
- Matrix::Multiply(tempMatrix, localMatrix, worldMatrix);
- worldMatrix = tempMatrix;
- }
- }
- }
- else
- {
- localPosition = actorPosition + centerPosition;
- worldMatrix.SetTransformComponents(localScale, localOrientation, localPosition);
- }
- }
-
- return worldMatrix;
-}
-
-Vector4 TransitionBase::GetWorldColor(Dali::Actor actor)
-{
- std::vector<Dali::Actor> descentList;
- std::vector<Dali::ColorMode> inheritanceModeList;
- Dali::Actor currentActor = actor;
- Dali::ColorMode inheritance = Dali::ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA;
- do
- {
- inheritance = currentActor.GetProperty<Dali::ColorMode>(Dali::Actor::Property::COLOR_MODE);
- inheritanceModeList.push_back(inheritance);
- descentList.push_back(currentActor);
- currentActor = currentActor.GetParent();
- } while(inheritance != Dali::ColorMode::USE_OWN_COLOR && currentActor);
-
- Vector4 worldColor;
- for(unsigned int i(descentList.size() - 1); i < descentList.size(); --i)
- {
- if(inheritanceModeList[i] == USE_OWN_COLOR || i == descentList.size() - 1)
- {
- worldColor = descentList[i].GetProperty<Vector4>(Dali::Actor::Property::COLOR);
- }
- else if(inheritanceModeList[i] == USE_OWN_MULTIPLY_PARENT_ALPHA)
- {
- Vector4 ownColor = descentList[i].GetProperty<Vector4>(Dali::Actor::Property::COLOR);
- worldColor = Vector4(ownColor.r, ownColor.g, ownColor.b, ownColor.a * worldColor.a);
- }
- else if(inheritanceModeList[i] == USE_OWN_MULTIPLY_PARENT_COLOR)
- {
- Vector4 ownColor = descentList[i].GetProperty<Vector4>(Dali::Actor::Property::COLOR);
- worldColor *= ownColor;
- }
- }
-
- return worldColor;
-}
-