1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OGLTrans_TransitionImpl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "OGLTrans_TransitionImpl.hxx"
32 #include "OGLTrans_Shaders.hxx"
37 void OGLTransitionImpl::clear()
39 for(unsigned int i( 0 ); i
< OverallOperations
.size(); ++i
)
40 delete OverallOperations
[i
];
41 OverallOperations
.clear();
42 maLeavingSlidePrimitives
.clear();
43 maEnteringSlidePrimitives
.clear();
44 for(unsigned int i(0); i
< maSceneObjects
.size(); ++i
)
45 delete maSceneObjects
[i
];
46 maSceneObjects
.clear();
48 mbReflectSlides
= false;
51 if( mProgramObject
) {
52 OGLShaders::glDeleteProgram( mProgramObject
);
57 OGLShaders::glDeleteShader( mVertexObject
);
61 if( mFragmentObject
) {
62 OGLShaders::glDeleteShader( mFragmentObject
);
67 if( maHelperTexture
) {
68 glDeleteTextures( 1, &maHelperTexture
);
72 if( mmClearTransition
)
73 (this->*mmClearTransition
)();
76 OGLTransitionImpl::~OGLTransitionImpl()
81 void OGLTransitionImpl::prepare( ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
)
83 for(unsigned int i(0); i
< maSceneObjects
.size(); ++i
) {
84 maSceneObjects
[i
]->prepare();
87 if( mmPrepareTransition
)
88 (this->*mmPrepareTransition
)( glLeavingSlideTex
, glEnteringSlideTex
);
91 void OGLTransitionImpl::finish()
93 for(unsigned int i(0); i
< maSceneObjects
.size(); ++i
) {
94 maSceneObjects
[i
]->finish();
98 static void blendSlide( double depth
)
100 double showHeight
= -1 + depth
*2;
101 GLfloat reflectionColor
[] = {0, 0, 0, 0.25};
103 glDisable( GL_DEPTH_TEST
);
105 glColor4fv( reflectionColor
);
106 glVertex3f( -1, -1, 0 );
107 glColor4f( 0, 0, 0, 1 );
108 glVertex3f(-1, showHeight
, 0 );
109 glVertex3f( 1, showHeight
, 0 );
110 glColor4fv( reflectionColor
);
111 glVertex3f( 1, -1, 0 );
115 glColor4f( 0, 0, 0, 1 );
116 glVertex3f( -1, showHeight
, 0 );
117 glVertex3f( -1, 1, 0 );
118 glVertex3f( 1, 1, 0 );
119 glVertex3f( 1, showHeight
, 0 );
121 glEnable( GL_DEPTH_TEST
);
124 static void slideShadow( double nTime
, Primitive
& primitive
, double sw
, double sh
)
126 double reflectionDepth
= 0.3;
129 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
130 glDisable(GL_LIGHTING
);
133 primitive
.applyOperations( nTime
, sw
, sh
);
134 blendSlide( reflectionDepth
);
138 glEnable(GL_LIGHTING
);
141 void OGLTransitionImpl::display( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
,
142 double SlideWidth
, double SlideHeight
, double DispWidth
, double DispHeight
)
144 double SlideWidthScale
, SlideHeightScale
;
146 SlideWidthScale
= SlideWidth
/DispWidth
;
147 SlideHeightScale
= SlideHeight
/DispHeight
;
151 (this->*mmPrepare
)( nTime
, SlideWidth
, SlideHeight
, DispWidth
, DispHeight
);
155 displaySlides( nTime
, glLeavingSlideTex
, glEnteringSlideTex
, SlideWidthScale
, SlideHeightScale
);
156 displayScene( nTime
, SlideWidth
, SlideHeight
, DispWidth
, DispHeight
);
160 void OGLTransitionImpl::applyOverallOperations( double nTime
, double SlideWidthScale
, double SlideHeightScale
)
162 for(unsigned int i(0); i
< OverallOperations
.size(); ++i
)
163 OverallOperations
[i
]->interpolate(nTime
,SlideWidthScale
,SlideHeightScale
);
166 void OGLTransitionImpl::displaySlide( double nTime
, ::sal_Int32 glSlideTex
, std::vector
<Primitive
>& primitives
,
167 double SlideWidthScale
, double SlideHeightScale
)
169 //TODO change to foreach
170 glBindTexture(GL_TEXTURE_2D
, glSlideTex
);
172 // display slide reflection
173 // note that depth test is turned off while blending the shadow
174 // so the slides has to be rendered in right order, see rochade as example
175 if( mbReflectSlides
) {
176 double surfaceLevel
= -0.04;
178 /* reflected slides */
181 glScaled( 1, -1, 1 );
182 glTranslated( 0, 2 - surfaceLevel
, 0 );
184 glCullFace(GL_FRONT
);
185 for(unsigned int i(0); i
< primitives
.size(); ++i
)
186 primitives
[i
].display(nTime
, SlideWidthScale
, SlideHeightScale
);
189 slideShadow( nTime
, primitives
[0], SlideWidthScale
, SlideHeightScale
);
194 for(unsigned int i(0); i
< primitives
.size(); ++i
)
195 primitives
[i
].display(nTime
, SlideWidthScale
, SlideHeightScale
);
198 void OGLTransitionImpl::displaySlides( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
,
199 double SlideWidthScale
, double SlideHeightScale
)
201 if( mmDisplaySlides
)
202 (this->*mmDisplaySlides
)( nTime
, glLeavingSlideTex
, glEnteringSlideTex
, SlideWidthScale
, SlideHeightScale
);
204 applyOverallOperations( nTime
, SlideWidthScale
, SlideHeightScale
);
206 glEnable(GL_TEXTURE_2D
);
207 displaySlide( nTime
, glLeavingSlideTex
, maLeavingSlidePrimitives
, SlideWidthScale
, SlideHeightScale
);
208 displaySlide( nTime
, glEnteringSlideTex
, maEnteringSlidePrimitives
, SlideWidthScale
, SlideHeightScale
);
212 void OGLTransitionImpl::displayScene( double nTime
, double SlideWidth
, double SlideHeight
, double DispWidth
, double DispHeight
)
214 glEnable(GL_TEXTURE_2D
);
215 for(unsigned int i(0); i
< maSceneObjects
.size(); ++i
)
216 maSceneObjects
[i
]->display(nTime
, SlideWidth
, SlideHeight
, DispWidth
, DispHeight
);
219 void Primitive::display(double nTime
, double WidthScale
, double HeightScale
)
223 applyOperations( nTime
, WidthScale
, HeightScale
);
225 glEnableClientState( GL_VERTEX_ARRAY
);
228 glNormalPointer( GL_DOUBLE
, 0 , &Normals
[0] );
229 glEnableClientState( GL_NORMAL_ARRAY
);
231 glEnableClientState( GL_TEXTURE_COORD_ARRAY
);
232 glTexCoordPointer( 2, GL_DOUBLE
, 0, &TexCoords
[0] );
233 glVertexPointer( 3, GL_DOUBLE
, 0, &Vertices
[0] );
234 glDrawArrays( GL_TRIANGLES
, 0, Vertices
.size() );
238 void Primitive::applyOperations(double nTime
, double WidthScale
, double HeightScale
)
240 for(unsigned int i(0); i
< Operations
.size(); ++i
)
241 Operations
[i
]->interpolate( nTime
,WidthScale
,HeightScale
);
242 glScaled(WidthScale
,HeightScale
,1);
245 Primitive::~Primitive()
247 for(unsigned int i( 0 ); i
< Operations
.size(); ++i
)
248 delete Operations
[i
];
252 void SceneObject::display(double nTime
, double /* SlideWidth */, double /* SlideHeight */, double DispWidth
, double DispHeight
)
254 for(unsigned int i(0); i
< maPrimitives
.size(); ++i
) {
255 // fixme: allow various model spaces, now we make it so that
256 // it is regular -1,-1 to 1,1, where the whole display fits in
258 if (DispHeight
> DispWidth
)
259 glScaled(DispHeight
/DispWidth
, 1, 1);
261 glScaled(1, DispWidth
/DispHeight
, 1);
262 maPrimitives
[i
].display(nTime
, 1, 1);
267 void SceneObject::pushPrimitive(const Primitive
&p
)
269 maPrimitives
.push_back(p
);
272 SceneObject::SceneObject()
282 void Iris::display(double nTime
, double SlideWidth
, double SlideHeight
, double DispWidth
, double DispHeight
)
284 glBindTexture(GL_TEXTURE_2D
, maTexture
);
285 SceneObject::display(nTime
, SlideWidth
, SlideHeight
, DispWidth
, DispHeight
);
290 static GLubyte img
[3] = { 80, 80, 80 };
292 glGenTextures(1, &maTexture
);
293 glBindTexture(GL_TEXTURE_2D
, maTexture
);
294 glTexImage2D(GL_TEXTURE_2D
, 0, 3, 1, 1, 0, GL_RGB
, GL_UNSIGNED_BYTE
, img
);
295 glTexParameteri(GL_TEXTURE_2D
,GL_TEXTURE_WRAP_S
,GL_REPEAT
);
296 glTexParameteri(GL_TEXTURE_2D
,GL_TEXTURE_WRAP_T
,GL_REPEAT
);
297 glTexParameteri(GL_TEXTURE_2D
,GL_TEXTURE_MAG_FILTER
,GL_LINEAR
);
298 glTexParameteri(GL_TEXTURE_2D
,GL_TEXTURE_MIN_FILTER
,GL_LINEAR
);
303 glDeleteTextures(1, &maTexture
);
306 void OGLTransitionImpl::makeOutsideCubeFaceToLeft()
311 Slide
.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
312 Slide
.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
314 maLeavingSlidePrimitives
.push_back(Slide
);
316 Slide
.Operations
.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,-1),90,false,0.0,1.0));
318 maEnteringSlidePrimitives
.push_back(Slide
);
320 OverallOperations
.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,-1),-90,true,0.0,1.0));
323 void OGLTransitionImpl::makeInsideCubeFaceToLeft()
328 Slide
.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
329 Slide
.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
331 maLeavingSlidePrimitives
.push_back(Slide
);
333 Slide
.Operations
.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,1),-90,false,0.0,1.0));
335 maEnteringSlidePrimitives
.push_back(Slide
);
337 OverallOperations
.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,1),90,true,0.0,1.0));
340 void OGLTransitionImpl::makeFallLeaving()
345 Slide
.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
346 Slide
.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
347 maEnteringSlidePrimitives
.push_back(Slide
);
349 Slide
.Operations
.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(1,0,0),basegfx::B3DVector(0,-1,0), 90,true,0.0,1.0));
350 maLeavingSlidePrimitives
.push_back(Slide
);
352 mbUseMipMapEntering
= false;
355 void OGLTransitionImpl::makeTurnAround()
360 mbReflectSlides
= true;
362 Slide
.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
363 Slide
.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
364 maLeavingSlidePrimitives
.push_back(Slide
);
366 Slide
.Operations
.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,0),-180,false,0.0,1.0));
367 maEnteringSlidePrimitives
.push_back(Slide
);
369 OverallOperations
.push_back(new STranslate(basegfx::B3DVector(0, 0, -1.5),true, 0, 0.5));
370 OverallOperations
.push_back(new STranslate(basegfx::B3DVector(0, 0, 1.5), true, 0.5, 1));
371 OverallOperations
.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0, 1, 0),basegfx::B3DVector(0, 0, 0), -180, true, 0.0, 1.0));
374 void OGLTransitionImpl::makeTurnDown()
379 Slide
.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
380 Slide
.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
381 maLeavingSlidePrimitives
.push_back(Slide
);
383 Slide
.Operations
.push_back(new STranslate(basegfx::B3DVector(0, 0, 0.0001), false, -1.0, 0.0));
384 Slide
.Operations
.push_back(new SRotate (basegfx::B3DVector(0, 0, 1), basegfx::B3DVector(-1, 1, 0), -90, true, 0.0, 1.0));
385 Slide
.Operations
.push_back(new SRotate (basegfx::B3DVector(0, 0, 1), basegfx::B3DVector(-1, 1, 0), 90, false, -1.0, 0.0));
386 maEnteringSlidePrimitives
.push_back(Slide
);
388 mbUseMipMapLeaving
= false;
391 void OGLTransitionImpl::makeIris()
396 Slide
.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
397 Slide
.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
398 maEnteringSlidePrimitives
.push_back (Slide
);
400 Slide
.Operations
.push_back (new STranslate (basegfx::B3DVector (0, 0, 0.000001), false, -1, 0));
401 Slide
.Operations
.push_back (new STranslate (basegfx::B3DVector (0, 0, -0.000002), false, 0.5, 1));
402 maLeavingSlidePrimitives
.push_back (Slide
);
405 Primitive irisPart
, part
;
406 int i
, nSteps
= 24, nParts
= 7;
407 double lt
= 0, t
= 1.0/nSteps
, cx
, cy
, lcx
, lcy
, lx
= 1, ly
= 0, x
, y
, cxo
, cyo
, lcxo
, lcyo
, of
=2.2, f
=1.42;
409 for (i
=1; i
<=nSteps
; i
++) {
410 x
= cos ((3*2*M_PI
*t
)/nParts
);
411 y
= -sin ((3*2*M_PI
*t
)/nParts
);
418 lcxo
= (of
*lx
+ 1)/2;
419 lcyo
= (of
*ly
+ 1)/2;
420 irisPart
.pushTriangle (basegfx::B2DVector (lcx
, lcy
),
421 basegfx::B2DVector (lcxo
, lcyo
),
422 basegfx::B2DVector (cx
, cy
));
423 irisPart
.pushTriangle (basegfx::B2DVector (cx
, cy
),
424 basegfx::B2DVector (lcxo
, lcyo
),
425 basegfx::B2DVector (cxo
, cyo
));
432 Iris
* pIris
= new Iris();
435 for (i
= 0; i
< nParts
; i
++) {
436 irisPart
.Operations
.clear ();
439 rx
= cos ((2*M_PI
*i
)/nParts
);
440 ry
= sin ((2*M_PI
*i
)/nParts
);
441 irisPart
.Operations
.push_back (new SRotate (basegfx::B3DVector(0, 0, 1), basegfx::B3DVector(rx
, ry
, 0), angle
, true, 0.0, 0.5));
442 irisPart
.Operations
.push_back (new SRotate (basegfx::B3DVector(0, 0, 1), basegfx::B3DVector(rx
, ry
, 0), -angle
, true, 0.5, 1));
444 irisPart
.Operations
.push_back (new STranslate (basegfx::B3DVector(rx
, ry
, 0), false, -1, 0));
445 irisPart
.Operations
.push_back (new SRotate (basegfx::B3DVector(0, 0, 1), basegfx::B3DVector(0, 0, 0), i
*360.0/nParts
, false, -1, 0));
446 irisPart
.Operations
.push_back (new STranslate (basegfx::B3DVector(-1, 0, 0), false, -1, 0));
448 irisPart
.Operations
.push_back(new STranslate(basegfx::B3DVector(0, 0, 1), false, -2, 0.0));
449 irisPart
.Operations
.push_back (new SRotate (basegfx::B3DVector(1, .5, 0), basegfx::B3DVector(1, 0, 0), -30, false, -1, 0));
450 pIris
->pushPrimitive (irisPart
);
453 maSceneObjects
.push_back (pIris
);
455 mbUseMipMapLeaving
= mbUseMipMapEntering
= false;
458 void OGLTransitionImpl::displaySlidesRochade( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
,
459 double SlideWidthScale
, double SlideHeightScale
)
461 applyOverallOperations( nTime
, SlideWidthScale
, SlideHeightScale
);
463 glEnable(GL_TEXTURE_2D
);
466 displaySlide( nTime
, glLeavingSlideTex
, maLeavingSlidePrimitives
, SlideWidthScale
, SlideHeightScale
);
467 displaySlide( nTime
, glEnteringSlideTex
, maEnteringSlidePrimitives
, SlideWidthScale
, SlideHeightScale
);
469 displaySlide( nTime
, glEnteringSlideTex
, maEnteringSlidePrimitives
, SlideWidthScale
, SlideHeightScale
);
470 displaySlide( nTime
, glLeavingSlideTex
, maLeavingSlidePrimitives
, SlideWidthScale
, SlideHeightScale
);
474 void OGLTransitionImpl::makeRochade()
479 mbReflectSlides
= true;
480 mmDisplaySlides
= &OGLTransitionImpl::displaySlidesRochade
;
487 Slide
.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
488 Slide
.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
490 Slide
.Operations
.push_back(new SEllipseTranslate(w
, h
, 0.25, -0.25, true, 0, 1));
491 Slide
.Operations
.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,0), -45, true, 0, 1));
492 maLeavingSlidePrimitives
.push_back(Slide
);
494 Slide
.Operations
.clear();
495 Slide
.Operations
.push_back(new SEllipseTranslate(w
, h
, 0.75, 0.25, true, 0, 1));
496 Slide
.Operations
.push_back(new STranslate(basegfx::B3DVector(0, 0, -h
), false, -1, 0));
497 Slide
.Operations
.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,0), -45, true, 0, 1));
498 Slide
.Operations
.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0,1,0),basegfx::B3DVector(0,0,0), 45, false, -1, 0));
499 maEnteringSlidePrimitives
.push_back(Slide
);
501 // OverallOperations.push_back(new SEllipseTranslate(0.5, 2, 0, 1, true, 0, 1));
502 // push_back(new STranslate(basegfx::B3DVector(0, 0, -2), true, 0, 0.5));
503 // OverallOperations.push_back(new STranslate(basegfx::B3DVector(0, 0, 2), true, 0.5, 1));
506 // TODO(Q3): extract to basegfx
507 inline basegfx::B2DVector
clamp(const basegfx::B2DVector
& v
)
509 return basegfx::B2DVector(min(max(v
.getX(),-1.0),1.0),
510 min(max(v
.getY(),-1.0),1.0));
513 // TODO(Q3): extract to basegfx
514 inline basegfx::B3DVector
clamp(const basegfx::B3DVector
& v
)
516 return basegfx::B3DVector(min(max(v
.getX(),-1.0),1.0),
517 min(max(v
.getY(),-1.0),1.0),
518 min(max(v
.getZ(),-1.0),1.0));
521 inline double randFromNeg1to1()
523 return ( ( static_cast<double>( rand() ) / static_cast<double>( RAND_MAX
) ) * 2.0 ) - 1.0;
526 // TODO(Q3): extract to basegfx
527 inline basegfx::B3DVector
randNormVectorInXYPlane()
529 basegfx::B3DVector
toReturn(randFromNeg1to1(),randFromNeg1to1(),0.0);
530 return toReturn
/toReturn
.getLength();
533 void OGLTransitionImpl::makeRevolvingCircles( ::sal_uInt16 nCircles
, ::sal_uInt16 nPointsOnCircles
)
536 double dAngle(2*3.1415926/static_cast<double>( nPointsOnCircles
));
537 if(nCircles
< 2 || nPointsOnCircles
< 4)
539 makeNByMTileFlip(1,1);
542 double Radius(1.0/static_cast<double>( nCircles
));
543 double dRadius(Radius
);
544 double LastRadius(0.0);
545 double NextRadius(2*Radius
);
547 /// now we know there is at least two circles
548 /// the first will always be a full circle
549 /// the last will always be the outer shell of the slide with a circle hole
551 //add the full circle
552 vector
<basegfx::B2DVector
> unScaledTexCoords
;
553 double TempAngle(0.0);
554 for(unsigned int Point(0); Point
< nPointsOnCircles
; ++Point
)
556 unScaledTexCoords
.push_back( basegfx::B2DVector( cos(TempAngle
- 3.1415926/2.0) , sin(TempAngle
- 3.1415926/2.0) ) );
563 Primitive EnteringSlide
;
564 Primitive LeavingSlide
;
565 for(int Point(0); Point
+ 1 < nPointsOnCircles
; ++Point
)
567 EnteringSlide
.pushTriangle( basegfx::B2DVector( 0.5 , 0.5 ) , Radius
* unScaledTexCoords
[ Point
+ 1 ] / 2.0 + basegfx::B2DVector( 0.5 , 0.5 ) , Radius
* unScaledTexCoords
[ Point
] / 2.0 + basegfx::B2DVector( 0.5 , 0.5 ) );
568 LeavingSlide
.pushTriangle( basegfx::B2DVector( 0.5 , 0.5 ) , Radius
* unScaledTexCoords
[ Point
+ 1 ] / 2.0 + basegfx::B2DVector( 0.5 , 0.5 ) , Radius
* unScaledTexCoords
[ Point
] / 2.0 + basegfx::B2DVector( 0.5, 0.5) );
570 EnteringSlide
.pushTriangle( basegfx::B2DVector(0.5,0.5) , Radius
* unScaledTexCoords
[ 0 ] / 2.0 + basegfx::B2DVector( 0.5 , 0.5 ) , Radius
* unScaledTexCoords
[ nPointsOnCircles
- 1 ] / 2.0 + basegfx::B2DVector( 0.5 , 0.5 ) );
571 LeavingSlide
.pushTriangle( basegfx::B2DVector(0.5,0.5) , Radius
*unScaledTexCoords
[0]/2.0 + basegfx::B2DVector(0.5,0.5) , Radius
*unScaledTexCoords
[nPointsOnCircles
- 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
573 basegfx::B3DVector
axis(randNormVectorInXYPlane());
574 EnteringSlide
.Operations
.push_back( new SRotate( axis
, basegfx::B3DVector(0,0,0) , 180, true, Radius
/2.0 , (NextRadius
+ 1)/2.0 ) );
575 LeavingSlide
.Operations
.push_back( new SRotate( axis
, basegfx::B3DVector(0,0,0) , 180, true, Radius
/2.0 , (NextRadius
+ 1)/2.0 ) );
576 EnteringSlide
.Operations
.push_back( new SRotate( axis
, basegfx::B3DVector(0,0,0) , -180, false,0.0,1.0) );
578 maEnteringSlidePrimitives
.push_back(EnteringSlide
);
579 maLeavingSlidePrimitives
.push_back(LeavingSlide
);
582 NextRadius
+= dRadius
;
585 for(int i(1); i
< nCircles
- 1; ++i
)
587 Primitive LeavingSlide
;
588 Primitive EnteringSlide
;
589 for(int Side(0); Side
< nPointsOnCircles
- 1; ++Side
)
591 EnteringSlide
.pushTriangle(Radius
*unScaledTexCoords
[Side
]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[Side
]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[Side
+ 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
592 EnteringSlide
.pushTriangle(Radius
*unScaledTexCoords
[Side
]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[Side
+ 1]/2.0 + basegfx::B2DVector(0.5,0.5) , Radius
*unScaledTexCoords
[Side
+ 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
594 LeavingSlide
.pushTriangle(Radius
*unScaledTexCoords
[Side
]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[Side
]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[Side
+ 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
595 LeavingSlide
.pushTriangle(Radius
*unScaledTexCoords
[Side
]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[Side
+ 1]/2.0 + basegfx::B2DVector(0.5,0.5) , Radius
*unScaledTexCoords
[Side
+ 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
598 EnteringSlide
.pushTriangle(Radius
*unScaledTexCoords
[nPointsOnCircles
- 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[nPointsOnCircles
- 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[0]/2.0 + basegfx::B2DVector(0.5,0.5) );
599 EnteringSlide
.pushTriangle(Radius
*unScaledTexCoords
[nPointsOnCircles
- 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[0]/2.0 + basegfx::B2DVector(0.5,0.5) , Radius
*unScaledTexCoords
[0]/2.0 + basegfx::B2DVector(0.5,0.5) );
601 LeavingSlide
.pushTriangle(Radius
*unScaledTexCoords
[nPointsOnCircles
- 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[nPointsOnCircles
- 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[0]/2.0 + basegfx::B2DVector(0.5,0.5) );
602 LeavingSlide
.pushTriangle(Radius
*unScaledTexCoords
[nPointsOnCircles
- 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[0]/2.0 + basegfx::B2DVector(0.5,0.5) , Radius
*unScaledTexCoords
[0]/2.0 + basegfx::B2DVector(0.5,0.5) );
604 basegfx::B3DVector
axis(randNormVectorInXYPlane());
605 EnteringSlide
.Operations
.push_back( new SRotate( axis
, basegfx::B3DVector(0,0,0) , 180, true, Radius
/2.0 , (NextRadius
+ 1)/2.0 ) );
606 LeavingSlide
.Operations
.push_back( new SRotate( axis
, basegfx::B3DVector(0,0,0) , 180, true, Radius
/2.0 , (NextRadius
+ 1)/2.0 ) );
607 EnteringSlide
.Operations
.push_back( new SRotate( axis
, basegfx::B3DVector(0,0,0) , -180, false,0.0,1.0) );
609 maEnteringSlidePrimitives
.push_back(EnteringSlide
);
610 maLeavingSlidePrimitives
.push_back(LeavingSlide
);
614 NextRadius
+= dRadius
;
618 Primitive LeavingSlide
;
619 Primitive EnteringSlide
;
620 for(int Side(0); Side
< nPointsOnCircles
- 1; ++Side
)
623 EnteringSlide
.pushTriangle(clamp(Radius
*unScaledTexCoords
[Side
])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[Side
]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[Side
+ 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
624 EnteringSlide
.pushTriangle(clamp(Radius
*unScaledTexCoords
[Side
])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[Side
+ 1]/2.0 + basegfx::B2DVector(0.5,0.5) , clamp(Radius
*unScaledTexCoords
[Side
+ 1])/2.0 + basegfx::B2DVector(0.5,0.5) );
626 LeavingSlide
.pushTriangle(clamp(Radius
*unScaledTexCoords
[Side
])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[Side
]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[Side
+ 1]/2.0 + basegfx::B2DVector(0.5,0.5) );
627 LeavingSlide
.pushTriangle(clamp(Radius
*unScaledTexCoords
[Side
])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[Side
+ 1]/2.0 + basegfx::B2DVector(0.5,0.5) , clamp(Radius
*unScaledTexCoords
[Side
+ 1])/2.0 + basegfx::B2DVector(0.5,0.5) );
630 EnteringSlide
.pushTriangle(clamp(Radius
*unScaledTexCoords
[nPointsOnCircles
- 1])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[nPointsOnCircles
- 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[0]/2.0 + basegfx::B2DVector(0.5,0.5) );
631 EnteringSlide
.pushTriangle(clamp(Radius
*unScaledTexCoords
[nPointsOnCircles
- 1])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[0]/2.0 + basegfx::B2DVector(0.5,0.5) , clamp(Radius
*unScaledTexCoords
[0])/2.0 + basegfx::B2DVector(0.5,0.5) );
633 LeavingSlide
.pushTriangle(clamp(Radius
*unScaledTexCoords
[nPointsOnCircles
- 1])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[nPointsOnCircles
- 1]/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[0]/2.0 + basegfx::B2DVector(0.5,0.5) );
634 LeavingSlide
.pushTriangle(clamp(Radius
*unScaledTexCoords
[nPointsOnCircles
- 1])/2.0 + basegfx::B2DVector(0.5,0.5) , LastRadius
*unScaledTexCoords
[0]/2.0 + basegfx::B2DVector(0.5,0.5) , clamp(Radius
*unScaledTexCoords
[0])/2.0 + basegfx::B2DVector(0.5,0.5) );
636 basegfx::B3DVector
axis(randNormVectorInXYPlane());
637 EnteringSlide
.Operations
.push_back( new SRotate( axis
, basegfx::B3DVector(0,0,0) , 180, true, (LastRadius
+ dRadius
)/2.0 , 1.0 ) );
638 LeavingSlide
.Operations
.push_back( new SRotate( axis
, basegfx::B3DVector(0,0,0) , 180, true, (LastRadius
+ dRadius
)/2.0 , 1.0 ) );
639 EnteringSlide
.Operations
.push_back( new SRotate( axis
, basegfx::B3DVector(0,0,0) , -180, false,0.0,1.0) );
641 maEnteringSlidePrimitives
.push_back(EnteringSlide
);
642 maLeavingSlidePrimitives
.push_back(LeavingSlide
);
646 void OGLTransitionImpl::makeHelix( ::sal_uInt16 nRows
)
649 double invN(1.0/static_cast<double>(nRows
));
652 for(unsigned int i(0); i
< nRows
; ++i
)
656 Tile
.pushTriangle(basegfx::B2DVector( 1.0 , iDn
) , basegfx::B2DVector( 0.0 , iDn
) , basegfx::B2DVector( 0.0 , iPDn
));
658 Tile
.pushTriangle(basegfx::B2DVector( 1.0 , iPDn
) , basegfx::B2DVector( 1.0 , iDn
) , basegfx::B2DVector( 0.0 , iPDn
));
660 Tile
.Operations
.push_back( new SRotate( basegfx::B3DVector( 0 , 1 , 0 ) , ( Tile
.getVertices()[1] + Tile
.getVertices()[3] )/2.0 , 180 ,
661 true,min(max(static_cast<double>(i
- nRows
/2.0)*invN
/2.0,0.0),1.0),
662 min(max(static_cast<double>(i
+ nRows
/2.0)*invN
/2.0,0.0),1.0) ) );
664 maLeavingSlidePrimitives
.push_back(Tile
);
666 Tile
.Operations
.push_back( new SRotate( basegfx::B3DVector( 0 , 1 , 0 ) , ( Tile
.getVertices()[1] + Tile
.getVertices()[3] )/2.0 , -180 , false,0.0,1.0) );
668 maEnteringSlidePrimitives
.push_back(Tile
);
675 void OGLTransitionImpl::makeNByMTileFlip( ::sal_uInt16 n
, ::sal_uInt16 m
)
678 double invN(1.0/static_cast<double>(n
));
679 double invM(1.0/static_cast<double>(m
));
682 for(unsigned int i(0); i
< n
; ++i
)
686 for(unsigned int j(0); j
< m
; ++j
)
690 Tile
.pushTriangle(basegfx::B2DVector( iPDn
, jDm
) , basegfx::B2DVector( iDn
, jDm
) , basegfx::B2DVector( iDn
, jPDm
));
692 Tile
.pushTriangle(basegfx::B2DVector( iPDn
, jPDm
) , basegfx::B2DVector( iPDn
, jDm
) , basegfx::B2DVector( iDn
, jPDm
));//bottom left corner of tile
694 Tile
.Operations
.push_back( new SRotate( basegfx::B3DVector( 1 , 1 , 0 ) , ( Tile
.getVertices()[1] + Tile
.getVertices()[3] )/2.0 , 180 , true, iDn
*jDm
/2.0 , ((iPDn
*jPDm
)+1.0)/2.0 ) );
695 maLeavingSlidePrimitives
.push_back(Tile
);
696 Tile
.Operations
.push_back( new SRotate( basegfx::B3DVector( 1 , 1 , 0 ) , ( Tile
.getVertices()[1] + Tile
.getVertices()[3] )/2.0 , -180, false, iDn
*jDm
/2.0 , ((iPDn
*jPDm
)+1.0)/2.0 ) );
698 maEnteringSlidePrimitives
.push_back(Tile
);
708 SRotate::SRotate(const basegfx::B3DVector
& Axis
,const basegfx::B3DVector
& Origin
,double Angle
, bool bInter
, double T0
, double T1
):axis(Axis
),origin(Origin
),angle(Angle
)
712 bInterpolate
= bInter
;
715 SScale::SScale(const basegfx::B3DVector
& Scale
,const basegfx::B3DVector
& Origin
, bool bInter
, double T0
, double T1
):scale(Scale
),origin(Origin
)
719 bInterpolate
= bInter
;
722 RotateAndScaleDepthByWidth::RotateAndScaleDepthByWidth(const basegfx::B3DVector
& Axis
,const basegfx::B3DVector
& Origin
,double Angle
, bool bInter
, double T0
, double T1
):axis(Axis
),origin(Origin
),angle(Angle
)
726 bInterpolate
= bInter
;
729 RotateAndScaleDepthByHeight::RotateAndScaleDepthByHeight(const basegfx::B3DVector
& Axis
,const basegfx::B3DVector
& Origin
,double Angle
, bool bInter
, double T0
, double T1
):axis(Axis
),origin(Origin
),angle(Angle
)
733 bInterpolate
= bInter
;
737 STranslate::STranslate(const basegfx::B3DVector
& Vector
, bool bInter
, double T0
, double T1
):vector(Vector
)
741 bInterpolate
= bInter
;
744 inline double intervalInter(double t
, double T0
, double T1
)
746 return ( t
- T0
) / ( T1
- T0
);
749 void STranslate::interpolate(double t
,double SlideWidthScale
,double SlideHeightScale
)
753 if(!bInterpolate
|| t
> nT1
)
755 t
= intervalInter(t
,nT0
,nT1
);
756 glTranslated(SlideWidthScale
*t
*vector
.getX(),SlideHeightScale
*t
*vector
.getY(),t
*vector
.getZ());
759 void SRotate::interpolate(double t
,double SlideWidthScale
,double SlideHeightScale
)
763 if(!bInterpolate
|| t
> nT1
)
765 t
= intervalInter(t
,nT0
,nT1
);
766 glTranslated(SlideWidthScale
*origin
.getX(),SlideHeightScale
*origin
.getY(),origin
.getZ());
767 glScaled(SlideWidthScale
,SlideHeightScale
,1);
768 glRotated(t
*angle
,axis
.getX(),axis
.getY(),axis
.getZ());
769 glScaled(1/SlideWidthScale
,1/SlideHeightScale
,1);
770 glTranslated(-SlideWidthScale
*origin
.getX(),-SlideHeightScale
*origin
.getY(),-origin
.getZ());
773 void SScale::interpolate(double t
,double SlideWidthScale
,double SlideHeightScale
)
777 if(!bInterpolate
|| t
> nT1
)
779 t
= intervalInter(t
,nT0
,nT1
);
780 glTranslated(SlideWidthScale
*origin
.getX(),SlideHeightScale
*origin
.getY(),origin
.getZ());
781 glScaled((1-t
) + t
*scale
.getX(),(1-t
) + t
*scale
.getY(),(1-t
) + t
*scale
.getZ());
782 glTranslated(-SlideWidthScale
*origin
.getX(),-SlideHeightScale
*origin
.getY(),-origin
.getZ());
785 void RotateAndScaleDepthByWidth::interpolate(double t
,double SlideWidthScale
,double SlideHeightScale
)
789 if(!bInterpolate
|| t
> nT1
)
791 t
= intervalInter(t
,nT0
,nT1
);
792 glTranslated(SlideWidthScale
*origin
.getX(),SlideHeightScale
*origin
.getY(),SlideWidthScale
*origin
.getZ());
793 glRotated(t
*angle
,axis
.getX(),axis
.getY(),axis
.getZ());
794 glTranslated(-SlideWidthScale
*origin
.getX(),-SlideHeightScale
*origin
.getY(),-SlideWidthScale
*origin
.getZ());
797 void RotateAndScaleDepthByHeight::interpolate(double t
,double SlideWidthScale
,double SlideHeightScale
)
801 if(!bInterpolate
|| t
> nT1
)
803 t
= intervalInter(t
,nT0
,nT1
);
804 glTranslated(SlideWidthScale
*origin
.getX(),SlideHeightScale
*origin
.getY(),SlideHeightScale
*origin
.getZ());
805 glRotated(t
*angle
,axis
.getX(),axis
.getY(),axis
.getZ());
806 glTranslated(-SlideWidthScale
*origin
.getX(),-SlideHeightScale
*origin
.getY(),-SlideHeightScale
*origin
.getZ());
809 SEllipseTranslate::SEllipseTranslate(double dWidth
, double dHeight
, double dStartPosition
, double dEndPosition
, bool bInter
, double T0
, double T1
)
813 bInterpolate
= bInter
;
816 startPosition
= dStartPosition
;
817 endPosition
= dEndPosition
;
820 void SEllipseTranslate::interpolate(double t
,double /* SlideWidthScale */,double /* SlideHeightScale */)
824 if(!bInterpolate
|| t
> nT1
)
826 t
= intervalInter(t
,nT0
,nT1
);
829 a1
= startPosition
*2*M_PI
;
830 a2
= (startPosition
+ t
*(endPosition
- startPosition
))*2*M_PI
;
831 x
= width
*(cos (a2
) - cos (a1
))/2;
832 y
= height
*(sin (a2
) - sin (a1
))/2;
834 glTranslated(x
, 0, y
);
837 STranslate
* STranslate::clone()
839 return new STranslate(*this);
841 SRotate
* SRotate::clone()
843 return new SRotate(*this);
846 SScale
* SScale::clone()
848 return new SScale(*this);
851 SEllipseTranslate
* SEllipseTranslate::clone()
853 return new SEllipseTranslate(*this);
856 RotateAndScaleDepthByWidth
* RotateAndScaleDepthByWidth::clone()
858 return new RotateAndScaleDepthByWidth(*this);
861 RotateAndScaleDepthByHeight
* RotateAndScaleDepthByHeight::clone()
863 return new RotateAndScaleDepthByHeight(*this);
866 const Primitive
& Primitive::operator=(const Primitive
& rvalue
)
868 for(unsigned int i( 0 ); i
< rvalue
.Operations
.size(); ++i
)
869 Operations
.push_back(rvalue
.Operations
[i
]->clone());
870 for(unsigned int i( 0 ); i
< rvalue
.Vertices
.size(); ++i
)//SPEED! use copy or something. this is slow.
871 Vertices
.push_back(rvalue
.Vertices
[i
]);
872 for(unsigned int i( 0 ); i
< rvalue
.TexCoords
.size(); ++i
)//SPEED! use copy or something. this is slow.
873 TexCoords
.push_back(rvalue
.TexCoords
[i
]);
874 for(unsigned int i( 0 ); i
< rvalue
.Normals
.size(); ++i
)//SPEED! use copy or something. this is slow.
875 Normals
.push_back(rvalue
.Normals
[i
]);
879 Primitive::Primitive(const Primitive
& rvalue
)
881 for(unsigned int i( 0 ); i
< rvalue
.Operations
.size(); ++i
)
882 Operations
.push_back(rvalue
.Operations
[i
]->clone());
883 for(unsigned int i( 0 ); i
< rvalue
.Vertices
.size(); ++i
)//SPEED! use copy or something. this is slow.
884 Vertices
.push_back(rvalue
.Vertices
[i
]);
885 for(unsigned int i( 0 ); i
< rvalue
.TexCoords
.size(); ++i
)//SPEED! use copy or something. this is slow.
886 TexCoords
.push_back(rvalue
.TexCoords
[i
]);
887 for(unsigned int i( 0 ); i
< rvalue
.Normals
.size(); ++i
)//SPEED! use copy or something. this is slow.
888 Normals
.push_back(rvalue
.Normals
[i
]);
891 void Primitive::pushTriangle(const basegfx::B2DVector
& SlideLocation0
,const basegfx::B2DVector
& SlideLocation1
,const basegfx::B2DVector
& SlideLocation2
)
893 vector
<basegfx::B3DVector
> Verts
;
894 vector
<basegfx::B2DVector
> Texs
;
898 Verts
.push_back(basegfx::B3DVector( 2*SlideLocation0
.getX() - 1, -2*SlideLocation0
.getY() + 1 , 0.0 ));
899 Verts
.push_back(basegfx::B3DVector( 2*SlideLocation1
.getX() - 1, -2*SlideLocation1
.getY() + 1 , 0.0 ));
900 Verts
.push_back(basegfx::B3DVector( 2*SlideLocation2
.getX() - 1, -2*SlideLocation2
.getY() + 1 , 0.0 ));
902 //figure out if they're facing the correct way, and make them face the correct way.
903 basegfx::B3DVector
Normal( basegfx::cross( Verts
[0] - Verts
[1] , Verts
[1] - Verts
[2] ) );
904 if(Normal
.getZ() >= 0.0)//if the normal is facing us
906 Texs
.push_back(SlideLocation0
);
907 Texs
.push_back(SlideLocation1
);
908 Texs
.push_back(SlideLocation2
);
910 else // if the normal is facing away from us, make it face us
912 Texs
.push_back(SlideLocation0
);
913 Texs
.push_back(SlideLocation2
);
914 Texs
.push_back(SlideLocation1
);
916 Verts
.push_back(basegfx::B3DVector( 2*SlideLocation0
.getX() - 1, -2*SlideLocation0
.getY() + 1 , 0.0 ));
917 Verts
.push_back(basegfx::B3DVector( 2*SlideLocation2
.getX() - 1, -2*SlideLocation2
.getY() + 1 , 0.0 ));
918 Verts
.push_back(basegfx::B3DVector( 2*SlideLocation1
.getX() - 1, -2*SlideLocation1
.getY() + 1 , 0.0 ));
921 Vertices
.push_back(Verts
[0]);
922 Vertices
.push_back(Verts
[1]);
923 Vertices
.push_back(Verts
[2]);
925 TexCoords
.push_back(Texs
[0]);
926 TexCoords
.push_back(Texs
[1]);
927 TexCoords
.push_back(Texs
[2]);
929 Normals
.push_back(basegfx::B3DVector(0,0,1));//all normals always face the screen when untransformed.
930 Normals
.push_back(basegfx::B3DVector(0,0,1));//all normals always face the screen when untransformed.
931 Normals
.push_back(basegfx::B3DVector(0,0,1));//all normals always face the screen when untransformed.
934 void OGLTransitionImpl::makeDiamond()
936 mmPrepare
= &OGLTransitionImpl::prepareDiamond
;
937 mbUseMipMapLeaving
= mbUseMipMapEntering
= false;
940 void OGLTransitionImpl::prepareDiamond( double nTime
, double /* SlideWidth */, double /* SlideHeight */, double /* DispWidth */, double /* DispHeight */ )
942 Primitive Slide1
, Slide2
;
944 Slide1
.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
945 Slide1
.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
946 maEnteringSlidePrimitives
.push_back (Slide1
);
950 double m
= 1 - nTime
;
952 Slide2
.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (m
,0), basegfx::B2DVector (0,m
));
953 Slide2
.pushTriangle (basegfx::B2DVector (nTime
,0), basegfx::B2DVector (1,0), basegfx::B2DVector (1,m
));
954 Slide2
.pushTriangle (basegfx::B2DVector (1,nTime
), basegfx::B2DVector (1,1), basegfx::B2DVector (nTime
,1));
955 Slide2
.pushTriangle (basegfx::B2DVector (0,nTime
), basegfx::B2DVector (m
,1), basegfx::B2DVector (0,1));
957 double l
= 0.5 - nTime
;
958 double h
= 0.5 + nTime
;
960 Slide2
.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0.5,l
));
961 Slide2
.pushTriangle (basegfx::B2DVector (0.5,l
), basegfx::B2DVector (1,0), basegfx::B2DVector (h
,0.5));
962 Slide2
.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (1,1), basegfx::B2DVector (h
,0.5));
963 Slide2
.pushTriangle (basegfx::B2DVector (h
,0.5), basegfx::B2DVector (1,1), basegfx::B2DVector (0.5,h
));
964 Slide2
.pushTriangle (basegfx::B2DVector (0.5,h
), basegfx::B2DVector (1,1), basegfx::B2DVector (0,1));
965 Slide2
.pushTriangle (basegfx::B2DVector (l
,0.5), basegfx::B2DVector (0.5,h
), basegfx::B2DVector (0,1));
966 Slide2
.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (l
,0.5), basegfx::B2DVector (0,1));
967 Slide2
.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (0.5,l
), basegfx::B2DVector (l
,0.5));
969 Slide2
.Operations
.push_back (new STranslate (basegfx::B3DVector (0, 0, 0.00000001), false, -1, 0));
970 maLeavingSlidePrimitives
.push_back (Slide2
);
973 void OGLTransitionImpl::makeVenetianBlinds( bool vertical
, int parts
)
975 static double t30
= tan( M_PI
/6.0 );
977 double p
= 1.0/parts
;
979 for( int i
=0; i
<parts
; i
++ ) {
981 n
= (i
+ 1)/(double)parts
;
983 Slide
.pushTriangle (basegfx::B2DVector (ln
,0), basegfx::B2DVector (n
,0), basegfx::B2DVector (ln
,1));
984 Slide
.pushTriangle (basegfx::B2DVector (n
,0), basegfx::B2DVector (ln
,1), basegfx::B2DVector (n
,1));
985 Slide
.Operations
.push_back(new RotateAndScaleDepthByWidth(basegfx::B3DVector(0, 1, 0), basegfx::B3DVector(n
+ ln
- 1, 0, -t30
*p
), -120, true, 0.0, 1.0));
987 Slide
.pushTriangle (basegfx::B2DVector (0,ln
), basegfx::B2DVector (1,ln
), basegfx::B2DVector (0,n
));
988 Slide
.pushTriangle (basegfx::B2DVector (1,ln
), basegfx::B2DVector (0,n
), basegfx::B2DVector (1,n
));
989 Slide
.Operations
.push_back(new RotateAndScaleDepthByHeight(basegfx::B3DVector(1, 0, 0), basegfx::B3DVector(0, 1 - n
- ln
, -t30
*p
), -120, true, 0.0, 1.0));
991 maLeavingSlidePrimitives
.push_back (Slide
);
994 Slide
.Operations
.push_back(new SRotate(basegfx::B3DVector(0, 1, 0), basegfx::B3DVector(2*n
- 1, 0, 0), -60, false, -1, 0));
995 Slide
.Operations
.push_back(new SRotate(basegfx::B3DVector(0, 1, 0), basegfx::B3DVector(n
+ ln
- 1, 0, 0), 180, false, -1, 0));
997 Slide
.Operations
.push_back(new SRotate(basegfx::B3DVector(1, 0, 0), basegfx::B3DVector(0, 1 - 2*n
, 0), -60, false, -1, 0));
998 Slide
.Operations
.push_back(new SRotate(basegfx::B3DVector(1, 0, 0), basegfx::B3DVector(0, 1 - n
- ln
, 0), 180, false, -1, 0));
1000 maEnteringSlidePrimitives
.push_back (Slide
);
1005 void OGLTransitionImpl::displaySlidesFadeSmoothly( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
, double SlideWidthScale
, double SlideHeightScale
)
1007 applyOverallOperations( nTime
, SlideWidthScale
, SlideHeightScale
);
1009 glDisable(GL_DEPTH_TEST
);
1011 displaySlide( nTime
, glLeavingSlideTex
, maLeavingSlidePrimitives
, SlideWidthScale
, SlideHeightScale
);
1013 glDisable(GL_LIGHTING
);
1015 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
1016 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_MODULATE
);
1017 glColor4f( 1, 1, 1, nTime
);
1018 displaySlide( nTime
, glEnteringSlideTex
, maEnteringSlidePrimitives
, SlideWidthScale
, SlideHeightScale
);
1019 glDisable(GL_BLEND
);
1020 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_REPLACE
);
1021 glEnable(GL_LIGHTING
);
1023 glEnable(GL_DEPTH_TEST
);
1026 void OGLTransitionImpl::makeFadeSmoothly()
1030 Slide
.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
1031 Slide
.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
1032 maLeavingSlidePrimitives
.push_back (Slide
);
1033 maEnteringSlidePrimitives
.push_back (Slide
);
1035 mmDisplaySlides
= &OGLTransitionImpl::displaySlidesFadeSmoothly
;
1036 mbUseMipMapLeaving
= mbUseMipMapEntering
= false;
1039 void OGLTransitionImpl::displaySlidesFadeThroughBlack( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
, double SlideWidthScale
, double SlideHeightScale
)
1041 applyOverallOperations( nTime
, SlideWidthScale
, SlideHeightScale
);
1043 glDisable(GL_DEPTH_TEST
);
1045 glDisable(GL_LIGHTING
);
1047 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
1048 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_MODULATE
);
1050 glColor4f( 1, 1, 1, 1 - nTime
*2 );
1051 displaySlide( nTime
, glLeavingSlideTex
, maLeavingSlidePrimitives
, SlideWidthScale
, SlideHeightScale
);
1053 glColor4f( 1, 1, 1, (nTime
- 0.5)*2 );
1054 displaySlide( nTime
, glEnteringSlideTex
, maEnteringSlidePrimitives
, SlideWidthScale
, SlideHeightScale
);
1056 glDisable(GL_BLEND
);
1057 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_REPLACE
);
1058 glEnable(GL_LIGHTING
);
1060 glEnable(GL_DEPTH_TEST
);
1063 void OGLTransitionImpl::makeFadeThroughBlack()
1067 Slide
.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
1068 Slide
.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
1069 maLeavingSlidePrimitives
.push_back (Slide
);
1070 maEnteringSlidePrimitives
.push_back (Slide
);
1072 mmDisplaySlides
= &OGLTransitionImpl::displaySlidesFadeThroughBlack
;
1073 mbUseMipMapLeaving
= mbUseMipMapEntering
= false;
1076 static const char* basicVertexShader
= "\n\
1077 varying vec2 v_texturePosition;\n\
1079 void main( void )\n\
1081 gl_Position = ftransform();\n\
1082 v_texturePosition = gl_MultiTexCoord0.xy;\n\
1086 static const char* staticFragmentShader
= "\n\
1087 uniform sampler2D leavingSlideTexture;\n\
1088 uniform sampler2D enteringSlideTexture;\n\
1089 uniform sampler2D permTexture;\n\
1090 uniform float time;\n\
1091 varying vec2 v_texturePosition;\n\
1093 float snoise(vec2 P) {\n\
1095 return texture2D(permTexture, P).r;\n\
1100 #define START 0.4\n\
1104 float sn = snoise(10.0*v_texturePosition+time*0.07);\n\
1105 if( time < PART ) {\n\
1106 float sn1 = snoise(vec2(time*15.0, 20.0*v_texturePosition.y));\n\
1107 float sn2 = snoise(v_texturePosition);\n\
1108 if (sn1 > 1.0 - time*time && sn2 < 2.0*time+0.1)\n\
1109 gl_FragColor = vec4(sn, sn, sn, 1.0);\n\
1110 else if (time > START )\n\
1111 gl_FragColor = ((time-START)/(PART - START))*vec4(sn, sn, sn, 1.0) + (1.0 - (time - START)/(PART - START))*texture2D(leavingSlideTexture, v_texturePosition);\n\
1113 gl_FragColor = texture2D(leavingSlideTexture, v_texturePosition);\n\
1114 } else if ( time < PART ) {\n\
1115 gl_FragColor = texture2D(leavingSlideTexture, v_texturePosition);\n\
1116 } else if ( time > END ) {\n\
1117 gl_FragColor = ((1.0 - time)/(1.0 - END))*vec4(sn, sn, sn, 1.0) + ((time - END)/(1.0 - END))*texture2D(enteringSlideTexture, v_texturePosition);\n\
1119 gl_FragColor = vec4(sn, sn, sn, 1.0);\n\
1123 static const char* dissolveFragmentShader
= "\n\
1124 uniform sampler2D leavingSlideTexture;\n\
1125 uniform sampler2D enteringSlideTexture;\n\
1126 uniform sampler2D permTexture;\n\
1127 uniform float time;\n\
1128 varying vec2 v_texturePosition;\n\
1130 float snoise(vec2 P) {\n\
1132 return texture2D(permTexture, P).r;\n\
1136 float sn = snoise(10.0*v_texturePosition);\n\
1138 gl_FragColor = texture2D(enteringSlideTexture, v_texturePosition);\n\
1140 gl_FragColor = texture2D(leavingSlideTexture, v_texturePosition);\n\
1144 int permutation256
[256]= {
1145 215, 100, 200, 204, 233, 50, 85, 196,
1146 71, 141, 122, 160, 93, 131, 243, 234,
1147 162, 183, 36, 155, 4, 62, 35, 205,
1148 40, 102, 33, 27, 255, 55, 214, 156,
1149 75, 163, 134, 126, 249, 74, 197, 228,
1150 72, 90, 206, 235, 17, 22, 49, 169,
1151 227, 89, 16, 5, 117, 60, 248, 230,
1152 217, 68, 138, 96, 194, 170, 136, 10,
1153 112, 238, 184, 189, 176, 42, 225, 212,
1154 84, 58, 175, 244, 150, 168, 219, 236,
1155 101, 208, 123, 37, 164, 110, 158, 201,
1156 78, 114, 57, 48, 70, 142, 106, 43,
1157 232, 26, 32, 252, 239, 98, 191, 94,
1158 59, 149, 39, 187, 203, 190, 19, 13,
1159 133, 45, 61, 247, 23, 34, 20, 52,
1160 118, 209, 146, 193, 222, 18, 1, 152,
1161 46, 41, 91, 148, 115, 25, 135, 77,
1162 254, 147, 224, 161, 9, 213, 223, 250,
1163 231, 251, 127, 166, 63, 179, 81, 130,
1164 139, 28, 120, 151, 241, 86, 111, 0,
1165 88, 153, 172, 182, 159, 105, 178, 47,
1166 51, 167, 65, 66, 92, 73, 198, 211,
1167 245, 195, 31, 220, 140, 76, 221, 186,
1168 154, 185, 56, 83, 38, 165, 109, 67,
1169 124, 226, 132, 53, 229, 29, 12, 181,
1170 121, 24, 207, 199, 177, 113, 30, 80,
1171 3, 97, 188, 79, 216, 173, 8, 145,
1172 87, 128, 180, 237, 240, 137, 125, 104,
1173 15, 242, 119, 246, 103, 143, 95, 144,
1174 2, 44, 69, 157, 192, 174, 14, 54,
1175 218, 82, 64, 210, 11, 6, 129, 21,
1176 116, 171, 99, 202, 7, 107, 253, 108
1179 void initPermTexture(GLuint
*texID
)
1181 glGenTextures(1, texID
);
1182 glBindTexture(GL_TEXTURE_2D
, *texID
);
1184 static bool initialized
= false;
1185 static unsigned char permutation2D
[256*256*4];
1186 if( !initialized
) {
1189 for( y
=0; y
< 256; y
++ )
1190 for( x
=0; x
< 256; x
++ )
1191 permutation2D
[x
*4 + y
*1024] = permutation256
[(y
+ permutation256
[x
]) & 0xff];
1196 glTexImage2D( GL_TEXTURE_2D
, 0, GL_RGBA
, 256, 256, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, permutation2D
);
1197 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
1198 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1201 void OGLTransitionImpl::preparePermShader()
1203 #ifdef GL_VERSION_2_0
1204 if( mProgramObject
) {
1205 OGLShaders::glUseProgram( mProgramObject
);
1207 GLint location
= OGLShaders::glGetUniformLocation( mProgramObject
, "leavingSlideTexture" );
1208 if( location
!= -1 ) {
1209 OGLShaders::glUniform1i( location
, 0 ); // texture unit 0
1212 glActiveTexture(GL_TEXTURE1
);
1213 if( !maHelperTexture
)
1214 initPermTexture( &maHelperTexture
);
1215 glActiveTexture(GL_TEXTURE0
);
1217 location
= OGLShaders::glGetUniformLocation( mProgramObject
, "permTexture" );
1218 if( location
!= -1 ) {
1219 OGLShaders::glUniform1i( location
, 1 ); // texture unit 1
1222 location
= OGLShaders::glGetUniformLocation( mProgramObject
, "enteringSlideTexture" );
1223 if( location
!= -1 ) {
1224 OGLShaders::glUniform1i( location
, 2 ); // texture unit 2
1230 void OGLTransitionImpl::prepareStatic( ::sal_Int32
/* glLeavingSlideTex */, ::sal_Int32
/* glEnteringSlideTex */ )
1232 mProgramObject
= OGLShaders::LinkProgram( basicVertexShader
, staticFragmentShader
);
1234 preparePermShader();
1237 void OGLTransitionImpl::displaySlidesShaders( double nTime
, ::sal_Int32 glLeavingSlideTex
, ::sal_Int32 glEnteringSlideTex
,
1238 double SlideWidthScale
, double SlideHeightScale
)
1240 applyOverallOperations( nTime
, SlideWidthScale
, SlideHeightScale
);
1242 #ifdef GL_VERSION_2_0
1243 if( mProgramObject
) {
1244 GLint location
= OGLShaders::glGetUniformLocation( mProgramObject
, "time" );
1245 if( location
!= -1 ) {
1246 OGLShaders::glUniform1f( location
, nTime
);
1250 glActiveTexture( GL_TEXTURE2
);
1251 glBindTexture( GL_TEXTURE_2D
, glEnteringSlideTex
);
1252 glActiveTexture( GL_TEXTURE0
);
1255 displaySlide( nTime
, glLeavingSlideTex
, maLeavingSlidePrimitives
, SlideWidthScale
, SlideHeightScale
);
1258 void OGLTransitionImpl::makeStatic()
1262 Slide
.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
1263 Slide
.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
1264 maLeavingSlidePrimitives
.push_back (Slide
);
1265 maEnteringSlidePrimitives
.push_back (Slide
);
1267 mmDisplaySlides
= &OGLTransitionImpl::displaySlidesShaders
;
1268 mmPrepareTransition
= &OGLTransitionImpl::prepareStatic
;
1269 mbUseMipMapLeaving
= mbUseMipMapEntering
= false;
1271 mnRequiredGLVersion
= 2.0;
1274 void OGLTransitionImpl::prepareDissolve( ::sal_Int32
/* glLeavingSlideTex */, ::sal_Int32
/* glEnteringSlideTex */ )
1276 mProgramObject
= OGLShaders::LinkProgram( basicVertexShader
, dissolveFragmentShader
);
1278 preparePermShader();
1281 void OGLTransitionImpl::makeDissolve()
1285 Slide
.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
1286 Slide
.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
1287 maLeavingSlidePrimitives
.push_back (Slide
);
1288 maEnteringSlidePrimitives
.push_back (Slide
);
1290 mmDisplaySlides
= &OGLTransitionImpl::displaySlidesShaders
;
1291 mmPrepareTransition
= &OGLTransitionImpl::prepareDissolve
;
1292 mbUseMipMapLeaving
= mbUseMipMapEntering
= false;
1294 mnRequiredGLVersion
= 2.0;
1297 void OGLTransitionImpl::makeNewsflash()
1301 Slide
.pushTriangle(basegfx::B2DVector(0,0),basegfx::B2DVector(1,0),basegfx::B2DVector(0,1));
1302 Slide
.pushTriangle(basegfx::B2DVector(1,0),basegfx::B2DVector(0,1),basegfx::B2DVector(1,1));
1303 Slide
.Operations
.push_back(new SRotate(basegfx::B3DVector(0,0,1),basegfx::B3DVector(0,0,0),3000,true,0,0.5));
1304 Slide
.Operations
.push_back(new SScale(basegfx::B3DVector(0.01,0.01,0.01),basegfx::B3DVector(0,0,0),true,0,0.5));
1305 Slide
.Operations
.push_back(new STranslate(basegfx::B3DVector(-10000, 0, 0),false, 0.5, 2));
1306 maLeavingSlidePrimitives
.push_back(Slide
);
1308 Slide
.Operations
.clear();
1309 Slide
.Operations
.push_back(new SRotate(basegfx::B3DVector(0,0,1),basegfx::B3DVector(0,0,0),-3000,true,0.5,1));
1310 Slide
.Operations
.push_back(new STranslate(basegfx::B3DVector(-100, 0, 0),false, -1, 1));
1311 Slide
.Operations
.push_back(new STranslate(basegfx::B3DVector(100, 0, 0),false, 0.5, 1));
1312 Slide
.Operations
.push_back(new SScale(basegfx::B3DVector(0.01,0.01,0.01),basegfx::B3DVector(0,0,0),false,-1,1));
1313 Slide
.Operations
.push_back(new SScale(basegfx::B3DVector(100,100,100),basegfx::B3DVector(0,0,0),true,0.5,1));
1314 maEnteringSlidePrimitives
.push_back(Slide
);
1316 OverallOperations
.push_back(new SRotate(basegfx::B3DVector(0,0,1),basegfx::B3DVector(0.2,0.2,0),1080,true,0,1));