├── PaperStackDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── lorenzo.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── WorkspaceSettings.xcsettings └── xcuserdata │ └── lorenzo.xcuserdatad │ ├── xcdebugger │ └── Breakpoints.xcbkptlist │ └── xcschemes │ ├── PaperStackDemo.xcscheme │ └── xcschememanagement.plist ├── PaperStackDemo ├── Assets │ ├── Default-Landscape~ipad.png │ ├── Default-Portrait~ipad.png │ ├── Icon.png │ ├── book.pdf │ ├── shadow.psd │ ├── shadow_bb.png │ ├── shadow_m.png │ └── shadow_tb.png ├── PaperStackDemo-Info.plist ├── PaperStackDemo-Prefix.pch ├── PaperStackDemoAppDelegate.h ├── PaperStackDemoAppDelegate.m ├── PaperStackDemoViewController.h ├── PaperStackDemoViewController.m ├── Vendor │ └── PaperStack │ │ ├── Additions │ │ ├── UIImage+Scale.h │ │ └── UIImage+Scale.m │ │ ├── GL │ │ ├── EAGLView.h │ │ ├── EAGLView.m │ │ ├── ES1Renderer.h │ │ ├── ES1Renderer.m │ │ ├── ESCommon.h │ │ └── ESRenderer.h │ │ ├── PSDrawings.h │ │ ├── PSDrawings.m │ │ ├── PSEffects.h │ │ ├── PSEffects.m │ │ ├── PSKonstants.h │ │ ├── PSPDFPageView.h │ │ ├── PSPDFPageView.m │ │ ├── PSPDFPageViewController.h │ │ ├── PSPDFPageViewController.m │ │ ├── PSPage.h │ │ ├── PSPage.m │ │ ├── PSPageCache.h │ │ ├── PSPageCache.m │ │ ├── PSPageView.h │ │ ├── PSPageView.m │ │ ├── PSPagesViewController.h │ │ └── PSPagesViewController.m ├── en.lproj │ ├── InfoPlist.strings │ ├── MainWindow.xib │ └── PaperStackDemoViewController.xib └── main.m └── README.md /PaperStackDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | ED67EE78138B12C900487AF1 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED67EE77138B12C900487AF1 /* UIKit.framework */; }; 11 | ED67EE7A138B12C900487AF1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED67EE79138B12C900487AF1 /* Foundation.framework */; }; 12 | ED67EE7C138B12C900487AF1 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED67EE7B138B12C900487AF1 /* CoreGraphics.framework */; }; 13 | ED67EE82138B12C900487AF1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = ED67EE80138B12C900487AF1 /* InfoPlist.strings */; }; 14 | ED67EE85138B12C900487AF1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ED67EE84138B12C900487AF1 /* main.m */; }; 15 | ED67EE88138B12C900487AF1 /* PaperStackDemoAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ED67EE87138B12C900487AF1 /* PaperStackDemoAppDelegate.m */; }; 16 | ED67EE8B138B12C900487AF1 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = ED67EE89138B12C900487AF1 /* MainWindow.xib */; }; 17 | ED67EE8E138B12C900487AF1 /* PaperStackDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ED67EE8D138B12C900487AF1 /* PaperStackDemoViewController.m */; }; 18 | ED67EE91138B12C900487AF1 /* PaperStackDemoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = ED67EE8F138B12C900487AF1 /* PaperStackDemoViewController.xib */; }; 19 | ED67EE99138B13BF00487AF1 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED67EE98138B13BF00487AF1 /* OpenGLES.framework */; }; 20 | ED67EE9C138B16AE00487AF1 /* book.pdf in Resources */ = {isa = PBXBuildFile; fileRef = ED67EE9B138B16AE00487AF1 /* book.pdf */; }; 21 | ED67EEEF138B1B2E00487AF1 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED67EEEE138B1B2E00487AF1 /* QuartzCore.framework */; }; 22 | ED77A7B0145DBAB000A2CADA /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = ED77A7AD145DBAB000A2CADA /* Icon.png */; }; 23 | ED77A7BA145DBB3F00A2CADA /* Default-Landscape~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = ED77A7B8145DBB3F00A2CADA /* Default-Landscape~ipad.png */; }; 24 | ED77A7BB145DBB3F00A2CADA /* Default-Portrait~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = ED77A7B9145DBB3F00A2CADA /* Default-Portrait~ipad.png */; }; 25 | ED84114D145AEC4E00E2E4D1 /* UIImage+Scale.m in Sources */ = {isa = PBXBuildFile; fileRef = ED841134145AEC4E00E2E4D1 /* UIImage+Scale.m */; }; 26 | ED84114E145AEC4E00E2E4D1 /* EAGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = ED841137145AEC4E00E2E4D1 /* EAGLView.m */; }; 27 | ED84114F145AEC4E00E2E4D1 /* ES1Renderer.m in Sources */ = {isa = PBXBuildFile; fileRef = ED841139145AEC4E00E2E4D1 /* ES1Renderer.m */; }; 28 | ED841150145AEC4E00E2E4D1 /* PSDrawings.m in Sources */ = {isa = PBXBuildFile; fileRef = ED84113D145AEC4E00E2E4D1 /* PSDrawings.m */; }; 29 | ED841151145AEC4E00E2E4D1 /* PSEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = ED84113F145AEC4E00E2E4D1 /* PSEffects.m */; }; 30 | ED841152145AEC4E00E2E4D1 /* PSPage.m in Sources */ = {isa = PBXBuildFile; fileRef = ED841142145AEC4E00E2E4D1 /* PSPage.m */; }; 31 | ED841153145AEC4E00E2E4D1 /* PSPageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = ED841144145AEC4E00E2E4D1 /* PSPageCache.m */; }; 32 | ED841154145AEC4E00E2E4D1 /* PSPagesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ED841146145AEC4E00E2E4D1 /* PSPagesViewController.m */; }; 33 | ED841155145AEC4E00E2E4D1 /* PSPageView.m in Sources */ = {isa = PBXBuildFile; fileRef = ED841148145AEC4E00E2E4D1 /* PSPageView.m */; }; 34 | ED841156145AEC4E00E2E4D1 /* PSPDFPageView.m in Sources */ = {isa = PBXBuildFile; fileRef = ED84114A145AEC4E00E2E4D1 /* PSPDFPageView.m */; }; 35 | ED841157145AEC4E00E2E4D1 /* PSPDFPageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ED84114C145AEC4E00E2E4D1 /* PSPDFPageViewController.m */; }; 36 | EDB2B70513AD0F5200C2CD6E /* shadow_m.png in Resources */ = {isa = PBXBuildFile; fileRef = EDB2B70313AD0F5200C2CD6E /* shadow_m.png */; }; 37 | EDB2B70613AD0F5200C2CD6E /* shadow_tb.png in Resources */ = {isa = PBXBuildFile; fileRef = EDB2B70413AD0F5200C2CD6E /* shadow_tb.png */; }; 38 | EDB2B70813AD11EA00C2CD6E /* shadow_bb.png in Resources */ = {isa = PBXBuildFile; fileRef = EDB2B70713AD11EA00C2CD6E /* shadow_bb.png */; }; 39 | /* End PBXBuildFile section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | ED67EE73138B12C900487AF1 /* PaperStackDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PaperStackDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | ED67EE77138B12C900487AF1 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 44 | ED67EE79138B12C900487AF1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 45 | ED67EE7B138B12C900487AF1 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 46 | ED67EE7F138B12C900487AF1 /* PaperStackDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PaperStackDemo-Info.plist"; sourceTree = ""; }; 47 | ED67EE81138B12C900487AF1 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 48 | ED67EE83138B12C900487AF1 /* PaperStackDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PaperStackDemo-Prefix.pch"; sourceTree = ""; }; 49 | ED67EE84138B12C900487AF1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 50 | ED67EE86138B12C900487AF1 /* PaperStackDemoAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaperStackDemoAppDelegate.h; sourceTree = ""; }; 51 | ED67EE87138B12C900487AF1 /* PaperStackDemoAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PaperStackDemoAppDelegate.m; sourceTree = ""; }; 52 | ED67EE8A138B12C900487AF1 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindow.xib; sourceTree = ""; }; 53 | ED67EE8C138B12C900487AF1 /* PaperStackDemoViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaperStackDemoViewController.h; sourceTree = ""; }; 54 | ED67EE8D138B12C900487AF1 /* PaperStackDemoViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PaperStackDemoViewController.m; sourceTree = ""; }; 55 | ED67EE90138B12C900487AF1 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/PaperStackDemoViewController.xib; sourceTree = ""; }; 56 | ED67EE98138B13BF00487AF1 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 57 | ED67EE9B138B16AE00487AF1 /* book.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = book.pdf; sourceTree = ""; }; 58 | ED67EEEE138B1B2E00487AF1 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 59 | ED77A7AD145DBAB000A2CADA /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = ""; }; 60 | ED77A7B8145DBB3F00A2CADA /* Default-Landscape~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Landscape~ipad.png"; sourceTree = ""; }; 61 | ED77A7B9145DBB3F00A2CADA /* Default-Portrait~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Portrait~ipad.png"; sourceTree = ""; }; 62 | ED841133145AEC4E00E2E4D1 /* UIImage+Scale.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Scale.h"; sourceTree = ""; }; 63 | ED841134145AEC4E00E2E4D1 /* UIImage+Scale.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Scale.m"; sourceTree = ""; }; 64 | ED841136145AEC4E00E2E4D1 /* EAGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EAGLView.h; sourceTree = ""; }; 65 | ED841137145AEC4E00E2E4D1 /* EAGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EAGLView.m; sourceTree = ""; }; 66 | ED841138145AEC4E00E2E4D1 /* ES1Renderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ES1Renderer.h; sourceTree = ""; }; 67 | ED841139145AEC4E00E2E4D1 /* ES1Renderer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ES1Renderer.m; sourceTree = ""; }; 68 | ED84113A145AEC4E00E2E4D1 /* ESCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESCommon.h; sourceTree = ""; }; 69 | ED84113B145AEC4E00E2E4D1 /* ESRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESRenderer.h; sourceTree = ""; }; 70 | ED84113C145AEC4E00E2E4D1 /* PSDrawings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSDrawings.h; sourceTree = ""; }; 71 | ED84113D145AEC4E00E2E4D1 /* PSDrawings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSDrawings.m; sourceTree = ""; }; 72 | ED84113E145AEC4E00E2E4D1 /* PSEffects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSEffects.h; sourceTree = ""; }; 73 | ED84113F145AEC4E00E2E4D1 /* PSEffects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSEffects.m; sourceTree = ""; }; 74 | ED841140145AEC4E00E2E4D1 /* PSKonstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSKonstants.h; sourceTree = ""; }; 75 | ED841141145AEC4E00E2E4D1 /* PSPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSPage.h; sourceTree = ""; }; 76 | ED841142145AEC4E00E2E4D1 /* PSPage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSPage.m; sourceTree = ""; }; 77 | ED841143145AEC4E00E2E4D1 /* PSPageCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSPageCache.h; sourceTree = ""; }; 78 | ED841144145AEC4E00E2E4D1 /* PSPageCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSPageCache.m; sourceTree = ""; }; 79 | ED841145145AEC4E00E2E4D1 /* PSPagesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSPagesViewController.h; sourceTree = ""; }; 80 | ED841146145AEC4E00E2E4D1 /* PSPagesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSPagesViewController.m; sourceTree = ""; }; 81 | ED841147145AEC4E00E2E4D1 /* PSPageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSPageView.h; sourceTree = ""; }; 82 | ED841148145AEC4E00E2E4D1 /* PSPageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSPageView.m; sourceTree = ""; }; 83 | ED841149145AEC4E00E2E4D1 /* PSPDFPageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSPDFPageView.h; sourceTree = ""; }; 84 | ED84114A145AEC4E00E2E4D1 /* PSPDFPageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSPDFPageView.m; sourceTree = ""; }; 85 | ED84114B145AEC4E00E2E4D1 /* PSPDFPageViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSPDFPageViewController.h; sourceTree = ""; }; 86 | ED84114C145AEC4E00E2E4D1 /* PSPDFPageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSPDFPageViewController.m; sourceTree = ""; }; 87 | EDB2B70313AD0F5200C2CD6E /* shadow_m.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = shadow_m.png; sourceTree = ""; }; 88 | EDB2B70413AD0F5200C2CD6E /* shadow_tb.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = shadow_tb.png; sourceTree = ""; }; 89 | EDB2B70713AD11EA00C2CD6E /* shadow_bb.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = shadow_bb.png; sourceTree = ""; }; 90 | /* End PBXFileReference section */ 91 | 92 | /* Begin PBXFrameworksBuildPhase section */ 93 | ED67EE70138B12C900487AF1 /* Frameworks */ = { 94 | isa = PBXFrameworksBuildPhase; 95 | buildActionMask = 2147483647; 96 | files = ( 97 | ED67EEEF138B1B2E00487AF1 /* QuartzCore.framework in Frameworks */, 98 | ED67EE99138B13BF00487AF1 /* OpenGLES.framework in Frameworks */, 99 | ED67EE78138B12C900487AF1 /* UIKit.framework in Frameworks */, 100 | ED67EE7A138B12C900487AF1 /* Foundation.framework in Frameworks */, 101 | ED67EE7C138B12C900487AF1 /* CoreGraphics.framework in Frameworks */, 102 | ); 103 | runOnlyForDeploymentPostprocessing = 0; 104 | }; 105 | /* End PBXFrameworksBuildPhase section */ 106 | 107 | /* Begin PBXGroup section */ 108 | ED67EE68138B12C900487AF1 = { 109 | isa = PBXGroup; 110 | children = ( 111 | ED841130145AEC4E00E2E4D1 /* Vendor */, 112 | ED67EE7D138B12C900487AF1 /* PaperStackDemo */, 113 | ED67EE76138B12C900487AF1 /* Frameworks */, 114 | ED67EE74138B12C900487AF1 /* Products */, 115 | ); 116 | sourceTree = ""; 117 | }; 118 | ED67EE74138B12C900487AF1 /* Products */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | ED67EE73138B12C900487AF1 /* PaperStackDemo.app */, 122 | ); 123 | name = Products; 124 | sourceTree = ""; 125 | }; 126 | ED67EE76138B12C900487AF1 /* Frameworks */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | ED67EEEE138B1B2E00487AF1 /* QuartzCore.framework */, 130 | ED67EE98138B13BF00487AF1 /* OpenGLES.framework */, 131 | ED67EE77138B12C900487AF1 /* UIKit.framework */, 132 | ED67EE79138B12C900487AF1 /* Foundation.framework */, 133 | ED67EE7B138B12C900487AF1 /* CoreGraphics.framework */, 134 | ); 135 | name = Frameworks; 136 | sourceTree = ""; 137 | }; 138 | ED67EE7D138B12C900487AF1 /* PaperStackDemo */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | ED67EE9A138B16AE00487AF1 /* Assets */, 142 | ED67EE86138B12C900487AF1 /* PaperStackDemoAppDelegate.h */, 143 | ED67EE87138B12C900487AF1 /* PaperStackDemoAppDelegate.m */, 144 | ED67EE89138B12C900487AF1 /* MainWindow.xib */, 145 | ED67EE8C138B12C900487AF1 /* PaperStackDemoViewController.h */, 146 | ED67EE8D138B12C900487AF1 /* PaperStackDemoViewController.m */, 147 | ED67EE8F138B12C900487AF1 /* PaperStackDemoViewController.xib */, 148 | ED67EE7E138B12C900487AF1 /* Supporting Files */, 149 | ); 150 | path = PaperStackDemo; 151 | sourceTree = ""; 152 | }; 153 | ED67EE7E138B12C900487AF1 /* Supporting Files */ = { 154 | isa = PBXGroup; 155 | children = ( 156 | ED67EE7F138B12C900487AF1 /* PaperStackDemo-Info.plist */, 157 | ED67EE80138B12C900487AF1 /* InfoPlist.strings */, 158 | ED67EE83138B12C900487AF1 /* PaperStackDemo-Prefix.pch */, 159 | ED67EE84138B12C900487AF1 /* main.m */, 160 | ); 161 | name = "Supporting Files"; 162 | sourceTree = ""; 163 | }; 164 | ED67EE9A138B16AE00487AF1 /* Assets */ = { 165 | isa = PBXGroup; 166 | children = ( 167 | ED77A7B8145DBB3F00A2CADA /* Default-Landscape~ipad.png */, 168 | ED77A7B9145DBB3F00A2CADA /* Default-Portrait~ipad.png */, 169 | ED77A7AD145DBAB000A2CADA /* Icon.png */, 170 | EDB2B70713AD11EA00C2CD6E /* shadow_bb.png */, 171 | EDB2B70313AD0F5200C2CD6E /* shadow_m.png */, 172 | EDB2B70413AD0F5200C2CD6E /* shadow_tb.png */, 173 | ED67EE9B138B16AE00487AF1 /* book.pdf */, 174 | ); 175 | path = Assets; 176 | sourceTree = ""; 177 | }; 178 | ED841130145AEC4E00E2E4D1 /* Vendor */ = { 179 | isa = PBXGroup; 180 | children = ( 181 | ED841131145AEC4E00E2E4D1 /* PaperStack */, 182 | ); 183 | name = Vendor; 184 | path = PaperStackDemo/Vendor; 185 | sourceTree = ""; 186 | }; 187 | ED841131145AEC4E00E2E4D1 /* PaperStack */ = { 188 | isa = PBXGroup; 189 | children = ( 190 | ED841132145AEC4E00E2E4D1 /* Additions */, 191 | ED841135145AEC4E00E2E4D1 /* GL */, 192 | ED84113C145AEC4E00E2E4D1 /* PSDrawings.h */, 193 | ED84113D145AEC4E00E2E4D1 /* PSDrawings.m */, 194 | ED84113E145AEC4E00E2E4D1 /* PSEffects.h */, 195 | ED84113F145AEC4E00E2E4D1 /* PSEffects.m */, 196 | ED841140145AEC4E00E2E4D1 /* PSKonstants.h */, 197 | ED841141145AEC4E00E2E4D1 /* PSPage.h */, 198 | ED841142145AEC4E00E2E4D1 /* PSPage.m */, 199 | ED841143145AEC4E00E2E4D1 /* PSPageCache.h */, 200 | ED841144145AEC4E00E2E4D1 /* PSPageCache.m */, 201 | ED841145145AEC4E00E2E4D1 /* PSPagesViewController.h */, 202 | ED841146145AEC4E00E2E4D1 /* PSPagesViewController.m */, 203 | ED841147145AEC4E00E2E4D1 /* PSPageView.h */, 204 | ED841148145AEC4E00E2E4D1 /* PSPageView.m */, 205 | ED841149145AEC4E00E2E4D1 /* PSPDFPageView.h */, 206 | ED84114A145AEC4E00E2E4D1 /* PSPDFPageView.m */, 207 | ED84114B145AEC4E00E2E4D1 /* PSPDFPageViewController.h */, 208 | ED84114C145AEC4E00E2E4D1 /* PSPDFPageViewController.m */, 209 | ); 210 | path = PaperStack; 211 | sourceTree = ""; 212 | }; 213 | ED841132145AEC4E00E2E4D1 /* Additions */ = { 214 | isa = PBXGroup; 215 | children = ( 216 | ED841133145AEC4E00E2E4D1 /* UIImage+Scale.h */, 217 | ED841134145AEC4E00E2E4D1 /* UIImage+Scale.m */, 218 | ); 219 | path = Additions; 220 | sourceTree = ""; 221 | }; 222 | ED841135145AEC4E00E2E4D1 /* GL */ = { 223 | isa = PBXGroup; 224 | children = ( 225 | ED841136145AEC4E00E2E4D1 /* EAGLView.h */, 226 | ED841137145AEC4E00E2E4D1 /* EAGLView.m */, 227 | ED841138145AEC4E00E2E4D1 /* ES1Renderer.h */, 228 | ED841139145AEC4E00E2E4D1 /* ES1Renderer.m */, 229 | ED84113A145AEC4E00E2E4D1 /* ESCommon.h */, 230 | ED84113B145AEC4E00E2E4D1 /* ESRenderer.h */, 231 | ); 232 | path = GL; 233 | sourceTree = ""; 234 | }; 235 | /* End PBXGroup section */ 236 | 237 | /* Begin PBXNativeTarget section */ 238 | ED67EE72138B12C900487AF1 /* PaperStackDemo */ = { 239 | isa = PBXNativeTarget; 240 | buildConfigurationList = ED67EE94138B12C900487AF1 /* Build configuration list for PBXNativeTarget "PaperStackDemo" */; 241 | buildPhases = ( 242 | ED67EE6F138B12C900487AF1 /* Sources */, 243 | ED67EE70138B12C900487AF1 /* Frameworks */, 244 | ED67EE71138B12C900487AF1 /* Resources */, 245 | ); 246 | buildRules = ( 247 | ); 248 | dependencies = ( 249 | ); 250 | name = PaperStackDemo; 251 | productName = PaperStackDemo; 252 | productReference = ED67EE73138B12C900487AF1 /* PaperStackDemo.app */; 253 | productType = "com.apple.product-type.application"; 254 | }; 255 | /* End PBXNativeTarget section */ 256 | 257 | /* Begin PBXProject section */ 258 | ED67EE6A138B12C900487AF1 /* Project object */ = { 259 | isa = PBXProject; 260 | attributes = { 261 | LastUpgradeCheck = 0420; 262 | ORGANIZATIONNAME = Mutado; 263 | }; 264 | buildConfigurationList = ED67EE6D138B12C900487AF1 /* Build configuration list for PBXProject "PaperStackDemo" */; 265 | compatibilityVersion = "Xcode 3.2"; 266 | developmentRegion = English; 267 | hasScannedForEncodings = 0; 268 | knownRegions = ( 269 | en, 270 | ); 271 | mainGroup = ED67EE68138B12C900487AF1; 272 | productRefGroup = ED67EE74138B12C900487AF1 /* Products */; 273 | projectDirPath = ""; 274 | projectRoot = ""; 275 | targets = ( 276 | ED67EE72138B12C900487AF1 /* PaperStackDemo */, 277 | ); 278 | }; 279 | /* End PBXProject section */ 280 | 281 | /* Begin PBXResourcesBuildPhase section */ 282 | ED67EE71138B12C900487AF1 /* Resources */ = { 283 | isa = PBXResourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | ED67EE82138B12C900487AF1 /* InfoPlist.strings in Resources */, 287 | ED67EE8B138B12C900487AF1 /* MainWindow.xib in Resources */, 288 | ED67EE91138B12C900487AF1 /* PaperStackDemoViewController.xib in Resources */, 289 | ED67EE9C138B16AE00487AF1 /* book.pdf in Resources */, 290 | EDB2B70513AD0F5200C2CD6E /* shadow_m.png in Resources */, 291 | EDB2B70613AD0F5200C2CD6E /* shadow_tb.png in Resources */, 292 | EDB2B70813AD11EA00C2CD6E /* shadow_bb.png in Resources */, 293 | ED77A7B0145DBAB000A2CADA /* Icon.png in Resources */, 294 | ED77A7BA145DBB3F00A2CADA /* Default-Landscape~ipad.png in Resources */, 295 | ED77A7BB145DBB3F00A2CADA /* Default-Portrait~ipad.png in Resources */, 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | /* End PBXResourcesBuildPhase section */ 300 | 301 | /* Begin PBXSourcesBuildPhase section */ 302 | ED67EE6F138B12C900487AF1 /* Sources */ = { 303 | isa = PBXSourcesBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | ED67EE85138B12C900487AF1 /* main.m in Sources */, 307 | ED67EE88138B12C900487AF1 /* PaperStackDemoAppDelegate.m in Sources */, 308 | ED67EE8E138B12C900487AF1 /* PaperStackDemoViewController.m in Sources */, 309 | ED84114D145AEC4E00E2E4D1 /* UIImage+Scale.m in Sources */, 310 | ED84114E145AEC4E00E2E4D1 /* EAGLView.m in Sources */, 311 | ED84114F145AEC4E00E2E4D1 /* ES1Renderer.m in Sources */, 312 | ED841150145AEC4E00E2E4D1 /* PSDrawings.m in Sources */, 313 | ED841151145AEC4E00E2E4D1 /* PSEffects.m in Sources */, 314 | ED841152145AEC4E00E2E4D1 /* PSPage.m in Sources */, 315 | ED841153145AEC4E00E2E4D1 /* PSPageCache.m in Sources */, 316 | ED841154145AEC4E00E2E4D1 /* PSPagesViewController.m in Sources */, 317 | ED841155145AEC4E00E2E4D1 /* PSPageView.m in Sources */, 318 | ED841156145AEC4E00E2E4D1 /* PSPDFPageView.m in Sources */, 319 | ED841157145AEC4E00E2E4D1 /* PSPDFPageViewController.m in Sources */, 320 | ); 321 | runOnlyForDeploymentPostprocessing = 0; 322 | }; 323 | /* End PBXSourcesBuildPhase section */ 324 | 325 | /* Begin PBXVariantGroup section */ 326 | ED67EE80138B12C900487AF1 /* InfoPlist.strings */ = { 327 | isa = PBXVariantGroup; 328 | children = ( 329 | ED67EE81138B12C900487AF1 /* en */, 330 | ); 331 | name = InfoPlist.strings; 332 | sourceTree = ""; 333 | }; 334 | ED67EE89138B12C900487AF1 /* MainWindow.xib */ = { 335 | isa = PBXVariantGroup; 336 | children = ( 337 | ED67EE8A138B12C900487AF1 /* en */, 338 | ); 339 | name = MainWindow.xib; 340 | sourceTree = ""; 341 | }; 342 | ED67EE8F138B12C900487AF1 /* PaperStackDemoViewController.xib */ = { 343 | isa = PBXVariantGroup; 344 | children = ( 345 | ED67EE90138B12C900487AF1 /* en */, 346 | ); 347 | name = PaperStackDemoViewController.xib; 348 | sourceTree = ""; 349 | }; 350 | /* End PBXVariantGroup section */ 351 | 352 | /* Begin XCBuildConfiguration section */ 353 | ED67EE92138B12C900487AF1 /* Debug */ = { 354 | isa = XCBuildConfiguration; 355 | buildSettings = { 356 | ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)"; 357 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 358 | GCC_C_LANGUAGE_STANDARD = gnu99; 359 | GCC_OPTIMIZATION_LEVEL = 0; 360 | GCC_PREPROCESSOR_DEFINITIONS = DEBUG; 361 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 362 | GCC_VERSION = com.apple.compilers.llvmgcc42; 363 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 364 | GCC_WARN_UNUSED_VARIABLE = YES; 365 | IPHONEOS_DEPLOYMENT_TARGET = 4.3; 366 | SDKROOT = iphoneos; 367 | TARGETED_DEVICE_FAMILY = 2; 368 | }; 369 | name = Debug; 370 | }; 371 | ED67EE93138B12C900487AF1 /* Release */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)"; 375 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 376 | GCC_C_LANGUAGE_STANDARD = gnu99; 377 | GCC_VERSION = com.apple.compilers.llvmgcc42; 378 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 379 | GCC_WARN_UNUSED_VARIABLE = YES; 380 | IPHONEOS_DEPLOYMENT_TARGET = 4.3; 381 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 382 | SDKROOT = iphoneos; 383 | TARGETED_DEVICE_FAMILY = 2; 384 | }; 385 | name = Release; 386 | }; 387 | ED67EE95138B12C900487AF1 /* Debug */ = { 388 | isa = XCBuildConfiguration; 389 | buildSettings = { 390 | ALWAYS_SEARCH_USER_PATHS = NO; 391 | COPY_PHASE_STRIP = NO; 392 | GCC_DYNAMIC_NO_PIC = NO; 393 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 394 | GCC_PREFIX_HEADER = "PaperStackDemo/PaperStackDemo-Prefix.pch"; 395 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 396 | INFOPLIST_FILE = "PaperStackDemo/PaperStackDemo-Info.plist"; 397 | IPHONEOS_DEPLOYMENT_TARGET = 4.0; 398 | OTHER_CFLAGS = "-DDEBUG"; 399 | PRODUCT_NAME = "$(TARGET_NAME)"; 400 | WRAPPER_EXTENSION = app; 401 | }; 402 | name = Debug; 403 | }; 404 | ED67EE96138B12C900487AF1 /* Release */ = { 405 | isa = XCBuildConfiguration; 406 | buildSettings = { 407 | ALWAYS_SEARCH_USER_PATHS = NO; 408 | COPY_PHASE_STRIP = YES; 409 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 410 | GCC_PREFIX_HEADER = "PaperStackDemo/PaperStackDemo-Prefix.pch"; 411 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 412 | INFOPLIST_FILE = "PaperStackDemo/PaperStackDemo-Info.plist"; 413 | IPHONEOS_DEPLOYMENT_TARGET = 4.0; 414 | PRODUCT_NAME = "$(TARGET_NAME)"; 415 | VALIDATE_PRODUCT = YES; 416 | WRAPPER_EXTENSION = app; 417 | }; 418 | name = Release; 419 | }; 420 | /* End XCBuildConfiguration section */ 421 | 422 | /* Begin XCConfigurationList section */ 423 | ED67EE6D138B12C900487AF1 /* Build configuration list for PBXProject "PaperStackDemo" */ = { 424 | isa = XCConfigurationList; 425 | buildConfigurations = ( 426 | ED67EE92138B12C900487AF1 /* Debug */, 427 | ED67EE93138B12C900487AF1 /* Release */, 428 | ); 429 | defaultConfigurationIsVisible = 0; 430 | defaultConfigurationName = Release; 431 | }; 432 | ED67EE94138B12C900487AF1 /* Build configuration list for PBXNativeTarget "PaperStackDemo" */ = { 433 | isa = XCConfigurationList; 434 | buildConfigurations = ( 435 | ED67EE95138B12C900487AF1 /* Debug */, 436 | ED67EE96138B12C900487AF1 /* Release */, 437 | ); 438 | defaultConfigurationIsVisible = 0; 439 | defaultConfigurationName = Release; 440 | }; 441 | /* End XCConfigurationList section */ 442 | }; 443 | rootObject = ED67EE6A138B12C900487AF1 /* Project object */; 444 | } 445 | -------------------------------------------------------------------------------- /PaperStackDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PaperStackDemo.xcodeproj/project.xcworkspace/xcuserdata/lorenzo.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lomanf/PaperStack/a0fa9a543ba238978c0fd3f606a9176896cd2328/PaperStackDemo.xcodeproj/project.xcworkspace/xcuserdata/lorenzo.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /PaperStackDemo.xcodeproj/project.xcworkspace/xcuserdata/lorenzo.xcuserdatad/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEWorkspaceUserSettings_HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges 6 | 7 | IDEWorkspaceUserSettings_SnapshotAutomaticallyBeforeSignificantChanges 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /PaperStackDemo.xcodeproj/xcuserdata/lorenzo.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /PaperStackDemo.xcodeproj/xcuserdata/lorenzo.xcuserdatad/xcschemes/PaperStackDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 71 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /PaperStackDemo.xcodeproj/xcuserdata/lorenzo.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PaperStackDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | ED67EE72138B12C900487AF1 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /PaperStackDemo/Assets/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lomanf/PaperStack/a0fa9a543ba238978c0fd3f606a9176896cd2328/PaperStackDemo/Assets/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /PaperStackDemo/Assets/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lomanf/PaperStack/a0fa9a543ba238978c0fd3f606a9176896cd2328/PaperStackDemo/Assets/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /PaperStackDemo/Assets/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lomanf/PaperStack/a0fa9a543ba238978c0fd3f606a9176896cd2328/PaperStackDemo/Assets/Icon.png -------------------------------------------------------------------------------- /PaperStackDemo/Assets/book.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lomanf/PaperStack/a0fa9a543ba238978c0fd3f606a9176896cd2328/PaperStackDemo/Assets/book.pdf -------------------------------------------------------------------------------- /PaperStackDemo/Assets/shadow.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lomanf/PaperStack/a0fa9a543ba238978c0fd3f606a9176896cd2328/PaperStackDemo/Assets/shadow.psd -------------------------------------------------------------------------------- /PaperStackDemo/Assets/shadow_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lomanf/PaperStack/a0fa9a543ba238978c0fd3f606a9176896cd2328/PaperStackDemo/Assets/shadow_bb.png -------------------------------------------------------------------------------- /PaperStackDemo/Assets/shadow_m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lomanf/PaperStack/a0fa9a543ba238978c0fd3f606a9176896cd2328/PaperStackDemo/Assets/shadow_m.png -------------------------------------------------------------------------------- /PaperStackDemo/Assets/shadow_tb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lomanf/PaperStack/a0fa9a543ba238978c0fd3f606a9176896cd2328/PaperStackDemo/Assets/shadow_tb.png -------------------------------------------------------------------------------- /PaperStackDemo/PaperStackDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleDocumentTypes 10 | 11 | CFBundleExecutable 12 | ${EXECUTABLE_NAME} 13 | CFBundleIconFile 14 | 15 | CFBundleIconFiles 16 | 17 | Icon.png 18 | 19 | CFBundleIcons 20 | 21 | CFBundlePrimaryIcon 22 | 23 | CFBundleIconFiles 24 | 25 | Icon.png 26 | 27 | UIPrerenderedIcon 28 | 29 | 30 | 31 | CFBundleIdentifier 32 | com.mutado.${PRODUCT_NAME:rfc1034identifier} 33 | CFBundleInfoDictionaryVersion 34 | 6.0 35 | CFBundleName 36 | ${PRODUCT_NAME} 37 | CFBundlePackageType 38 | APPL 39 | CFBundleShortVersionString 40 | 1.0 41 | CFBundleSignature 42 | ???? 43 | CFBundleURLTypes 44 | 45 | CFBundleVersion 46 | 1.0 47 | LSRequiresIPhoneOS 48 | 49 | NSMainNibFile 50 | MainWindow 51 | UISupportedInterfaceOrientations~ipad 52 | 53 | UIInterfaceOrientationPortrait 54 | UIInterfaceOrientationPortraitUpsideDown 55 | UIInterfaceOrientationLandscapeRight 56 | UIInterfaceOrientationLandscapeLeft 57 | 58 | UTExportedTypeDeclarations 59 | 60 | UTImportedTypeDeclarations 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /PaperStackDemo/PaperStackDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'PaperStackDemo' target in the 'PaperStackDemo' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | 16 | #ifdef DEBUG 17 | # define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); 18 | #else 19 | # define DLog(...) 20 | #endif 21 | -------------------------------------------------------------------------------- /PaperStackDemo/PaperStackDemoAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // PaperStackDemoAppDelegate.h 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 24/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PaperStackDemoAppDelegate : NSObject { 12 | 13 | } 14 | 15 | @property (nonatomic, retain) IBOutlet UIWindow *window; 16 | 17 | @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /PaperStackDemo/PaperStackDemoAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // PaperStackDemoAppDelegate.m 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 24/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import "PaperStackDemoAppDelegate.h" 10 | 11 | #import "PaperStackDemoViewController.h" 12 | 13 | @implementation PaperStackDemoAppDelegate 14 | 15 | 16 | @synthesize window=_window; 17 | 18 | @synthesize navigationController=_navigationController; 19 | 20 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 21 | { 22 | // Override point for customization after application launch. 23 | self.window.rootViewController = self.navigationController; 24 | [self.window makeKeyAndVisible]; 25 | 26 | return YES; 27 | } 28 | 29 | - (void)applicationWillResignActive:(UIApplication *)application 30 | { 31 | /* 32 | Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 33 | Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 34 | */ 35 | } 36 | 37 | - (void)applicationDidEnterBackground:(UIApplication *)application 38 | { 39 | /* 40 | Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 41 | If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 42 | */ 43 | } 44 | 45 | - (void)applicationWillEnterForeground:(UIApplication *)application 46 | { 47 | /* 48 | Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 49 | */ 50 | } 51 | 52 | - (void)applicationDidBecomeActive:(UIApplication *)application 53 | { 54 | /* 55 | Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 56 | */ 57 | } 58 | 59 | - (void)applicationWillTerminate:(UIApplication *)application 60 | { 61 | /* 62 | Called when the application is about to terminate. 63 | Save data if appropriate. 64 | See also applicationDidEnterBackground:. 65 | */ 66 | } 67 | 68 | - (void)dealloc 69 | { 70 | [_window release]; 71 | [_navigationController release]; 72 | [super dealloc]; 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /PaperStackDemo/PaperStackDemoViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PaperStackDemoViewController.h 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 24/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PSPagesViewController.h" 11 | 12 | @interface PaperStackDemoViewController : UIViewController { 13 | CGPDFDocumentRef pdf; 14 | } 15 | 16 | - (IBAction)launchPlayer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /PaperStackDemo/PaperStackDemoViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PaperStackDemoViewController.m 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 24/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import "PaperStackDemoViewController.h" 10 | #import "PSPDFPageViewController.h" 11 | 12 | @implementation PaperStackDemoViewController 13 | 14 | - (void)dealloc 15 | { 16 | CGPDFDocumentRelease(pdf); 17 | [super dealloc]; 18 | } 19 | 20 | - (void)didReceiveMemoryWarning 21 | { 22 | // Releases the view if it doesn't have a superview. 23 | [super didReceiveMemoryWarning]; 24 | 25 | // Release any cached data, images, etc that aren't in use. 26 | } 27 | 28 | #pragma mark - Actions 29 | 30 | - (IBAction)launchPlayer 31 | { 32 | PSPagesViewController *aController = [[PSPagesViewController alloc] initWithNibName:nil bundle:nil]; 33 | aController.datasource = self; 34 | aController.shouldUseInitialEmptyLeftPage = NO; 35 | [self.navigationController pushViewController:aController animated:YES]; 36 | [aController release]; 37 | 38 | } 39 | 40 | #pragma mark - View lifecycle 41 | 42 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 43 | - (void)viewDidLoad 44 | { 45 | [super viewDidLoad]; 46 | 47 | // load pdf 48 | CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("book.pdf"), NULL, NULL); 49 | pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); 50 | 51 | } 52 | 53 | - (void)viewDidUnload 54 | { 55 | [super viewDidUnload]; 56 | // Release any retained subviews of the main view. 57 | // e.g. self.myOutlet = nil; 58 | } 59 | 60 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 61 | { 62 | // Return YES for supported orientations 63 | return YES; 64 | } 65 | 66 | #pragma mark - 67 | #pragma mark - PSPagesViewControllerDatasource 68 | 69 | - (NSUInteger)pagesNumberOfControllers 70 | { 71 | return CGPDFDocumentGetNumberOfPages(pdf); 72 | } 73 | 74 | - (UIViewController*)pagesPageViewControllerAtIndex:(NSUInteger)index 75 | { 76 | CGPDFPageRef page = CGPDFDocumentGetPage(pdf, index+1); 77 | PSPDFPageViewController *aController = [[PSPDFPageViewController alloc] initwithPDFPage:page]; 78 | return [aController autorelease]; 79 | } 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/Additions/UIImage+Scale.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Scale.h 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 25/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface UIImage( Scale ) 13 | 14 | - (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/Additions/UIImage+Scale.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Scale.m 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 25/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import "UIImage+Scale.h" 10 | 11 | 12 | @implementation UIImage( Scale ) 13 | 14 | #pragma mark - 15 | #pragma mark Scale and crop image 16 | 17 | - (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize 18 | { 19 | UIImage *sourceImage = self; 20 | UIImage *newImage = nil; 21 | CGSize imageSize = sourceImage.size; 22 | CGFloat width = imageSize.width; 23 | CGFloat height = imageSize.height; 24 | CGFloat targetWidth = targetSize.width; 25 | CGFloat targetHeight = targetSize.height; 26 | CGFloat scaleFactor = 0.0; 27 | CGFloat scaledWidth = targetWidth; 28 | CGFloat scaledHeight = targetHeight; 29 | CGPoint thumbnailPoint = CGPointMake(0.0,0.0); 30 | 31 | if (CGSizeEqualToSize(imageSize, targetSize) == NO) 32 | { 33 | CGFloat widthFactor = targetWidth / width; 34 | CGFloat heightFactor = targetHeight / height; 35 | 36 | if (widthFactor > heightFactor) 37 | scaleFactor = widthFactor; // scale to fit height 38 | else 39 | scaleFactor = heightFactor; // scale to fit width 40 | scaledWidth = width * scaleFactor; 41 | scaledHeight = height * scaleFactor; 42 | 43 | // center the image 44 | if (widthFactor > heightFactor) 45 | { 46 | thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5; 47 | } 48 | else 49 | if (widthFactor < heightFactor) 50 | { 51 | thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5; 52 | } 53 | } 54 | 55 | UIGraphicsBeginImageContext(targetSize); // this will crop 56 | 57 | CGRect thumbnailRect = CGRectZero; 58 | thumbnailRect.origin = thumbnailPoint; 59 | thumbnailRect.size.width = scaledWidth; 60 | thumbnailRect.size.height = scaledHeight; 61 | 62 | [sourceImage drawInRect:thumbnailRect]; 63 | 64 | newImage = UIGraphicsGetImageFromCurrentImageContext(); 65 | if(newImage == nil) 66 | NSLog(@"could not scale image"); 67 | 68 | //pop the context to get back to the default 69 | UIGraphicsEndImageContext(); 70 | return newImage; 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/GL/EAGLView.h: -------------------------------------------------------------------------------- 1 | // 2 | // EAGLView.h 3 | // ConeCurl 4 | // 5 | // Created by W. Dana Nuon on 4/18/10. 6 | // Copyright lunaray 2010. All rights reserved. 7 | // 8 | // Modified from Xcode OpenGL ES template project. 9 | // 10 | 11 | #import 12 | #import 13 | 14 | #import "ESRenderer.h" 15 | #import "ESCommon.h" 16 | #import "PSPage.h" 17 | #import "PSEffects.h" 18 | 19 | // This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. 20 | // The view content is basically an EAGL surface you render your OpenGL scene into. 21 | // Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. 22 | @interface EAGLView : UIView 23 | { 24 | CGFloat animationTime; 25 | @private 26 | id renderer; 27 | BOOL setupCompleted; 28 | BOOL animating; 29 | BOOL displayLinkSupported; 30 | NSInteger animationFrameInterval; 31 | // Use of the CADisplayLink class is the preferred method for controlling your animation timing. 32 | // CADisplayLink will link to the main display and fire every vsync when added to a given run-loop. 33 | // The NSTimer class is used only as fallback when running on a pre 3.1 device where CADisplayLink 34 | // isn't available. 35 | id displayLink; 36 | NSTimer *animationTimer; 37 | } 38 | 39 | @property (readonly, nonatomic, getter=isAnimating) BOOL animating; 40 | @property (nonatomic) NSInteger animationFrameInterval; 41 | @property (nonatomic) IBOutlet CGFloat animationTime; 42 | @property (nonatomic,assign) id datasource; 43 | 44 | - (void)loadLeftTextures; 45 | - (void)loadRightTextures; 46 | - (PSPage *)activePage; 47 | - (PSEffects *)activeEffects; 48 | - (void)applyTransform; 49 | - (void)animateToEnd; 50 | 51 | - (void)activateLeftPage; 52 | - (void)activateRightPage; 53 | 54 | - (void)setOrthoTranslate:(CGFloat)value; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/GL/EAGLView.m: -------------------------------------------------------------------------------- 1 | // 2 | // EAGLView.m 3 | // ConeCurl 4 | // 5 | // Created by W. Dana Nuon on 4/18/10. 6 | // Copyright lunaray 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "EAGLView.h" 11 | #import "ES1Renderer.h" 12 | #import "PSEffects.h" 13 | #import "PSDrawings.h" 14 | #import "PSKonstants.h" 15 | 16 | @interface EAGLView() 17 | 18 | - (void)startAnimation; 19 | - (void)stopAnimation; 20 | - (void)updateView:(id)sender; 21 | 22 | @property (nonatomic, retain) PSPage* leftPage_; 23 | @property (nonatomic, retain) PSPage* rightPage_; 24 | @property (nonatomic, assign) PSPage* activePage_; 25 | @property (nonatomic, retain) PSEffects* effects_; 26 | @property (nonatomic, assign) CGPoint targetPoint_; 27 | @property (nonatomic, assign) CGPoint targetVector_; 28 | @property (nonatomic, assign) CGFloat targetTime_; 29 | @property (nonatomic, assign) CGFloat currentTime_; 30 | 31 | @end 32 | 33 | @implementation EAGLView 34 | 35 | @synthesize animating; 36 | @dynamic animationFrameInterval; 37 | @synthesize animationTime; 38 | @synthesize datasource; 39 | 40 | @synthesize leftPage_, rightPage_, activePage_, effects_, targetPoint_, targetVector_, targetTime_, currentTime_; 41 | 42 | // You must implement this method 43 | + (Class)layerClass 44 | { 45 | return [CAEAGLLayer class]; 46 | } 47 | 48 | //The EAGL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: 49 | - (id)initWithFrame:(CGRect)frame 50 | { 51 | if ((self = [super initWithFrame:frame])) 52 | { 53 | // Get the layer 54 | CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; 55 | 56 | eaglLayer.opaque = YES; 57 | eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: 58 | [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; 59 | 60 | self.backgroundColor = [UIColor clearColor]; 61 | 62 | if ( !renderer ) { 63 | renderer = [[ES1Renderer alloc] init]; 64 | if (!renderer) { 65 | [self release]; 66 | return nil; 67 | } 68 | } 69 | 70 | animating = FALSE; 71 | displayLinkSupported = FALSE; 72 | animationFrameInterval = 1; 73 | displayLink = nil; 74 | animationTimer = nil; 75 | 76 | // A system version of 3.1 or greater is required to use CADisplayLink. The NSTimer 77 | // class is used as fallback when it isn't available. 78 | NSString *reqSysVer = @"3.1"; 79 | NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; 80 | if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) { 81 | displayLinkSupported = TRUE; 82 | } 83 | 84 | PSPage *aPage = [[PSPage alloc] init]; 85 | aPage.currentFrame = 0; 86 | aPage.framesPerCycle = 120; 87 | aPage.width = 1.0f; 88 | aPage.height = 1.0f; 89 | aPage.columns = PAGE_COLUMNS; 90 | aPage.rows = PAGE_ROWS; 91 | aPage.delegate = self; 92 | [aPage createMesh]; 93 | 94 | self.rightPage_ = aPage; 95 | 96 | aPage = [[PSPage alloc] init]; 97 | aPage.currentFrame = 0; 98 | aPage.framesPerCycle = 120; 99 | aPage.width = 1.0f; 100 | aPage.height = 1.0f; 101 | aPage.columns = PAGE_COLUMNS; 102 | aPage.rows = PAGE_ROWS; 103 | aPage.delegate = self; 104 | aPage.hasReverseCurl = YES; 105 | [aPage createMesh]; 106 | 107 | self.leftPage_ = aPage; 108 | 109 | self.clearsContextBeforeDrawing = YES; 110 | 111 | PSEffects *aEffects = [[PSEffects alloc] init]; 112 | self.effects_ = aEffects; 113 | [aEffects release]; 114 | } 115 | 116 | return self; 117 | } 118 | 119 | - (void)updateView:(id)sender 120 | { 121 | PSPage *active = [self activePage]; 122 | /* 123 | self.currentTime_ = self.currentTime_ + 1.0/60.0; 124 | CGFloat t = self.currentTime_ / self.targetTime_; 125 | if ( currentTime_ >= targetTime_ ) { 126 | t = 1.0; 127 | [self stopAnimation]; 128 | } 129 | CGFloat tv = PSQuad( t, 0, 1 ); 130 | active.P = CGPointMake( self.targetPoint_.x - self.targetVector_.x * tv, self.targetPoint_.y - self.targetVector_.y * tv ); 131 | [self applyTransform]; 132 | */ 133 | CGFloat dx = ( active.SP.x - active.P.x ) * kPSPageAnimationFriction; 134 | CGFloat dy = ( active.SP.y - active.P.y ) * kPSPageAnimationFriction; 135 | if ( fabs(dx) < kPSPageAnimationThreshold && fabs(dy) < kPSPageAnimationThreshold ) { 136 | [self stopAnimation]; 137 | active.P = active.SP; 138 | } else { 139 | active.P = CGPointMake(active.P.x+dx,active.P.y+dy); 140 | } 141 | [self applyTransform]; 142 | 143 | } 144 | 145 | - (void)applyTransform 146 | { 147 | [activePage_ deform]; 148 | [renderer renderObject:activePage_ withEffects:effects_]; 149 | } 150 | 151 | - (void)loadLeftTextures 152 | { 153 | DLog(@"loadLeftTextures"); 154 | 155 | [renderer loadTextures]; 156 | 157 | // update texture coord 158 | 159 | UIImage *tex = [renderer.datasource rendererGetLeftFrontTexture]; 160 | CGRect rect = [renderer.datasource rendererGetLeftFrontTextureRect]; 161 | 162 | // correct width 163 | leftPage_.width = rect.size.width / self.frame.size.width; 164 | leftPage_.height = rect.size.height / self.frame.size.height; 165 | [leftPage_ createMesh]; 166 | 167 | // interpolate texture rect 168 | rect.origin.x /= tex.size.width; 169 | rect.origin.y = ( tex.size.height - rect.size.height - rect.origin.y ) / tex.size.height; 170 | rect.size.width /= tex.size.width; 171 | rect.size.height /= tex.size.height; 172 | 173 | //DLog( @"RectPerc -->: %f, %f, %f, %f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height ); 174 | [leftPage_ updateTextureCoord:rect]; 175 | 176 | } 177 | 178 | - (void)loadRightTextures 179 | { 180 | DLog(@"loadRightTextures"); 181 | 182 | [renderer loadTextures]; 183 | 184 | // update texture coord 185 | 186 | UIImage *tex = [renderer.datasource rendererGetRightFrontTexture]; 187 | CGRect rect = [renderer.datasource rendererGetRightFrontTextureRect]; 188 | 189 | DLog( @"Rect -->: %f, %f, %f, %f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height ); 190 | DLog( @"Bounds -->: %f, %f", self.frame.size.width, self.frame.size.height ); 191 | 192 | // correct width 193 | rightPage_.width = rect.size.width / self.frame.size.width; 194 | rightPage_.height = rect.size.height / self.frame.size.height; 195 | [rightPage_ createMesh]; 196 | 197 | effects_.pageRect = rect; 198 | effects_.pageSize = tex.size; 199 | [effects_ buildEffects]; 200 | [renderer loadEffects]; 201 | 202 | // interpolate texture rect 203 | rect.origin.x /= tex.size.width; 204 | rect.origin.y = ( tex.size.height - rect.size.height - rect.origin.y ) / tex.size.height; 205 | rect.size.width /= tex.size.width; 206 | rect.size.height /= tex.size.height; 207 | 208 | DLog( @"RectPerc -->: %f, %f, %f, %f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height ); 209 | [rightPage_ updateTextureCoord:rect]; 210 | 211 | } 212 | 213 | - (void)layoutSubviews 214 | { 215 | if ( !setupCompleted ) { 216 | DLog(@"layoutSubviews"); 217 | setupCompleted = YES; 218 | effects_.bounds = self.bounds; 219 | [renderer resizeFromLayer:(CAEAGLLayer*)self.layer]; 220 | [renderer setupView:(CAEAGLLayer*)self.layer]; 221 | } 222 | } 223 | 224 | - (NSInteger)animationFrameInterval 225 | { 226 | return animationFrameInterval; 227 | } 228 | 229 | - (void)setAnimationFrameInterval:(NSInteger)frameInterval 230 | { 231 | // Frame interval defines how many display frames must pass between each time the 232 | // display link fires. The display link will only fire 30 times a second when the 233 | // frame internal is two on a display that refreshes 60 times a second. The default 234 | // frame interval setting of one will fire 60 times a second when the display refreshes 235 | // at 60 times a second. A frame interval setting of less than one results in undefined 236 | // behavior. 237 | if (frameInterval >= 1) 238 | { 239 | animationFrameInterval = frameInterval; 240 | 241 | if (animating) 242 | { 243 | [self stopAnimation]; 244 | [self startAnimation]; 245 | } 246 | } 247 | } 248 | 249 | - (void)startAnimation 250 | { 251 | if (!animating) 252 | { 253 | if (displayLinkSupported ) 254 | { 255 | DLog(@"displayLinkSupported"); 256 | // CADisplayLink is API new to iPhone SDK 3.1. Compiling against earlier versions will result in a warning, but can be dismissed 257 | // if the system version runtime check for CADisplayLink exists in -initWithCoder:. The runtime check ensures this code will 258 | // not be called in system versions earlier than 3.1. 259 | displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(updateView:)]; 260 | [displayLink setFrameInterval:animationFrameInterval]; 261 | [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; 262 | } else { 263 | animationTimer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)((1.0 / 60.0) * animationFrameInterval) target:self selector:@selector(updateView:) userInfo:nil repeats:TRUE]; 264 | } 265 | 266 | animating = TRUE; 267 | } 268 | } 269 | 270 | - (void)stopAnimation 271 | { 272 | NSLog(@"StopAnimation" ); 273 | if (animating) 274 | { 275 | if (displayLinkSupported) 276 | { 277 | [displayLink invalidate]; 278 | displayLink = nil; 279 | } 280 | else 281 | { 282 | [animationTimer invalidate]; 283 | animationTimer = nil; 284 | } 285 | 286 | animating = FALSE; 287 | } 288 | } 289 | 290 | - (void)animateToEnd 291 | { 292 | self.targetPoint_ = [self activePage].P; 293 | self.targetVector_ = PSVector( self.targetPoint_, CGPointMake( [self activePage].SP.x, [self activePage].SP.y ) ); 294 | self.currentTime_ = 0.0; 295 | CGPoint vp = CGPointMake( self.targetPoint_.x+self.targetVector_.x, self.targetPoint_.y+self.targetVector_.y); 296 | self.targetTime_ = fminf( PSDistance( self.targetPoint_, vp ) * 0.66, 0.25 ); 297 | [self startAnimation]; 298 | } 299 | 300 | - (void)activateLeftPage 301 | { 302 | DLog(@"activateLeftPage"); 303 | self.activePage_ = leftPage_; 304 | } 305 | 306 | - (void)activateRightPage 307 | { 308 | DLog(@"activateRightPage"); 309 | self.activePage_ = rightPage_; 310 | } 311 | 312 | - (PSPage *)activePage 313 | { 314 | return activePage_; 315 | } 316 | 317 | - (PSEffects *)activeEffects 318 | { 319 | return effects_; 320 | } 321 | 322 | - (void)setDatasource:(id)value 323 | { 324 | renderer.datasource = value; 325 | } 326 | 327 | - (void)setOrthoTranslate:(CGFloat)value 328 | { 329 | renderer.orthoTranslate = value; 330 | } 331 | 332 | #pragma mark - 333 | #pragma mark CCPageDelegate 334 | 335 | - (void)pageDidFinishDeformWithAngle:(CGFloat)angle andTime:(CGFloat)time point:(CGPoint)point theta:(CGFloat)theta 336 | { 337 | [effects_ updateCurlTime:time angle:angle point:point theta:theta]; 338 | } 339 | 340 | - (void)dealloc 341 | { 342 | [rightPage_ release]; 343 | [leftPage_ release]; 344 | [effects_ release]; 345 | [renderer release]; 346 | [super dealloc]; 347 | } 348 | 349 | @end 350 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/GL/ES1Renderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // ES1Renderer.h 3 | // ConeCurl 4 | // 5 | // Created by W. Dana Nuon on 4/18/10. 6 | // Copyright lunaray 2010. All rights reserved. 7 | // 8 | // Modified from Xcode OpenGL ES template project. 9 | // 10 | // TODO: Add proper lighting once we calculate surface normals. 11 | 12 | #import "ESRenderer.h" 13 | #import 14 | #import 15 | #import "ESCommon.h" 16 | 17 | @interface ES1Renderer : NSObject 18 | { 19 | @private 20 | EAGLContext *context; 21 | 22 | // The pixel dimensions of the CAEAGLLayer 23 | GLint backingWidth; 24 | GLint backingHeight; 25 | 26 | // The OpenGL ES names for the framebuffer and renderbuffer used to render to this view 27 | GLuint defaultFramebuffer, colorRenderbuffer; 28 | GLuint texture[6]; 29 | 30 | NSUInteger frontTextureIndex; 31 | NSUInteger backTextureIndex; 32 | } 33 | 34 | @property (nonatomic, assign) id datasource; 35 | @property (nonatomic, assign) CGFloat orthoTranslate; 36 | 37 | - (void)setupView:(CAEAGLLayer *)layer; 38 | - (BOOL)resizeFromLayer:(CAEAGLLayer *)layer; 39 | - (void)renderObject:(id)obj withEffects:(id)effects; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/GL/ES1Renderer.m: -------------------------------------------------------------------------------- 1 | // 2 | // ES1Renderer.m 3 | // ConeCurl 4 | // 5 | // Created by W. Dana Nuon on 4/18/10. 6 | // Copyright lunaray 2010. All rights reserved. 7 | // 8 | // Portions borrowed and slightly modified from Jeff LaMarche, (C) 2009. 9 | 10 | #import "ES1Renderer.h" 11 | #import "PSPage.h" 12 | #import "PSEffects.h" 13 | 14 | @interface ES1Renderer() 15 | 16 | @property (nonatomic, assign) BOOL hasSinglePage; 17 | 18 | - (void)drawShaderWithEffects:(id)effects; 19 | - (void)drawInnerShadowWithEffects:(id)effects andObject:(id)obj; 20 | - (void)drawOuterShadowWithEffects:(id)effects andObject:(id)obj; 21 | 22 | @end 23 | 24 | @implementation ES1Renderer 25 | 26 | @synthesize datasource, orthoTranslate, hasSinglePage; 27 | 28 | // Create an OpenGL ES 1.1 context 29 | - (id)init 30 | { 31 | if ((self = [super init])) 32 | { 33 | context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; 34 | 35 | if (!context || ![EAGLContext setCurrentContext:context]) 36 | { 37 | [self release]; 38 | return nil; 39 | } 40 | 41 | // Create default framebuffer object. The backing will be allocated for the current layer in -resizeFromLayer 42 | glGenFramebuffersOES(1, &defaultFramebuffer); 43 | glGenRenderbuffersOES(1, &colorRenderbuffer); 44 | glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer); 45 | glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer); 46 | glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, colorRenderbuffer); 47 | } 48 | 49 | return self; 50 | } 51 | 52 | - (void)setupView:(CAEAGLLayer *)layer 53 | { 54 | [EAGLContext setCurrentContext:context]; 55 | glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer); 56 | 57 | //const GLfloat zNear = 0.01f, zFar = 100.0f, fieldOfView = 1.0f; 58 | glMatrixMode(GL_PROJECTION); 59 | //GLfloat size = zNear * tanf(DEGREES_TO_RADIANS(fieldOfView) / 2.0f); 60 | //GLfloat aspectRatio = (GLfloat)backingWidth / backingHeight; 61 | //glFrustumf(-size, size, -size / aspectRatio, size / aspectRatio, zNear, zFar); 62 | glViewport(0, 0, backingWidth, backingHeight); 63 | //glTranslatef(0.0f, 0.0f, 0.0f); 64 | glOrthof(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); 65 | 66 | glEnable(GL_DEPTH_TEST); 67 | glEnable(GL_CULL_FACE); 68 | glEnable(GL_TEXTURE_2D); 69 | glGenTextures(6, &texture[0]); 70 | } 71 | 72 | - (void)loadTextures 73 | { 74 | 75 | // single page 76 | self.hasSinglePage = [datasource rendererHasSinglePage]; 77 | 78 | glBindTexture(GL_TEXTURE_2D, texture[0]); 79 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 80 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); 81 | 82 | UIImage *image = [datasource rendererGetRightFrontTexture]; 83 | 84 | if (image == nil) 85 | NSLog(@"Do real error checking here"); 86 | 87 | GLuint width = CGImageGetWidth(image.CGImage); 88 | GLuint height = CGImageGetHeight(image.CGImage); 89 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 90 | void *imageData = malloc( height * width * 4 ); 91 | 92 | CGContextRef bitmapContext = CGBitmapContextCreate( imageData, width, height, 8, 4 * width, colorSpace, 93 | kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big ); 94 | 95 | // Flip the Y-axis 96 | CGContextTranslateCTM (bitmapContext, 0, height); 97 | CGContextScaleCTM (bitmapContext, 1.0, -1.0); 98 | 99 | CGColorSpaceRelease(colorSpace); 100 | CGContextClearRect(bitmapContext, CGRectMake( 0, 0, width, height ) ); 101 | CGContextDrawImage(bitmapContext, CGRectMake( 0, 0, width, height ), image.CGImage ); 102 | 103 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); 104 | 105 | CGContextRelease(bitmapContext); 106 | 107 | free(imageData); 108 | 109 | glBindTexture(GL_TEXTURE_2D, texture[1]); 110 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 111 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); 112 | image = [datasource rendererGetRightBackTexture]; 113 | 114 | if (image == nil) 115 | NSLog(@"Do real error checking here"); 116 | 117 | width = CGImageGetWidth(image.CGImage); 118 | height = CGImageGetHeight(image.CGImage); 119 | imageData = malloc( height * width * 4 ); 120 | 121 | bitmapContext = CGBitmapContextCreate( imageData, width, height, 8, 4 * width, colorSpace, 122 | kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big ); 123 | 124 | // Flip the Y-axis 125 | CGContextTranslateCTM (bitmapContext, 0, height); 126 | CGContextScaleCTM (bitmapContext, 1.0, -1.0); 127 | 128 | CGColorSpaceRelease(colorSpace); 129 | CGContextClearRect(bitmapContext, CGRectMake( 0, 0, width, height ) ); 130 | CGContextDrawImage(bitmapContext, CGRectMake( 0, 0, width, height ), image.CGImage ); 131 | 132 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); 133 | 134 | CGContextRelease(bitmapContext); 135 | 136 | free(imageData); 137 | 138 | if ( !self.hasSinglePage ) { 139 | glBindTexture(GL_TEXTURE_2D, texture[2]); 140 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 141 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); 142 | image = [datasource rendererGetLeftFrontTexture]; 143 | 144 | if (image == nil) 145 | NSLog(@"Do real error checking here"); 146 | 147 | width = CGImageGetWidth(image.CGImage); 148 | height = CGImageGetHeight(image.CGImage); 149 | imageData = malloc( height * width * 4 ); 150 | 151 | bitmapContext = CGBitmapContextCreate( imageData, width, height, 8, 4 * width, colorSpace, 152 | kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big ); 153 | 154 | // Flip the Y-axis 155 | CGContextTranslateCTM (bitmapContext, 0, height); 156 | CGContextScaleCTM (bitmapContext, 1.0, -1.0); 157 | 158 | CGColorSpaceRelease(colorSpace); 159 | CGContextClearRect(bitmapContext, CGRectMake( 0, 0, width, height ) ); 160 | CGContextDrawImage(bitmapContext, CGRectMake( 0, 0, width, height ), image.CGImage ); 161 | 162 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); 163 | 164 | CGContextRelease(bitmapContext); 165 | 166 | free(imageData); 167 | 168 | glBindTexture(GL_TEXTURE_2D, texture[3]); 169 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 170 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); 171 | image = [datasource rendererGetLeftBackTexture]; 172 | 173 | if (image == nil) 174 | NSLog(@"Do real error checking here"); 175 | 176 | width = CGImageGetWidth(image.CGImage); 177 | height = CGImageGetHeight(image.CGImage); 178 | imageData = malloc( height * width * 4 ); 179 | 180 | bitmapContext = CGBitmapContextCreate( imageData, width, height, 8, 4 * width, colorSpace, 181 | kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big ); 182 | 183 | // Flip the Y-axis 184 | CGContextTranslateCTM (bitmapContext, 0, height); 185 | CGContextScaleCTM (bitmapContext, 1.0, -1.0); 186 | 187 | CGColorSpaceRelease(colorSpace); 188 | CGContextClearRect(bitmapContext, CGRectMake( 0, 0, width, height ) ); 189 | CGContextDrawImage(bitmapContext, CGRectMake( 0, 0, width, height ), image.CGImage ); 190 | 191 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); 192 | 193 | CGContextRelease(bitmapContext); 194 | 195 | free(imageData); 196 | } 197 | 198 | } 199 | 200 | - (void)loadEffects 201 | { 202 | glBindTexture(GL_TEXTURE_2D, texture[4]); 203 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 204 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); 205 | 206 | UIImage *image = [datasource rendererGetShaderTexture]; 207 | 208 | if (image == nil) 209 | NSLog(@"Do real error checking here"); 210 | 211 | GLuint width = CGImageGetWidth(image.CGImage); 212 | GLuint height = CGImageGetHeight(image.CGImage); 213 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 214 | void *imageData = malloc( height * width * 4 ); 215 | 216 | CGContextRef bitmapContext = CGBitmapContextCreate( imageData, width, height, 8, 4 * width, colorSpace, 217 | kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big ); 218 | 219 | // Flip the Y-axis 220 | CGContextTranslateCTM (bitmapContext, 0, height); 221 | CGContextScaleCTM (bitmapContext, 1.0, -1.0); 222 | 223 | CGColorSpaceRelease(colorSpace); 224 | CGContextClearRect(bitmapContext, CGRectMake( 0, 0, width, height ) ); 225 | CGContextDrawImage(bitmapContext, CGRectMake( 0, 0, width, height ), image.CGImage ); 226 | 227 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); 228 | 229 | CGContextRelease(bitmapContext); 230 | 231 | free(imageData); 232 | 233 | glBindTexture(GL_TEXTURE_2D, texture[5]); 234 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 235 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); 236 | image = [datasource rendererGetInnerShadowTexture]; 237 | 238 | if (image == nil) 239 | NSLog(@"Do real error checking here"); 240 | 241 | width = CGImageGetWidth(image.CGImage); 242 | height = CGImageGetHeight(image.CGImage); 243 | imageData = malloc( height * width * 4 ); 244 | 245 | bitmapContext = CGBitmapContextCreate( imageData, width, height, 8, 4 * width, colorSpace, 246 | kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big ); 247 | 248 | // Flip the Y-axis 249 | CGContextTranslateCTM (bitmapContext, 0, height); 250 | CGContextScaleCTM (bitmapContext, 1.0, -1.0); 251 | 252 | CGColorSpaceRelease(colorSpace); 253 | CGContextClearRect(bitmapContext, CGRectMake( 0, 0, width, height ) ); 254 | CGContextDrawImage(bitmapContext, CGRectMake( 0, 0, width, height ), image.CGImage ); 255 | 256 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); 257 | 258 | CGContextRelease(bitmapContext); 259 | 260 | free(imageData); 261 | 262 | } 263 | 264 | - (BOOL)resizeFromLayer:(CAEAGLLayer *)layer 265 | { 266 | 267 | // Allocate color buffer backing based on the current layer size 268 | glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer); 269 | [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:layer]; 270 | glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); 271 | glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); 272 | 273 | // NSLog(@"BackinW: %d", backingWidth); 274 | // NSLog(@"BackinH: %d", backingHeight); 275 | 276 | if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) 277 | { 278 | NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); 279 | return NO; 280 | } 281 | 282 | return YES; 283 | } 284 | 285 | - (void)renderObject:(id)obj withEffects:(id)effects 286 | { 287 | const Vertex3f *vertices = [obj vertices]; 288 | const Vertex2f *textures = [obj textureArray]; 289 | 290 | frontTextureIndex = 0; 291 | backTextureIndex = 1; 292 | if ( ![datasource rendererisRightPage] ) { 293 | frontTextureIndex = 2; 294 | backTextureIndex = 3; 295 | } 296 | 297 | glMatrixMode(GL_PROJECTION); 298 | glLoadIdentity(); 299 | glOrthof(-0.5, 0.5, -0.5f, 0.5f, -1.0f, 1.0f); 300 | glTranslatef(-orthoTranslate, 0.0f, 0.0f); 301 | 302 | glEnable(GL_BLEND); 303 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 304 | 305 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f); 306 | glClear(GL_COLOR_BUFFER_BIT); 307 | 308 | // Load our vertex and texture arrays. This needs to be done only once since the front and back pages share this data. 309 | glEnableClientState(GL_VERTEX_ARRAY); 310 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); 311 | 312 | glVertexPointer(3, GL_FLOAT, 0, vertices); 313 | glTexCoordPointer(2, GL_FLOAT, 0, textures); 314 | 315 | #if USE_TRIANGLE_STRIPS 316 | 317 | const GLushort *frontStrip = [obj frontStrip]; 318 | const GLushort *backStrip = [obj backStrip]; 319 | GLuint stripLength = [obj stripLength]; 320 | 321 | // Draw the back page 322 | if ( hasSinglePage ) { 323 | glColor4f(0.4, 0.4, 0.4, 0.4); 324 | } 325 | glBindTexture(GL_TEXTURE_2D, texture[backTextureIndex]); 326 | glDrawElements(GL_TRIANGLE_STRIP, stripLength, GL_UNSIGNED_SHORT, backStrip); 327 | 328 | if ( hasSinglePage ) { 329 | glDisable(GL_TEXTURE_2D); 330 | glBlendFunc(GL_ONE_MINUS_DST_ALPHA,GL_ONE); 331 | glColor4f(1.0, 1.0, 1.0, 1.0); 332 | glDrawElements(GL_TRIANGLE_STRIP, stripLength, GL_UNSIGNED_SHORT, backStrip); 333 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 334 | glEnable(GL_TEXTURE_2D); 335 | 336 | glColor4f(1.0, 1.0, 1.0, 1.0); 337 | } 338 | 339 | [self drawShaderWithEffects:effects]; 340 | [self drawInnerShadowWithEffects:effects andObject:obj]; 341 | [self drawOuterShadowWithEffects:effects andObject:obj]; 342 | glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE); 343 | 344 | glVertexPointer(3, GL_FLOAT, 0, vertices); 345 | glTexCoordPointer(2, GL_FLOAT, 0, textures); 346 | 347 | // Draw the front page 348 | glBindTexture(GL_TEXTURE_2D, texture[frontTextureIndex]); 349 | glDrawElements(GL_TRIANGLE_STRIP, stripLength, GL_UNSIGNED_SHORT, frontStrip); 350 | 351 | #else 352 | 353 | const GLushort *frontFaces = [obj frontFaces]; 354 | const GLushort *backFaces = [obj backFaces]; 355 | GLuint numFaces = [obj numFaces]; 356 | 357 | // Draw the back page 358 | glBindTexture(GL_TEXTURE_2D, texture[backTextureIndex]); 359 | glDrawElements(GL_TRIANGLES, numFaces * 3, GL_UNSIGNED_SHORT, backFaces); 360 | 361 | [self drawShaderWithEffects:effects]; 362 | 363 | glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA); 364 | 365 | glVertexPointer(3, GL_FLOAT, 0, vertices); 366 | glTexCoordPointer(2, GL_FLOAT, 0, textures); 367 | 368 | // Draw the front page 369 | glBindTexture(GL_TEXTURE_2D, texture[frontTextureIndex]); 370 | glDrawElements(GL_TRIANGLES, numFaces * 3, GL_UNSIGNED_SHORT, frontFaces); 371 | 372 | #endif 373 | 374 | // This application only creates a single color renderbuffer which is already bound at this point. 375 | // This call is redundant, but needed if dealing with multiple renderbuffers. 376 | glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer); 377 | [context presentRenderbuffer:GL_RENDERBUFFER_OES]; 378 | 379 | } 380 | 381 | - (void)drawShaderWithEffects:(id)effects 382 | { 383 | // shader 384 | 385 | glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA); 386 | 387 | const Vertex2f *shaderVertices = [effects shaderVertices]; 388 | const Vertex2f *shaderCoords = [effects shaderCoords]; 389 | 390 | glBindTexture(GL_TEXTURE_2D, texture[4]); 391 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 392 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 393 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 394 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 395 | 396 | glVertexPointer(2, GL_FLOAT, 0, shaderVertices); 397 | glTexCoordPointer(2, GL_FLOAT, 0, shaderCoords); 398 | 399 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 400 | } 401 | 402 | - (void)drawInnerShadowWithEffects:(id)effects andObject:(id)obj 403 | { 404 | 405 | glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA); 406 | 407 | const Vertex3f *vertices = [obj innerShadowVertices]; 408 | const Vertex2f *textures = [obj textureArray]; 409 | 410 | glVertexPointer(3, GL_FLOAT, 0, vertices); 411 | glTexCoordPointer(2, GL_FLOAT, 0, textures); 412 | 413 | const GLushort *backStrip = [obj backStrip]; 414 | GLuint stripLength = [obj stripLength]; 415 | 416 | // Draw the back page 417 | glBindTexture(GL_TEXTURE_2D, texture[5]); 418 | 419 | glDrawElements(GL_TRIANGLE_STRIP, stripLength, GL_UNSIGNED_SHORT, backStrip); 420 | 421 | } 422 | 423 | - (void)drawOuterShadowWithEffects:(id)effects andObject:(id)obj 424 | { 425 | return; 426 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 427 | //glBlendFunc(GL_ONE, GL_ONE); 428 | 429 | const Vertex3f *vertices = [obj outerShadowVertices]; 430 | const Vertex2f *textures = [obj textureArray]; 431 | 432 | glVertexPointer(3, GL_FLOAT, 0, vertices); 433 | glTexCoordPointer(2, GL_FLOAT, 0, textures); 434 | 435 | const GLushort *frontStrip = [obj frontStrip]; 436 | GLuint stripLength = [obj stripLength]; 437 | 438 | // Draw the back page 439 | glBindTexture(GL_TEXTURE_2D, texture[5]); 440 | 441 | glDrawElements(GL_TRIANGLE_STRIP, stripLength, GL_UNSIGNED_SHORT, frontStrip); 442 | 443 | } 444 | 445 | - (void)dealloc 446 | { 447 | // Tear down GL 448 | if (defaultFramebuffer) 449 | { 450 | glDeleteFramebuffersOES(1, &defaultFramebuffer); 451 | defaultFramebuffer = 0; 452 | } 453 | 454 | if (colorRenderbuffer) 455 | { 456 | glDeleteRenderbuffersOES(1, &colorRenderbuffer); 457 | colorRenderbuffer = 0; 458 | } 459 | 460 | // Tear down context 461 | if ([EAGLContext currentContext] == context) 462 | [EAGLContext setCurrentContext:nil]; 463 | 464 | [context release]; 465 | context = nil; 466 | 467 | [super dealloc]; 468 | } 469 | 470 | @end 471 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/GL/ESCommon.h: -------------------------------------------------------------------------------- 1 | 2 | #define USE_TRIANGLE_STRIPS 1 3 | #define SHOW_DEBUG_LINES 1 4 | #define PAGE_COLUMNS 46 5 | #define PAGE_ROWS 72 6 | 7 | #define M_PI_HALF M_PI * 0.5 8 | 9 | #define DEGREES_TO_RADIANS(__ANGLE__) ((__ANGLE__) / 180.0f * M_PI) 10 | #define RAD (180.0f / M_PI) 11 | 12 | typedef struct 13 | { 14 | CGFloat x; 15 | CGFloat y; 16 | } Vector2f; 17 | typedef Vector2f Vertex2f; 18 | 19 | typedef struct 20 | { 21 | u_int x; 22 | u_int y; 23 | } Vector2ui; 24 | typedef Vector2ui Vertex2ui; 25 | 26 | typedef struct 27 | { 28 | CGFloat x; 29 | CGFloat y; 30 | CGFloat z; 31 | } Vector3f; 32 | typedef Vector3f Vertex3f; 33 | 34 | typedef struct 35 | { 36 | u_int x; 37 | u_int y; 38 | u_int z; 39 | } Vector3ui; 40 | typedef Vector3ui Vertex3ui; 41 | 42 | typedef struct 43 | { 44 | u_char r; 45 | u_char g; 46 | u_char b; 47 | u_char a; 48 | } Color4b; 49 | 50 | typedef struct { 51 | Vertex3f v1; 52 | Vertex3f v2; 53 | Vertex3f v3; 54 | } Triangle3D; 55 | 56 | static inline Vertex2f Vertex2fMake(CGFloat inX, CGFloat inY) 57 | { 58 | Vertex2f ret; 59 | ret.x = inX; 60 | ret.y = inY; 61 | return ret; 62 | } 63 | 64 | static inline void Vertex2fSet(Vertex2f *vertex, CGFloat inX, CGFloat inY) 65 | { 66 | vertex->x = inX; 67 | vertex->y = inY; 68 | } 69 | 70 | static inline Vertex2ui Vertex2uiMake(u_int inX, u_int inY) 71 | { 72 | Vertex2ui ret; 73 | ret.x = inX; 74 | ret.y = inY; 75 | return ret; 76 | } 77 | 78 | static inline void Vertex2uiSet(Vertex2ui *vertex, u_int inX, u_int inY) 79 | { 80 | vertex->x = inX; 81 | vertex->y = inY; 82 | } 83 | 84 | static inline Vector2f Vector2fMake(CGFloat inX, CGFloat inY) 85 | { 86 | Vector2f ret; 87 | ret.x = inX; 88 | ret.y = inY; 89 | return ret; 90 | } 91 | 92 | static inline Vector2ui Vector2uiMake(u_int inX, u_int inY) 93 | { 94 | Vector2ui ret; 95 | ret.x = inX; 96 | ret.y = inY; 97 | return ret; 98 | } 99 | 100 | static inline Vertex3f Vertex3fMake(CGFloat inX, CGFloat inY, CGFloat inZ) 101 | { 102 | Vertex3f ret; 103 | ret.x = inX; 104 | ret.y = inY; 105 | ret.z = inZ; 106 | return ret; 107 | } 108 | 109 | static inline void Vertex3fSet(Vertex3f *vertex, CGFloat inX, CGFloat inY, CGFloat inZ) 110 | { 111 | vertex->x = inX; 112 | vertex->y = inY; 113 | vertex->z = inZ; 114 | } 115 | 116 | static inline Vertex3ui Vertex3uiMake(u_int inX, u_int inY, u_int inZ) 117 | { 118 | Vertex3ui ret; 119 | ret.x = inX; 120 | ret.y = inY; 121 | ret.z = inZ; 122 | return ret; 123 | } 124 | 125 | static inline void Vertex3uiSet(Vertex3ui *vertex, u_int inX, u_int inY, u_int inZ) 126 | { 127 | vertex->x = inX; 128 | vertex->y = inY; 129 | vertex->z = inZ; 130 | } 131 | 132 | static inline Vector3f Vector3fMake(CGFloat inX, CGFloat inY, CGFloat inZ) 133 | { 134 | Vector3f ret; 135 | ret.x = inX; 136 | ret.y = inY; 137 | ret.z = inZ; 138 | return ret; 139 | } 140 | 141 | static inline Vector3ui Vector3uiMake(u_int inX, u_int inY, u_int inZ) 142 | { 143 | Vector3ui ret; 144 | ret.x = inX; 145 | ret.y = inY; 146 | ret.z = inZ; 147 | return ret; 148 | } 149 | 150 | static inline Color4b Color4bMake(u_char inR, u_char inG, u_char inB, u_char inA) 151 | { 152 | Color4b ret; 153 | ret.r = inR; 154 | ret.g = inG; 155 | ret.b = inB; 156 | ret.a = inA; 157 | return ret; 158 | } 159 | 160 | static inline Triangle3D Triangle3DMake(Vertex3f inV1, Vertex3f inV2, Vertex3f inV3) 161 | { 162 | Triangle3D ret; 163 | ret.v1 = inV1; 164 | ret.v2 = inV2; 165 | ret.v3 = inV3; 166 | return ret; 167 | } 168 | 169 | static inline void QuadToTrianglesWindCWSet(u_short *vertex, CGFloat ul, CGFloat ur, CGFloat ll, CGFloat lr) 170 | { 171 | // Break a quad into two triangles, since OpenGL ES does not support quads. Clockwise winding. 172 | vertex[0] = lr; 173 | vertex[1] = ll; 174 | vertex[2] = ul; 175 | vertex[3] = lr; 176 | vertex[4] = ul; 177 | vertex[5] = ur; 178 | } 179 | 180 | static inline void QuadToTrianglesWindCCWSet(u_short *vertex, CGFloat ul, CGFloat ur, CGFloat ll, CGFloat lr) 181 | { 182 | // Break a quad into two triangles, since OpenGL ES does not support quads. Counter-clockwise winding. 183 | vertex[0] = lr; 184 | vertex[1] = ul; 185 | vertex[2] = ll; 186 | vertex[3] = lr; 187 | vertex[4] = ur; 188 | vertex[5] = ul; 189 | } 190 | 191 | static inline float vectorMagnitude( Vector3f vector ){ 192 | return sqrt((vector.x * vector.x) + (vector.y * vector.y) + (vector.z * vector.z)); 193 | } 194 | 195 | static inline void normalizeVector(Vector3f *vector) 196 | { 197 | float vecMag = vectorMagnitude(*vector); 198 | vector->x /= vecMag; 199 | vector->y /= vecMag; 200 | vector->z /= vecMag; 201 | } 202 | 203 | 204 | static inline Vector3f Vector3DMakeWithStartAndEndPoints(Vertex3f start, Vertex3f end) 205 | { 206 | Vector3f ret; 207 | ret.x = end.x - start.x; 208 | ret.y = end.y - start.y; 209 | ret.z = end.z - start.z; 210 | normalizeVector(&ret); 211 | return ret; 212 | } 213 | 214 | static inline Vector3f Triangle3DCalculateSurfaceNormal( Triangle3D triangle ) 215 | { 216 | Vector3f u = Vector3DMakeWithStartAndEndPoints(triangle.v2, triangle.v1); 217 | Vector3f v = Vector3DMakeWithStartAndEndPoints(triangle.v3, triangle.v1); 218 | 219 | Vector3f ret; 220 | ret.x = (u.y * v.z) - (u.z * v.y); 221 | ret.y = (u.z * v.x) - (u.x * v.z); 222 | ret.z = (u.x * v.y) - (u.y * v.x); 223 | return ret; 224 | } 225 | 226 | static inline CGFloat funcLinear(CGFloat ft, CGFloat f0, CGFloat f1) 227 | { 228 | // Linear interpolation between f0 and f1 229 | return f0 + (f1 - f0) * ft; 230 | } 231 | 232 | static inline CGFloat funcQuad(CGFloat ft, CGFloat f0, CGFloat f1) 233 | { 234 | // Quadratic interpolation between f0 and f1 235 | return f0 + (f1 - f0) * ft * ft; 236 | } 237 | 238 | static inline CGFloat funcPower(CGFloat ft, CGFloat f0, CGFloat f1, CGFloat p) 239 | { 240 | // Exponential interpolation between f0 and f1 241 | return f0 + (f1 - f0) * pow(ft, p); 242 | } 243 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/GL/ESRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESRenderer.h 3 | // ConeCurl 4 | // 5 | // Created by W. Dana Nuon on 4/18/10. 6 | // Copyright lunaray 2010. All rights reserved. 7 | // 8 | // Modified from Xcode OpenGL ES template. Replaced -render method with -renderObject: to allow passing in 9 | // of arbitrary object data so the renderer isn't responsible for keeping model state. 10 | // 11 | 12 | #import 13 | 14 | #import 15 | #import 16 | 17 | @protocol ESRendererDataSource 18 | 19 | - (BOOL)rendererHasSinglePage; 20 | - (BOOL)rendererisRightPage; 21 | - (UIImage*)rendererGetRightFrontTexture; 22 | - (UIImage*)rendererGetRightBackTexture; 23 | - (UIImage*)rendererGetLeftFrontTexture; 24 | - (UIImage*)rendererGetLeftBackTexture; 25 | - (UIImage*)rendererGetShaderTexture; 26 | - (UIImage*)rendererGetInnerShadowTexture; 27 | - (CGRect)rendererGetRightFrontTextureRect; 28 | - (CGRect)rendererGetRightBackTextureRect; 29 | - (CGRect)rendererGetLeftFrontTextureRect; 30 | - (CGRect)rendererGetLeftBackTextureRect; 31 | - (CGRect)rendererGetRightFrontTextureBounds; 32 | - (CGRect)rendererGetRightBackTextureBounds; 33 | - (CGRect)rendererGetLeftFrontTextureBounds; 34 | - (CGRect)rendererGetLeftBackTextureBounds; 35 | 36 | @end 37 | 38 | @protocol ESRenderer 39 | 40 | - (void)loadTextures; 41 | - (void)loadEffects; 42 | - (void)setupView:(CAEAGLLayer *)layer; 43 | - (BOOL)resizeFromLayer:(CAEAGLLayer *)layer; 44 | - (void)renderObject:(id)obj withEffects:(id)effects; 45 | 46 | @property (nonatomic, assign) id datasource; 47 | @property (nonatomic, assign) CGFloat orthoTranslate; 48 | 49 | @end 50 | 51 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSDrawings.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSDrawings.h 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 28/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef enum { 12 | PSPagesViewPageOrientationUnknow, 13 | PSPagesViewPageOrientationPortrait, 14 | PSPagesViewPageOrientationLandscape 15 | 16 | } PSPagesViewPageOrientation; 17 | 18 | typedef enum { 19 | PSDrawingsPixelFormat_Automatic = 0, 20 | //! 32-bit texture: RGBA8888 21 | PSDrawingsPixelFormat_RGBA8888, 22 | //! 16-bit texture without Alpha channel 23 | PSDrawingsPixelFormat_RGB565, 24 | //! 8-bit textures used as masks 25 | PSDrawingsPixelFormat_A8, 26 | //! 16-bit textures: RGBA4444 27 | PSDrawingsPixelFormat_RGBA4444, 28 | //! 16-bit textures: RGB5A1 29 | PSDrawingsPixelFormat_RGB5A1, 30 | 31 | //! Default texture format: RGBA8888 32 | PSDrawingsPixelFormat_Default = PSDrawingsPixelFormat_RGBA8888 33 | 34 | } PSDrawingsPixelFormat; 35 | 36 | 37 | CGMutablePathRef PSCreatePagePath( CGRect rect, CGFloat padding, CGFloat span ); 38 | 39 | CGMutablePathRef PSCreatePageSquarePath( CGRect rect, CGFloat padding, CGFloat span ); 40 | 41 | CGMutablePathRef PSCreateRoundedBoxPath( CGRect rect, CGFloat radius ); 42 | 43 | 44 | unsigned int PSNextPOT( unsigned int x ); 45 | 46 | CGPoint PSVector( CGPoint firstPoint, CGPoint secondPoint ); 47 | 48 | CGFloat PSDistance( CGPoint firstPoint, CGPoint secondPoint ); 49 | 50 | CGFloat PSAngle( CGPoint firstPoint, CGPoint secondPoint ); 51 | 52 | CGFloat PSQuad( CGFloat ft, CGFloat f0, CGFloat f1 ); 53 | 54 | CGFloat PSLinear( CGFloat ft, CGFloat f0, CGFloat f1 ); 55 | 56 | CGFloat PSPower( CGFloat ft, CGFloat f0, CGFloat f1, CGFloat p ); 57 | 58 | CGPoint PSRotatePointBy( CGPoint point, CGPoint origin, CGFloat angle ); 59 | 60 | CGAffineTransform PSRectScaleAspectFit( CGRect innerRect, CGRect outerRect ); 61 | 62 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSDrawings.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSDrawings.m 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 28/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import "PSDrawings.h" 10 | 11 | 12 | CGMutablePathRef PSCreatePagePath( CGRect rect, CGFloat padding, CGFloat span ) 13 | { 14 | CGFloat radius = rect.size.height * 0.05; 15 | CGFloat sp = radius * 0.25; 16 | CGFloat dpadding = span; 17 | CGFloat ox = rect.origin.x; 18 | CGMutablePathRef path = CGPathCreateMutable(); 19 | CGPathMoveToPoint( path, NULL, 0.0, sp + padding ); 20 | CGPathAddQuadCurveToPoint( path, NULL, ox, 0.0 + padding, radius + padding, 0.0 + padding ); 21 | CGPathAddLineToPoint( path, NULL, rect.size.width - dpadding, 0.0 + padding ); 22 | CGPathAddLineToPoint( path, NULL, rect.size.width - dpadding, rect.size.height - padding ); 23 | CGPathAddLineToPoint( path, NULL, radius + padding, rect.size.height - padding ); 24 | CGPathAddQuadCurveToPoint( path, NULL, ox, rect.size.height - padding, ox, rect.size.height - sp - padding ); 25 | CGPathAddLineToPoint( path, NULL, ox, sp + padding ); 26 | return path; 27 | } 28 | 29 | CGMutablePathRef PSCreatePageSquarePath( CGRect rect, CGFloat padding, CGFloat span ) 30 | { 31 | CGFloat dpadding = span; 32 | CGFloat ox = rect.origin.x; 33 | CGMutablePathRef path = CGPathCreateMutable(); 34 | CGPathMoveToPoint( path, NULL, ox, padding ); 35 | CGPathAddLineToPoint( path, NULL, rect.size.width - dpadding, 0.0 + padding ); 36 | CGPathAddLineToPoint( path, NULL, rect.size.width - dpadding, rect.size.height - padding ); 37 | CGPathAddLineToPoint( path, NULL, ox, rect.size.height - padding ); 38 | CGPathAddLineToPoint( path, NULL, ox, padding ); 39 | return path; 40 | } 41 | 42 | CGMutablePathRef PSCreateRoundedBoxPath( CGRect rect, CGFloat radius ) 43 | { 44 | CGFloat ox = rect.origin.x; 45 | CGFloat oy = rect.origin.y; 46 | CGMutablePathRef path = CGPathCreateMutable(); 47 | CGPathMoveToPoint( path, NULL, ox, oy+radius ); 48 | CGPathAddQuadCurveToPoint( path, NULL, ox, oy, ox+radius, oy ); 49 | CGPathAddLineToPoint( path, NULL, rect.size.width-radius, oy); 50 | CGPathAddQuadCurveToPoint( path, NULL, rect.size.width, oy, rect.size.width, oy+radius ); 51 | CGPathAddLineToPoint( path, NULL, rect.size.width, rect.size.height-radius+oy); 52 | CGPathAddQuadCurveToPoint( path, NULL, rect.size.width, rect.size.height+oy, rect.size.width-radius, rect.size.height+oy ); 53 | CGPathAddLineToPoint( path, NULL, ox+radius, rect.size.height+oy); 54 | CGPathAddQuadCurveToPoint( path, NULL, ox, rect.size.height+oy, ox, rect.size.height-radius+oy ); 55 | CGPathAddLineToPoint( path, NULL, ox, oy+radius ); 56 | return path; 57 | 58 | } 59 | 60 | unsigned int PSNextPOT( unsigned int x ) { 61 | x = x - 1; 62 | x = x | (x >> 1); 63 | x = x | (x >> 2); 64 | x = x | (x >> 4); 65 | x = x | (x >> 8); 66 | x = x | (x >>16); 67 | return x + 1; 68 | } 69 | 70 | CGPoint PSVector( CGPoint firstPoint, CGPoint secondPoint ) 71 | { 72 | return CGPointMake( firstPoint.x - secondPoint.x, firstPoint.y - secondPoint.y ); 73 | } 74 | 75 | CGFloat PSDistance( CGPoint firstPoint, CGPoint secondPoint ) 76 | { 77 | return sqrtf( powf( firstPoint.x - secondPoint.x, 2 ) + powf( firstPoint.y - secondPoint.y, 2 ) ); 78 | } 79 | 80 | CGFloat PSAngle( CGPoint firstPoint, CGPoint secondPoint ) 81 | { 82 | return acosf( PSVector( firstPoint, secondPoint ).x / PSDistance( firstPoint, secondPoint) ); 83 | } 84 | 85 | CGFloat PSQuad( CGFloat ft, CGFloat f0, CGFloat f1 ) 86 | { 87 | return f0 + (f1 - f0) * ft * ft; 88 | } 89 | 90 | CGFloat PSLinear( CGFloat ft, CGFloat f0, CGFloat f1 ) 91 | 92 | { 93 | return f0 + (f1 - f0) * ft; 94 | } 95 | 96 | CGFloat PSPower( CGFloat ft, CGFloat f0, CGFloat f1, CGFloat p ) 97 | { 98 | return f0 + (f1 - f0) * powf(ft, p); 99 | } 100 | 101 | CGPoint PSRotatePointBy( CGPoint point, CGPoint origin, CGFloat angle ) 102 | { 103 | CGFloat px = cosf( angle ) * ( point.x - origin.x ) + sinf( angle ) * ( point.y - origin.y ) + origin.x; 104 | CGFloat py = sinf( angle ) * ( point.x - origin.x ) + cosf( angle ) * ( point.y - origin.y ) + origin.y; 105 | return CGPointMake( px, py ); 106 | } 107 | 108 | CGAffineTransform PSRectScaleAspectFit( CGRect innerRect, CGRect outerRect ) { 109 | CGFloat scaleFactor = MIN(outerRect.size.width/innerRect.size.width, outerRect.size.height/innerRect.size.height); 110 | CGAffineTransform scale = CGAffineTransformMakeScale(scaleFactor, scaleFactor); 111 | CGRect scaledInnerRect = CGRectApplyAffineTransform(innerRect, scale); 112 | CGAffineTransform translation = 113 | CGAffineTransformMakeTranslation((outerRect.size.width - scaledInnerRect.size.width) / 2 - scaledInnerRect.origin.x, 114 | (outerRect.size.height - scaledInnerRect.size.height) / 2 - scaledInnerRect.origin.y); 115 | return CGAffineTransformConcat(scale, translation); 116 | } 117 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSEffects.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSEffectsView.h 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 09/06/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ESCommon.h" 11 | 12 | @interface PSEffects : NSObject { 13 | Vertex2f *shaderVertices_; 14 | Vertex2f *shaderCoords_; 15 | Vertex2f *innerShadowVertices_; 16 | } 17 | 18 | @property (nonatomic, assign) CGRect bounds; 19 | @property (nonatomic, assign) CGSize pageSize; 20 | @property (nonatomic, assign) CGRect pageRect; 21 | @property (nonatomic, retain) UIImage *shaderImage; 22 | @property (nonatomic, retain) UIImage *innerShadowImage; 23 | 24 | - (void)buildEffects; 25 | - (void)updateCurlTime:(CGFloat)time angle:(CGFloat)angle point:(CGPoint)point theta:(CGFloat)theta; 26 | 27 | - (const Vertex2f *)shaderVertices; 28 | - (const Vertex2f *)shaderCoords; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSEffects.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSEffectsView.m 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 09/06/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import "PSEffects.h" 10 | #import 11 | #import "PSDrawings.h" 12 | 13 | @interface PSEffects() 14 | 15 | @property (nonatomic, assign) CGFloat angleValue; 16 | @property (nonatomic, assign) CGFloat thetaValue; 17 | @property (nonatomic, assign) CGFloat radiusValue; 18 | @property (nonatomic, assign) CGFloat timeValue; 19 | @property (nonatomic, assign) CGPoint pointValue; 20 | 21 | @end 22 | 23 | @implementation PSEffects 24 | 25 | @synthesize bounds, pageRect, pageSize, shaderImage, innerShadowImage; 26 | @synthesize angleValue, pointValue, timeValue, radiusValue, thetaValue; 27 | 28 | - (id)init 29 | { 30 | self = [super init]; 31 | if (self) { 32 | // init 33 | } 34 | return self; 35 | } 36 | 37 | - (void)buildEffects 38 | { 39 | CGSize size = bounds.size; 40 | size.width = 128; 41 | size.height = 128; 42 | 43 | UIGraphicsBeginImageContext( size ); 44 | CGContextRef context = UIGraphicsGetCurrentContext(); 45 | 46 | CGPoint startPoint = CGPointMake( 0.0, 0.0 ); 47 | CGPoint endPoint = CGPointMake( size.width, 0 ); 48 | 49 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 50 | 51 | CGFloat components [16] = { 52 | 1.0, 1.0, 1.0, 0.0, 53 | 0.0, 0.0, 0.0, 0.055, 54 | 0.9, 0.9, 0.9, 0.15, 55 | 0.0, 0.0, 0.0, 0.05, 56 | }; 57 | 58 | CGFloat locations[4] = {0.35, 0.82, 0.95, 1.0}; 59 | 60 | CGGradientRef gradient = 61 | CGGradientCreateWithColorComponents(colorSpace, 62 | components, 63 | locations, 64 | (size_t)4); 65 | CGContextDrawLinearGradient(context, 66 | gradient, 67 | startPoint, 68 | endPoint, 69 | (CGGradientDrawingOptions)NULL); 70 | CGColorSpaceRelease(colorSpace); 71 | 72 | CGImageRef img = CGBitmapContextCreateImage( context ); 73 | UIImage *newImage = [UIImage imageWithCGImage:img]; 74 | 75 | self.shaderImage = newImage; 76 | 77 | CGImageRelease( img ); 78 | UIGraphicsEndImageContext(); 79 | 80 | // draw inner shadow 81 | CGRect rect = self.pageRect; 82 | CGFloat ratio; 83 | rect.origin.y = round( rect.origin.y ); 84 | rect.size.height = round( rect.size.height ); 85 | 86 | UIGraphicsBeginImageContext( pageSize ); 87 | context = UIGraphicsGetCurrentContext(); 88 | 89 | UIImage *shadow_top = [UIImage imageNamed:@"shadow_tb.png"]; 90 | UIImage *shadow_bottom = [UIImage imageNamed:@"shadow_bb.png"]; 91 | UIImage *shadow_stretch = [UIImage imageNamed:@"shadow_m.png"]; 92 | 93 | CGRect rtop = rect; 94 | ratio = shadow_top.size.width / rect.size.width; 95 | rtop.size.height = round( shadow_top.size.height / ratio ); 96 | 97 | CGRect rmid = rect; 98 | rmid.origin.y = rtop.origin.y + rtop.size.height; 99 | rmid.size.height = rmid.size.height - rtop.size.height * 2; 100 | 101 | CGRect rbot = rect; 102 | rbot.origin.y = rmid.origin.y + rmid.size.height; 103 | rbot.size.height = round( shadow_bottom.size.height / ratio ); 104 | 105 | CGContextDrawImage( context, rtop, shadow_bottom.CGImage ); 106 | CGContextDrawImage( context, rbot, shadow_top.CGImage ); 107 | CGContextDrawImage( context, rmid, shadow_stretch.CGImage ); 108 | 109 | img = CGBitmapContextCreateImage( context ); 110 | newImage = [UIImage imageWithCGImage:img]; 111 | 112 | self.innerShadowImage = newImage; 113 | 114 | CGImageRelease( img ); 115 | UIGraphicsEndImageContext(); 116 | } 117 | 118 | - (void)updateCurlTime:(CGFloat)time angle:(CGFloat)angle point:(CGPoint)point theta:(CGFloat)theta 119 | { 120 | self.angleValue = angle; 121 | self.pointValue = CGPointMake( point.x + 0.5, 1-fabs(-point.y+0.5)); 122 | self.timeValue = time; 123 | self.radiusValue = time / M_PI; 124 | } 125 | 126 | - (const Vertex2f *)shaderVertices 127 | { 128 | CGFloat angle = angleValue-thetaValue; 129 | CGFloat sinangle = sinf(angle); 130 | CGFloat cosangle = cosf(angle); 131 | CGPoint pv = pointValue; 132 | CGPoint pv1 = CGPointMake( (pv.x-2*sinangle)-0.5, pv.y-2*cosf(angle)-0.5); 133 | CGPoint pv2 = CGPointMake( pv1.x+radiusValue*cosangle, pv1.y-radiusValue*sinangle ); 134 | CGPoint pv3 = CGPointMake( (pv.x+2*sinangle)-0.5, (pv.y+2*cosangle)-0.5 ); 135 | CGPoint pv4 = CGPointMake( pv3.x+radiusValue*cosangle, pv3.y-radiusValue*sinangle); 136 | 137 | if (shaderVertices_ != NULL) 138 | free(shaderVertices_); 139 | shaderVertices_ = malloc(sizeof(Vertex2f)*4); 140 | shaderVertices_[0] = Vertex2fMake(pv1.x, pv1.y); 141 | shaderVertices_[1] = Vertex2fMake(pv2.x, pv2.y); 142 | shaderVertices_[2] = Vertex2fMake(pv3.x, pv3.y); 143 | shaderVertices_[3] = Vertex2fMake(pv4.x, pv4.y); 144 | return shaderVertices_; 145 | } 146 | 147 | - (const Vertex2f *)shaderCoords 148 | { 149 | 150 | if (shaderCoords_ != NULL) 151 | free(shaderCoords_); 152 | shaderCoords_ = malloc(sizeof(Vertex2f)*4); 153 | shaderCoords_[0] = Vertex2fMake(0, 0); 154 | shaderCoords_[1] = Vertex2fMake(1, 0); 155 | shaderCoords_[2] = Vertex2fMake(0, 1); 156 | shaderCoords_[3] = Vertex2fMake(1, 1); 157 | return shaderCoords_; 158 | } 159 | 160 | - (void)dealloc 161 | { 162 | [shaderImage release]; 163 | [super dealloc]; 164 | } 165 | 166 | @end 167 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSKonstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSKonstants.h 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 28/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | #define kPSPagePaddingRatio 0.015 13 | #define kPSPageSideRatio 0.04 14 | #define kPSPageTimeCorrection 0.9 15 | 16 | #define kPSPageAnimationFriction 0.18 17 | #define kPSPageAnimationThreshold 0.005 -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSPDFPageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSPDFPageView.h 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 15/09/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface PSPDFPageView : UIView { 13 | 14 | } 15 | 16 | - (id)initWithPDFPage:(CGPDFPageRef)pdfPage; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSPDFPageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSPDFPageView.m 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 15/09/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import "PSPDFPageView.h" 10 | #import "PSDrawings.h" 11 | 12 | @interface PSPDFPageView() 13 | 14 | @property (nonatomic, assign) CGPDFPageRef pdfPageRef; 15 | 16 | @end 17 | 18 | @implementation PSPDFPageView 19 | 20 | @synthesize pdfPageRef; 21 | 22 | - (id)initWithFrame:(CGRect)frame 23 | { 24 | self = [super initWithFrame:frame]; 25 | if (self) { 26 | // Initialization code 27 | } 28 | return self; 29 | } 30 | 31 | - (id)initWithPDFPage:(CGPDFPageRef)pdfPage 32 | { 33 | self = [super initWithFrame:CGRectZero]; 34 | if ( self ) { 35 | self.backgroundColor = [UIColor whiteColor]; 36 | self.pdfPageRef = pdfPage; 37 | } 38 | return self; 39 | } 40 | 41 | // Only override drawRect: if you perform custom drawing. 42 | // An empty implementation adversely affects performance during animation. 43 | - (void)drawRect:(CGRect)rect 44 | { 45 | // Drawing code 46 | CGContextRef context = UIGraphicsGetCurrentContext(); 47 | CGContextTranslateCTM(context, 0.0, self.bounds.size.height); 48 | CGContextScaleCTM(context, 1.0, -1.0); 49 | 50 | // Draw PDF (scaled to fit) 51 | CGAffineTransform transform = PSRectScaleAspectFit( CGPDFPageGetBoxRect(pdfPageRef, kCGPDFMediaBox), CGContextGetClipBoundingBox(context)); 52 | CGContextConcatCTM(context, transform); 53 | CGContextDrawPDFPage(context, pdfPageRef); 54 | } 55 | 56 | - (void)dealloc 57 | { 58 | [super dealloc]; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSPDFPageViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSPDFPageViewController.h 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 15/09/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface PSPDFPageViewController : UIViewController { 13 | 14 | } 15 | 16 | - (id)initwithPDFPage:(CGPDFPageRef)pdfPage; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSPDFPageViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSPDFPageViewController.m 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 15/09/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import "PSPDFPageViewController.h" 10 | #import "PSPDFPageView.h" 11 | 12 | @interface PSPDFPageViewController() 13 | 14 | @property (nonatomic, assign) CGPDFPageRef pdfPageRef; 15 | 16 | @end 17 | 18 | @implementation PSPDFPageViewController 19 | 20 | @synthesize pdfPageRef; 21 | 22 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 23 | { 24 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 25 | if (self) { 26 | // Custom initialization 27 | } 28 | return self; 29 | } 30 | 31 | - (id)initwithPDFPage:(CGPDFPageRef)pdfPage 32 | { 33 | self = [self initWithNibName:nil bundle:nil]; 34 | if ( self ) { 35 | self.pdfPageRef = pdfPage; 36 | PSPDFPageView *pdfView = [[PSPDFPageView alloc] initWithPDFPage:pdfPage]; 37 | self.view = pdfView; 38 | [pdfView release]; 39 | } 40 | return self; 41 | } 42 | 43 | - (void)dealloc 44 | { 45 | [super dealloc]; 46 | } 47 | 48 | - (void)didReceiveMemoryWarning 49 | { 50 | // Releases the view if it doesn't have a superview. 51 | [super didReceiveMemoryWarning]; 52 | 53 | // Release any cached data, images, etc that aren't in use. 54 | } 55 | 56 | #pragma mark - View lifecycle 57 | 58 | /* 59 | // Implement loadView to create a view hierarchy programmatically, without using a nib. 60 | - (void)loadView 61 | { 62 | } 63 | */ 64 | 65 | /* 66 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 67 | - (void)viewDidLoad 68 | { 69 | [super viewDidLoad]; 70 | } 71 | */ 72 | 73 | - (void)viewDidUnload 74 | { 75 | [super viewDidUnload]; 76 | // Release any retained subviews of the main view. 77 | // e.g. self.myOutlet = nil; 78 | } 79 | 80 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 81 | { 82 | // Return YES for supported orientations 83 | return YES; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSPage.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "ESCommon.h" 4 | 5 | @protocol PSPageDelegate 6 | 7 | - (void)pageDidFinishDeformWithAngle:(CGFloat)angle andTime:(CGFloat)time point:(CGPoint)point theta:(CGFloat)theta; 8 | 9 | @end 10 | 11 | 12 | @interface PSPage : NSObject 13 | { 14 | CGFloat width; // Width of the page (x axis) } 15 | CGFloat height; // Height of the page (y axis) }--- Must call -createMesh if any of these properties change. 16 | u_short columns; // Number of mesh subdivisions along the x axis } 17 | u_short rows; // Number of mesh subdivisions along the y axis } 18 | 19 | CGFloat rho; // Rotation of the page around the spine of the book (y axis). 20 | 21 | u_short currentFrame; // The current frame in the animation sequence. Range of {0...framesPerCycle}. 22 | u_short framesPerCycle; // Total number of frames in one complete animation sequence (one page flip). 23 | 24 | @private 25 | Vertex2f *inputMesh_; 26 | Vertex3f *outputMesh_; // Vertex array for the page (front and back combined) after being deformed by rho, theta, and A deformation parameters. 27 | Vertex2f *textureArray_; 28 | Vertex3f *outputInnerShadowMesh_; // Vertex array for the page (front and back combined) after being deformed by rho, theta, and A deformation parameters. 29 | Vertex3f *outputOuterShadowMesh_; // Vertex array for the page (front and back combined) after being deformed by rho, theta, and A deformation parameters. 30 | 31 | u_short numVertices_; // For large, complex meshes where the vertex count exceeds the max range of u_short (65535), 32 | // replace with unsigned longs where needed. For most purposes unsigned shorts should suffice and conserve memory. 33 | Vertex3f *triangles_; 34 | u_short *faces_; // Triangle index array that includes data for both the front and back sides. 35 | u_short numFaces_; 36 | u_short *frontStrip_; // Index triangle strip for the front side. 37 | u_short *backStrip_; // Index triangle strip for the back side. 38 | u_short stripLength_; 39 | 40 | } 41 | 42 | @property (nonatomic) CGFloat width; // We use standard data types to decouple our model class from the implementation details of its view. 43 | @property (nonatomic) CGFloat height; 44 | @property (nonatomic) u_short columns; 45 | @property (nonatomic) u_short rows; 46 | @property (nonatomic) u_short currentFrame; 47 | @property (nonatomic) u_short framesPerCycle; 48 | @property (nonatomic) CGPoint SP; 49 | @property (nonatomic) CGPoint P; 50 | @property (nonatomic, assign) id delegate; 51 | @property (nonatomic, assign) BOOL hasReverseCurl; 52 | 53 | - (const Vertex2f *) textureArray; 54 | - (const Vertex3f *) vertices; // Deformed page mesh as a vertex array. 55 | - (const Vertex3f *) innerShadowVertices; // Deformed page mesh as a vertex array. 56 | - (const Vertex3f *) outerShadowVertices; // Deformed page mesh as a vertex array. 57 | - (const u_short *) frontFaces; // Triangle array tesselated from vertices in counter-clockwise order to represent the front face. 58 | - (const u_short *) backFaces; // Triangle array tesselated from vertices in clockwise order to represent the back face. 59 | - (u_short) numFaces; 60 | - (const u_short *) frontStrip; 61 | - (const u_short *) backStrip; 62 | - (u_short) stripLength; 63 | - (void) createMesh; 64 | - (void) updateTextureCoord:(CGRect)rect; 65 | - (void) incrementTime; 66 | - (CGFloat) currentTime; 67 | - (void) deformForTime:(CGFloat)t; // t from {0...1} 68 | - (void) deform; 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSPage.m: -------------------------------------------------------------------------------- 1 | // 2 | // CCPage.m 3 | // ConeCurl 4 | // 5 | // Created by W. Dana Nuon on 4/18/10. 6 | // Copyright 2010 lunaray. All rights reserved. 7 | // 8 | 9 | 10 | #import "PSPage.h" 11 | #import 12 | #import 13 | #import "PSDrawings.h" 14 | #import "PSKonstants.h" 15 | 16 | @interface PSPage () 17 | 18 | // Empty category for "private" methods 19 | - (void)createTriangleArray; 20 | - (void)createTriangleStrip; 21 | @end 22 | 23 | 24 | @implementation PSPage 25 | 26 | @synthesize delegate, hasReverseCurl; 27 | @synthesize width, height, columns, rows; 28 | @synthesize currentFrame, framesPerCycle; 29 | @synthesize SP, P; 30 | 31 | 32 | - (id)init 33 | { 34 | self = [super init]; 35 | if ( self ) 36 | { 37 | 38 | } 39 | return self; 40 | } 41 | 42 | - (void)dealloc 43 | { 44 | if (inputMesh_ != NULL) 45 | free(inputMesh_); 46 | if (outputMesh_ != NULL) 47 | free(outputMesh_); 48 | if (textureArray_ != NULL) 49 | free(textureArray_); 50 | if (triangles_ != NULL) 51 | free(triangles_); 52 | if (faces_ != NULL) 53 | free(faces_); 54 | if (frontStrip_ != NULL) 55 | free(frontStrip_); 56 | if (backStrip_ != NULL) 57 | free(backStrip_); 58 | if (outputInnerShadowMesh_ != NULL) 59 | free(outputInnerShadowMesh_); 60 | if (outputOuterShadowMesh_ != NULL) 61 | free(outputOuterShadowMesh_); 62 | [super dealloc]; 63 | } 64 | 65 | - (const Vertex2f *)textureArray 66 | { 67 | return textureArray_; 68 | } 69 | 70 | - (const Vertex3f *)vertices 71 | { 72 | return outputMesh_; 73 | } 74 | 75 | - (const Vertex3f *)innerShadowVertices 76 | { 77 | return outputInnerShadowMesh_; 78 | } 79 | 80 | - (const Vertex3f *)outerShadowVertices 81 | { 82 | return outputOuterShadowMesh_; 83 | } 84 | 85 | - (const u_short *)frontFaces 86 | { 87 | return faces_; 88 | } 89 | 90 | - (const u_short *)backFaces 91 | { 92 | // Return an offset since we store both front and back triangle arrays together in one array. 93 | return faces_ + numFaces_ * 3; 94 | } 95 | 96 | - (u_short)numFaces 97 | { 98 | return numFaces_; 99 | } 100 | 101 | - (const u_short *)frontStrip 102 | { 103 | return frontStrip_; 104 | } 105 | 106 | - (const u_short *)backStrip 107 | { 108 | return backStrip_; 109 | } 110 | 111 | - (u_short)stripLength 112 | { 113 | return stripLength_; 114 | } 115 | 116 | - (void)createMesh 117 | { 118 | u_short vCountX = columns + 1; // Number of vertices along the x axis 119 | u_short vCountY = rows + 1; // Number of vertices along the y axis 120 | numFaces_ = columns * rows * 2; 121 | 122 | numVertices_ = vCountX * vCountY; 123 | if (inputMesh_ != NULL) 124 | free(inputMesh_); 125 | inputMesh_ = malloc(sizeof(Vertex2f) * numVertices_); 126 | if (outputMesh_ != NULL) 127 | free(outputMesh_); 128 | outputMesh_ = malloc(sizeof(Vertex3f) * numVertices_); 129 | if (textureArray_ != NULL) 130 | free(textureArray_); 131 | textureArray_ = malloc(sizeof(Vertex2f) * numVertices_); 132 | 133 | if (outputInnerShadowMesh_ != NULL) 134 | free(outputInnerShadowMesh_); 135 | outputInnerShadowMesh_ = malloc(sizeof(Vertex3f) * numVertices_); 136 | if (outputOuterShadowMesh_ != NULL) 137 | free(outputOuterShadowMesh_); 138 | outputOuterShadowMesh_ = malloc(sizeof(Vertex3f) * numVertices_); 139 | 140 | 141 | u_short vi = 0; // vertex index 142 | short iiX, iiY; 143 | CGFloat px, py; 144 | CGFloat offsetX = hasReverseCurl ? -width : 0.0; 145 | // Create our flat page geometry as a vertex array. Even though our page has two sides, we need to generate only one 146 | // set of vertices since the front and back are coplanar meshes. 147 | for (iiY = 0; iiY < vCountY; iiY++) 148 | { 149 | for (iiX = 0; iiX < vCountX; iiX++) 150 | { 151 | px = (CGFloat)iiX * width / columns + offsetX; 152 | py = (CGFloat)iiY * height / rows - (height*0.5); 153 | inputMesh_[vi].x = px; 154 | inputMesh_[vi].y = py; 155 | textureArray_[vi].x = (CGFloat)iiX / columns; 156 | textureArray_[vi].y = (CGFloat)(iiY) / rows; 157 | vi++; 158 | } 159 | } 160 | 161 | // Once we have our basic page geometry, tesselate it into an array of discrete triangles or triangle strips. 162 | #if USE_TRIANGLE_STRIPS 163 | [self createTriangleStrip]; 164 | #else 165 | [self createTriangleArray]; 166 | #endif 167 | 168 | } 169 | 170 | - (void) updateTextureCoord:(CGRect)rect 171 | { 172 | u_short vCountX = columns + 1; // Number of vertices along the x axis 173 | u_short vCountY = rows + 1; // Number of vertices along the y axis 174 | 175 | CGFloat rox = rect.origin.x; 176 | CGFloat roy = rect.origin.y; 177 | CGFloat row = rect.size.width; 178 | CGFloat roh = rect.size.height; 179 | 180 | if (textureArray_ != NULL) 181 | free(textureArray_); 182 | textureArray_ = malloc(sizeof(Vertex2f) * numVertices_); 183 | 184 | u_short vi = 0; // vertex index 185 | short iiX, iiY; 186 | // Create our flat page geometry as a vertex array. Even though our page has two sides, we need to generate only one 187 | // set of vertices since the front and back are coplanar meshes. 188 | for (iiY = 0; iiY < vCountY; iiY++) 189 | { 190 | for (iiX = 0; iiX < vCountX; iiX++) 191 | { 192 | textureArray_[vi].x = rox + (CGFloat)iiX / columns * row; 193 | textureArray_[vi].y = roy + (CGFloat)(iiY) / rows * roh; 194 | vi++; 195 | } 196 | } 197 | 198 | } 199 | 200 | - (void)incrementTime 201 | { 202 | currentFrame++; 203 | currentFrame %= framesPerCycle; 204 | } 205 | 206 | - (CGFloat)currentTime 207 | { 208 | return (CGFloat)currentFrame / framesPerCycle; 209 | } 210 | 211 | - (void)deformForTime:(CGFloat)t 212 | { 213 | 214 | } 215 | 216 | - (void)deform 217 | { 218 | CGFloat time = fabs( PSVector(SP, P).x ) * kPSPageTimeCorrection; // iOS 5 Curl style 219 | // CGFloat time = PSDistance( SP, P ) * kPSPageTimeCorrection; // iBooks Curl style 220 | CGFloat angle = roundf( ( ( PSAngle( SP, P ) + 0.00001 ) * ( P.y > SP.y ? 1.0 : -1.0 ) + 0.00001 ) * 1000.0f ) / 1000.0f; 221 | CGFloat side = angle >= 0 ? 1.0 : -1.0; 222 | BOOL upsideFlag = angle < 0; 223 | CGFloat upside = upsideFlag ? 1.0 : -1.0; 224 | 225 | if ( ( !hasReverseCurl && P.x < 0.0 ) || ( hasReverseCurl && P.x > 0.0 ) ) { 226 | time = kPSPageTimeCorrection - time; 227 | } 228 | 229 | NSLog(@"Time:%f",time); 230 | 231 | // interpolate cone base 232 | CGFloat RB = fmax( height/columns, ( time / M_PI ) ); 233 | 234 | CGPoint checkPoint1 = CGPointMake( P.x + RB * cosf( angle ), P.y - RB * sinf( angle ) ); 235 | CGPoint checkPoint2 = CGPointMake( 0, height*0.5*upside ); 236 | CGFloat checkDistance = PSDistance( checkPoint1, checkPoint2 ); 237 | CGFloat checkDeltaY = fabsf( checkPoint1.y - checkPoint2.y ); 238 | CGFloat angleLimit; 239 | if ( hasReverseCurl ) { 240 | angleLimit = ( M_PI_HALF + asinf( checkDeltaY/checkDistance ) ) * side; 241 | angle = upsideFlag ? fmin( angleLimit, angle ) : fmax( angleLimit, angle ); 242 | } else { 243 | angleLimit = ( M_PI_HALF - asinf( checkDeltaY/checkDistance ) ) * side; 244 | angle = upsideFlag ? fmax( angleLimit, angle ) : fmin( angleLimit, angle ); 245 | } 246 | 247 | CGFloat sinangle, cosangle, sintetha, costheta; 248 | 249 | sinangle = sinf( angle ); 250 | cosangle = cosf( angle ); 251 | 252 | // interpolate theta 253 | CGFloat tt = fmin( fabs( angle ) / ( M_PI_HALF ), 1.0 ); 254 | CGFloat theta = PSQuad( tt, 0.000001, 0.00001 ) * side; 255 | 256 | sintetha = sinf( theta ); 257 | costheta = cosf( theta ); 258 | 259 | // calculate cone apex 260 | CGFloat dist = RB * ( 1 / tanf( theta ) ); 261 | CGPoint A = CGPointMake( P.x + dist * sinangle, P.y + dist * cosangle ); 262 | if ( A.y < height*0.5 || A.y > -height*05 ) { 263 | if ( A.x < width ) { 264 | A.x = width; 265 | } 266 | } 267 | 268 | // shado 269 | 270 | CGPoint shadowPO = CGPointMake( 0, 0 ); 271 | 272 | CGFloat shadowTheta = angle*2-theta; 273 | CGPoint shadowPV = CGPointMake( P.x, P.y + (-SP.y) ); 274 | CGPoint shadowPT = PSRotatePointBy( shadowPV, P, shadowTheta ); 275 | CGFloat spx = width * 0.5 * cosf(shadowTheta) * (hasReverseCurl?-1.0:1.0); 276 | CGFloat spy = width * 0.5 * sinf(shadowTheta) * (hasReverseCurl?-1.0:1.0); 277 | CGPoint shadowP = CGPointMake( shadowPT.x + spx, shadowPT.y - spy ); 278 | 279 | // deform mash 280 | 281 | Vertex2f vi; 282 | CGPoint vp, vn; 283 | CGFloat ttheta, alpha, ipo, normal, dx, dy, R, Rc, beta, gamma, shadow, shadowval, shadowsidex, shadowsidey; 284 | Vertex3f v1, vis1, vos1; 285 | Vertex3f *vo, *viso, *voso; 286 | BOOL vertexFlag; 287 | CGFloat reverseShadowRatio = hasReverseCurl ? -1.0 : 1.0; 288 | 289 | for ( u_short ii = 0; ii < numVertices_; ii++ ) { 290 | vi = inputMesh_[ ii ]; 291 | 292 | vp = CGPointMake( vi.x, vi.y ); 293 | alpha = PSAngle( vp, P ) + ( vp.y > P.y ? angle : -angle ); 294 | ipo = PSDistance( P, vp ); 295 | normal = ipo * cosf( alpha ); 296 | dx = normal * cosangle; 297 | dy = normal * sinangle; 298 | vn = CGPointMake( vp.x - dx, vp.y + dy ); 299 | 300 | ttheta = theta; 301 | 302 | R = PSDistance( vp, A ); 303 | Rc = R * sintetha; 304 | beta = asinf( normal / R ) / sintetha; 305 | 306 | vertexFlag = hasReverseCurl ? ( vp.x > vn.x ) : ( vp.x < vn.x ); 307 | 308 | if ( vertexFlag ) { 309 | 310 | v1.x = vp.x; 311 | v1.y = vp.y; 312 | v1.z = 0.0; 313 | 314 | vis1.x = vp.x; 315 | vis1.y = vp.y; 316 | vis1.z = 0.0; 317 | 318 | vos1.x = v1.x; 319 | vos1.y = v1.y; 320 | vos1.z = 0; 321 | 322 | } else { 323 | 324 | // translate vertex 325 | if ( abs(beta) >= 0 && abs(beta) <= M_PI * 0.95 ) { 326 | // dynamic cone distortion 327 | v1.x = vn.x + Rc * sinf( beta ) * cosangle; 328 | v1.y = vn.y - Rc * sinf( beta ) * costheta * sinangle; 329 | v1.z = Rc * ( 1.0 - cosf( beta ) ) * costheta; 330 | 331 | } else { 332 | // flip over normal 333 | v1.x = vn.x; 334 | v1.y = vn.y; 335 | v1.z = Rc * ( 1.0 - cosf( M_PI ) ) * costheta; 336 | CGFloat nredux = ( fabs( normal ) - fabs( Rc * M_PI ) ) * side; 337 | v1.x -= nredux * cosangle * side; 338 | v1.y += nredux * sinangle * side; 339 | } 340 | 341 | vis1.x = v1.x; 342 | vis1.y = v1.y; 343 | vis1.z = v1.z; 344 | 345 | vos1.x = v1.x; 346 | vos1.y = v1.y; 347 | vos1.z = v1.z; 348 | 349 | gamma = PSAngle( shadowP, CGPointMake( vis1.x, vis1.y ) ); 350 | shadow = fmax(fabs(beta)-M_PI_HALF, 0.0) / M_PI_HALF; 351 | shadowsidey = vis1.y > shadowP.y ? 1.0 : -1.0; 352 | shadowval = fmin( shadow * fmax(0.075, RB), RB * 0.75 ); 353 | vis1.x -= shadowval * cosf( gamma ); 354 | vis1.y += shadowval * sinf( gamma ) * shadowsidey; 355 | 356 | if ( fabs(beta) 0.1 && NO ) { 357 | gamma = PSAngle( shadowPO, CGPointMake( vos1.x, vos1.y ) ); 358 | shadowsidex = vos1.x < shadowPO.x ? -1.0 : 1.0; 359 | shadowsidey = vos1.y > shadowPO.y ? 1.0 : -1.0; 360 | shadow = M_PI / fabs(beta); 361 | shadowval = RB * 0.75; 362 | shadowval = 0; 363 | vos1.x -= shadowval * cosf( gamma ) * shadowsidex * reverseShadowRatio; 364 | vos1.y += shadowval * sinf( gamma ) * shadowsidey; 365 | } 366 | 367 | } 368 | 369 | 370 | // output vertex 371 | vo = &outputMesh_[ ii ]; 372 | viso = &outputInnerShadowMesh_[ ii ]; 373 | voso = &outputOuterShadowMesh_[ ii ]; 374 | vo->x = v1.x; 375 | vo->y = v1.y; 376 | vo->z = v1.z; 377 | 378 | viso->x = vis1.x; 379 | viso->y = vis1.y; 380 | viso->z = vis1.z; 381 | 382 | voso->x = vos1.x; 383 | voso->y = vos1.y; 384 | voso->z = vos1.z; 385 | } 386 | 387 | [delegate pageDidFinishDeformWithAngle:angle andTime:time point:P theta:theta]; 388 | } 389 | 390 | 391 | #pragma mark - 392 | #pragma mark Private methods 393 | 394 | - (void)createTriangleArray 395 | { 396 | u_short vCountX = columns + 1; // Number of vertices along the x axis 397 | u_short numQuads = columns * rows; 398 | numFaces_ = numQuads * 2; 399 | if (faces_ != NULL) 400 | free(faces_); 401 | faces_ = malloc(sizeof(u_short) * numFaces_ * 6); // Store both front and back triangle arrays in one array. 402 | 403 | u_short vi = 0; // vertex index 404 | u_short index; 405 | u_short rowNum, colNum; 406 | u_short ll, lr, ul, ur; 407 | 408 | for (index = 0; index < numQuads; index++) 409 | { 410 | rowNum = index / columns; 411 | colNum = index % columns; 412 | ll = (rowNum) * vCountX + colNum; 413 | lr = ll + 1; 414 | ul = (rowNum + 1) * vCountX + colNum; 415 | ur = ul + 1; 416 | // Make two triangles out of each quad. 417 | // Wind the front of the page counter-clockwise so we can view it straight on. 418 | QuadToTrianglesWindCCWSet(&faces_[vi], ul, ur, ll, lr); 419 | // Wind the back of the page clockwise so it's visible only when it's been flipped. 420 | QuadToTrianglesWindCWSet(&faces_[vi + numFaces_ * 3], ul, ur, ll, lr); 421 | vi += 6; 422 | } 423 | } 424 | 425 | - (void)createTriangleStrip 426 | { 427 | // Standard algorithm for tesselating a grid into an optimized triangle strip without resorting to a complex Hamiltonian algorithm. 428 | 429 | u_short vCountX = columns + 1; // Number of vertices along the x axis 430 | u_short vCountY = rows + 1; // Number of vertices along the y axis 431 | 432 | stripLength_ = (vCountX * 2) * (vCountY - 1) + (vCountY - 2); 433 | if (frontStrip_ != NULL) 434 | free(frontStrip_); 435 | frontStrip_ = malloc(sizeof(u_short) * stripLength_); 436 | if (backStrip_ != NULL) 437 | free(backStrip_); 438 | backStrip_ = malloc(sizeof(u_short) * stripLength_); 439 | 440 | // Construct a triangle strip by scanning back and forth up our mesh, inserting degenerate triangles as necessary 441 | // to link adjacent rows. 442 | short iiX, iiY; 443 | u_short rowOffset, index = 0; 444 | BOOL lastRow, oddRow; 445 | for (iiY = 0; iiY < rows; iiY++) 446 | { 447 | // For the front, go right to left for odd rows, left to right for even rows. Weaving back and forth rather 448 | // than always restarting each row on the same side allows us the graphics hardware to reuse cached vertex 449 | // calculations, per Apple's best practices. 450 | // Build the back at the same time by scanning in reverse. 451 | rowOffset = iiY * vCountX; 452 | lastRow = (iiY == rows); 453 | oddRow = (iiY & 1); 454 | for (iiX = 0; iiX <= columns; iiX++) 455 | { 456 | if (oddRow) 457 | { 458 | frontStrip_[index] = rowOffset + columns - iiX + vCountX; 459 | backStrip_[index++] = rowOffset + iiX + vCountX; 460 | frontStrip_[index] = rowOffset + columns - iiX; 461 | backStrip_[index++] = rowOffset + iiX; 462 | } 463 | else 464 | { 465 | frontStrip_[index] = rowOffset + iiX + vCountX; 466 | backStrip_[index++] = rowOffset + columns - iiX + vCountX; 467 | frontStrip_[index] = rowOffset + iiX; 468 | backStrip_[index++] = rowOffset + columns - iiX; 469 | } 470 | } 471 | // Unless we're on the last row, insert a degenerate vertex to enable us to connect to the next row. 472 | if (!lastRow) 473 | { 474 | if (oddRow) 475 | { 476 | frontStrip_[index] = rowOffset + vCountX; 477 | backStrip_[index] = rowOffset + vCountX + columns; 478 | } 479 | else 480 | { 481 | frontStrip_[index] = rowOffset + vCountX + columns; 482 | backStrip_[index] = rowOffset + vCountX; 483 | } 484 | index++; 485 | } 486 | } 487 | } 488 | 489 | @end 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSPageCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSPageCache.h 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 28/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface PSPageCache : UIView { 13 | 14 | } 15 | 16 | @property (nonatomic, assign) BOOL flipped; 17 | 18 | - (UIImage*)pageCacheWithView:(UIView*)view; 19 | - (UIImage*)textureData; 20 | - (CGRect)textureRect; 21 | - (CGRect)contentRect; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSPageCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSPageCache.m 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 28/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import "PSPageCache.h" 10 | #import "PSDrawings.h" 11 | #import "PSKonstants.h" 12 | #import 13 | 14 | @interface PSPageCache() 15 | 16 | @property (nonatomic, retain) UIImage *currentImage; 17 | 18 | @end 19 | 20 | @implementation PSPageCache 21 | 22 | @synthesize currentImage, flipped; 23 | 24 | static CGMutablePathRef pagePath; 25 | 26 | - (id)initWithFrame:(CGRect)frame 27 | { 28 | self = [super initWithFrame:frame]; 29 | if (self) { 30 | // Initialization code 31 | self.backgroundColor = [UIColor clearColor]; 32 | self.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 33 | } 34 | return self; 35 | } 36 | 37 | // Only override drawRect: if you perform custom drawing. 38 | // An empty implementation adversely affects performance during animation. 39 | - (void)drawRect:(CGRect)rect 40 | { 41 | CGFloat pad = rect.size.width * kPSPagePaddingRatio; 42 | CGFloat side = rect.size.width * kPSPageSideRatio; 43 | 44 | CGMutablePathRef page1 = PSCreatePagePath( rect, pad, side+pad ); 45 | pagePath = page1; 46 | 47 | CGColorRef alphaBlack = [[UIColor blackColor] colorWithAlphaComponent:0.15].CGColor; 48 | 49 | CGContextRef context = UIGraphicsGetCurrentContext(); 50 | CGContextSetStrokeColorWithColor( context, alphaBlack); 51 | CGContextSetLineWidth( context, 1.0 ); 52 | CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor); 53 | 54 | // fill & stroke 55 | 56 | if ( flipped ) { 57 | CGContextTranslateCTM(context, rect.size.width, 0); 58 | CGContextScaleCTM(context, -1, 1); 59 | } 60 | 61 | CGContextSaveGState( context ); 62 | 63 | CGContextAddPath( context, page1 ); 64 | CGContextFillPath( context ); 65 | CGContextAddPath( context, page1 ); 66 | CGContextStrokePath( context ); 67 | 68 | CGContextRestoreGState( context ); 69 | 70 | } 71 | 72 | #pragma mark - 73 | #pragma mark Cache renderer 74 | 75 | - (UIImage*)pageCacheWithView:(UIView*)view 76 | { 77 | UIGraphicsBeginImageContext(view.bounds.size); 78 | [view.layer renderInContext:UIGraphicsGetCurrentContext()]; 79 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 80 | UIGraphicsEndImageContext(); 81 | UIImageView *iv = [[UIImageView alloc] initWithImage:image]; 82 | iv.backgroundColor = [UIColor blueColor]; 83 | iv.frame = [self contentRect]; 84 | iv.contentMode = UIViewContentModeScaleAspectFill; 85 | [self addSubview:iv]; 86 | 87 | UIGraphicsBeginImageContext( self.bounds.size ); 88 | CGContextRef context = UIGraphicsGetCurrentContext(); 89 | if ( flipped ) { 90 | CGContextTranslateCTM(context, -iv.frame.origin.x, 0); 91 | } 92 | [self.layer renderInContext:context]; 93 | UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 94 | UIGraphicsEndImageContext(); 95 | 96 | [iv removeFromSuperview]; 97 | [iv release]; 98 | 99 | CGImageRef CGImage = viewImage.CGImage; 100 | unsigned int potW = PSNextPOT( CGImageGetWidth( CGImage ) ); 101 | unsigned int potH = PSNextPOT( CGImageGetHeight( CGImage ) ); 102 | 103 | NSUInteger length = potW * potH * 4; 104 | void *data = malloc( length ); 105 | 106 | //DLog( @"UIImage: %d, %d", potW, potH ); 107 | 108 | CGContextRef contextRef = CGBitmapContextCreate( data, potW, potH, 8, potW * 4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaPremultipliedLast ); 109 | CGRect rect = CGRectMake( 0, potH - self.frame.size.height, self.frame.size.width, self.frame.size.height ); 110 | CGContextDrawImage( contextRef, rect, CGImage ); 111 | CGImageRef img = CGBitmapContextCreateImage( contextRef ); 112 | UIImage *newImage = [UIImage imageWithCGImage:img]; 113 | 114 | CGImageRelease( img ); 115 | CGContextRelease( contextRef ); 116 | free( data ); 117 | 118 | self.currentImage = newImage; 119 | 120 | return newImage; 121 | } 122 | 123 | - (UIImage*)textureData; 124 | { 125 | return self.currentImage; 126 | } 127 | 128 | - (CGRect)textureRect 129 | { 130 | CGFloat pad = self.bounds.size.width * kPSPagePaddingRatio; 131 | CGFloat side = self.bounds.size.width * kPSPageSideRatio; 132 | 133 | CGMutablePathRef page1 = PSCreatePagePath( self.bounds, pad, side+pad ); 134 | 135 | CGRect pageFrame = CGPathGetPathBoundingBox( page1 ); 136 | pageFrame.origin.x = round(pageFrame.origin.x); 137 | pageFrame.origin.y = round(pageFrame.origin.y); 138 | pageFrame.size.width = floor(pageFrame.size.width); 139 | pageFrame.size.height = floor(pageFrame.size.height); 140 | // pageFrame.origin.x += 1; 141 | // pageFrame.size.width -= 2; 142 | //DLog( @"Rect <--: %f, %f, %f, %f", pageFrame.origin.x, pageFrame.origin.y, pageFrame.size.width, pageFrame.size.height ); 143 | // if ( flipped ) { 144 | // pageFrame.origin.x += self.bounds.size.width - pageFrame.size.width; 145 | // } 146 | return pageFrame; 147 | } 148 | 149 | - (CGRect)contentRect 150 | { 151 | CGFloat pad = self.bounds.size.width * kPSPagePaddingRatio; 152 | CGFloat side = self.bounds.size.width * kPSPageSideRatio; 153 | 154 | CGMutablePathRef page1 = PSCreatePagePath( self.bounds, pad, side+pad ); 155 | CGRect trect = CGPathGetPathBoundingBox( page1 ); 156 | CGFloat radius = self.bounds.size.height * 0.05; 157 | CGFloat sp = radius * 0.25; 158 | trect.origin.y += sp; 159 | trect.size.height -= sp * 2; 160 | trect.origin.x = round(trect.origin.x); 161 | trect.origin.y = round(trect.origin.y); 162 | trect.size.width = floor(trect.size.width); 163 | trect.size.height = floor(trect.size.height); 164 | if ( flipped ) { 165 | trect.origin.x = self.bounds.size.width - trect.size.width; 166 | } 167 | return trect; 168 | } 169 | 170 | - (void)dealloc 171 | { 172 | [currentImage release]; 173 | [super dealloc]; 174 | } 175 | 176 | @end 177 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSPageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSPageView.h 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 25/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PSDrawings.h" 11 | 12 | @class PSPageView; 13 | 14 | @protocol PSPageViewDatasource 15 | 16 | - (UIView*)pageViewForPage:(PSPageView*)pageView; 17 | 18 | @end 19 | 20 | @protocol PSPageViewDelegate 21 | @optional 22 | - (void)pageViewDidFinishLoadContentForPage:(PSPageView*)pageView; 23 | 24 | @end 25 | 26 | @interface PSPageView : UIView { 27 | 28 | } 29 | 30 | @property (nonatomic, assign) id datasource; 31 | @property (nonatomic, assign) id delegate; 32 | @property (nonatomic, assign) NSDictionary *properties; 33 | @property (nonatomic, assign) BOOL flipped; 34 | 35 | - (void)setFlippedFlag; 36 | - (void)pageDidRotateWithPageOrientation:(PSPagesViewPageOrientation)orientation; 37 | 38 | - (UIImage*)textureData; 39 | - (CGRect)textureRect; 40 | - (CGRect)textureBounds; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSPageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSPageView.m 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 25/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import "PSPageView.h" 10 | #import "UIImage+Scale.h" 11 | #import 12 | #import "PSDrawings.h" 13 | #import "PSKonstants.h" 14 | #import "PSPageCache.h" 15 | 16 | #define kPSSkinBookBaseLandscape @"kPSSkinBookBase~Landscape" 17 | #define kPSSkinBookBasePortrait @"kPSSkinBookBase~Portrait" 18 | 19 | @interface PSPageView() 20 | 21 | @property (nonatomic, assign) PSPageCache *pageCache; 22 | @property (nonatomic, assign) BOOL landscapeMode; 23 | @property (nonatomic, retain) UIImage *backgroundLandscape; 24 | @property (nonatomic, retain) UIImage *backgroundPortrait; 25 | @property (nonatomic, assign) UIImageView *pageBackground; 26 | @property (nonatomic, retain) UIView *contentView; 27 | @property (nonatomic, assign) UIView *pageContent; 28 | @property (nonatomic, assign) CGFloat flipTargetValue; 29 | @property (nonatomic, assign) CGFloat flipCurrentValue; 30 | 31 | - (UIImage*)drawBackground; 32 | - (void)loadPageContent; 33 | - (void)adjustBackground; 34 | 35 | @end 36 | 37 | @implementation PSPageView 38 | 39 | @synthesize datasource, delegate; 40 | @synthesize flipped, properties; 41 | @synthesize backgroundLandscape, backgroundPortrait; 42 | @synthesize pageCache, landscapeMode, pageContent, pageBackground, contentView; 43 | @synthesize flipTargetValue, flipCurrentValue; 44 | 45 | - (id)initWithFrame:(CGRect)frame 46 | { 47 | self = [super initWithFrame:frame]; 48 | if (self) { 49 | self.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.5]; 50 | self.opaque = YES; 51 | self.clipsToBounds = YES; 52 | self.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 53 | 54 | // content view 55 | UIView *cView = [[UIView alloc] initWithFrame:self.bounds]; 56 | cView.backgroundColor = [UIColor whiteColor]; 57 | [self addSubview:cView]; 58 | self.contentView = cView; 59 | [cView release]; 60 | } 61 | return self; 62 | } 63 | 64 | 65 | #pragma mark - Private 66 | 67 | - (UIImage*)drawBackground 68 | { 69 | CGRect rect = self.bounds; 70 | 71 | UIGraphicsBeginImageContext(rect.size); 72 | 73 | CGContextRef context = UIGraphicsGetCurrentContext(); 74 | 75 | // draw bg 76 | UIImage *bg = nil; 77 | if ( self.landscapeMode ) { 78 | bg = [UIImage imageNamed:[properties objectForKey:kPSSkinBookBaseLandscape]]; 79 | } else { 80 | bg = [UIImage imageNamed:[properties objectForKey:kPSSkinBookBasePortrait]]; 81 | } 82 | 83 | CGContextDrawImage( context, rect, bg.CGImage ); 84 | 85 | CGFloat pad = rect.size.width * kPSPagePaddingRatio; 86 | CGFloat side = rect.size.width * kPSPageSideRatio; 87 | 88 | CGMutablePathRef page1 = PSCreatePagePath( rect, pad, side+pad ); 89 | CGMutablePathRef page2 = PSCreatePagePath( rect, pad*1.3, side*.78+pad ); 90 | CGMutablePathRef page3 = PSCreatePagePath( rect, pad*1.7, side*.58+pad ); 91 | CGMutablePathRef page4 = PSCreatePagePath( rect, pad*2.1, side*.43+pad ); 92 | CGMutablePathRef page5 = PSCreatePagePath( rect, pad*2.5, side*.30+pad ); 93 | CGMutablePathRef page6 = PSCreatePagePath( rect, pad*2.9, side*.20+pad ); 94 | 95 | CGColorRef alphaBlack = [[UIColor blackColor] colorWithAlphaComponent:0.15].CGColor; 96 | CGColorRef alphaShadow = [[UIColor blackColor] colorWithAlphaComponent:0.40].CGColor; 97 | 98 | CGContextSetStrokeColorWithColor( context, alphaBlack); 99 | CGContextSetLineWidth( context, 1.0 ); 100 | CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor); 101 | CGContextSetShadowWithColor( context, CGSizeMake( 1.5, 0 ), 2.0, alphaShadow ); 102 | 103 | if ( flipped ) { 104 | CGContextScaleCTM(context, -1, 1); 105 | CGContextTranslateCTM(context, -rect.size.width, 0); 106 | } 107 | 108 | // fill & stroke 109 | 110 | CGContextSaveGState( context ); 111 | 112 | CGContextAddPath( context, page6 ); 113 | CGContextFillPath( context ); 114 | CGContextAddPath( context, page6 ); 115 | CGContextStrokePath( context ); 116 | 117 | CGContextAddPath( context, page5 ); 118 | CGContextFillPath( context ); 119 | CGContextAddPath( context, page5 ); 120 | CGContextStrokePath( context ); 121 | 122 | CGContextAddPath( context, page4 ); 123 | CGContextFillPath( context ); 124 | CGContextAddPath( context, page4 ); 125 | CGContextStrokePath( context ); 126 | 127 | CGContextAddPath( context, page3 ); 128 | CGContextFillPath( context ); 129 | CGContextAddPath( context, page3 ); 130 | CGContextStrokePath( context ); 131 | 132 | CGContextAddPath( context, page2 ); 133 | CGContextFillPath( context ); 134 | CGContextAddPath( context, page2 ); 135 | CGContextStrokePath( context ); 136 | 137 | CGContextAddPath( context, page1 ); 138 | CGContextFillPath( context ); 139 | CGContextAddPath( context, page1 ); 140 | CGContextStrokePath( context ); 141 | 142 | CGContextRestoreGState( context ); 143 | 144 | UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 145 | 146 | UIGraphicsEndImageContext(); 147 | 148 | return viewImage; 149 | } 150 | 151 | - (void)adjustBackground 152 | { 153 | if ( self.pageBackground == nil ) { 154 | UIImageView *bg = [[UIImageView alloc] initWithFrame:self.bounds]; 155 | bg.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 156 | [self insertSubview:bg atIndex:0]; 157 | self.pageBackground = bg; 158 | [bg release]; 159 | } 160 | 161 | if ( self.landscapeMode ) { 162 | if ( self.backgroundLandscape == nil ) { 163 | self.backgroundLandscape = [self drawBackground]; 164 | } 165 | self.pageBackground.image = self.backgroundLandscape; 166 | } else { 167 | if ( self.backgroundPortrait == nil ) { 168 | self.backgroundPortrait = [self drawBackground]; 169 | } 170 | self.pageBackground.image = self.backgroundPortrait; 171 | } 172 | } 173 | 174 | - (void)loadPageContent 175 | { 176 | self.pageContent = [datasource pageViewForPage:self]; 177 | self.pageContent.frame = contentView.bounds; 178 | [pageCache pageCacheWithView:self.pageContent]; 179 | [contentView addSubview:pageContent]; 180 | if ( [delegate respondsToSelector:@selector(pageViewDidFinishLoadContentForPage:)] ) { 181 | [delegate pageViewDidFinishLoadContentForPage:self]; 182 | } 183 | } 184 | 185 | - (void)setFlippedFlag 186 | { 187 | self.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 188 | //self.transform = CGAffineTransformMakeScale( -1, 1); 189 | //self.contentView.transform = CGAffineTransformMakeScale( -1, 1); 190 | self.flipped = YES; 191 | } 192 | 193 | 194 | #pragma mark - Public 195 | 196 | - (void)layoutSubviews 197 | { 198 | //DLog(@"layoutSubviews %d", self.tag); 199 | CGRect rect = self.bounds; 200 | rect.origin.y = -rect.size.height; 201 | 202 | [self adjustBackground]; 203 | 204 | if ( self.pageCache != nil ) { 205 | [pageCache removeFromSuperview]; 206 | self.pageCache = nil; 207 | } 208 | 209 | PSPageCache *pc = [[PSPageCache alloc] initWithFrame:rect]; 210 | pc.flipped = self.flipped; 211 | [self addSubview:pc]; 212 | self.pageCache = pc; 213 | [pc release]; 214 | 215 | self.contentView.frame = [pageCache contentRect]; 216 | if ( flipped ) { 217 | rect = self.contentView.frame; 218 | rect.origin.x = self.frame.size.width - rect.size.width; 219 | self.contentView.frame = rect; 220 | } 221 | 222 | if ( self.pageContent != nil ) { 223 | [self.pageContent removeFromSuperview]; 224 | self.pageContent = nil; 225 | } 226 | 227 | [NSObject cancelPreviousPerformRequestsWithTarget:self]; 228 | [self performSelector:@selector(loadPageContent) withObject:nil afterDelay:0.5]; 229 | } 230 | 231 | - (void)pageDidRotateWithPageOrientation:(PSPagesViewPageOrientation)orientation 232 | { 233 | self.landscapeMode = orientation == PSPagesViewPageOrientationLandscape; 234 | if ( self.pageContent != nil ) { 235 | [self.pageContent removeFromSuperview]; 236 | self.pageContent = nil; 237 | } 238 | //DLog(@"Subviews:%d > %@",self.tag, self.contentView.subviews); 239 | } 240 | 241 | - (UIImage*)textureData 242 | { 243 | return [self.pageCache textureData]; 244 | } 245 | 246 | - (CGRect)textureRect 247 | { 248 | return [self.pageCache textureRect]; 249 | } 250 | 251 | - (CGRect)textureBounds 252 | { 253 | return self.pageCache.bounds; 254 | } 255 | 256 | 257 | - (void)dealloc 258 | { 259 | [contentView release]; 260 | [backgroundPortrait release]; 261 | [backgroundLandscape release]; 262 | [super dealloc]; 263 | } 264 | 265 | @end 266 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSPagesViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSPlayerController.h 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 25/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PSPageView.h" 11 | #import "ESRenderer.h" 12 | #import "EAGLView.h" 13 | #import "PSDrawings.h" 14 | 15 | @protocol PSPagesViewControllerDatasource 16 | 17 | - (NSUInteger)pagesNumberOfControllers; 18 | - (UIViewController*)pagesPageViewControllerAtIndex:(NSUInteger)index; 19 | 20 | @end 21 | 22 | @interface PSPagesViewController : UIViewController { 23 | @private 24 | id datasource; 25 | NSUInteger pageIndex; 26 | BOOL pageShouldCurl; 27 | BOOL needsAdjustGLView; 28 | } 29 | 30 | @property (nonatomic, assign) id datasource; 31 | @property (nonatomic, assign) BOOL shouldUseInitialEmptyLeftPage; 32 | @property (nonatomic, assign) PSPagesViewPageOrientation pageOrientation; 33 | @property (nonatomic, readonly) UIViewController *leftPageViewController; 34 | @property (nonatomic, readonly) UIViewController *rightPageViewController; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /PaperStackDemo/Vendor/PaperStack/PSPagesViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSPlayerController.m 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 25/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import "PSPagesViewController.h" 10 | #import 11 | #import "PSPage.h" 12 | #import "PSDrawings.h" 13 | 14 | @interface PSPagesViewController() 15 | 16 | @property (nonatomic, retain) EAGLView *glView; 17 | @property (nonatomic, retain) NSDictionary *properties; 18 | @property (nonatomic, assign) BOOL landscapeMode; 19 | @property (nonatomic, assign) PSPageView *pageTarget; 20 | @property (nonatomic, retain) PSPageView *pageLeft; 21 | @property (nonatomic, retain) PSPageView *pageRight; 22 | 23 | @property (nonatomic, retain) UIViewController *leftPageViewController_; 24 | @property (nonatomic, retain) UIViewController *rightPageViewController_; 25 | 26 | 27 | - (void)deviceOrientationDidChange:(NSNotification*)notification; 28 | 29 | // drawing elements 30 | 31 | - (void)checkOrientation; 32 | - (void)deviceDidRotateWithPageOrientation:(PSPagesViewPageOrientation)orientation; 33 | - (void)adjustGLView; 34 | - (CGPoint)convertPointToGL:(CGPoint)point; 35 | - (void)pageCurlBeganWithPoint:(CGPoint)point; 36 | - (void)pageCurlTrackWithPoint:(CGPoint)point; 37 | - (void)pageCurlEndedWithPoint:(CGPoint)point; 38 | 39 | @end 40 | 41 | @implementation PSPagesViewController 42 | 43 | @synthesize datasource, shouldUseInitialEmptyLeftPage; 44 | @synthesize properties; 45 | @synthesize landscapeMode, pageTarget, pageLeft, pageRight; 46 | @synthesize glView, pageOrientation; 47 | @synthesize leftPageViewController_, rightPageViewController_; 48 | 49 | #pragma mark - Init 50 | 51 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 52 | { 53 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 54 | if (self) { 55 | 56 | // Custom initialization 57 | EAGLView *glv = [[EAGLView alloc] initWithFrame:CGRectMake(0, 0, 1024, 1024)]; 58 | glv.autoresizingMask = UIViewAutoresizingNone; 59 | self.glView = glv; 60 | [glv release]; 61 | 62 | self.properties = [NSDictionary dictionary]; 63 | self.pageOrientation = PSPagesViewPageOrientationUnknow; 64 | } 65 | return self; 66 | } 67 | 68 | - (void)dealloc 69 | { 70 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 71 | [leftPageViewController_ release]; 72 | [rightPageViewController_ release]; 73 | [properties release]; 74 | [glView release]; 75 | [pageLeft release]; 76 | [pageRight release]; 77 | [super dealloc]; 78 | } 79 | 80 | - (void)didReceiveMemoryWarning 81 | { 82 | // Releases the view if it doesn't have a superview. 83 | [super didReceiveMemoryWarning]; 84 | 85 | // Release any cached data, images, etc that aren't in use. 86 | } 87 | 88 | #pragma mark - View lifecycle 89 | 90 | /* 91 | // Implement loadView to create a view hierarchy programmatically, without using a nib. 92 | - (void)loadView 93 | { 94 | } 95 | */ 96 | 97 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 98 | - (void)viewDidLoad 99 | { 100 | 101 | [super viewDidLoad]; 102 | 103 | //self.view.userInteractionEnabled = NO; 104 | self.view.multipleTouchEnabled = NO; 105 | 106 | pageIndex = 0; 107 | 108 | CGRect rect = self.view.frame; 109 | rect.origin.y = 0; 110 | self.view.frame = rect; 111 | 112 | [self.view addSubview:self.glView]; 113 | self.glView.datasource = self; 114 | 115 | self.view.opaque = YES; 116 | self.view.backgroundColor = [UIColor blackColor]; 117 | 118 | CGRect plRect, prRect; 119 | 120 | plRect = self.view.bounds; 121 | prRect = self.view.bounds; 122 | 123 | PSPageView *lp = [[PSPageView alloc] initWithFrame:plRect]; 124 | PSPageView *rp = [[PSPageView alloc] initWithFrame:prRect]; 125 | 126 | lp.tag = 100; 127 | rp.tag = 200; 128 | 129 | lp.properties = self.properties; 130 | lp.datasource = self; 131 | lp.delegate = self; 132 | 133 | rp.properties = self.properties; 134 | rp.datasource = self; 135 | rp.delegate = self; 136 | 137 | [lp setFlippedFlag]; 138 | 139 | self.pageRight = rp; 140 | self.pageLeft = lp; 141 | 142 | [self.view addSubview:lp]; 143 | [self.view addSubview:rp]; 144 | 145 | [lp release]; 146 | [rp release]; 147 | 148 | [self.view bringSubviewToFront:glView]; 149 | 150 | // rotation notifications 151 | [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 152 | [[NSNotificationCenter defaultCenter] addObserver:self 153 | selector:@selector(deviceOrientationDidChange:) 154 | name:UIDeviceOrientationDidChangeNotification 155 | object:nil]; 156 | 157 | [self checkOrientation]; 158 | } 159 | 160 | - (void)deviceOrientationDidChange:(NSNotification*)notification 161 | { 162 | [self checkOrientation]; 163 | } 164 | 165 | - (void)viewDidUnload 166 | { 167 | [super viewDidUnload]; 168 | // Release any retained subviews of the main view. 169 | // e.g. self.myOutlet = nil; 170 | } 171 | 172 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 173 | { 174 | // Return YES for supported orientations 175 | return YES; 176 | } 177 | 178 | - (void)checkOrientation 179 | { 180 | UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; 181 | if ( UIInterfaceOrientationIsLandscape(orientation) || UIInterfaceOrientationIsPortrait(orientation) ) { 182 | PSPagesViewPageOrientation newPageOrientation = UIInterfaceOrientationIsLandscape(orientation) ? PSPagesViewPageOrientationLandscape : PSPagesViewPageOrientationPortrait; 183 | if ( self.pageOrientation != newPageOrientation ) { 184 | [self deviceDidRotateWithPageOrientation:newPageOrientation]; 185 | } 186 | } 187 | } 188 | 189 | - (void)deviceDidRotateWithPageOrientation:(PSPagesViewPageOrientation)orientation 190 | { 191 | DLog(@"deviceDidRotateWithOrientation:%d",orientation); 192 | 193 | self.pageOrientation = orientation; 194 | 195 | CGRect plRect, prRect; 196 | 197 | plRect = self.view.bounds; 198 | prRect = self.view.bounds; 199 | 200 | self.pageLeft.hidden = YES; 201 | 202 | needsAdjustGLView = YES; 203 | 204 | if ( orientation == PSPagesViewPageOrientationLandscape ) { 205 | prRect.size.width = prRect.size.width * 0.5; 206 | prRect.origin.x = prRect.size.width; 207 | plRect.size.width = plRect.size.width * 0.5; 208 | self.pageLeft.hidden = NO; 209 | [self.pageLeft pageDidRotateWithPageOrientation:orientation]; 210 | landscapeMode = YES; 211 | self.pageLeft.frame = plRect; 212 | } else { 213 | landscapeMode = NO; 214 | } 215 | [self.pageRight pageDidRotateWithPageOrientation:orientation]; 216 | 217 | self.pageRight.frame = prRect; 218 | } 219 | 220 | - (void)adjustGLView 221 | { 222 | CGSize screen = [UIScreen mainScreen].bounds.size; 223 | CGSize size = self.view.bounds.size; 224 | CGFloat dimension = fmaxf(screen.width, screen.height); 225 | CGFloat x, y; 226 | if ( self.pageOrientation == PSPagesViewPageOrientationPortrait ) { 227 | x = (dimension-size.width)*-0.5; 228 | y = (dimension-size.height)*-0.5; 229 | self.glView.frame = CGRectMake( x, y, dimension, dimension ); 230 | [self.glView setOrthoTranslate:size.width*0.5/dimension]; 231 | } else { 232 | x = (dimension-size.width)*-0.5; 233 | y = (dimension-size.height)*-0.5; 234 | self.glView.frame = CGRectMake( x, y, dimension, dimension ); 235 | [self.glView setOrthoTranslate:0.0]; 236 | } 237 | DLog(@"GLViewFrame: %f %f %f %f", self.glView.frame.origin.x, self.glView.frame.origin.y, self.glView.frame.size.width, self.glView.frame.size.height ); 238 | } 239 | 240 | #pragma mark - 241 | #pragma mark - Public 242 | 243 | - (UIViewController*)leftPageViewController 244 | { 245 | return self.leftPageViewController_; 246 | } 247 | 248 | - (UIViewController*)rightPageViewController 249 | { 250 | return self.rightPageViewController_; 251 | } 252 | 253 | #pragma mark - 254 | #pragma ESRenderer Datasource 255 | 256 | - (BOOL)rendererHasSinglePage 257 | { 258 | return landscapeMode == NO; 259 | } 260 | 261 | - (BOOL)rendererisRightPage 262 | { 263 | return self.pageTarget == self.pageRight; 264 | } 265 | 266 | - (UIImage*)rendererGetRightFrontTexture 267 | { 268 | return [self.pageRight textureData]; 269 | } 270 | 271 | - (UIImage*)rendererGetRightBackTexture { 272 | return [self.pageRight textureData]; 273 | } 274 | 275 | - (UIImage*)rendererGetLeftFrontTexture 276 | { 277 | return [self.pageLeft textureData]; 278 | } 279 | 280 | - (UIImage*)rendererGetLeftBackTexture { 281 | return [self.pageLeft textureData]; 282 | } 283 | 284 | - (CGRect)rendererGetRightFrontTextureRect 285 | { 286 | return [self.pageRight textureRect]; 287 | } 288 | 289 | - (CGRect)rendererGetRightBackTextureRect 290 | { 291 | return [self.pageRight textureRect]; 292 | } 293 | 294 | - (CGRect)rendererGetLeftFrontTextureRect 295 | { 296 | return [self.pageLeft textureRect]; 297 | } 298 | 299 | - (CGRect)rendererGetLeftBackTextureRect 300 | { 301 | return [self.pageLeft textureRect]; 302 | } 303 | 304 | - (CGRect)rendererGetRightFrontTextureBounds 305 | { 306 | return [self.pageRight textureBounds]; 307 | } 308 | 309 | - (CGRect)rendererGetRightBackTextureBounds 310 | { 311 | return [self.pageRight textureBounds]; 312 | } 313 | 314 | - (CGRect)rendererGetLeftFrontTextureBounds 315 | { 316 | return [self.pageLeft textureBounds]; 317 | } 318 | 319 | - (CGRect)rendererGetLeftBackTextureBounds 320 | { 321 | return [self.pageLeft textureBounds]; 322 | } 323 | 324 | - (UIImage*)rendererGetShaderTexture 325 | { 326 | return [glView activeEffects].shaderImage; 327 | } 328 | 329 | - (UIImage*)rendererGetInnerShadowTexture 330 | { 331 | return [glView activeEffects].innerShadowImage; 332 | } 333 | 334 | #pragma mark - 335 | #pragma mark Manipulating 336 | 337 | - (CGPoint)convertPointToGL:(CGPoint)point 338 | { 339 | CGFloat halfw, halfh, dx, dy, pX, pY; 340 | CGRect rect = self.glView.frame; 341 | if ( landscapeMode ) { 342 | halfw = rect.size.width * 0.5; 343 | } else { 344 | halfw = rect.size.width * 0.5 - self.view.frame.size.width * 0.5; 345 | } 346 | halfh = rect.size.height * 0.5; 347 | dx = ( point.x - halfw ) / rect.size.width; 348 | dy = ( point.y - halfh ) / rect.size.height; 349 | pX = dx; 350 | pY = -dy; 351 | return CGPointMake( pX, pY ); 352 | } 353 | 354 | - (void)pageCurlBeganWithPoint:(CGPoint)point 355 | { 356 | // update textures 357 | //[glView loadTextures]; 358 | PSPage *page = [glView activePage]; 359 | page.SP = [self convertPointToGL:point]; 360 | DLog(@"SP: %f %f", page.SP.x, page.SP.y ); 361 | } 362 | 363 | - (void)pageCurlTrackWithPoint:(CGPoint)point 364 | { 365 | PSPage *page = [glView activePage]; 366 | CGPoint np = [self convertPointToGL:point]; 367 | if ( !CGPointEqualToPoint(np, page.P) ) { 368 | page.P = np; 369 | [glView applyTransform]; 370 | } 371 | } 372 | 373 | - (void)pageCurlEndedWithPoint:(CGPoint)point 374 | { 375 | [glView animateToEnd]; 376 | } 377 | 378 | #pragma mark - 379 | #pragma Touches handler 380 | 381 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 382 | { 383 | UITouch *touch = [event.allTouches anyObject]; 384 | CGPoint testPoint = [touch locationInView:self.view]; 385 | 386 | if ( landscapeMode ) { 387 | if ( testPoint.x <= self.view.bounds.size.width * 0.5 ) { 388 | self.pageTarget = pageLeft; 389 | [glView activateLeftPage]; 390 | pageShouldCurl = testPoint.x < self.view.bounds.size.width * 0.1; 391 | testPoint.x = 0; 392 | } else { 393 | self.pageTarget = pageRight; 394 | [glView activateRightPage]; 395 | pageShouldCurl = testPoint.x > self.view.bounds.size.width * 0.9; 396 | testPoint.x = self.view.bounds.size.width; 397 | } 398 | } else { 399 | self.pageTarget = pageRight; 400 | [glView activateRightPage]; 401 | pageShouldCurl = testPoint.x > self.view.bounds.size.width * 0.9; 402 | testPoint.x = self.view.bounds.size.width; 403 | } 404 | // start curl 405 | if ( pageShouldCurl ) { 406 | CGPoint touchPoint = [self.glView convertPoint:testPoint fromView:self.view]; 407 | [self pageCurlBeganWithPoint:touchPoint]; 408 | } 409 | } 410 | 411 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 412 | { 413 | UITouch *touch = [event.allTouches anyObject]; 414 | CGPoint touchPoint = [touch locationInView:self.glView]; 415 | if ( pageShouldCurl ) { 416 | [self pageCurlTrackWithPoint:touchPoint]; 417 | } 418 | } 419 | 420 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 421 | { 422 | UITouch *touch = [event.allTouches anyObject]; 423 | CGPoint touchPoint = [touch locationInView:self.glView]; 424 | if ( pageShouldCurl ) { 425 | [self pageCurlEndedWithPoint:touchPoint]; 426 | } 427 | pageShouldCurl = NO; 428 | } 429 | 430 | #pragma mark - 431 | #pragma mark PSPageViewDatasource 432 | 433 | - (UIView*)pageViewForPage:(PSPageView *)pageView 434 | { 435 | if ( self.landscapeMode ) { 436 | if ( pageView == self.pageLeft ) { 437 | if ( pageIndex == 0 && self.shouldUseInitialEmptyLeftPage ) { 438 | return nil; 439 | } 440 | self.leftPageViewController_ = [datasource pagesPageViewControllerAtIndex:pageIndex]; 441 | return self.leftPageViewController_.view; 442 | } else { 443 | NSInteger rIndex = pageIndex + 1; 444 | if ( pageIndex == 0 && self.shouldUseInitialEmptyLeftPage ) { 445 | rIndex = pageIndex; 446 | } 447 | self.rightPageViewController_ = [datasource pagesPageViewControllerAtIndex:rIndex]; 448 | return self.rightPageViewController_.view; 449 | } 450 | } 451 | self.rightPageViewController_ = [datasource pagesPageViewControllerAtIndex:pageIndex]; 452 | return self.rightPageViewController_.view; 453 | } 454 | 455 | #pragma mark - 456 | #pragma mark PSPageViewDelegate 457 | 458 | - (void)pageViewDidFinishLoadContentForPage:(PSPageView *)pageView 459 | { 460 | self.pageTarget = pageView; 461 | if (needsAdjustGLView) { 462 | DLog(@"AdjustGLView"); 463 | needsAdjustGLView = NO; 464 | [self adjustGLView]; 465 | } 466 | if ( pageView == pageLeft && landscapeMode ) { 467 | [glView loadLeftTextures]; 468 | } 469 | if ( pageView == pageRight ) { 470 | [glView loadRightTextures]; 471 | } 472 | } 473 | 474 | @end 475 | -------------------------------------------------------------------------------- /PaperStackDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /PaperStackDemo/en.lproj/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 800 5 | 10J869 6 | 1306 7 | 1038.35 8 | 461.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 301 12 | 13 | 14 | YES 15 | IBProxyObject 16 | IBUINavigationController 17 | IBUIViewController 18 | IBUICustomObject 19 | IBUIWindow 20 | IBUINavigationBar 21 | IBUINavigationItem 22 | 23 | 24 | YES 25 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 26 | 27 | 28 | YES 29 | 30 | YES 31 | 32 | 33 | 34 | 35 | YES 36 | 37 | IBFilesOwner 38 | IBIPadFramework 39 | 40 | 41 | IBFirstResponder 42 | IBIPadFramework 43 | 44 | 45 | 46 | 292 47 | {768, 1024} 48 | 49 | 50 | 51 | 1 52 | MSAxIDEAA 53 | 54 | NO 55 | NO 56 | 57 | 2 58 | 59 | IBIPadFramework 60 | YES 61 | 62 | 63 | IBIPadFramework 64 | 65 | 66 | 67 | 2 68 | 69 | 70 | 1 71 | 1 72 | 73 | IBIPadFramework 74 | NO 75 | 76 | 77 | 256 78 | {0, 0} 79 | YES 80 | YES 81 | IBIPadFramework 82 | 83 | 84 | YES 85 | 86 | 87 | 88 | Item 89 | IBIPadFramework 90 | 91 | 92 | PaperStackDemoViewController 93 | 94 | 95 | 1 96 | 1 97 | 98 | IBIPadFramework 99 | NO 100 | 101 | 102 | YES 103 | 104 | 105 | 106 | 107 | YES 108 | 109 | 110 | delegate 111 | 112 | 113 | 114 | 9 115 | 116 | 117 | 118 | window 119 | 120 | 121 | 122 | 10 123 | 124 | 125 | 126 | navigationController 127 | 128 | 129 | 130 | 18 131 | 132 | 133 | 134 | 135 | YES 136 | 137 | 0 138 | 139 | 140 | 141 | 142 | 143 | -1 144 | 145 | 146 | File's Owner 147 | 148 | 149 | -2 150 | 151 | 152 | 153 | 154 | 2 155 | 156 | 157 | Window 158 | 159 | 160 | 6 161 | 162 | 163 | PaperStackDemo App Delegate 164 | 165 | 166 | 11 167 | 168 | 169 | YES 170 | 171 | 172 | 173 | 174 | 175 | 176 | 12 177 | 178 | 179 | 180 | 181 | 7 182 | 183 | 184 | YES 185 | 186 | 187 | 188 | 189 | 190 | 15 191 | 192 | 193 | 194 | 195 | 196 | 197 | YES 198 | 199 | YES 200 | -1.CustomClassName 201 | -2.CustomClassName 202 | 11.IBPluginDependency 203 | 12.IBPluginDependency 204 | 2.IBEditorWindowLastContentRect 205 | 2.IBPluginDependency 206 | 6.CustomClassName 207 | 6.IBPluginDependency 208 | 7.CustomClassName 209 | 7.IBEditorWindowLastContentRect 210 | 7.IBPluginDependency 211 | 212 | 213 | YES 214 | UIApplication 215 | UIResponder 216 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 217 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 218 | {{200, 57}, {783, 799}} 219 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 220 | PaperStackDemoAppDelegate 221 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 222 | PaperStackDemoViewController 223 | {{512, 351}, {320, 480}} 224 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 225 | 226 | 227 | 228 | YES 229 | 230 | 231 | 232 | 233 | 234 | YES 235 | 236 | 237 | 238 | 239 | 18 240 | 241 | 242 | 243 | YES 244 | 245 | PaperStackDemoAppDelegate 246 | NSObject 247 | 248 | YES 249 | 250 | YES 251 | navigationController 252 | window 253 | 254 | 255 | YES 256 | UINavigationController 257 | UIWindow 258 | 259 | 260 | 261 | YES 262 | 263 | YES 264 | navigationController 265 | window 266 | 267 | 268 | YES 269 | 270 | navigationController 271 | UINavigationController 272 | 273 | 274 | window 275 | UIWindow 276 | 277 | 278 | 279 | 280 | IBProjectSource 281 | ./Classes/PaperStackDemoAppDelegate.h 282 | 283 | 284 | 285 | PaperStackDemoViewController 286 | UIViewController 287 | 288 | launchPlayer 289 | id 290 | 291 | 292 | launchPlayer 293 | 294 | launchPlayer 295 | id 296 | 297 | 298 | 299 | IBProjectSource 300 | ./Classes/PaperStackDemoViewController.h 301 | 302 | 303 | 304 | 305 | 0 306 | IBIPadFramework 307 | 308 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 309 | 310 | 311 | 312 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 313 | 314 | 315 | YES 316 | 3 317 | 301 318 | 319 | 320 | -------------------------------------------------------------------------------- /PaperStackDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PaperStackDemo 4 | // 5 | // Created by Lorenzo Manfredi on 24/05/11. 6 | // Copyright 2011 Mutado. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | [pool release]; 16 | return retVal; 17 | } 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PaperStack Alpha Source Code 2 | 3 | PaperStack is an iOS Page Curl filter. 4 | After iOS 5 release (introducing PageViewController and Book Applications) PaperStack team decided to convert the "Books" project in something more interesting and portable. Anyway, we decided to release our alpha source code to reveal the geometry and math behind the Page Curl filter to everyone. Hope this helps! 5 | 6 | ## Join Paperstack Team 7 | 8 | Would you like to join our next PaperStack project? Feel free to contact us on [twitter](https://twitter.com/lomanf). 9 | 10 | ## Info & Credits 11 | 12 | The code is open source then GitHub forks and pull requests are really appreciated. 13 | This code was released because around 200 developers around the world ask for it in the last weeks. The scope is to share the conical dynamic deformation, finger tracking, shadow casting, page constrain logic and texture mapping. 14 | **It means that it's not yet ready to be used in a commercial project.** 15 | 16 | If you decide to use this code or part of it for your own project, please do not forget people that spent time and passion on it. Here is the list of people to thanks: 17 | 18 | * [Mutado Mobile API & PaperStack team for the dynamic conical deformation and finger tracking](http://mutado.com/mobile) 19 | * [W. Dana Nuon for the "basic" conical algorithm mesh deformation and source](http://wdnuon.blogspot.com/2010/05/implementing-ibooks-page-curling-using.html) 20 | * [Jeff LaMarche for his extensive and incredibly helpful OpenGL ES from the ground up tutorials](http://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-ground-up-table-of.html) 21 | 22 | ## License 23 | 24 | Copyright (c) 2011 Mutado, http://mutado.com 25 | 26 | ------------------------------------------------------------------- 27 | 28 | Permission is hereby granted, free of charge, to any person 29 | obtaining a copy of this software and associated documentation 30 | files (the "Software"), to deal in the Software without 31 | restriction, including without limitation the rights to use, 32 | copy, modify, merge, publish, distribute, sublicense, and/or sell 33 | copies of the Software, and to permit persons to whom the 34 | Software is furnished to do so, subject to the following 35 | conditions: 36 | 37 | The above copyright notice and this permission notice shall be 38 | included in all copies or substantial portions of the Software. 39 | 40 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 41 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 42 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 43 | NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 44 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 45 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 46 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 47 | OTHER DEALINGS IN THE SOFTWARE. 48 | 49 | ------------------------------------------------------------------- 50 | --------------------------------------------------------------------------------