summaryrefslogtreecommitdiff
path: root/slideshow
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>2015-11-23 21:53:23 +0000
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2015-11-23 23:06:39 +0100
commit68ab250d73cc981fe3760f4e8671d3df3971ca05 (patch)
tree685cbcf75f24873c2f6f0b3158303929ee493ed7 /slideshow
parent6bc132f8bf85516b4a89386c371fdd3e9937b4bf (diff)
slideshow: Fix rotations when the slide and the screen have a different ratio
Change-Id: Ia6dcc352531a6bf067f3e87086cb275b00f81c97
Diffstat (limited to 'slideshow')
-rw-r--r--slideshow/source/engine/OGLTrans/generic/OGLTrans_Operation.cxx30
-rw-r--r--slideshow/source/engine/OGLTrans/generic/OGLTrans_Operation.hxx10
-rw-r--r--slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx24
3 files changed, 39 insertions, 25 deletions
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_Operation.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_Operation.cxx
index 7199a7e4d9d8..3709f3a72ed6 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_Operation.cxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_Operation.cxx
@@ -49,20 +49,22 @@ SScale::SScale(const glm::vec3& Scale, const glm::vec3& Origin,
}
RotateAndScaleDepthByWidth::RotateAndScaleDepthByWidth(const glm::vec3& Axis,
- const glm::vec3& Origin, double Angle, bool bInter, double T0, double T1):
+ const glm::vec3& Origin, double Angle, bool bScale, bool bInter, double T0, double T1):
Operation(bInter, T0, T1),
axis(Axis),
origin(Origin),
- angle(Angle)
+ angle(Angle),
+ scale(bScale)
{
}
RotateAndScaleDepthByHeight::RotateAndScaleDepthByHeight(const glm::vec3& Axis,
- const glm::vec3& Origin, double Angle, bool bInter, double T0, double T1):
+ const glm::vec3& Origin, double Angle, bool bScale, bool bInter, double T0, double T1):
Operation(bInter, T0, T1),
axis(Axis),
origin(Origin),
- angle(Angle)
+ angle(Angle),
+ scale(bScale)
{
}
@@ -98,15 +100,15 @@ makeSEllipseTranslate(double dWidth, double dHeight, double dStartPosition, doub
}
std::shared_ptr<RotateAndScaleDepthByWidth>
-makeRotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1)
+makeRotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1)
{
- return std::make_shared<RotateAndScaleDepthByWidth>(Axis, Origin, Angle, bInter, T0, T1);
+ return std::make_shared<RotateAndScaleDepthByWidth>(Axis, Origin, Angle, bScale, bInter, T0, T1);
}
std::shared_ptr<RotateAndScaleDepthByHeight>
-makeRotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1)
+makeRotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bScale, bool bInter, double T0, double T1)
{
- return std::make_shared<RotateAndScaleDepthByHeight>(Axis, Origin, Angle, bInter, T0, T1);
+ return std::make_shared<RotateAndScaleDepthByHeight>(Axis, Origin, Angle, bScale, bInter, T0, T1);
}
inline double intervalInter(double t, double T0, double T1)
@@ -132,7 +134,7 @@ void SRotate::interpolate(glm::mat4& matrix, double t, double SlideWidthScale, d
t = mnT1;
t = intervalInter(t,mnT0,mnT1);
glm::vec3 translation_vector(SlideWidthScale*origin.x, SlideHeightScale*origin.y, origin.z);
- glm::vec3 scale_vector(SlideWidthScale, SlideHeightScale, 1);
+ glm::vec3 scale_vector(SlideWidthScale * SlideWidthScale, SlideHeightScale * SlideHeightScale, 1);
matrix = glm::translate(matrix, translation_vector);
matrix = glm::scale(matrix, scale_vector);
matrix = glm::rotate(matrix, static_cast<float>(t*angle), axis);
@@ -161,8 +163,13 @@ void RotateAndScaleDepthByWidth::interpolate(glm::mat4& matrix, double t, double
t = mnT1;
t = intervalInter(t,mnT0,mnT1);
glm::vec3 translation_vector(SlideWidthScale*origin.x, SlideHeightScale*origin.y, SlideWidthScale*origin.z);
+ glm::vec3 scale_vector(SlideWidthScale * SlideWidthScale, SlideHeightScale * SlideHeightScale, 1);
matrix = glm::translate(matrix, translation_vector);
+ if (scale)
+ matrix = glm::scale(matrix, scale_vector);
matrix = glm::rotate(matrix, static_cast<float>(t*angle), axis);
+ if (scale)
+ matrix = glm::scale(matrix, 1.f / scale_vector);
matrix = glm::translate(matrix, -translation_vector);
}
@@ -174,8 +181,13 @@ void RotateAndScaleDepthByHeight::interpolate(glm::mat4& matrix, double t, doubl
t = mnT1;
t = intervalInter(t,mnT0,mnT1);
glm::vec3 translation_vector(SlideWidthScale*origin.x, SlideHeightScale*origin.y, SlideHeightScale*origin.z);
+ glm::vec3 scale_vector(SlideWidthScale * SlideWidthScale, SlideHeightScale * SlideHeightScale, 1);
matrix = glm::translate(matrix, translation_vector);
+ if (scale)
+ matrix = glm::scale(matrix, scale_vector);
matrix = glm::rotate(matrix, static_cast<float>(t*angle), axis);
+ if (scale)
+ matrix = glm::scale(matrix, 1.f / scale_vector);
matrix = glm::translate(matrix, -translation_vector);
}
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_Operation.hxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_Operation.hxx
index bf657d00d3ee..df058c24626c 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_Operation.hxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_Operation.hxx
@@ -236,16 +236,17 @@ class RotateAndScaleDepthByWidth: public Operation
public:
virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
- RotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1);
+ RotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1);
virtual ~RotateAndScaleDepthByWidth(){}
private:
glm::vec3 axis;
glm::vec3 origin;
double angle;
+ bool scale;
};
std::shared_ptr<RotateAndScaleDepthByWidth>
-makeRotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1);
+makeRotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1);
/** Same as SRotate, except the depth is scaled by the width of the slide divided by the height of the window.
*/
@@ -254,16 +255,17 @@ class RotateAndScaleDepthByHeight: public Operation
public:
virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
- RotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1);
+ RotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1);
virtual ~RotateAndScaleDepthByHeight(){}
private:
glm::vec3 axis;
glm::vec3 origin;
double angle;
+ bool scale;
};
std::shared_ptr<RotateAndScaleDepthByHeight>
-makeRotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1);
+makeRotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1);
#endif // INCLUDED_SLIDESHOW_OPERATIONS_HXX_
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
index a9991f144309..ab44f3dca01c 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
@@ -535,13 +535,13 @@ std::shared_ptr<OGLTransitionImpl> makeOutsideCubeFaceToLeft()
Primitives_t aLeavingPrimitives;
aLeavingPrimitives.push_back(Slide);
- Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,-1),90,false,0.0,1.0));
+ Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,-1),90,false,false,0.0,1.0));
Primitives_t aEnteringPrimitives;
aEnteringPrimitives.push_back(Slide);
Operations_t aOperations;
- aOperations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,-1),-90,true,0.0,1.0));
+ aOperations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,-1),-90,false,true,0.0,1.0));
return makeSimpleTransition(aLeavingPrimitives, aEnteringPrimitives, aOperations);
}
@@ -556,13 +556,13 @@ std::shared_ptr<OGLTransitionImpl> makeInsideCubeFaceToLeft()
Primitives_t aLeavingPrimitives;
aLeavingPrimitives.push_back(Slide);
- Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,1),-90,false,0.0,1.0));
+ Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,1),-90,false,false,0.0,1.0));
Primitives_t aEnteringPrimitives;
aEnteringPrimitives.push_back(Slide);
Operations_t aOperations;
- aOperations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,1),90,true,0.0,1.0));
+ aOperations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,1),90,false,true,0.0,1.0));
return makeSimpleTransition(aLeavingPrimitives, aEnteringPrimitives, aOperations);
}
@@ -577,7 +577,7 @@ std::shared_ptr<OGLTransitionImpl> makeFallLeaving()
Primitives_t aEnteringPrimitives;
aEnteringPrimitives.push_back(Slide);
- Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(1,0,0),glm::vec3(0,-1,0), 90,true,0.0,1.0));
+ Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(1,0,0),glm::vec3(0,-1,0), 90,true,true,0.0,1.0));
Primitives_t aLeavingPrimitives;
aLeavingPrimitives.push_back(Slide);
@@ -602,7 +602,7 @@ std::shared_ptr<OGLTransitionImpl> makeTurnAround()
aLeavingPrimitives.push_back(Slide);
Slide.Operations.clear();
- Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,0),-180,false,0.0,1.0));
+ Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,0),-180,true,false,0.0,1.0));
Primitives_t aEnteringPrimitives;
aEnteringPrimitives.push_back(Slide);
@@ -612,7 +612,7 @@ std::shared_ptr<OGLTransitionImpl> makeTurnAround()
Operations_t aOperations;
aOperations.push_back(makeSTranslate(glm::vec3(0, 0, -1.5),true, 0, 0.5));
aOperations.push_back(makeSTranslate(glm::vec3(0, 0, 1.5), true, 0.5, 1));
- aOperations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0, 1, 0),glm::vec3(0, 0, 0), -180, true, 0.0, 1.0));
+ aOperations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0, 1, 0),glm::vec3(0, 0, 0), -180, true, true, 0.0, 1.0));
return makeReflectionTransition(aLeavingPrimitives, aEnteringPrimitives, aOperations, aSettings);
}
@@ -767,7 +767,7 @@ std::shared_ptr<OGLTransitionImpl> makeRochade()
Slide.pushTriangle(glm::vec2(1,0),glm::vec2(0,1),glm::vec2(1,1));
Slide.Operations.push_back(makeSEllipseTranslate(w, h, 0.25, -0.25, true, 0, 1));
- Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,0), -45, true, 0, 1));
+ Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,0), -45, true, true, 0, 1));
Primitives_t aLeavingSlide;
aLeavingSlide.push_back(Slide);
@@ -777,8 +777,8 @@ std::shared_ptr<OGLTransitionImpl> makeRochade()
Slide.Operations.clear();
Slide.Operations.push_back(makeSEllipseTranslate(w, h, 0.75, 0.25, true, 0, 1));
Slide.Operations.push_back(makeSTranslate(glm::vec3(0, 0, -h), false, -1, 0));
- Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,0), -45, true, 0, 1));
- Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,0), 45, false, -1, 0));
+ Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,0), -45, true, true, 0, 1));
+ Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0,1,0),glm::vec3(0,0,0), 45, true, false, -1, 0));
Primitives_t aEnteringSlide;
aEnteringSlide.push_back(Slide);
@@ -1129,11 +1129,11 @@ std::shared_ptr<OGLTransitionImpl> makeVenetianBlinds( bool vertical, int parts
if( vertical ) {
Slide.pushTriangle (glm::vec2 (ln,0), glm::vec2 (n,0), glm::vec2 (ln,1));
Slide.pushTriangle (glm::vec2 (n,0), glm::vec2 (ln,1), glm::vec2 (n,1));
- Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0, 1, 0), glm::vec3(n + ln - 1, 0, -t30*p), -120, true, 0.0, 1.0));
+ Slide.Operations.push_back(makeRotateAndScaleDepthByWidth(glm::vec3(0, 1, 0), glm::vec3(n + ln - 1, 0, -t30*p), -120, true, true, 0.0, 1.0));
} else {
Slide.pushTriangle (glm::vec2 (0,ln), glm::vec2 (1,ln), glm::vec2 (0,n));
Slide.pushTriangle (glm::vec2 (1,ln), glm::vec2 (0,n), glm::vec2 (1,n));
- Slide.Operations.push_back(makeRotateAndScaleDepthByHeight(glm::vec3(1, 0, 0), glm::vec3(0, 1 - n - ln, -t30*p), -120, true, 0.0, 1.0));
+ Slide.Operations.push_back(makeRotateAndScaleDepthByHeight(glm::vec3(1, 0, 0), glm::vec3(0, 1 - n - ln, -t30*p), -120, true, true, 0.0, 1.0));
}
aLeavingSlide.push_back (Slide);