diff --git a/Classes/HMGLTransitions/CubeTransition.h b/Classes/HMGLTransitions/CubeTransition.h new file mode 100644 index 0000000..fc9acfb --- /dev/null +++ b/Classes/HMGLTransitions/CubeTransition.h @@ -0,0 +1,25 @@ +// +// CubeTransition.h +// HMGLTransitions +// +// Created by Patrick Pietens on 11/14/11. +// Copyright (c) 2011 PatrickPietens.com. All rights reserved. +// + +#import +#import "HMGLTransition.h" + +typedef enum { + CubeTransitionRight, + CubeTransitionLeft +} CubeTransitionType; + +@interface CubeTransition : HMGLTransition +{ + CubeTransitionType transitionType; + GLfloat animationTime; +} + +@property (nonatomic, assign) CubeTransitionType transitionType; + +@end diff --git a/Classes/HMGLTransitions/CubeTransition.m b/Classes/HMGLTransitions/CubeTransition.m new file mode 100644 index 0000000..f23666d --- /dev/null +++ b/Classes/HMGLTransitions/CubeTransition.m @@ -0,0 +1,93 @@ +// +// CubeTransition.m +// HMGLTransitions +// +// Created by Patrick Pietens on 11/14/11. +// Copyright (c) 2011 PatrickPietens.com. All rights reserved. +// + +#import "CubeTransition.h" + +@implementation CubeTransition + +@synthesize transitionType; + +- (id)init +{ + if (self = [super init]) + { + transitionType = CubeTransitionLeft; + } + + return self; +} + + +- (void)initTransition +{ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustumf(-0.1, 0.1, -0.1, 0.1, 0.1, 100.0); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + + glDisable(GL_LIGHTING); + glColor4f(1.0, 1.0, 1.0, 1.0); + + animationTime = 0; +} + + +- (void)drawWithBeginTexture:(GLuint)beginTexture endTexture:(GLuint)endTexture +{ + int myDirection = transitionType == CubeTransitionLeft ? -1 : 1; + + glClearColor(0.0, 0.0, 0.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + GLfloat vertices[] = { + -0.5, -0.5, + 0.5, -0.5, + -0.5, 0.5, + 0.5, 0.5, + }; + + glEnable(GL_TEXTURE_2D); + + glVertexPointer(2, GL_FLOAT, 0, vertices); + glEnableClientState(GL_VERTEX_ARRAY); + glTexCoordPointer(2, GL_FLOAT, 0, &basicTexCoords); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glPushMatrix(); + // begin view + glBindTexture(GL_TEXTURE_2D, beginTexture); + glTranslatef(0, 0, -1.0); + glRotatef(myDirection * -90 * sin(animationTime), 0, 1, 0); + glTranslatef(0, 0, 0.5); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glPopMatrix(); + + glPushMatrix(); + // end view + glBindTexture(GL_TEXTURE_2D, endTexture); + glTranslatef(0, 0, -1.0 ); + glRotatef(myDirection * -90 * sin(animationTime), 0, 1, 0); + glTranslatef(myDirection * 0.5, 0.0, 0); + glRotatef(myDirection * 90, 0, 1, 0); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glPopMatrix(); +} + + +- (BOOL)calc:(NSTimeInterval)frameTime +{ + animationTime += M_PI * 0.5 * frameTime * 1.5; + return animationTime > M_PI * 0.5; +} + +@end diff --git a/HMGLTransitions.xcodeproj/project.pbxproj b/HMGLTransitions.xcodeproj/project.pbxproj index 7476f18..f650e34 100755 --- a/HMGLTransitions.xcodeproj/project.pbxproj +++ b/HMGLTransitions.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; }; 28D7ACF80DDB3853001CB0EB /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* RootViewController.m */; }; 55F884E3142A0B47008F9C14 /* MainWindow~ipad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 55F884E2142A0B47008F9C14 /* MainWindow~ipad.xib */; }; + 87B7430C14716AD00019895C /* CubeTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 87B7430B14716AD00019895C /* CubeTransition.m */; }; AC13782B124ECCD800D21E3F /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AC13782A124ECCD800D21E3F /* QuartzCore.framework */; }; AC137831124ECCDC00D21E3F /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AC137830124ECCDC00D21E3F /* OpenGLES.framework */; }; AC137845124ECD2B00D21E3F /* HMGLTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = AC13783C124ECD2B00D21E3F /* HMGLTransition.m */; }; @@ -45,11 +46,13 @@ 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 2899E5210DE3E06400AC0155 /* RootViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = RootViewController.xib; sourceTree = ""; }; 28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; - 28D7ACF60DDB3853001CB0EB /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; path = RootViewController.h; sourceTree = ""; }; + 28D7ACF60DDB3853001CB0EB /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 28D7ACF70DDB3853001CB0EB /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = ""; }; 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 32CA4F630368D1EE00C91783 /* HMGLTransitions_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMGLTransitions_Prefix.pch; sourceTree = ""; }; 55F884E2142A0B47008F9C14 /* MainWindow~ipad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = "MainWindow~ipad.xib"; sourceTree = ""; }; + 87B7430A14716AD00019895C /* CubeTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CubeTransition.h; sourceTree = ""; }; + 87B7430B14716AD00019895C /* CubeTransition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CubeTransition.m; sourceTree = ""; }; 8D1107310486CEB800E47090 /* HMGLTransitions-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "HMGLTransitions-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; AC13782A124ECCD800D21E3F /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; AC137830124ECCDC00D21E3F /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; @@ -65,7 +68,7 @@ AC137926124ED75E00D21E3F /* FlipTransition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlipTransition.m; sourceTree = ""; }; AC169A71124FCD72008F43EA /* RotateTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RotateTransition.h; sourceTree = ""; }; AC169A72124FCD72008F43EA /* RotateTransition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RotateTransition.m; sourceTree = ""; }; - AC169B0E124FD5FC008F43EA /* ModalViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; path = ModalViewController.h; sourceTree = ""; }; + AC169B0E124FD5FC008F43EA /* ModalViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModalViewController.h; sourceTree = ""; }; AC169B0F124FD5FC008F43EA /* ModalViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ModalViewController.m; sourceTree = ""; }; AC169B10124FD5FC008F43EA /* ModalViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ModalViewController.xib; path = Classes/ModalViewController.xib; sourceTree = ""; }; AC169B6A124FE159008F43EA /* HMLogo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = HMLogo.png; sourceTree = ""; }; @@ -170,6 +173,8 @@ AC169A74124FCD7C008F43EA /* Transitions */ = { isa = PBXGroup; children = ( + 87B7430A14716AD00019895C /* CubeTransition.h */, + 87B7430B14716AD00019895C /* CubeTransition.m */, AC3E6FA8125264130066AF56 /* DoorsTransition.h */, AC3E6FA9125264130066AF56 /* DoorsTransition.m */, AC169CD4124FF423008F43EA /* ClothTransition.h */, @@ -300,6 +305,7 @@ AC169B11124FD5FC008F43EA /* ModalViewController.m in Sources */, AC169CD6124FF423008F43EA /* ClothTransition.m in Sources */, AC3E6FAA125264130066AF56 /* DoorsTransition.m in Sources */, + 87B7430C14716AD00019895C /* CubeTransition.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/HMGLTransitions.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/HMGLTransitions.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..2cf3dd3 --- /dev/null +++ b/HMGLTransitions.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/HMGLTransitions.xcodeproj/project.xcworkspace/xcuserdata/patrickpietens.xcuserdatad/UserInterfaceState.xcuserstate b/HMGLTransitions.xcodeproj/project.xcworkspace/xcuserdata/patrickpietens.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..bf069fb Binary files /dev/null and b/HMGLTransitions.xcodeproj/project.xcworkspace/xcuserdata/patrickpietens.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/HMGLTransitions.xcodeproj/xcuserdata/patrickpietens.xcuserdatad/xcschemes/HMGLTransitions.xcscheme b/HMGLTransitions.xcodeproj/xcuserdata/patrickpietens.xcuserdatad/xcschemes/HMGLTransitions.xcscheme new file mode 100644 index 0000000..a904029 --- /dev/null +++ b/HMGLTransitions.xcodeproj/xcuserdata/patrickpietens.xcuserdatad/xcschemes/HMGLTransitions.xcscheme @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HMGLTransitions.xcodeproj/xcuserdata/patrickpietens.xcuserdatad/xcschemes/xcschememanagement.plist b/HMGLTransitions.xcodeproj/xcuserdata/patrickpietens.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..0be2b49 --- /dev/null +++ b/HMGLTransitions.xcodeproj/xcuserdata/patrickpietens.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + HMGLTransitions.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 1D6058900D05DD3D006BFB54 + + primary + + + + +