Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Animation for closing doors transition #7

Open
wants to merge 14 commits into
from

Conversation

Projects
None yet
3 participants

Hi,

Your animation for closing doors transition was wrong (I guess that's why it was not in the demo). Here is a correct one.

Cheers,

@kypselia kypselia commented on the diff Sep 23, 2011

Classes/HMGLTransitions/DoorsTransition.m
-
+ GLuint outerTexture, innerTexture; GLfloat sah, depth;
+ switch (transitionType) {
+ case DoorsTransitionTypeOpen:
+ sah = sin(animationTime * 0.5);
+ innerTexture = endTexture;
+ outerTexture = beginTexture;
+ depth = -1.2 + sah * 0.2;
+ break;
+
+ case DoorsTransitionTypeClose:
+ default:
+ sah = -sin(animationTime * 0.5);
+ innerTexture = beginTexture;
+ outerTexture = endTexture;
+ depth = -1.0 + 0.5 * ( (animationTime < - M_PI_2) ? 0.0 : 1/(animationTime-0.25)-1/(-M_PI_2-0.25) );
@kypselia

kypselia Sep 23, 2011

Lot of trial-and-error to adjust for a proper animation of the inner view. Found that a hyperbolic function, delayed until the doors were at -π/2 (and therefore beginning to show), was the right choice.

@kypselia kypselia commented on the diff Sep 23, 2011

Classes/HMGLTransitions/DoorsTransition.m
@@ -43,17 +46,29 @@
glDisable(GL_LIGHTING);
glColor4f(1.0, 1.0, 1.0, 1.0);
- animationTime = 0;
+ animationTime = (transitionType == DoorsTransitionTypeOpen)?0:-2*M_PI/3;
@kypselia

kypselia Sep 23, 2011

-2π/3 and not -π/2 to smoothen the animation.

@kypselia kypselia commented on the diff Sep 23, 2011

Classes/HMGLTransitions/DoorsTransition.m
}
- (void)drawWithBeginTexture:(GLuint)beginTexture endTexture:(GLuint)endTexture {
- if (transitionType == DoorsTransitionTypeClose) {
- GLuint t = endTexture;
- endTexture = beginTexture;
- beginTexture = t;
- }
-
+ GLuint outerTexture, innerTexture; GLfloat sah, depth;
+ switch (transitionType) {
+ case DoorsTransitionTypeOpen:
+ sah = sin(animationTime * 0.5);
+ innerTexture = endTexture;
+ outerTexture = beginTexture;
@kypselia

kypselia Sep 23, 2011

Assigning "inner" and "outer" textures is clearer for code lisibiity than switching the "begin" and the "end" textures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment