├── OpenWorldTest.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── steven.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── WorkspaceSettings.xcsettings └── xcuserdata │ └── steven.xcuserdatad │ ├── xcdebugger │ └── Breakpoints.xcbkptlist │ └── xcschemes │ ├── SceneKitRPG.xcscheme │ └── xcschememanagement.plist ├── OpenWorldTest ├── 3D │ ├── cube.dae │ ├── shader.frag │ ├── shader.vert │ └── tree.dae ├── Images │ ├── crosshair.png │ ├── dirt.png │ ├── grass.png │ └── water.png ├── OWTAppDelegate.h ├── OWTAppDelegate.m ├── OWTChunk.h ├── OWTChunk.m ├── OWTEntity.h ├── OWTEntity.m ├── OWTGameView.h ├── OWTGameView.m ├── OWTLevelGenerator.h ├── OWTLevelGenerator.m ├── OWTPlayer.h ├── OWTPlayer.m ├── OpenWorldTest-Info.plist ├── OpenWorldTest-Prefix.pch ├── en.lproj │ ├── Credits.rtf │ ├── InfoPlist.strings │ └── MainMenu.xib └── main.m ├── README.md ├── libddhid.a └── libdhid ├── DDHidAppleRemote.h ├── DDHidDevice.h ├── DDHidElement.h ├── DDHidEvent.h ├── DDHidJoystick.h ├── DDHidKeyboard.h ├── DDHidKeyboardBarcodeScanner.h ├── DDHidLib.h ├── DDHidMouse.h ├── DDHidQueue.h ├── DDHidUsage.h └── DDHidUsageTables.h /OpenWorldTest.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B02C44F11686B37E0050BD75 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B02C44F01686B37E0050BD75 /* Cocoa.framework */; }; 11 | B02C450E1686B39E0050BD75 /* SceneKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B02C450D1686B39E0050BD75 /* SceneKit.framework */; }; 12 | B02C45131686B5610050BD75 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B02C45121686B5610050BD75 /* QuartzCore.framework */; }; 13 | B03D9A8C1686C4D60013F526 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B03D9A8B1686C4D60013F526 /* OpenGL.framework */; }; 14 | B03D9A8F1686CD340013F526 /* libddhid.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B03D9A8E1686CD340013F526 /* libddhid.a */; }; 15 | B03D9AA31686CDD90013F526 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B03D9AA21686CDD90013F526 /* IOKit.framework */; }; 16 | B0429D1316A3501500331EDE /* shader.frag in Resources */ = {isa = PBXBuildFile; fileRef = B0AC59BF16A346E300E90A1A /* shader.frag */; }; 17 | B0429D1416A3501700331EDE /* shader.vert in Resources */ = {isa = PBXBuildFile; fileRef = B0AC59C016A346E300E90A1A /* shader.vert */; }; 18 | B0AC59DC16A346E300E90A1A /* cube.dae in Resources */ = {isa = PBXBuildFile; fileRef = B0AC59BE16A346E300E90A1A /* cube.dae */; }; 19 | B0AC59DD16A346E300E90A1A /* shader.frag in Sources */ = {isa = PBXBuildFile; fileRef = B0AC59BF16A346E300E90A1A /* shader.frag */; }; 20 | B0AC59DE16A346E300E90A1A /* shader.vert in Sources */ = {isa = PBXBuildFile; fileRef = B0AC59C016A346E300E90A1A /* shader.vert */; }; 21 | B0AC59DF16A346E300E90A1A /* tree.dae in Resources */ = {isa = PBXBuildFile; fileRef = B0AC59C116A346E300E90A1A /* tree.dae */; }; 22 | B0AC59E016A346E300E90A1A /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = B0AC59C216A346E300E90A1A /* Credits.rtf */; }; 23 | B0AC59E116A346E300E90A1A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B0AC59C416A346E300E90A1A /* InfoPlist.strings */; }; 24 | B0AC59E216A346E300E90A1A /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = B0AC59C616A346E300E90A1A /* MainMenu.xib */; }; 25 | B0AC59E316A346E300E90A1A /* crosshair.png in Resources */ = {isa = PBXBuildFile; fileRef = B0AC59C916A346E300E90A1A /* crosshair.png */; }; 26 | B0AC59E416A346E300E90A1A /* dirt.png in Resources */ = {isa = PBXBuildFile; fileRef = B0AC59CA16A346E300E90A1A /* dirt.png */; }; 27 | B0AC59E516A346E300E90A1A /* grass.png in Resources */ = {isa = PBXBuildFile; fileRef = B0AC59CB16A346E300E90A1A /* grass.png */; }; 28 | B0AC59E616A346E300E90A1A /* water.png in Resources */ = {isa = PBXBuildFile; fileRef = B0AC59CC16A346E300E90A1A /* water.png */; }; 29 | B0AC59E716A346E300E90A1A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B0AC59CD16A346E300E90A1A /* main.m */; }; 30 | B0AC59E916A346E300E90A1A /* OWTAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B0AC59D116A346E300E90A1A /* OWTAppDelegate.m */; }; 31 | B0AC59EA16A346E300E90A1A /* OWTChunk.m in Sources */ = {isa = PBXBuildFile; fileRef = B0AC59D316A346E300E90A1A /* OWTChunk.m */; }; 32 | B0AC59EB16A346E300E90A1A /* OWTEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = B0AC59D516A346E300E90A1A /* OWTEntity.m */; }; 33 | B0AC59EC16A346E300E90A1A /* OWTGameView.m in Sources */ = {isa = PBXBuildFile; fileRef = B0AC59D716A346E300E90A1A /* OWTGameView.m */; }; 34 | B0AC59ED16A346E300E90A1A /* OWTLevelGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = B0AC59D916A346E300E90A1A /* OWTLevelGenerator.m */; }; 35 | B0AC59EE16A346E300E90A1A /* OWTPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = B0AC59DB16A346E300E90A1A /* OWTPlayer.m */; }; 36 | /* End PBXBuildFile section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | B02C44EC1686B37E0050BD75 /* OpenWorldTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OpenWorldTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | B02C44F01686B37E0050BD75 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 41 | B02C44F31686B37E0050BD75 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 42 | B02C44F41686B37E0050BD75 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 43 | B02C44F51686B37E0050BD75 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 44 | B02C450D1686B39E0050BD75 /* SceneKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SceneKit.framework; path = System/Library/Frameworks/SceneKit.framework; sourceTree = SDKROOT; }; 45 | B02C45121686B5610050BD75 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 46 | B03D9A8B1686C4D60013F526 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; 47 | B03D9A8E1686CD340013F526 /* libddhid.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libddhid.a; sourceTree = ""; }; 48 | B03D9A961686CD6D0013F526 /* DDHidAppleRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDHidAppleRemote.h; sourceTree = ""; }; 49 | B03D9A971686CD6D0013F526 /* DDHidDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDHidDevice.h; sourceTree = ""; }; 50 | B03D9A981686CD6D0013F526 /* DDHidElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDHidElement.h; sourceTree = ""; }; 51 | B03D9A991686CD6D0013F526 /* DDHidEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDHidEvent.h; sourceTree = ""; }; 52 | B03D9A9A1686CD6D0013F526 /* DDHidJoystick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDHidJoystick.h; sourceTree = ""; }; 53 | B03D9A9B1686CD6D0013F526 /* DDHidKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDHidKeyboard.h; sourceTree = ""; }; 54 | B03D9A9C1686CD6D0013F526 /* DDHidKeyboardBarcodeScanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDHidKeyboardBarcodeScanner.h; sourceTree = ""; }; 55 | B03D9A9D1686CD6D0013F526 /* DDHidLib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDHidLib.h; sourceTree = ""; }; 56 | B03D9A9E1686CD6D0013F526 /* DDHidMouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDHidMouse.h; sourceTree = ""; }; 57 | B03D9A9F1686CD6D0013F526 /* DDHidQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDHidQueue.h; sourceTree = ""; }; 58 | B03D9AA01686CD6D0013F526 /* DDHidUsage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDHidUsage.h; sourceTree = ""; }; 59 | B03D9AA11686CD6D0013F526 /* DDHidUsageTables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDHidUsageTables.h; sourceTree = ""; }; 60 | B03D9AA21686CDD90013F526 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; 61 | B0AC59BE16A346E300E90A1A /* cube.dae */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = cube.dae; sourceTree = ""; }; 62 | B0AC59BF16A346E300E90A1A /* shader.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = shader.frag; sourceTree = ""; }; 63 | B0AC59C016A346E300E90A1A /* shader.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = shader.vert; sourceTree = ""; }; 64 | B0AC59C116A346E300E90A1A /* tree.dae */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = tree.dae; sourceTree = ""; }; 65 | B0AC59C316A346E300E90A1A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; }; 66 | B0AC59C516A346E300E90A1A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 67 | B0AC59C716A346E300E90A1A /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 68 | B0AC59C916A346E300E90A1A /* crosshair.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = crosshair.png; sourceTree = ""; }; 69 | B0AC59CA16A346E300E90A1A /* dirt.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = dirt.png; sourceTree = ""; }; 70 | B0AC59CB16A346E300E90A1A /* grass.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = grass.png; sourceTree = ""; }; 71 | B0AC59CC16A346E300E90A1A /* water.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = water.png; sourceTree = ""; }; 72 | B0AC59CD16A346E300E90A1A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 73 | B0AC59CE16A346E300E90A1A /* OpenWorldTest-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "OpenWorldTest-Info.plist"; sourceTree = ""; }; 74 | B0AC59CF16A346E300E90A1A /* OpenWorldTest-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "OpenWorldTest-Prefix.pch"; sourceTree = ""; }; 75 | B0AC59D016A346E300E90A1A /* OWTAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWTAppDelegate.h; sourceTree = ""; }; 76 | B0AC59D116A346E300E90A1A /* OWTAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWTAppDelegate.m; sourceTree = ""; }; 77 | B0AC59D216A346E300E90A1A /* OWTChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWTChunk.h; sourceTree = ""; }; 78 | B0AC59D316A346E300E90A1A /* OWTChunk.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWTChunk.m; sourceTree = ""; }; 79 | B0AC59D416A346E300E90A1A /* OWTEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWTEntity.h; sourceTree = ""; }; 80 | B0AC59D516A346E300E90A1A /* OWTEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWTEntity.m; sourceTree = ""; }; 81 | B0AC59D616A346E300E90A1A /* OWTGameView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWTGameView.h; sourceTree = ""; }; 82 | B0AC59D716A346E300E90A1A /* OWTGameView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWTGameView.m; sourceTree = ""; }; 83 | B0AC59D816A346E300E90A1A /* OWTLevelGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWTLevelGenerator.h; sourceTree = ""; }; 84 | B0AC59D916A346E300E90A1A /* OWTLevelGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWTLevelGenerator.m; sourceTree = ""; }; 85 | B0AC59DA16A346E300E90A1A /* OWTPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWTPlayer.h; sourceTree = ""; }; 86 | B0AC59DB16A346E300E90A1A /* OWTPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWTPlayer.m; sourceTree = ""; }; 87 | /* End PBXFileReference section */ 88 | 89 | /* Begin PBXFrameworksBuildPhase section */ 90 | B02C44E91686B37E0050BD75 /* Frameworks */ = { 91 | isa = PBXFrameworksBuildPhase; 92 | buildActionMask = 2147483647; 93 | files = ( 94 | B03D9AA31686CDD90013F526 /* IOKit.framework in Frameworks */, 95 | B03D9A8C1686C4D60013F526 /* OpenGL.framework in Frameworks */, 96 | B02C45131686B5610050BD75 /* QuartzCore.framework in Frameworks */, 97 | B02C450E1686B39E0050BD75 /* SceneKit.framework in Frameworks */, 98 | B02C44F11686B37E0050BD75 /* Cocoa.framework in Frameworks */, 99 | B03D9A8F1686CD340013F526 /* libddhid.a in Frameworks */, 100 | ); 101 | runOnlyForDeploymentPostprocessing = 0; 102 | }; 103 | /* End PBXFrameworksBuildPhase section */ 104 | 105 | /* Begin PBXGroup section */ 106 | B02C44E11686B37E0050BD75 = { 107 | isa = PBXGroup; 108 | children = ( 109 | B0AC59BB16A3467C00E90A1A /* Controller Support */, 110 | B0AC59BC16A346E300E90A1A /* OpenWorldTest */, 111 | B02C44EF1686B37E0050BD75 /* Frameworks */, 112 | B02C44ED1686B37E0050BD75 /* Products */, 113 | ); 114 | sourceTree = ""; 115 | }; 116 | B02C44ED1686B37E0050BD75 /* Products */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | B02C44EC1686B37E0050BD75 /* OpenWorldTest.app */, 120 | ); 121 | name = Products; 122 | sourceTree = ""; 123 | }; 124 | B02C44EF1686B37E0050BD75 /* Frameworks */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | B03D9AA21686CDD90013F526 /* IOKit.framework */, 128 | B03D9A8B1686C4D60013F526 /* OpenGL.framework */, 129 | B02C45121686B5610050BD75 /* QuartzCore.framework */, 130 | B02C450D1686B39E0050BD75 /* SceneKit.framework */, 131 | B02C44F01686B37E0050BD75 /* Cocoa.framework */, 132 | B02C44F21686B37E0050BD75 /* Other Frameworks */, 133 | ); 134 | name = Frameworks; 135 | sourceTree = ""; 136 | }; 137 | B02C44F21686B37E0050BD75 /* Other Frameworks */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | B02C44F31686B37E0050BD75 /* AppKit.framework */, 141 | B02C44F41686B37E0050BD75 /* CoreData.framework */, 142 | B02C44F51686B37E0050BD75 /* Foundation.framework */, 143 | ); 144 | name = "Other Frameworks"; 145 | sourceTree = ""; 146 | }; 147 | B03D9A951686CD6D0013F526 /* libdhid */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | B03D9A961686CD6D0013F526 /* DDHidAppleRemote.h */, 151 | B03D9A971686CD6D0013F526 /* DDHidDevice.h */, 152 | B03D9A981686CD6D0013F526 /* DDHidElement.h */, 153 | B03D9A991686CD6D0013F526 /* DDHidEvent.h */, 154 | B03D9A9A1686CD6D0013F526 /* DDHidJoystick.h */, 155 | B03D9A9B1686CD6D0013F526 /* DDHidKeyboard.h */, 156 | B03D9A9C1686CD6D0013F526 /* DDHidKeyboardBarcodeScanner.h */, 157 | B03D9A9D1686CD6D0013F526 /* DDHidLib.h */, 158 | B03D9A9E1686CD6D0013F526 /* DDHidMouse.h */, 159 | B03D9A9F1686CD6D0013F526 /* DDHidQueue.h */, 160 | B03D9AA01686CD6D0013F526 /* DDHidUsage.h */, 161 | B03D9AA11686CD6D0013F526 /* DDHidUsageTables.h */, 162 | ); 163 | path = libdhid; 164 | sourceTree = ""; 165 | }; 166 | B0429D1516A3505F00331EDE /* Game Logic */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | B0AC59D216A346E300E90A1A /* OWTChunk.h */, 170 | B0AC59D316A346E300E90A1A /* OWTChunk.m */, 171 | B0AC59D416A346E300E90A1A /* OWTEntity.h */, 172 | B0AC59D516A346E300E90A1A /* OWTEntity.m */, 173 | B0AC59DA16A346E300E90A1A /* OWTPlayer.h */, 174 | B0AC59DB16A346E300E90A1A /* OWTPlayer.m */, 175 | ); 176 | name = "Game Logic"; 177 | sourceTree = ""; 178 | }; 179 | B0AC59BB16A3467C00E90A1A /* Controller Support */ = { 180 | isa = PBXGroup; 181 | children = ( 182 | B03D9A951686CD6D0013F526 /* libdhid */, 183 | B03D9A8E1686CD340013F526 /* libddhid.a */, 184 | ); 185 | name = "Controller Support"; 186 | sourceTree = ""; 187 | }; 188 | B0AC59BC16A346E300E90A1A /* OpenWorldTest */ = { 189 | isa = PBXGroup; 190 | children = ( 191 | B0AC59BD16A346E300E90A1A /* 3D */, 192 | B0AC59C216A346E300E90A1A /* Credits.rtf */, 193 | B0AC59C416A346E300E90A1A /* InfoPlist.strings */, 194 | B0AC59C616A346E300E90A1A /* MainMenu.xib */, 195 | B0AC59C816A346E300E90A1A /* Images */, 196 | B0AC59CD16A346E300E90A1A /* main.m */, 197 | B0AC59CE16A346E300E90A1A /* OpenWorldTest-Info.plist */, 198 | B0AC59CF16A346E300E90A1A /* OpenWorldTest-Prefix.pch */, 199 | B0AC59D016A346E300E90A1A /* OWTAppDelegate.h */, 200 | B0AC59D116A346E300E90A1A /* OWTAppDelegate.m */, 201 | B0AC59D616A346E300E90A1A /* OWTGameView.h */, 202 | B0AC59D716A346E300E90A1A /* OWTGameView.m */, 203 | B0AC59D816A346E300E90A1A /* OWTLevelGenerator.h */, 204 | B0AC59D916A346E300E90A1A /* OWTLevelGenerator.m */, 205 | B0429D1516A3505F00331EDE /* Game Logic */, 206 | ); 207 | path = OpenWorldTest; 208 | sourceTree = ""; 209 | }; 210 | B0AC59BD16A346E300E90A1A /* 3D */ = { 211 | isa = PBXGroup; 212 | children = ( 213 | B0AC59BE16A346E300E90A1A /* cube.dae */, 214 | B0AC59BF16A346E300E90A1A /* shader.frag */, 215 | B0AC59C016A346E300E90A1A /* shader.vert */, 216 | B0AC59C116A346E300E90A1A /* tree.dae */, 217 | ); 218 | path = 3D; 219 | sourceTree = ""; 220 | }; 221 | B0AC59C816A346E300E90A1A /* Images */ = { 222 | isa = PBXGroup; 223 | children = ( 224 | B0AC59C916A346E300E90A1A /* crosshair.png */, 225 | B0AC59CA16A346E300E90A1A /* dirt.png */, 226 | B0AC59CB16A346E300E90A1A /* grass.png */, 227 | B0AC59CC16A346E300E90A1A /* water.png */, 228 | ); 229 | path = Images; 230 | sourceTree = ""; 231 | }; 232 | /* End PBXGroup section */ 233 | 234 | /* Begin PBXNativeTarget section */ 235 | B02C44EB1686B37E0050BD75 /* OpenWorldTest */ = { 236 | isa = PBXNativeTarget; 237 | buildConfigurationList = B02C450A1686B37F0050BD75 /* Build configuration list for PBXNativeTarget "OpenWorldTest" */; 238 | buildPhases = ( 239 | B02C44E81686B37E0050BD75 /* Sources */, 240 | B02C44E91686B37E0050BD75 /* Frameworks */, 241 | B02C44EA1686B37E0050BD75 /* Resources */, 242 | ); 243 | buildRules = ( 244 | ); 245 | dependencies = ( 246 | ); 247 | name = OpenWorldTest; 248 | productName = SceneKitRPG; 249 | productReference = B02C44EC1686B37E0050BD75 /* OpenWorldTest.app */; 250 | productType = "com.apple.product-type.application"; 251 | }; 252 | /* End PBXNativeTarget section */ 253 | 254 | /* Begin PBXProject section */ 255 | B02C44E31686B37E0050BD75 /* Project object */ = { 256 | isa = PBXProject; 257 | attributes = { 258 | CLASSPREFIX = OWT; 259 | LastUpgradeCheck = 0450; 260 | ORGANIZATIONNAME = "High Caffeine Content"; 261 | }; 262 | buildConfigurationList = B02C44E61686B37E0050BD75 /* Build configuration list for PBXProject "OpenWorldTest" */; 263 | compatibilityVersion = "Xcode 3.2"; 264 | developmentRegion = English; 265 | hasScannedForEncodings = 0; 266 | knownRegions = ( 267 | en, 268 | ); 269 | mainGroup = B02C44E11686B37E0050BD75; 270 | productRefGroup = B02C44ED1686B37E0050BD75 /* Products */; 271 | projectDirPath = ""; 272 | projectRoot = ""; 273 | targets = ( 274 | B02C44EB1686B37E0050BD75 /* OpenWorldTest */, 275 | ); 276 | }; 277 | /* End PBXProject section */ 278 | 279 | /* Begin PBXResourcesBuildPhase section */ 280 | B02C44EA1686B37E0050BD75 /* Resources */ = { 281 | isa = PBXResourcesBuildPhase; 282 | buildActionMask = 2147483647; 283 | files = ( 284 | B0AC59DC16A346E300E90A1A /* cube.dae in Resources */, 285 | B0AC59DF16A346E300E90A1A /* tree.dae in Resources */, 286 | B0AC59E016A346E300E90A1A /* Credits.rtf in Resources */, 287 | B0AC59E116A346E300E90A1A /* InfoPlist.strings in Resources */, 288 | B0AC59E216A346E300E90A1A /* MainMenu.xib in Resources */, 289 | B0AC59E316A346E300E90A1A /* crosshair.png in Resources */, 290 | B0AC59E416A346E300E90A1A /* dirt.png in Resources */, 291 | B0AC59E516A346E300E90A1A /* grass.png in Resources */, 292 | B0AC59E616A346E300E90A1A /* water.png in Resources */, 293 | B0429D1316A3501500331EDE /* shader.frag in Resources */, 294 | B0429D1416A3501700331EDE /* shader.vert in Resources */, 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | }; 298 | /* End PBXResourcesBuildPhase section */ 299 | 300 | /* Begin PBXSourcesBuildPhase section */ 301 | B02C44E81686B37E0050BD75 /* Sources */ = { 302 | isa = PBXSourcesBuildPhase; 303 | buildActionMask = 2147483647; 304 | files = ( 305 | B0AC59DD16A346E300E90A1A /* shader.frag in Sources */, 306 | B0AC59DE16A346E300E90A1A /* shader.vert in Sources */, 307 | B0AC59E716A346E300E90A1A /* main.m in Sources */, 308 | B0AC59E916A346E300E90A1A /* OWTAppDelegate.m in Sources */, 309 | B0AC59EA16A346E300E90A1A /* OWTChunk.m in Sources */, 310 | B0AC59EB16A346E300E90A1A /* OWTEntity.m in Sources */, 311 | B0AC59EC16A346E300E90A1A /* OWTGameView.m in Sources */, 312 | B0AC59ED16A346E300E90A1A /* OWTLevelGenerator.m in Sources */, 313 | B0AC59EE16A346E300E90A1A /* OWTPlayer.m in Sources */, 314 | ); 315 | runOnlyForDeploymentPostprocessing = 0; 316 | }; 317 | /* End PBXSourcesBuildPhase section */ 318 | 319 | /* Begin PBXVariantGroup section */ 320 | B0AC59C216A346E300E90A1A /* Credits.rtf */ = { 321 | isa = PBXVariantGroup; 322 | children = ( 323 | B0AC59C316A346E300E90A1A /* en */, 324 | ); 325 | name = Credits.rtf; 326 | sourceTree = ""; 327 | }; 328 | B0AC59C416A346E300E90A1A /* InfoPlist.strings */ = { 329 | isa = PBXVariantGroup; 330 | children = ( 331 | B0AC59C516A346E300E90A1A /* en */, 332 | ); 333 | name = InfoPlist.strings; 334 | sourceTree = ""; 335 | }; 336 | B0AC59C616A346E300E90A1A /* MainMenu.xib */ = { 337 | isa = PBXVariantGroup; 338 | children = ( 339 | B0AC59C716A346E300E90A1A /* en */, 340 | ); 341 | name = MainMenu.xib; 342 | sourceTree = ""; 343 | }; 344 | /* End PBXVariantGroup section */ 345 | 346 | /* Begin XCBuildConfiguration section */ 347 | B02C45081686B37F0050BD75 /* Debug */ = { 348 | isa = XCBuildConfiguration; 349 | buildSettings = { 350 | ALWAYS_SEARCH_USER_PATHS = NO; 351 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 352 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 353 | CLANG_CXX_LIBRARY = "libc++"; 354 | CLANG_ENABLE_OBJC_ARC = YES; 355 | CLANG_WARN_EMPTY_BODY = YES; 356 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 357 | COPY_PHASE_STRIP = NO; 358 | GCC_C_LANGUAGE_STANDARD = gnu99; 359 | GCC_DYNAMIC_NO_PIC = NO; 360 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 361 | GCC_OPTIMIZATION_LEVEL = 0; 362 | GCC_PREPROCESSOR_DEFINITIONS = ( 363 | "DEBUG=1", 364 | "$(inherited)", 365 | ); 366 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 367 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 368 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 369 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 370 | GCC_WARN_UNUSED_VARIABLE = YES; 371 | MACOSX_DEPLOYMENT_TARGET = 10.8; 372 | ONLY_ACTIVE_ARCH = YES; 373 | SDKROOT = macosx; 374 | }; 375 | name = Debug; 376 | }; 377 | B02C45091686B37F0050BD75 /* Release */ = { 378 | isa = XCBuildConfiguration; 379 | buildSettings = { 380 | ALWAYS_SEARCH_USER_PATHS = NO; 381 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 382 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 383 | CLANG_CXX_LIBRARY = "libc++"; 384 | CLANG_ENABLE_OBJC_ARC = YES; 385 | CLANG_WARN_EMPTY_BODY = YES; 386 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 387 | COPY_PHASE_STRIP = YES; 388 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 389 | GCC_C_LANGUAGE_STANDARD = gnu99; 390 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 391 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 392 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 393 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 394 | GCC_WARN_UNUSED_VARIABLE = YES; 395 | MACOSX_DEPLOYMENT_TARGET = 10.8; 396 | SDKROOT = macosx; 397 | }; 398 | name = Release; 399 | }; 400 | B02C450B1686B37F0050BD75 /* Debug */ = { 401 | isa = XCBuildConfiguration; 402 | buildSettings = { 403 | COMBINE_HIDPI_IMAGES = YES; 404 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 405 | GCC_PREFIX_HEADER = "OpenWorldTest/OpenWorldTest-Prefix.pch"; 406 | INFOPLIST_FILE = "OpenWorldTest/OpenWorldTest-Info.plist"; 407 | LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/\""; 408 | OTHER_LDFLAGS = ( 409 | "-all_load", 410 | "-ObjC", 411 | ); 412 | PRODUCT_NAME = OpenWorldTest; 413 | WRAPPER_EXTENSION = app; 414 | }; 415 | name = Debug; 416 | }; 417 | B02C450C1686B37F0050BD75 /* Release */ = { 418 | isa = XCBuildConfiguration; 419 | buildSettings = { 420 | COMBINE_HIDPI_IMAGES = YES; 421 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 422 | GCC_PREFIX_HEADER = "OpenWorldTest/OpenWorldTest-Prefix.pch"; 423 | INFOPLIST_FILE = "OpenWorldTest/OpenWorldTest-Info.plist"; 424 | LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/\""; 425 | OTHER_LDFLAGS = ( 426 | "-all_load", 427 | "-ObjC", 428 | ); 429 | PRODUCT_NAME = OpenWorldTest; 430 | WRAPPER_EXTENSION = app; 431 | }; 432 | name = Release; 433 | }; 434 | /* End XCBuildConfiguration section */ 435 | 436 | /* Begin XCConfigurationList section */ 437 | B02C44E61686B37E0050BD75 /* Build configuration list for PBXProject "OpenWorldTest" */ = { 438 | isa = XCConfigurationList; 439 | buildConfigurations = ( 440 | B02C45081686B37F0050BD75 /* Debug */, 441 | B02C45091686B37F0050BD75 /* Release */, 442 | ); 443 | defaultConfigurationIsVisible = 0; 444 | defaultConfigurationName = Release; 445 | }; 446 | B02C450A1686B37F0050BD75 /* Build configuration list for PBXNativeTarget "OpenWorldTest" */ = { 447 | isa = XCConfigurationList; 448 | buildConfigurations = ( 449 | B02C450B1686B37F0050BD75 /* Debug */, 450 | B02C450C1686B37F0050BD75 /* Release */, 451 | ); 452 | defaultConfigurationIsVisible = 0; 453 | defaultConfigurationName = Release; 454 | }; 455 | /* End XCConfigurationList section */ 456 | }; 457 | rootObject = B02C44E31686B37E0050BD75 /* Project object */; 458 | } 459 | -------------------------------------------------------------------------------- /OpenWorldTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OpenWorldTest.xcodeproj/project.xcworkspace/xcuserdata/steven.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steventroughtonsmith/OpenWorldTest/a07ae437f0465e4278e50911891a5cac71b761f0/OpenWorldTest.xcodeproj/project.xcworkspace/xcuserdata/steven.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /OpenWorldTest.xcodeproj/project.xcworkspace/xcuserdata/steven.xcuserdatad/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges 6 | 7 | SnapshotAutomaticallyBeforeSignificantChanges 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /OpenWorldTest.xcodeproj/xcuserdata/steven.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /OpenWorldTest.xcodeproj/xcuserdata/steven.xcuserdatad/xcschemes/SceneKitRPG.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /OpenWorldTest.xcodeproj/xcuserdata/steven.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SceneKitRPG.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | B02C44EB1686B37E0050BD75 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /OpenWorldTest/3D/cube.dae: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SceneKit Collada Exporter v1.0 6 | 7 | 2013-01-13T00:09:56Z 8 | 2013-01-13T00:09:56Z 9 | Y_UP 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 0 0 0 1 23 | 24 | 25 | 0.4 0.4 0.4 1 26 | 27 | 28 | 0 0 0 1 29 | 30 | 31 | 1 32 | 33 | 34 | 0 0 0 1 35 | 36 | 37 | 0 38 | 39 | 40 | 1 41 | 42 | 43 | 44 | 45 | 46 | 47 | 1 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 0.5 0.5 0.5 -0.5 0.5 0.5 -0.5 -0.5 0.5 0.5 0.5 0.5 -0.5 -0.5 0.5 0.5 -0.5 0.5 0.5 0.5 0.5 0.5 0.5 -0.5 -0.5 0.5 0.5 -0.5 0.5 0.5 0.5 0.5 -0.5 -0.5 0.5 -0.5 0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 0.5 -0.5 0.5 -0.5 -0.5 -0.5 0.5 -0.5 0.5 0.5 -0.5 0.5 -0.5 0.5 -0.5 -0.5 0.5 -0.5 -0.5 -0.5 0.5 -0.5 0.5 -0.5 -0.5 -0.5 0.5 -0.5 -0.5 0.5 0.5 0.5 0.5 -0.5 0.5 0.5 0.5 -0.5 0.5 -0.5 0.5 0.5 -0.5 -0.5 0.5 0.5 -0.5 -0.5 0.5 0.5 -0.5 -0.5 -0.5 -0.5 -0.5 0.5 -0.5 -0.5 -0.5 -0.5 0.5 0.5 -0.5 0.5 -0.5 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 0.625 0.25 0.375 0.25 0.375 0 0.625 0.25 0.375 0 0.625 0 0.625 0.25 0.625 0.5 0.375 0.25 0.375 0.25 0.625 0.5 0.375 0.5 0.625 0.75 0.375 0.75 0.375 0.5 0.625 0.75 0.375 0.5 0.625 0.5 0.625 1 0.375 1 0.375 0.75 0.625 1 0.375 0.75 0.625 0.75 0.625 0.25 0.625 0 0.875 0.25 0.625 0 0.875 0 0.875 0.25 0.375 0.25 0.125 0 0.375 0 0.125 0 0.375 0.25 0.125 0.25 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 |

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

92 |
93 |
94 |
95 | 96 | 97 | 98 | 1.44294 -0.72147 0 -1.44294 -0.72147 -0 0 -0.72147 -1.44294 -1.44294 -0.72147 -0 1.44294 -0.72147 0 -0 -0.72147 1.44294 0 -0.72147 -1.44294 -1.44294 -0.72147 -0 0 0.72147 0 -1.44294 -0.72147 -0 -0 -0.72147 1.44294 0 0.72147 0 -0 -0.72147 1.44294 1.44294 -0.72147 0 0 0.72147 0 1.44294 -0.72147 0 0 -0.72147 -1.44294 0 0.72147 0 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -0.57735 0.57735 -0.57735 -0.57735 0.57735 -0.57735 -0.57735 0.57735 -0.57735 -0.57735 0.57735 0.57735 -0.57735 0.57735 0.57735 -0.57735 0.57735 0.57735 0.57735 0.57735 0.57735 0.57735 0.57735 0.57735 0.57735 0.57735 0.57735 0.57735 0.57735 -0.57735 0.57735 0.57735 -0.57735 0.57735 0.57735 -0.57735 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 0.75 0.25 0.25 0.25 0.5 0 0.25 0.25 0.75 0.25 0.5 0.5 0.25 0.5 0.375 0.5 0.5 1 0.375 0.5 0.5 0.5 0.5 1 0.5 0.5 0.625 0.5 0.5 1 0.625 0.5 0.75 0.5 0.5 1 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 |

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

134 |
135 |
136 |
137 |
138 | 139 | 140 | 141 | 1 0 0 0.026093 0 1 0 0 0 0 1 0.009443 0 0 0 1 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 1 0 0 -4.61469 0 1 0 0 0 0 1 0.084043 0 0 0 1 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 |
166 | -------------------------------------------------------------------------------- /OpenWorldTest/3D/shader.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D colorTexture; 2 | uniform sampler2D depthTexture; 3 | varying vec2 TexCoord; 4 | 5 | 6 | void main (void) 7 | { 8 | float fog = texture2D(depthTexture,TexCoord).r; 9 | 10 | float fogStart = 0.995; 11 | float fogEnd = 1.0; 12 | float fogFactor = 1.0; 13 | 14 | fog = smoothstep(fogStart, fogEnd, fog) * fogFactor; 15 | 16 | vec4 fogColor = vec4(0.5,0.8,1.0,1.0); 17 | 18 | gl_FragColor = texture2D(colorTexture,TexCoord) * (1.0-fog) + fogColor*fog; 19 | } -------------------------------------------------------------------------------- /OpenWorldTest/3D/shader.vert: -------------------------------------------------------------------------------- 1 | attribute vec3 a_position; 2 | varying vec2 TexCoord; 3 | 4 | void main(void) 5 | { 6 | gl_Position = vec4(a_position, 1.0); 7 | TexCoord = (a_position.xy + 1.0) * 0.5; 8 | } -------------------------------------------------------------------------------- /OpenWorldTest/3D/tree.dae: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SceneKit Collada Exporter v1.0 6 | 7 | 2013-01-12T10:31:57Z 8 | 2013-01-12T10:31:57Z 9 | Z_UP 10 | 11 | 12 | 13 | 14 | 15 | 16 | 49.1343 17 | 0.1 18 | 100 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 1 1 1 29 | 0 30 | 0 31 | 1 32 | 33 | 34 | 35 | 36 | 0 37 | 0 38 | 2 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 0.2 0.2 0.2 1 61 | 62 | 63 | 1 1 1 1 64 | 65 | 66 | 0 0 0 1 67 | 68 | 69 | 0.022516 70 | 71 | 72 | 0 0 0 1 73 | 74 | 75 | 1 76 | 77 | 78 | 1 1 1 1 79 | 80 | 81 | 1 82 | 83 | 84 | 1 85 | 86 | 87 | 88 | 89 | 90 | 91 | 1 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 0.2 0.2 0.2 1 101 | 102 | 103 | 1 1 1 1 104 | 105 | 106 | 0 0 0 1 107 | 108 | 109 | 0.022516 110 | 111 | 112 | 0 0 0 1 113 | 114 | 115 | 1 116 | 117 | 118 | 1 1 1 1 119 | 120 | 121 | 1 122 | 123 | 124 | 1 125 | 126 | 127 | 128 | 129 | 130 | 131 | 1 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 0.2 0.2 0.2 1 141 | 142 | 143 | 1 1 1 1 144 | 145 | 146 | 0 0 0 1 147 | 148 | 149 | 0.022516 150 | 151 | 152 | 0 0 0 1 153 | 154 | 155 | 1 156 | 157 | 158 | 1 1 1 1 159 | 160 | 161 | 1 162 | 163 | 164 | 1 165 | 166 | 167 | 168 | 169 | 170 | 171 | 1 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | -0.382682 0.92388 -1 0 0 1 -0.195089 0.980786 -1 0 1 -1 0 0 1 0.19509 0.980785 -1 0 0 1 0 1 -1 -0.195089 0.980786 -1 0.19509 0.980785 -1 0 0 1 0.382683 0.92388 -1 -0.555569 0.83147 -1 0 0 1 -0.382682 0.92388 -1 -0.707106 0.707108 -1 0 0 1 -0.555569 0.83147 -1 -0.831469 0.555571 -1 0 0 1 -0.707106 0.707108 -1 -0.923879 0.382684 -1 0 0 1 -0.831469 0.555571 -1 -0.980785 0.195091 -1 0 0 1 -0.923879 0.382684 -1 -1 9.65599e-07 -1 0 0 1 -0.980785 0.195091 -1 -0.980785 -0.195089 -1 0 0 1 -1 9.65599e-07 -1 -0.92388 -0.382683 -1 0 0 1 -0.980785 -0.195089 -1 -0.83147 -0.55557 -1 0 0 1 -0.92388 -0.382683 -1 -0.707107 -0.707106 -1 0 0 1 -0.83147 -0.55557 -1 -0.555571 -0.831469 -1 0 0 1 -0.707107 -0.707106 -1 -0.382684 -0.923879 -1 0 0 1 -0.555571 -0.831469 -1 -0.195091 -0.980785 -1 0 0 1 -0.382684 -0.923879 -1 -3.25841e-07 -1 -1 0 0 1 -0.195091 -0.980785 -1 0.19509 -0.980785 -1 0 0 1 -3.25841e-07 -1 -1 0.382683 -0.92388 -1 0 0 1 0.19509 -0.980785 -1 0.55557 -0.83147 -1 0 0 1 0.382683 -0.92388 -1 0.707107 -0.707107 -1 0 0 1 0.55557 -0.83147 -1 0.83147 -0.55557 -1 0 0 1 0.707107 -0.707107 -1 0.92388 -0.382683 -1 0 0 1 0.83147 -0.55557 -1 0.980785 -0.19509 -1 0 0 1 0.92388 -0.382683 -1 1 0 -1 0 0 1 0.980785 -0.19509 -1 0.980785 0.19509 -1 0 0 1 1 0 -1 0.92388 0.382683 -1 0 0 1 0.980785 0.19509 -1 0.83147 0.55557 -1 0 0 1 0.92388 0.382683 -1 0.707107 0.707107 -1 0 0 1 0.83147 0.55557 -1 0.55557 0.83147 -1 0 0 1 0.707107 0.707107 -1 0.382683 0.92388 -1 0 0 1 0.55557 0.83147 -1 0 1 -1 0.19509 0.980785 -1 -0.195089 0.980786 -1 0.19509 0.980785 -1 -0.382682 0.92388 -1 -0.195089 0.980786 -1 0.19509 0.980785 -1 0.382683 0.92388 -1 -0.382682 0.92388 -1 0.382683 0.92388 -1 -0.555569 0.83147 -1 -0.382682 0.92388 -1 0.382683 0.92388 -1 0.55557 0.83147 -1 -0.555569 0.83147 -1 0.55557 0.83147 -1 -0.707106 0.707108 -1 -0.555569 0.83147 -1 0.55557 0.83147 -1 0.707107 0.707107 -1 -0.707106 0.707108 -1 0.707107 0.707107 -1 -0.831469 0.555571 -1 -0.707106 0.707108 -1 0.707107 0.707107 -1 0.83147 0.55557 -1 -0.831469 0.555571 -1 0.83147 0.55557 -1 -0.923879 0.382684 -1 -0.831469 0.555571 -1 0.83147 0.55557 -1 0.92388 0.382683 -1 -0.923879 0.382684 -1 0.92388 0.382683 -1 -0.980785 0.195091 -1 -0.923879 0.382684 -1 0.92388 0.382683 -1 0.980785 0.19509 -1 -0.980785 0.195091 -1 0.980785 0.19509 -1 -1 9.65599e-07 -1 -0.980785 0.195091 -1 0.980785 0.19509 -1 1 0 -1 -1 9.65599e-07 -1 1 0 -1 -0.980785 -0.195089 -1 -1 9.65599e-07 -1 1 0 -1 0.980785 -0.19509 -1 -0.980785 -0.195089 -1 0.980785 -0.19509 -1 -0.92388 -0.382683 -1 -0.980785 -0.195089 -1 0.980785 -0.19509 -1 0.92388 -0.382683 -1 -0.92388 -0.382683 -1 0.92388 -0.382683 -1 -0.83147 -0.55557 -1 -0.92388 -0.382683 -1 0.92388 -0.382683 -1 0.83147 -0.55557 -1 -0.83147 -0.55557 -1 0.83147 -0.55557 -1 -0.707107 -0.707106 -1 -0.83147 -0.55557 -1 0.83147 -0.55557 -1 0.707107 -0.707107 -1 -0.707107 -0.707106 -1 0.707107 -0.707107 -1 -0.555571 -0.831469 -1 -0.707107 -0.707106 -1 0.707107 -0.707107 -1 0.55557 -0.83147 -1 -0.555571 -0.831469 -1 0.55557 -0.83147 -1 -0.382684 -0.923879 -1 -0.555571 -0.831469 -1 0.55557 -0.83147 -1 0.382683 -0.92388 -1 -0.382684 -0.923879 -1 0.382683 -0.92388 -1 -0.195091 -0.980785 -1 -0.382684 -0.923879 -1 0.382683 -0.92388 -1 0.19509 -0.980785 -1 -0.195091 -0.980785 -1 0.19509 -0.980785 -1 -3.25841e-07 -1 -1 -0.195091 -0.980785 -1 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | -0.259887 0.856737 0.445488 -0.259887 0.856737 0.445488 -0.259887 0.856737 0.445488 0.0877533 0.890977 0.445488 0.0877533 0.890977 0.445488 0.0877533 0.890977 0.445488 -0.0877527 0.890977 0.445488 -0.0877527 0.890977 0.445488 -0.0877527 0.890977 0.445488 0.259888 0.856737 0.445488 0.259888 0.856737 0.445488 0.259888 0.856737 0.445488 -0.422035 0.789574 0.445488 -0.422035 0.789574 0.445488 -0.422035 0.789574 0.445488 -0.567964 0.692068 0.445488 -0.567964 0.692068 0.445488 -0.567964 0.692068 0.445488 -0.692066 0.567966 0.445488 -0.692066 0.567966 0.445488 -0.692066 0.567966 0.445488 -0.789573 0.422036 0.445488 -0.789573 0.422036 0.445488 -0.789573 0.422036 0.445488 -0.856737 0.259889 0.445488 -0.856737 0.259889 0.445488 -0.856737 0.259889 0.445488 -0.890977 0.0877544 0.445488 -0.890977 0.0877544 0.445488 -0.890977 0.0877544 0.445488 -0.890977 -0.0877525 0.445488 -0.890977 -0.0877525 0.445488 -0.890977 -0.0877525 0.445488 -0.856737 -0.259888 0.445488 -0.856737 -0.259888 0.445488 -0.856737 -0.259888 0.445488 -0.789574 -0.422035 0.445488 -0.789574 -0.422035 0.445488 -0.789574 -0.422035 0.445488 -0.692067 -0.567964 0.445488 -0.692067 -0.567964 0.445488 -0.692067 -0.567964 0.445488 -0.567965 -0.692066 0.445488 -0.567965 -0.692066 0.445488 -0.567965 -0.692066 0.445488 -0.422036 -0.789573 0.445488 -0.422036 -0.789573 0.445488 -0.422036 -0.789573 0.445488 -0.259889 -0.856737 0.445488 -0.259889 -0.856737 0.445488 -0.259889 -0.856737 0.445488 -0.0877539 -0.890977 0.445488 -0.0877539 -0.890977 0.445488 -0.0877539 -0.890977 0.445488 0.0877531 -0.890977 0.445488 0.0877531 -0.890977 0.445488 0.0877531 -0.890977 0.445488 0.259888 -0.856737 0.445488 0.259888 -0.856737 0.445488 0.259888 -0.856737 0.445488 0.422035 -0.789573 0.445488 0.422035 -0.789573 0.445488 0.422035 -0.789573 0.445488 0.567965 -0.692067 0.445488 0.567965 -0.692067 0.445488 0.567965 -0.692067 0.445488 0.692067 -0.567965 0.445488 0.692067 -0.567965 0.445488 0.692067 -0.567965 0.445488 0.789573 -0.422036 0.445488 0.789573 -0.422036 0.445488 0.789573 -0.422036 0.445488 0.856737 -0.259888 0.445488 0.856737 -0.259888 0.445488 0.856737 -0.259888 0.445488 0.890977 -0.0877534 0.445488 0.890977 -0.0877534 0.445488 0.890977 -0.0877534 0.445488 0.890977 0.0877534 0.445488 0.890977 0.0877534 0.445488 0.890977 0.0877534 0.445488 0.856737 0.259889 0.445488 0.856737 0.259889 0.445488 0.856737 0.259889 0.445488 0.789573 0.422036 0.445488 0.789573 0.422036 0.445488 0.789573 0.422036 0.445488 0.692067 0.567964 0.445488 0.692067 0.567964 0.445488 0.692067 0.567964 0.445488 0.567965 0.692067 0.445488 0.567965 0.692067 0.445488 0.567965 0.692067 0.445488 0.422036 0.789573 0.445488 0.422036 0.789573 0.445488 0.422036 0.789573 0.445488 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 |

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185

206 |
207 |
208 |
209 | 210 | 211 | 212 | -0.382682 0.92388 -1 0 0 1 -0.195089 0.980786 -1 0 1 -1 0 0 1 0.19509 0.980785 -1 0 0 1 0 1 -1 -0.195089 0.980786 -1 0.19509 0.980785 -1 0 0 1 0.382683 0.92388 -1 -0.555569 0.83147 -1 0 0 1 -0.382682 0.92388 -1 -0.707106 0.707108 -1 0 0 1 -0.555569 0.83147 -1 -0.831469 0.555571 -1 0 0 1 -0.707106 0.707108 -1 -0.923879 0.382684 -1 0 0 1 -0.831469 0.555571 -1 -0.980785 0.195091 -1 0 0 1 -0.923879 0.382684 -1 -1 9.65599e-07 -1 0 0 1 -0.980785 0.195091 -1 -0.980785 -0.195089 -1 0 0 1 -1 9.65599e-07 -1 -0.92388 -0.382683 -1 0 0 1 -0.980785 -0.195089 -1 -0.83147 -0.55557 -1 0 0 1 -0.92388 -0.382683 -1 -0.707107 -0.707106 -1 0 0 1 -0.83147 -0.55557 -1 -0.555571 -0.831469 -1 0 0 1 -0.707107 -0.707106 -1 -0.382684 -0.923879 -1 0 0 1 -0.555571 -0.831469 -1 -0.195091 -0.980785 -1 0 0 1 -0.382684 -0.923879 -1 -3.25841e-07 -1 -1 0 0 1 -0.195091 -0.980785 -1 0.19509 -0.980785 -1 0 0 1 -3.25841e-07 -1 -1 0.382683 -0.92388 -1 0 0 1 0.19509 -0.980785 -1 0.55557 -0.83147 -1 0 0 1 0.382683 -0.92388 -1 0.707107 -0.707107 -1 0 0 1 0.55557 -0.83147 -1 0.83147 -0.55557 -1 0 0 1 0.707107 -0.707107 -1 0.92388 -0.382683 -1 0 0 1 0.83147 -0.55557 -1 0.980785 -0.19509 -1 0 0 1 0.92388 -0.382683 -1 1 0 -1 0 0 1 0.980785 -0.19509 -1 0.980785 0.19509 -1 0 0 1 1 0 -1 0.92388 0.382683 -1 0 0 1 0.980785 0.19509 -1 0.83147 0.55557 -1 0 0 1 0.92388 0.382683 -1 0.707107 0.707107 -1 0 0 1 0.83147 0.55557 -1 0.55557 0.83147 -1 0 0 1 0.707107 0.707107 -1 0.382683 0.92388 -1 0 0 1 0.55557 0.83147 -1 0 1 -1 0.19509 0.980785 -1 -0.195089 0.980786 -1 0.19509 0.980785 -1 -0.382682 0.92388 -1 -0.195089 0.980786 -1 0.19509 0.980785 -1 0.382683 0.92388 -1 -0.382682 0.92388 -1 0.382683 0.92388 -1 -0.555569 0.83147 -1 -0.382682 0.92388 -1 0.382683 0.92388 -1 0.55557 0.83147 -1 -0.555569 0.83147 -1 0.55557 0.83147 -1 -0.707106 0.707108 -1 -0.555569 0.83147 -1 0.55557 0.83147 -1 0.707107 0.707107 -1 -0.707106 0.707108 -1 0.707107 0.707107 -1 -0.831469 0.555571 -1 -0.707106 0.707108 -1 0.707107 0.707107 -1 0.83147 0.55557 -1 -0.831469 0.555571 -1 0.83147 0.55557 -1 -0.923879 0.382684 -1 -0.831469 0.555571 -1 0.83147 0.55557 -1 0.92388 0.382683 -1 -0.923879 0.382684 -1 0.92388 0.382683 -1 -0.980785 0.195091 -1 -0.923879 0.382684 -1 0.92388 0.382683 -1 0.980785 0.19509 -1 -0.980785 0.195091 -1 0.980785 0.19509 -1 -1 9.65599e-07 -1 -0.980785 0.195091 -1 0.980785 0.19509 -1 1 0 -1 -1 9.65599e-07 -1 1 0 -1 -0.980785 -0.195089 -1 -1 9.65599e-07 -1 1 0 -1 0.980785 -0.19509 -1 -0.980785 -0.195089 -1 0.980785 -0.19509 -1 -0.92388 -0.382683 -1 -0.980785 -0.195089 -1 0.980785 -0.19509 -1 0.92388 -0.382683 -1 -0.92388 -0.382683 -1 0.92388 -0.382683 -1 -0.83147 -0.55557 -1 -0.92388 -0.382683 -1 0.92388 -0.382683 -1 0.83147 -0.55557 -1 -0.83147 -0.55557 -1 0.83147 -0.55557 -1 -0.707107 -0.707106 -1 -0.83147 -0.55557 -1 0.83147 -0.55557 -1 0.707107 -0.707107 -1 -0.707107 -0.707106 -1 0.707107 -0.707107 -1 -0.555571 -0.831469 -1 -0.707107 -0.707106 -1 0.707107 -0.707107 -1 0.55557 -0.83147 -1 -0.555571 -0.831469 -1 0.55557 -0.83147 -1 -0.382684 -0.923879 -1 -0.555571 -0.831469 -1 0.55557 -0.83147 -1 0.382683 -0.92388 -1 -0.382684 -0.923879 -1 0.382683 -0.92388 -1 -0.195091 -0.980785 -1 -0.382684 -0.923879 -1 0.382683 -0.92388 -1 0.19509 -0.980785 -1 -0.195091 -0.980785 -1 0.19509 -0.980785 -1 -3.25841e-07 -1 -1 -0.195091 -0.980785 -1 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | -0.259887 0.856737 0.445488 -0.259887 0.856737 0.445488 -0.259887 0.856737 0.445488 0.0877533 0.890977 0.445488 0.0877533 0.890977 0.445488 0.0877533 0.890977 0.445488 -0.0877527 0.890977 0.445488 -0.0877527 0.890977 0.445488 -0.0877527 0.890977 0.445488 0.259888 0.856737 0.445488 0.259888 0.856737 0.445488 0.259888 0.856737 0.445488 -0.422035 0.789574 0.445488 -0.422035 0.789574 0.445488 -0.422035 0.789574 0.445488 -0.567964 0.692068 0.445488 -0.567964 0.692068 0.445488 -0.567964 0.692068 0.445488 -0.692066 0.567966 0.445488 -0.692066 0.567966 0.445488 -0.692066 0.567966 0.445488 -0.789573 0.422036 0.445488 -0.789573 0.422036 0.445488 -0.789573 0.422036 0.445488 -0.856737 0.259889 0.445488 -0.856737 0.259889 0.445488 -0.856737 0.259889 0.445488 -0.890977 0.0877544 0.445488 -0.890977 0.0877544 0.445488 -0.890977 0.0877544 0.445488 -0.890977 -0.0877525 0.445488 -0.890977 -0.0877525 0.445488 -0.890977 -0.0877525 0.445488 -0.856737 -0.259888 0.445488 -0.856737 -0.259888 0.445488 -0.856737 -0.259888 0.445488 -0.789574 -0.422035 0.445488 -0.789574 -0.422035 0.445488 -0.789574 -0.422035 0.445488 -0.692067 -0.567964 0.445488 -0.692067 -0.567964 0.445488 -0.692067 -0.567964 0.445488 -0.567965 -0.692066 0.445488 -0.567965 -0.692066 0.445488 -0.567965 -0.692066 0.445488 -0.422036 -0.789573 0.445488 -0.422036 -0.789573 0.445488 -0.422036 -0.789573 0.445488 -0.259889 -0.856737 0.445488 -0.259889 -0.856737 0.445488 -0.259889 -0.856737 0.445488 -0.0877539 -0.890977 0.445488 -0.0877539 -0.890977 0.445488 -0.0877539 -0.890977 0.445488 0.0877531 -0.890977 0.445488 0.0877531 -0.890977 0.445488 0.0877531 -0.890977 0.445488 0.259888 -0.856737 0.445488 0.259888 -0.856737 0.445488 0.259888 -0.856737 0.445488 0.422035 -0.789573 0.445488 0.422035 -0.789573 0.445488 0.422035 -0.789573 0.445488 0.567965 -0.692067 0.445488 0.567965 -0.692067 0.445488 0.567965 -0.692067 0.445488 0.692067 -0.567965 0.445488 0.692067 -0.567965 0.445488 0.692067 -0.567965 0.445488 0.789573 -0.422036 0.445488 0.789573 -0.422036 0.445488 0.789573 -0.422036 0.445488 0.856737 -0.259888 0.445488 0.856737 -0.259888 0.445488 0.856737 -0.259888 0.445488 0.890977 -0.0877534 0.445488 0.890977 -0.0877534 0.445488 0.890977 -0.0877534 0.445488 0.890977 0.0877534 0.445488 0.890977 0.0877534 0.445488 0.890977 0.0877534 0.445488 0.856737 0.259889 0.445488 0.856737 0.259889 0.445488 0.856737 0.259889 0.445488 0.789573 0.422036 0.445488 0.789573 0.422036 0.445488 0.789573 0.422036 0.445488 0.692067 0.567964 0.445488 0.692067 0.567964 0.445488 0.692067 0.567964 0.445488 0.567965 0.692067 0.445488 0.567965 0.692067 0.445488 0.567965 0.692067 0.445488 0.422036 0.789573 0.445488 0.422036 0.789573 0.445488 0.422036 0.789573 0.445488 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 |

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185

238 |
239 |
240 |
241 | 242 | 243 | 244 | 0 1 -1 0 1 1 0.19509 0.980785 1 0.19509 0.980785 -1 0.19509 0.980785 -1 0.19509 0.980785 1 0.382683 0.92388 1 0.382683 0.92388 -1 0.382683 0.92388 -1 0.382683 0.92388 1 0.55557 0.83147 1 0.55557 0.83147 -1 0.55557 0.83147 -1 0.55557 0.83147 1 0.707107 0.707107 1 0.707107 0.707107 -1 0.707107 0.707107 -1 0.707107 0.707107 1 0.83147 0.55557 1 0.83147 0.55557 -1 0.83147 0.55557 -1 0.83147 0.55557 1 0.92388 0.382683 1 0.92388 0.382683 -1 0.92388 0.382683 -1 0.92388 0.382683 1 0.980785 0.19509 1 0.980785 0.19509 -1 0.980785 0.19509 -1 0.980785 0.19509 1 1 0 1 1 0 -1 1 0 -1 1 0 1 0.980785 -0.19509 1 0.980785 -0.19509 -1 0.980785 -0.19509 -1 0.980785 -0.19509 1 0.92388 -0.382683 1 0.92388 -0.382683 -1 0.92388 -0.382683 -1 0.92388 -0.382683 1 0.83147 -0.55557 1 0.83147 -0.55557 -1 0.83147 -0.55557 -1 0.83147 -0.55557 1 0.707107 -0.707107 1 0.707107 -0.707107 -1 0.707107 -0.707107 -1 0.707107 -0.707107 1 0.55557 -0.83147 1 0.55557 -0.83147 -1 0.55557 -0.83147 -1 0.55557 -0.83147 1 0.382683 -0.92388 1 0.382683 -0.92388 -1 0.382683 -0.92388 -1 0.382683 -0.92388 1 0.19509 -0.980785 1 0.19509 -0.980785 -1 0.19509 -0.980785 -1 0.19509 -0.980785 1 -3.25841e-07 -1 1 -3.25841e-07 -1 -1 -3.25841e-07 -1 -1 -3.25841e-07 -1 1 -0.195091 -0.980785 1 -0.195091 -0.980785 -1 -0.195091 -0.980785 -1 -0.195091 -0.980785 1 -0.382684 -0.923879 1 -0.382684 -0.923879 -1 -0.382684 -0.923879 -1 -0.382684 -0.923879 1 -0.555571 -0.831469 1 -0.555571 -0.831469 -1 -0.555571 -0.831469 -1 -0.555571 -0.831469 1 -0.707107 -0.707106 1 -0.707107 -0.707106 -1 -0.707107 -0.707106 -1 -0.707107 -0.707106 1 -0.83147 -0.55557 1 -0.83147 -0.55557 -1 -0.83147 -0.55557 -1 -0.83147 -0.55557 1 -0.92388 -0.382683 1 -0.92388 -0.382683 -1 -0.92388 -0.382683 -1 -0.92388 -0.382683 1 -0.980785 -0.195089 1 -0.980785 -0.195089 -1 -0.980785 -0.195089 -1 -0.980785 -0.195089 1 -1 9.65599e-07 1 -1 9.65599e-07 -1 -1 9.65599e-07 -1 -1 9.65599e-07 1 -0.980785 0.195091 1 -0.980785 0.195091 -1 -0.980785 0.195091 -1 -0.980785 0.195091 1 -0.923879 0.382684 1 -0.923879 0.382684 -1 -0.923879 0.382684 -1 -0.923879 0.382684 1 -0.831469 0.555571 1 -0.831469 0.555571 -1 -0.831469 0.555571 -1 -0.831469 0.555571 1 -0.707106 0.707108 1 -0.707106 0.707108 -1 -0.707106 0.707108 -1 -0.707106 0.707108 1 -0.555569 0.83147 1 -0.555569 0.83147 -1 -0.555569 0.83147 -1 -0.555569 0.83147 1 -0.382682 0.92388 1 -0.382682 0.92388 -1 0.19509 0.980785 1 0 1 1 -0.195089 0.980786 1 0.19509 0.980785 1 -0.195089 0.980786 1 -0.382682 0.92388 1 0.19509 0.980785 1 -0.382682 0.92388 1 0.382683 0.92388 1 -0.382682 0.92388 1 -0.555569 0.83147 1 0.382683 0.92388 1 -0.555569 0.83147 1 0.55557 0.83147 1 0.382683 0.92388 1 -0.555569 0.83147 1 -0.707106 0.707108 1 0.55557 0.83147 1 -0.707106 0.707108 1 0.707107 0.707107 1 0.55557 0.83147 1 -0.707106 0.707108 1 -0.831469 0.555571 1 0.707107 0.707107 1 -0.831469 0.555571 1 0.83147 0.55557 1 0.707107 0.707107 1 -0.831469 0.555571 1 -0.923879 0.382684 1 0.83147 0.55557 1 -0.923879 0.382684 1 0.92388 0.382683 1 0.83147 0.55557 1 -0.923879 0.382684 1 -0.980785 0.195091 1 0.92388 0.382683 1 -0.980785 0.195091 1 0.980785 0.19509 1 0.92388 0.382683 1 -0.980785 0.195091 1 -1 9.65599e-07 1 0.980785 0.19509 1 -1 9.65599e-07 1 1 0 1 0.980785 0.19509 1 -1 9.65599e-07 1 -0.980785 -0.195089 1 1 0 1 -0.980785 -0.195089 1 0.980785 -0.19509 1 1 0 1 -0.980785 -0.195089 1 -0.92388 -0.382683 1 0.980785 -0.19509 1 -0.92388 -0.382683 1 0.92388 -0.382683 1 0.980785 -0.19509 1 -0.92388 -0.382683 1 -0.83147 -0.55557 1 0.92388 -0.382683 1 -0.83147 -0.55557 1 0.83147 -0.55557 1 0.92388 -0.382683 1 -0.83147 -0.55557 1 -0.707107 -0.707106 1 0.83147 -0.55557 1 -0.707107 -0.707106 1 0.707107 -0.707107 1 0.83147 -0.55557 1 -0.707107 -0.707106 1 -0.555571 -0.831469 1 0.707107 -0.707107 1 -0.555571 -0.831469 1 0.55557 -0.83147 1 0.707107 -0.707107 1 -0.555571 -0.831469 1 -0.382684 -0.923879 1 0.55557 -0.83147 1 -0.382684 -0.923879 1 0.382683 -0.92388 1 0.55557 -0.83147 1 -0.382684 -0.923879 1 -0.195091 -0.980785 1 0.382683 -0.92388 1 -0.195091 -0.980785 1 0.19509 -0.980785 1 0.382683 -0.92388 1 -0.195091 -0.980785 1 -3.25841e-07 -1 1 0.19509 -0.980785 1 0 1 1 0 1 -1 -0.195089 0.980786 -1 -0.195089 0.980786 1 -0.382682 0.92388 -1 -0.382682 0.92388 1 -0.195089 0.980786 1 -0.195089 0.980786 -1 0 1 -1 0.19509 0.980785 -1 -0.195089 0.980786 -1 0.19509 0.980785 -1 -0.382682 0.92388 -1 -0.195089 0.980786 -1 0.19509 0.980785 -1 0.382683 0.92388 -1 -0.382682 0.92388 -1 0.382683 0.92388 -1 -0.555569 0.83147 -1 -0.382682 0.92388 -1 0.382683 0.92388 -1 0.55557 0.83147 -1 -0.555569 0.83147 -1 0.55557 0.83147 -1 -0.707106 0.707108 -1 -0.555569 0.83147 -1 0.55557 0.83147 -1 0.707107 0.707107 -1 -0.707106 0.707108 -1 0.707107 0.707107 -1 -0.831469 0.555571 -1 -0.707106 0.707108 -1 0.707107 0.707107 -1 0.83147 0.55557 -1 -0.831469 0.555571 -1 0.83147 0.55557 -1 -0.923879 0.382684 -1 -0.831469 0.555571 -1 0.83147 0.55557 -1 0.92388 0.382683 -1 -0.923879 0.382684 -1 0.92388 0.382683 -1 -0.980785 0.195091 -1 -0.923879 0.382684 -1 0.92388 0.382683 -1 0.980785 0.19509 -1 -0.980785 0.195091 -1 0.980785 0.19509 -1 -1 9.65599e-07 -1 -0.980785 0.195091 -1 0.980785 0.19509 -1 1 0 -1 -1 9.65599e-07 -1 1 0 -1 -0.980785 -0.195089 -1 -1 9.65599e-07 -1 1 0 -1 0.980785 -0.19509 -1 -0.980785 -0.195089 -1 0.980785 -0.19509 -1 -0.92388 -0.382683 -1 -0.980785 -0.195089 -1 0.980785 -0.19509 -1 0.92388 -0.382683 -1 -0.92388 -0.382683 -1 0.92388 -0.382683 -1 -0.83147 -0.55557 -1 -0.92388 -0.382683 -1 0.92388 -0.382683 -1 0.83147 -0.55557 -1 -0.83147 -0.55557 -1 0.83147 -0.55557 -1 -0.707107 -0.707106 -1 -0.83147 -0.55557 -1 0.83147 -0.55557 -1 0.707107 -0.707107 -1 -0.707107 -0.707106 -1 0.707107 -0.707107 -1 -0.555571 -0.831469 -1 -0.707107 -0.707106 -1 0.707107 -0.707107 -1 0.55557 -0.83147 -1 -0.555571 -0.831469 -1 0.55557 -0.83147 -1 -0.382684 -0.923879 -1 -0.555571 -0.831469 -1 0.55557 -0.83147 -1 0.382683 -0.92388 -1 -0.382684 -0.923879 -1 0.382683 -0.92388 -1 -0.195091 -0.980785 -1 -0.382684 -0.923879 -1 0.382683 -0.92388 -1 0.19509 -0.980785 -1 -0.195091 -0.980785 -1 0.19509 -0.980785 -1 -3.25841e-07 -1 -1 -0.195091 -0.980785 -1 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 0.098017 0.995185 0 0.098017 0.995185 0 0.098017 0.995185 0 0.098017 0.995185 0 0.290285 0.95694 0 0.290285 0.95694 0 0.290285 0.95694 0 0.290285 0.95694 0 0.471397 0.881921 0 0.471397 0.881921 0 0.471397 0.881921 0 0.471397 0.881921 0 0.634393 0.77301 0 0.634393 0.77301 0 0.634393 0.77301 0 0.634393 0.77301 0 0.773011 0.634393 0 0.773011 0.634393 0 0.773011 0.634393 0 0.773011 0.634393 0 0.881921 0.471397 0 0.881921 0.471397 0 0.881921 0.471397 0 0.881921 0.471397 0 0.95694 0.290285 0 0.95694 0.290285 0 0.95694 0.290285 0 0.95694 0.290285 0 0.995185 0.098017 0 0.995185 0.098017 0 0.995185 0.098017 0 0.995185 0.098017 0 0.995185 -0.098017 0 0.995185 -0.098017 0 0.995185 -0.098017 0 0.995185 -0.098017 0 0.95694 -0.290285 0 0.95694 -0.290285 0 0.95694 -0.290285 0 0.95694 -0.290285 0 0.881921 -0.471397 0 0.881921 -0.471397 0 0.881921 -0.471397 0 0.881921 -0.471397 0 0.77301 -0.634393 0 0.77301 -0.634393 0 0.77301 -0.634393 0 0.77301 -0.634393 0 0.634393 -0.77301 0 0.634393 -0.77301 0 0.634393 -0.77301 0 0.634393 -0.77301 0 0.471397 -0.881921 0 0.471397 -0.881921 0 0.471397 -0.881921 0 0.471397 -0.881921 0 0.290285 -0.95694 0 0.290285 -0.95694 0 0.290285 -0.95694 0 0.290285 -0.95694 0 0.0980166 -0.995185 0 0.0980166 -0.995185 0 0.0980166 -0.995185 0 0.0980166 -0.995185 0 -0.0980175 -0.995185 0 -0.0980175 -0.995185 0 -0.0980175 -0.995185 0 -0.0980175 -0.995185 0 -0.290285 -0.95694 0 -0.290285 -0.95694 0 -0.290285 -0.95694 0 -0.290285 -0.95694 0 -0.471397 -0.881921 0 -0.471397 -0.881921 0 -0.471397 -0.881921 0 -0.471397 -0.881921 0 -0.634394 -0.77301 0 -0.634394 -0.77301 0 -0.634394 -0.77301 0 -0.634394 -0.77301 0 -0.773011 -0.634393 0 -0.773011 -0.634393 0 -0.773011 -0.634393 0 -0.773011 -0.634393 0 -0.881922 -0.471396 0 -0.881922 -0.471396 0 -0.881922 -0.471396 0 -0.881922 -0.471396 0 -0.95694 -0.290284 0 -0.95694 -0.290284 0 -0.95694 -0.290284 0 -0.95694 -0.290284 0 -0.995185 -0.098016 0 -0.995185 -0.098016 0 -0.995185 -0.098016 0 -0.995185 -0.098016 0 -0.995185 0.0980181 0 -0.995185 0.0980181 0 -0.995185 0.0980181 0 -0.995185 0.0980181 0 -0.95694 0.290286 0 -0.95694 0.290286 0 -0.95694 0.290286 0 -0.95694 0.290286 0 -0.881921 0.471398 0 -0.881921 0.471398 0 -0.881921 0.471398 0 -0.881921 0.471398 0 -0.77301 0.634394 0 -0.77301 0.634394 0 -0.77301 0.634394 0 -0.77301 0.634394 0 -0.634392 0.773011 0 -0.634392 0.773011 0 -0.634392 0.773011 0 -0.634392 0.773011 0 -0.471396 0.881922 0 -0.471396 0.881922 0 -0.471396 0.881922 0 -0.471396 0.881922 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 -0.0980162 0.995185 0 -0.0980162 0.995185 0 -0.0980162 0.995185 0 -0.0980162 0.995185 0 -0.290283 0.956941 0 -0.290283 0.956941 0 -0.290283 0.956941 0 -0.290283 0.956941 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 |

0 1 2 0 2 3 4 5 6 4 6 7 8 9 10 8 10 11 12 13 14 12 14 15 16 17 18 16 18 19 20 21 22 20 22 23 24 25 26 24 26 27 28 29 30 28 30 31 32 33 34 32 34 35 36 37 38 36 38 39 40 41 42 40 42 43 44 45 46 44 46 47 48 49 50 48 50 51 52 53 54 52 54 55 56 57 58 56 58 59 60 61 62 60 62 63 64 65 66 64 66 67 68 69 70 68 70 71 72 73 74 72 74 75 76 77 78 76 78 79 80 81 82 80 82 83 84 85 86 84 86 87 88 89 90 88 90 91 92 93 94 92 94 95 96 97 98 96 98 99 100 101 102 100 102 103 104 105 106 104 106 107 108 109 110 108 110 111 112 113 114 112 114 115 116 117 118 116 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 210 212 213 214 215 216 214 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307

270 |
271 |
272 |
273 |
274 | 275 | 276 | 277 | 1 0 0 0.0423443 0 1 0 0.0327435 0 0 1 2.19479 0 0 0 1 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 0 288 | 289 | 290 | 291 | 292 | -0.293191 0 0 0.0188467 0 -0.293191 0 0.0327435 0 0 -0.293191 0.361961 0 0 0 1 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 0 303 | 304 | 305 | 306 | 307 | 1 0 0 0.0188466 0 1 0 0.0327435 0 0 1 1.60734 0 0 0 1 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | -0.290864 -0.771101 0.566393 4.07624 0.955171 -0.199883 0.218391 1.00545 -0.0551891 0.604525 0.794672 5.90386 0 0 0 1 318 | 319 | 320 | 321 | 0 322 | 323 | 324 | 325 | 326 | 0.685881 -0.31737 0.654862 7.48113 0.727634 0.312469 -0.610666 -6.50764 -0.0108168 0.895343 0.445245 5.34367 0 0 0 1 327 | 328 | 329 | 330 | 0 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 |
340 | -------------------------------------------------------------------------------- /OpenWorldTest/Images/crosshair.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steventroughtonsmith/OpenWorldTest/a07ae437f0465e4278e50911891a5cac71b761f0/OpenWorldTest/Images/crosshair.png -------------------------------------------------------------------------------- /OpenWorldTest/Images/dirt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steventroughtonsmith/OpenWorldTest/a07ae437f0465e4278e50911891a5cac71b761f0/OpenWorldTest/Images/dirt.png -------------------------------------------------------------------------------- /OpenWorldTest/Images/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steventroughtonsmith/OpenWorldTest/a07ae437f0465e4278e50911891a5cac71b761f0/OpenWorldTest/Images/grass.png -------------------------------------------------------------------------------- /OpenWorldTest/Images/water.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steventroughtonsmith/OpenWorldTest/a07ae437f0465e4278e50911891a5cac71b761f0/OpenWorldTest/Images/water.png -------------------------------------------------------------------------------- /OpenWorldTest/OWTAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKRAppDelegate.h 3 | // OpenWorldTest 4 | // 5 | // Created by Steven Troughton-Smith on 23/12/2012. 6 | // Copyright (c) 2012 High Caffeine Content. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | 14 | @interface OWTAppDelegate : NSObject 15 | { 16 | IBOutlet SCNView *_view; 17 | GLuint _colorTexture, _depthTexture; 18 | GLuint _fbo; //offscreen framebuffer 19 | GLuint _program; 20 | GLint _cafbo; 21 | 22 | } 23 | @property (assign) IBOutlet NSWindow *window; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /OpenWorldTest/OWTAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKRAppDelegate.m 3 | // OpenWorldTest 4 | // 5 | // Created by Steven Troughton-Smith on 23/12/2012. 6 | // Copyright (c) 2012 High Caffeine Content. All rights reserved. 7 | // 8 | 9 | /* 10 | 11 | The following GL code was written by Thomas Goossens, one of the 12 | engineers behind SceneKit @ Apple. Thanks Thomas! 13 | 14 | */ 15 | 16 | #import "OWTAppDelegate.h" 17 | 18 | @implementation OWTAppDelegate 19 | 20 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 21 | { 22 | // Insert code here to initialize your application 23 | } 24 | 25 | -(void)awakeFromNib 26 | { 27 | [self performSelector:@selector(beginFog) withObject:nil afterDelay:1.0]; // lazy, making sure the shader inits with right size 28 | } 29 | 30 | -(void)beginFog 31 | { 32 | _view.delegate = self; 33 | 34 | //setup offscreen buffer 35 | NSSize viewportSize = [_view convertRectToBase:[_view bounds]].size; //HiDPI 36 | 37 | viewportSize.width *= _view.layer.contentsScale; 38 | viewportSize.height *= _view.layer.contentsScale; 39 | 40 | 41 | [self setupOffscreenFramebuffer:viewportSize]; 42 | } 43 | - (void) setupOffscreenFramebuffer:(NSSize) size 44 | { 45 | //release previous renderer if any 46 | if(_fbo!=0){ 47 | glDeleteTextures(1, &_colorTexture); 48 | glDeleteTextures(1, &_depthTexture); 49 | glDeleteFramebuffersEXT(1, &_fbo); 50 | } 51 | 52 | //start GL stuffs 53 | if([_view openGLContext]==nil) return; 54 | 55 | [[_view openGLContext] makeCurrentContext]; 56 | 57 | //create a fbo 58 | glGenFramebuffersEXT (1, &_fbo); 59 | 60 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbo); 61 | 62 | //create a texture to render into 63 | glGenTextures(1, &_colorTexture); 64 | glGenTextures(1, &_depthTexture); 65 | 66 | //setup and attach color 67 | glBindTexture(GL_TEXTURE_2D, _colorTexture); 68 | 69 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 70 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 71 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, size.width, size.height, 0, 72 | GL_RGBA, GL_UNSIGNED_BYTE, NULL); 73 | 74 | glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, 75 | GL_TEXTURE_2D, _colorTexture, 0); 76 | 77 | //setup and attach depth 78 | glBindTexture(GL_TEXTURE_2D, _depthTexture); 79 | 80 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 81 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 82 | glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, size.width, size.height, 0, 83 | GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL); 84 | 85 | glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, 86 | GL_TEXTURE_2D, _depthTexture, 0); 87 | 88 | 89 | GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); 90 | if (status != GL_FRAMEBUFFER_COMPLETE_EXT) 91 | NSLog(@"failed to create the FBO : %d", status); 92 | 93 | //unbind for now 94 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 95 | } 96 | 97 | - (void) loadFogShader 98 | { 99 | 100 | //load shader if needed 101 | GLuint prgName; 102 | 103 | GLint logLength, status; 104 | 105 | // Create a program object 106 | prgName = glCreateProgram(); 107 | 108 | // Indicate the attribute indicies on which vertex arrays will be 109 | // set with glVertexAttribPointer 110 | // See buildVAO to see where vertex arrays are actually set 111 | glBindAttribLocation(prgName, 0, "a_position"); 112 | 113 | ////////////////////////////////////// 114 | // Specify and compile VertexShader // 115 | ////////////////////////////////////// 116 | 117 | NSString *vertexPath = [[NSBundle mainBundle] pathForResource:@"shader" ofType:@"vert"]; 118 | NSString *fragmentPath = [[NSBundle mainBundle] pathForResource:@"shader" ofType:@"frag"]; 119 | 120 | // Allocate memory for the source string including the version preprocessor information 121 | NSString *vertexString = [NSString stringWithContentsOfFile:vertexPath encoding:NSUTF8StringEncoding error:nil]; 122 | NSString *fragmentString = [NSString stringWithContentsOfFile:fragmentPath encoding:NSUTF8StringEncoding error:nil]; 123 | 124 | const char *vertex = [vertexString cStringUsingEncoding:NSUTF8StringEncoding]; 125 | const char *fragment = [fragmentString cStringUsingEncoding:NSUTF8StringEncoding]; 126 | 127 | GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); 128 | glShaderSource(vertexShader, 1, (const GLchar **)&(vertex), NULL); 129 | glCompileShader(vertexShader); 130 | glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &logLength); 131 | 132 | if (logLength > 0) 133 | { 134 | GLchar *log = (GLchar*) malloc(logLength); 135 | glGetShaderInfoLog(vertexShader, logLength, &logLength, log); 136 | NSLog(@"Vtx Shader compile log:%s\n", log); 137 | free(log); 138 | } 139 | 140 | glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &status); 141 | if (status == 0) 142 | { 143 | NSLog(@"Failed to compile vtx shader:\n%s\n", vertex); 144 | exit(0); 145 | } 146 | 147 | // Attach the vertex shader to our program 148 | glAttachShader(prgName, vertexShader); 149 | 150 | 151 | // Specify and compile Fragment Shader // 152 | 153 | GLuint fragShader = glCreateShader(GL_FRAGMENT_SHADER); 154 | glShaderSource(fragShader, 1, (const GLchar **)&(fragment), NULL); 155 | glCompileShader(fragShader); 156 | glGetShaderiv(fragShader, GL_INFO_LOG_LENGTH, &logLength); 157 | if (logLength > 0) 158 | { 159 | GLchar *log = (GLchar*)malloc(logLength); 160 | glGetShaderInfoLog(fragShader, logLength, &logLength, log); 161 | NSLog(@"Frag Shader compile log:\n%s\n", log); 162 | free(log); 163 | } 164 | 165 | glGetShaderiv(fragShader, GL_COMPILE_STATUS, &status); 166 | if (status == 0) 167 | { 168 | NSLog(@"Failed to compile frag shader:\n%s\n", fragment); 169 | exit(0); 170 | } 171 | 172 | // Attach the fragment shader to our program 173 | glAttachShader(prgName, fragShader); 174 | 175 | 176 | // Link the program // 177 | glLinkProgram(prgName); 178 | glGetProgramiv(prgName, GL_INFO_LOG_LENGTH, &logLength); 179 | if (logLength > 0) 180 | { 181 | GLchar *log = (GLchar*)malloc(logLength); 182 | glGetProgramInfoLog(prgName, logLength, &logLength, log); 183 | NSLog(@"Program link log:\n%s\n", log); 184 | free(log); 185 | } 186 | 187 | glGetProgramiv(prgName, GL_LINK_STATUS, &status); 188 | if (status == 0) 189 | { 190 | NSLog(@"Failed to link program"); 191 | exit(0); 192 | } 193 | 194 | glValidateProgram(prgName); 195 | glGetProgramiv(prgName, GL_INFO_LOG_LENGTH, &logLength); 196 | if (logLength > 0) 197 | { 198 | GLchar *log = (GLchar*)malloc(logLength); 199 | glGetProgramInfoLog(prgName, logLength, &logLength, log); 200 | NSLog(@"Program validate log:\n%s\n", log); 201 | free(log); 202 | } 203 | 204 | glGetProgramiv(prgName, GL_VALIDATE_STATUS, &status); 205 | if (status == 0) 206 | { 207 | NSLog(@"Failed to validate program"); 208 | exit(0); 209 | } 210 | 211 | 212 | _program = prgName; 213 | } 214 | 215 | - (void) bindFogShader 216 | { 217 | if(_program == 0){ 218 | [self loadFogShader]; 219 | } 220 | 221 | //bind 222 | glUseProgram(_program); 223 | 224 | //set texture inputs 225 | GLint samplerLoc = glGetUniformLocation(_program, "colorTexture"); 226 | 227 | // Indicate that the diffuse texture will be bound to texture unit 0 228 | GLint unit = 0; 229 | glUniform1i(samplerLoc, unit); 230 | 231 | samplerLoc = glGetUniformLocation(_program, "depthTexture"); 232 | 233 | // Indicate that the depth texture will be bound to texture unit 1 234 | unit = 1; 235 | glUniform1i(samplerLoc, unit); 236 | 237 | 238 | glActiveTexture(GL_TEXTURE0); 239 | glBindTexture(GL_TEXTURE_2D, _colorTexture); 240 | glActiveTexture(GL_TEXTURE1); 241 | glBindTexture(GL_TEXTURE_2D, _depthTexture); 242 | } 243 | 244 | - (void) drawFullscreenQuad 245 | { 246 | const float vertices[] = {-1,-1, 247 | 1,-1, 248 | 1,1, 249 | -1,1 250 | }; 251 | const GLubyte indices[] = {0,1,2,0,2,3}; 252 | 253 | glEnableClientState(GL_VERTEX_ARRAY); 254 | glVertexPointer(2, GL_FLOAT, sizeof(float)*2, &vertices[0]); 255 | 256 | glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices); 257 | } 258 | 259 | // SCNView delegate 260 | - (void)renderer:(id )aRenderer willRenderScene:(SCNScene *)scene atTime:(NSTimeInterval)time 261 | { 262 | //setup offscreen buffer 263 | if(_fbo==0){ 264 | NSSize viewportSize = [_view convertRectToBase:[_view bounds]].size; //HiDPI 265 | [self setupOffscreenFramebuffer:viewportSize]; 266 | } 267 | 268 | //save fbo 269 | glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &_cafbo); 270 | 271 | //bind our fbo so that scenekit renders into it 272 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbo); 273 | 274 | //clear 275 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 276 | } 277 | 278 | - (void)renderer:(id )aRenderer didRenderScene:(SCNScene *)scene atTime:(NSTimeInterval)time 279 | { 280 | //draw the texture inside the view 281 | [self bindFogShader]; 282 | 283 | //unbind FBO 284 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _cafbo); 285 | 286 | [self drawFullscreenQuad]; 287 | 288 | 289 | //cleanup 290 | glBindTexture(GL_TEXTURE_2D, 0); 291 | glActiveTexture(GL_TEXTURE0); 292 | glBindTexture(GL_TEXTURE_2D, 0); 293 | 294 | [(id )_view renderer:aRenderer didRenderScene:scene atTime:time]; 295 | } 296 | @end 297 | -------------------------------------------------------------------------------- /OpenWorldTest/OWTChunk.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKRChunk.h 3 | // OpenWorldTest 4 | // 5 | // Created by Steven Troughton-Smith on 12/01/2013. 6 | // Copyright (c) 2013 High Caffeine Content. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OWTChunk : SCNNode 12 | @property CGFloat chunkX; 13 | @property CGFloat chunkY; 14 | @end 15 | -------------------------------------------------------------------------------- /OpenWorldTest/OWTChunk.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKRChunk.m 3 | // OpenWorldTest 4 | // 5 | // Created by Steven Troughton-Smith on 12/01/2013. 6 | // Copyright (c) 2013 High Caffeine Content. All rights reserved. 7 | // 8 | 9 | #import "OWTChunk.h" 10 | 11 | @implementation OWTChunk 12 | 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /OpenWorldTest/OWTEntity.h: -------------------------------------------------------------------------------- 1 | // 2 | // ParticleNode.h 3 | // SceneKraft 4 | // 5 | // Created by Tom Irving on 10/09/2012. 6 | // Copyright (c) 2012 Tom Irving. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OWTEntity : SCNNode { 12 | 13 | SCNVector3 velocity; 14 | SCNVector3 acceleration; 15 | CGFloat mass; 16 | 17 | BOOL touchingGround; 18 | } 19 | 20 | @property (nonatomic, assign) SCNVector3 velocity; 21 | @property (nonatomic, assign) SCNVector3 acceleration; 22 | @property (nonatomic, assign) CGFloat mass; 23 | @property (nonatomic, readonly) BOOL touchingGround; 24 | 25 | - (void)updatePositionWithRefreshPeriod:(CGFloat)refreshPeriod; 26 | - (void)checkCollisionWithNodes:(NSArray *)nodes; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /OpenWorldTest/OWTEntity.m: -------------------------------------------------------------------------------- 1 | // 2 | // ParticleNode.m 3 | // SceneKraft 4 | // 5 | // Created by Tom Irving on 10/09/2012. 6 | // Copyright (c) 2012 Tom Irving. All rights reserved. 7 | // 8 | 9 | #import "OWTEntity.h" 10 | 11 | @implementation OWTEntity 12 | @synthesize velocity; 13 | @synthesize acceleration; 14 | @synthesize mass; 15 | @synthesize touchingGround; 16 | 17 | 18 | - (void)updatePositionWithRefreshPeriod:(CGFloat)refreshPeriod { 19 | 20 | velocity.x += acceleration.x * refreshPeriod; 21 | velocity.y += acceleration.y * refreshPeriod; 22 | velocity.z += acceleration.z * refreshPeriod; 23 | 24 | SCNVector3 position = self.position; 25 | position.x += velocity.x * refreshPeriod; 26 | position.y += velocity.y * refreshPeriod; 27 | position.z += velocity.z * refreshPeriod; 28 | [self setPosition:position]; 29 | } 30 | 31 | - (void)checkCollisionWithNodes:(NSArray *)nodes { 32 | // TODO: Make this better. 33 | 34 | touchingGround = NO; 35 | __block SCNVector3 selfPosition = self.position; 36 | 37 | [nodes enumerateObjectsUsingBlock:^(SCNNode * node, NSUInteger idx, BOOL *stop) { 38 | 39 | if (self != node) 40 | { 41 | if (NodeCollision(node,selfPosition)) 42 | { 43 | selfPosition.z = node.position.z+1.5; 44 | velocity.z = 0; 45 | node.opacity = 0.5; 46 | 47 | touchingGround = YES; 48 | *stop = YES; 49 | } 50 | } 51 | }]; 52 | 53 | [self setPosition:selfPosition]; 54 | } 55 | 56 | BOOL NodeCollision(SCNNode *node, SCNVector3 point) 57 | { 58 | SCNVector3 min, max; 59 | 60 | [node getBoundingBoxMin:&min max:&max]; 61 | 62 | min.x += node.position.x; 63 | min.y += node.position.y; 64 | min.z += node.position.z; 65 | 66 | max.x += node.position.x; 67 | max.y += node.position.y; 68 | max.z += node.position.z; 69 | 70 | return point.x <= max.x && point.x >= min.x && 71 | point.y <= max.y && point.y >= min.y && 72 | point.z <= max.z && point.z >= min.z ; 73 | } 74 | 75 | 76 | NSString *NSStringFromSCNVector3(SCNVector3 vec) 77 | { 78 | return [NSString stringWithFormat:@"(%f, %f, %f)", vec.x, vec.y, vec.z]; 79 | } 80 | 81 | @end -------------------------------------------------------------------------------- /OpenWorldTest/OWTGameView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKRGameView.h 3 | // OpenWorldTest 4 | // 5 | // Created by Steven Troughton-Smith on 23/12/2012. 6 | // Copyright (c) 2012 High Caffeine Content. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | #import "OWTLevelGenerator.h" 14 | #import "OWTChunk.h" 15 | #import "OWTPlayer.h" 16 | 17 | typedef struct _SKRInput 18 | { 19 | BOOL up; 20 | BOOL down; 21 | 22 | BOOL forward; 23 | BOOL backward; 24 | BOOL left; 25 | BOOL right; 26 | 27 | SCNVector3 look; 28 | 29 | } SKRInput; 30 | 31 | typedef struct _SKRPlayer 32 | { 33 | BOOL moving; 34 | 35 | } SKRPlayer; 36 | 37 | 38 | typedef enum _SKRBlockType 39 | { 40 | SKRBlockTypeWater, 41 | SKRBlockTypeDirt, 42 | SKRBlockTypeGrass, 43 | SKRBlockTypeTree 44 | } SKRBlockType; 45 | 46 | 47 | @interface OWTGameView : SCNView 48 | { 49 | 50 | NSMutableDictionary *chunkCache; 51 | CATextLayer *frameRateLabel; 52 | 53 | SKRInput input; 54 | SKRPlayer player; 55 | 56 | OWTPlayer *playerNode; 57 | NSMutableArray *blocks; 58 | NSArray *joysticks; 59 | OWTLevelGenerator *gen; 60 | NSTrackingArea * trackingArea; 61 | CVDisplayLinkRef displayLinkRef; 62 | 63 | BOOL gameLoopRunning; 64 | SCNNode *skyNode; 65 | SCNNode *floorNode; 66 | SCNNode *lastNode; 67 | 68 | CALayer *crosshairLayer; 69 | } 70 | 71 | -(IBAction)reload:(id)sender; 72 | - (CVReturn)gameLoopAtTime:(CVTimeStamp)time; 73 | @end 74 | -------------------------------------------------------------------------------- /OpenWorldTest/OWTGameView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKRGameView.m 3 | // OpenWorldTest 4 | // 5 | // Created by Steven Troughton-Smith on 23/12/2012. 6 | // Copyright (c) 2012 High Caffeine Content. All rights reserved. 7 | // 8 | 9 | /* 10 | 11 | Check OpenWorldTest-Prefix.pch for constants 12 | 13 | */ 14 | 15 | #import "OWTGameView.h" 16 | #import "DDHidLib.h" 17 | 18 | // Standard units. 19 | CGFloat const kGravityAcceleration = 0;//-9.80665; 20 | CGFloat const kJumpHeight = 1.5; 21 | CGFloat const kPlayerMovementSpeed = 1.4; 22 | 23 | SCNGeometry *dirtGeometry; 24 | SCNGeometry *grassGeometry; 25 | SCNGeometry *waterGeometry; 26 | SCNGeometry *treeGeometry; 27 | 28 | @implementation OWTGameView 29 | 30 | - (id)initWithCoder:(NSCoder *)decoder; 31 | { 32 | if (!(self = [super initWithCoder:decoder])) 33 | return nil; 34 | 35 | /* 36 | Turning off Antialiasing here for perf 37 | */ 38 | 39 | NSOpenGLPixelFormatAttribute attrs[] = { 40 | NSOpenGLPFADepthSize, 24, 41 | NSOpenGLPFAAccelerated, 42 | NSOpenGLPFACompliant, 43 | NSOpenGLPFAMPSafe, 44 | 0 45 | }; 46 | self.pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; 47 | 48 | return self; 49 | } 50 | 51 | -(void)initCrosshairs 52 | { 53 | crosshairLayer = [CALayer layer]; 54 | crosshairLayer.contents = (id)[NSImage imageNamed:@"crosshair.png"]; 55 | crosshairLayer.bounds = CGRectMake(0, 0, 40., 40.); 56 | crosshairLayer.position = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); 57 | 58 | [self.layer addSublayer:crosshairLayer]; 59 | } 60 | 61 | 62 | -(void)initFPSLabel 63 | { 64 | 65 | frameRateLabel = [CATextLayer layer]; 66 | frameRateLabel.anchorPoint = CGPointZero; 67 | frameRateLabel.position = CGPointZero; 68 | frameRateLabel.bounds = CGRectMake(0, 0, 100, 23); 69 | frameRateLabel.foregroundColor = [[NSColor whiteColor] CGColor]; 70 | frameRateLabel.font = (__bridge CFTypeRef)([NSFont boldSystemFontOfSize:6]) ; 71 | frameRateLabel.fontSize = 16; 72 | 73 | [self.layer addSublayer:frameRateLabel]; 74 | } 75 | 76 | -(void)resetMouse 77 | { 78 | [self removeTrackingArea:trackingArea]; 79 | trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds 80 | options:(NSTrackingActiveInKeyWindow | NSTrackingMouseMoved) owner:self userInfo:nil]; 81 | [self addTrackingArea:trackingArea]; 82 | 83 | } 84 | 85 | #pragma mark - DisplayLink 86 | 87 | static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *inNow, const CVTimeStamp *inOutputTime, 88 | CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *displayLinkContext){ 89 | return [(__bridge OWTGameView *)displayLinkContext gameLoopAtTime:*inOutputTime]; 90 | } 91 | 92 | -(void)setupLink 93 | { 94 | if (CVDisplayLinkCreateWithActiveCGDisplays(&displayLinkRef) == kCVReturnSuccess){ 95 | CVDisplayLinkSetOutputCallback(displayLinkRef, DisplayLinkCallback, (__bridge void *)(self)); 96 | [self setRunning:YES]; 97 | } 98 | } 99 | 100 | -(void)setRunning:(BOOL)running 101 | { 102 | if (gameLoopRunning != running){ 103 | gameLoopRunning = running; 104 | 105 | CGAssociateMouseAndMouseCursorPosition(gameLoopRunning ? FALSE : TRUE); 106 | 107 | if (gameLoopRunning){ 108 | [NSCursor hide]; 109 | CVDisplayLinkStart(displayLinkRef); 110 | } 111 | else 112 | { 113 | CVDisplayLinkStop(displayLinkRef); 114 | [NSCursor unhide]; 115 | } 116 | } 117 | } 118 | 119 | BOOL previousActive = NO; 120 | 121 | CVTimeStamp oldTime; 122 | 123 | CVTimeStamp lastChunkTick; 124 | 125 | - (CVReturn)gameLoopAtTime:(CVTimeStamp)time { 126 | 127 | if (time.hostTime-oldTime.hostTime < (NSEC_PER_MSEC)) 128 | return kCVReturnSuccess; 129 | 130 | if ([NSApplication sharedApplication].isActive && !previousActive) 131 | { 132 | CGWarpMouseCursorPosition([self.window convertBaseToScreen:CGPointMake(0, 90)]); 133 | } 134 | 135 | previousActive = [NSApplication sharedApplication].isActive; 136 | 137 | dispatch_async(dispatch_get_main_queue(), ^{ 138 | 139 | CGFloat refreshPeriod = CVDisplayLinkGetActualOutputVideoRefreshPeriod(displayLinkRef); 140 | 141 | [playerNode setAcceleration:SCNVector3Make(0, 0, kGravityAcceleration)]; 142 | [playerNode updatePositionWithRefreshPeriod:refreshPeriod]; 143 | 144 | [playerNode checkCollisionWithNodes:blocks]; 145 | 146 | SCNVector3 playerNodePosition = playerNode.position; 147 | 148 | if (playerNodePosition.z < 0) playerNodePosition.z = 0; 149 | [playerNode setPosition:playerNodePosition]; 150 | 151 | [playerNode rotateByAmount:CGSizeMake(MCP_DEGREES_TO_RADIANS(-input.look.x / 10000), MCP_DEGREES_TO_RADIANS(-input.look.y / 10000))]; 152 | 153 | 154 | oldTime = time; 155 | 156 | if (time.hostTime-lastChunkTick.hostTime > (NSEC_PER_SEC*1)) 157 | { 158 | lastChunkTick = time; 159 | [self loadChunksAroundPlayerPosition]; 160 | } 161 | }); 162 | 163 | return kCVReturnSuccess; 164 | } 165 | 166 | #pragma mark - 167 | -(void)awakeFromNib 168 | { 169 | blocks = @[].mutableCopy; 170 | chunkCache = @{}.mutableCopy; 171 | 172 | [self premakeMaterials]; 173 | [self setWantsLayer:YES]; 174 | 175 | [self initFPSLabel]; 176 | [self initCrosshairs]; 177 | 178 | SCNScene *scene = [SCNScene scene]; 179 | self.scene = scene; 180 | 181 | playerNode = [OWTPlayer node]; 182 | playerNode.position = SCNVector3Make(MAP_BOUNDS/2, MAP_BOUNDS/2, 5); 183 | [playerNode rotateByAmount:CGSizeMake(0, 0)]; 184 | 185 | [scene.rootNode addChildNode:playerNode]; 186 | 187 | [self reload:self]; 188 | [self resetMouse]; 189 | 190 | [self becomeFirstResponder]; 191 | [self startWatchingJoysticks]; 192 | 193 | [self setupLink]; 194 | 195 | SCNLight *sunlight = [SCNLight light]; 196 | sunlight.type = SCNLightTypeDirectional; 197 | scene.rootNode.light = sunlight; 198 | } 199 | 200 | -(void)setFrame:(NSRect)frameRect 201 | { 202 | [self resetMouse]; 203 | 204 | [super setFrame:frameRect]; 205 | crosshairLayer.position = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); 206 | CGWarpMouseCursorPosition([self.window convertBaseToScreen:CGPointMake(0, 90)]); 207 | } 208 | 209 | BOOL canReload = YES; 210 | 211 | -(IBAction)reload:(id)sender 212 | { 213 | if (!canReload) 214 | return; 215 | 216 | [blocks removeAllObjects]; 217 | 218 | for (OWTChunk *chunk in self.scene.rootNode.childNodes) 219 | { 220 | if (![chunk isKindOfClass:[OWTChunk class]]) 221 | continue; 222 | [chunk performSelector:@selector(removeFromParentNode)]; 223 | } 224 | 225 | [chunkCache removeAllObjects]; 226 | 227 | gen = [[OWTLevelGenerator alloc] init]; 228 | 229 | [gen gen:12]; 230 | 231 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 232 | canReload = NO; 233 | [self loadChunksAroundPlayerPosition]; 234 | canReload = YES; 235 | }); 236 | 237 | } 238 | 239 | #pragma mark - Map Generation 240 | 241 | -(void)generateChunk:(CGPoint)chunkCoord 242 | { 243 | OWTChunk *chunk = [chunkCache objectForKey:NSStringFromPoint(chunkCoord)]; 244 | SCNScene *scene = self.scene; 245 | 246 | if (!chunk) 247 | { 248 | chunk = [[OWTChunk alloc] init]; 249 | chunk.chunkX = chunkCoord.x; 250 | chunk.chunkY = chunkCoord.y; 251 | chunk.name = [NSString stringWithFormat:@"chunk:%@", NSStringFromPoint(chunkCoord)]; 252 | 253 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 254 | 255 | CGPoint position = chunkCoord; 256 | 257 | position.x *= CHUNK_SIZE; 258 | position.y *= CHUNK_SIZE; 259 | 260 | for (int y = position.y; y < position.y+CHUNK_SIZE; y++) 261 | { 262 | for (int x = position.x; x < position.x+CHUNK_SIZE; x++) 263 | { 264 | int maxZ = [gen valueForX:x Y:y]/GAME_DEPTH; 265 | 266 | for (int z = 0; z <= maxZ; z++) 267 | { 268 | SKRBlockType blockType = SKRBlockTypeGrass; 269 | 270 | if (z == 0 && z == maxZ) 271 | blockType = SKRBlockTypeWater; 272 | 273 | else if (z < 2 && z == maxZ) 274 | blockType = SKRBlockTypeDirt; 275 | 276 | if (z > 3 && z == maxZ) 277 | blockType = SKRBlockTypeTree; 278 | 279 | if (z >= 0 && z == maxZ) 280 | [self addBlockAtLocation:SCNVector3Make(x, y, z) inNode:chunk withType:blockType]; 281 | } 282 | } 283 | } 284 | }); 285 | 286 | [chunkCache setObject:chunk forKey:NSStringFromPoint(chunkCoord)]; 287 | } 288 | 289 | if (!chunk.parentNode) 290 | { 291 | /* Animate the chunk into position */ 292 | 293 | SCNVector3 cp = chunk.position; 294 | chunk.opacity = 0; 295 | cp.z = -4; 296 | chunk.position = cp; 297 | cp.z = 0; 298 | [scene.rootNode addChildNode:chunk]; 299 | 300 | [SCNTransaction begin]; 301 | [SCNTransaction setAnimationDuration:0.5]; 302 | chunk.opacity = 1; 303 | chunk.position = cp; 304 | [SCNTransaction commit]; 305 | } 306 | } 307 | 308 | -(void)loadChunksAroundPlayerPosition 309 | { 310 | CGPoint playerChunk = CGPointMake(round(playerNode.position.x/CHUNK_SIZE), round(playerNode.position.y/CHUNK_SIZE)); 311 | 312 | if (playerChunk.x > 2) 313 | playerChunk.x -= 2; 314 | if (playerChunk.y > 2) 315 | playerChunk.y -= 2; 316 | 317 | for (int j = 0; j < 4; j++) 318 | { 319 | for (int i = 0; i < 4; i++) 320 | { 321 | CGPoint newChunk; 322 | newChunk.x = playerChunk.x+i; 323 | newChunk.y = playerChunk.y+j; 324 | 325 | [self generateChunk:newChunk]; 326 | } 327 | } 328 | 329 | /* Now unload chunks away from the player */ 330 | 331 | for (OWTChunk *chunk in self.scene.rootNode.childNodes) 332 | { 333 | if (![chunk isKindOfClass:[OWTChunk class]]) 334 | continue; 335 | 336 | double chunkDistance = sqrt(pow((playerChunk.x-chunk.chunkX),2)+pow((playerChunk.y-chunk.chunkY),2)); 337 | 338 | if (chunkDistance > 4) 339 | { 340 | [chunk performSelector:@selector(removeFromParentNode) withObject:nil afterDelay:0.0]; 341 | } 342 | } 343 | } 344 | 345 | 346 | -(SCNMaterial *)generateMaterialForBlockType:(SKRBlockType)type 347 | { 348 | SCNMaterial *material = [SCNMaterial material]; 349 | 350 | switch (type) { 351 | case SKRBlockTypeGrass: 352 | material.diffuse.contents = [NSImage imageNamed:@"grass.png"]; 353 | break; 354 | case SKRBlockTypeWater: 355 | { 356 | material.diffuse.contents = [NSImage imageNamed:@"water.png"]; 357 | material.transparency = 0.9; 358 | break; 359 | } 360 | case SKRBlockTypeDirt: 361 | material.diffuse.contents = [NSImage imageNamed:@"dirt.png"]; 362 | break; 363 | case SKRBlockTypeTree: 364 | { 365 | material.diffuse.contents = [NSColor colorWithCalibratedRed:0.001 green:0.352 blue:0.001 alpha:1.000]; 366 | break; 367 | } 368 | default: 369 | break; 370 | } 371 | 372 | material.diffuse.wrapS = SCNRepeat; 373 | material.diffuse.wrapT = SCNRepeat; 374 | material.diffuse.magnificationFilter = SCNNearestFiltering; 375 | material.doubleSided = NO; 376 | 377 | material.diffuse.contentsTransform = CATransform3DMakeScale(4, 4, 4); 378 | 379 | return material; 380 | } 381 | 382 | -(void)premakeMaterials 383 | { 384 | /* Blocks */ 385 | 386 | /* 387 | We share the same scene for the different blocks, but copy the geometry 388 | for each kind. Each geometry has its own texture it shares with blocks 389 | of same type. 390 | */ 391 | 392 | NSString *cubePath = [[NSBundle mainBundle] pathForResource:@"cube" ofType:@"dae"]; 393 | SCNScene *cubeScene = [SCNScene sceneWithURL:[NSURL fileURLWithPath:cubePath] options:nil error:nil]; 394 | 395 | SCNNode *cubeNode = [cubeScene.rootNode childNodeWithName:@"cube" recursively:NO]; 396 | 397 | dirtGeometry = cubeNode.geometry.copy; 398 | dirtGeometry.materials = @[[self generateMaterialForBlockType:SKRBlockTypeDirt]]; 399 | 400 | grassGeometry = cubeNode.geometry.copy; 401 | grassGeometry.materials = @[[self generateMaterialForBlockType:SKRBlockTypeGrass]]; 402 | 403 | waterGeometry = cubeNode.geometry.copy; 404 | waterGeometry.materials = @[[self generateMaterialForBlockType:SKRBlockTypeWater]]; 405 | 406 | /* Trees */ 407 | 408 | NSString *treePath = [[NSBundle mainBundle] pathForResource:@"tree" ofType:@"dae"]; 409 | SCNScene *treeScene = [SCNScene sceneWithURL:[NSURL fileURLWithPath:treePath] options:nil error:nil]; 410 | 411 | SCNNode *treeNode = [treeScene.rootNode childNodeWithName:@"tree" recursively:NO]; 412 | 413 | treeGeometry = treeNode.geometry; 414 | treeGeometry.materials = @[[self generateMaterialForBlockType:SKRBlockTypeTree]]; 415 | 416 | } 417 | 418 | -(void)addBlockAtLocation:(SCNVector3)location inNode:(SCNNode *)node withType:(SKRBlockType)type 419 | { 420 | SCNGeometry *geometry = nil; 421 | 422 | switch (type) { 423 | case SKRBlockTypeGrass: 424 | { 425 | geometry = grassGeometry; 426 | break; 427 | } 428 | case SKRBlockTypeWater: 429 | { 430 | geometry = waterGeometry; 431 | break; 432 | } 433 | case SKRBlockTypeDirt: 434 | { 435 | geometry = dirtGeometry; 436 | break; 437 | } 438 | case SKRBlockTypeTree: 439 | { 440 | geometry = treeGeometry; 441 | break; 442 | } 443 | 444 | default: 445 | break; 446 | } 447 | 448 | dispatch_async(dispatch_get_main_queue(), ^{ 449 | 450 | SCNNode *boxNode = [SCNNode nodeWithGeometry:geometry]; 451 | boxNode.position = SCNVector3Make(location.x, location.y, location.z); 452 | [node addChildNode:boxNode]; 453 | [blocks addObject:boxNode]; 454 | }); 455 | } 456 | 457 | #pragma mark - Input 458 | 459 | -(BOOL)canBecomKeyView 460 | { 461 | return YES; 462 | } 463 | 464 | - (void)mouseMoved:(NSEvent *)theEvent { 465 | 466 | [playerNode rotateByAmount:CGSizeMake(MCP_DEGREES_TO_RADIANS(-theEvent.deltaX / 10000), MCP_DEGREES_TO_RADIANS(-theEvent.deltaY / 10000))]; 467 | } 468 | 469 | -(void)keyDown:(NSEvent *)theEvent 470 | { 471 | CGFloat delta = 4; 472 | 473 | SCNVector4 movement = playerNode.movement; 474 | if (theEvent.keyCode == 126 || theEvent.keyCode == 13) movement.x = delta; 475 | if (theEvent.keyCode == 123 || theEvent.keyCode == 0) movement.y = delta; 476 | if (theEvent.keyCode == 125 || theEvent.keyCode == 1) movement.z = delta; 477 | if (theEvent.keyCode == 124 || theEvent.keyCode == 2) movement.w = delta; 478 | [playerNode setMovement:movement]; 479 | 480 | 481 | if (theEvent.keyCode == 49 && playerNode.touchingGround) 482 | { 483 | 484 | // v^2 = u^2 + 2as 485 | // 0 = u^2 + 2as (v = 0 at top of jump) 486 | // -u^2 = 2as; 487 | // u^2 = -2as; 488 | // u = sqrt(-2 * kGravityAcceleration * kJumpHeight) 489 | 490 | [self jump]; 491 | } 492 | } 493 | 494 | -(void)jump 495 | { 496 | SCNVector3 playerNodeVelocity = playerNode.velocity; 497 | playerNodeVelocity.z = sqrtf(-2 * kGravityAcceleration * kJumpHeight); 498 | [playerNode setVelocity:playerNodeVelocity]; 499 | } 500 | 501 | 502 | -(void)keyUp:(NSEvent *)theEvent 503 | { 504 | SCNVector4 movement = playerNode.movement; 505 | if (theEvent.keyCode == 126 || theEvent.keyCode == 13) movement.x = 0; 506 | if (theEvent.keyCode == 123 || theEvent.keyCode == 0) movement.y = 0; 507 | if (theEvent.keyCode == 125 || theEvent.keyCode == 1) movement.z = 0; 508 | if (theEvent.keyCode == 124 || theEvent.keyCode == 2) movement.w = 0; 509 | [playerNode setMovement:movement]; 510 | 511 | } 512 | 513 | #pragma mark - Joystick input 514 | 515 | /* 516 | 517 | Xbox Controller Mapping 518 | 519 | */ 520 | 521 | #define ABUTTON 0 522 | #define BBUTTON 1 523 | #define XBUTTON 2 524 | #define YBUTTON 3 525 | 526 | 527 | - (void)startWatchingJoysticks 528 | { 529 | joysticks = [DDHidJoystick allJoysticks] ; 530 | 531 | if ([joysticks count]) // assume only one joystick connected 532 | { 533 | [[joysticks lastObject] setDelegate:self]; 534 | [[joysticks lastObject] startListening]; 535 | } 536 | } 537 | - (void)ddhidJoystick:(DDHidJoystick *)joystick buttonDown:(unsigned)buttonNumber 538 | { 539 | NSLog(@"JOYSTICK = %i", buttonNumber); 540 | 541 | if (buttonNumber == XBUTTON) 542 | { 543 | 544 | } 545 | 546 | if (buttonNumber == ABUTTON) 547 | { 548 | [self jump]; 549 | } 550 | } 551 | 552 | - (void)ddhidJoystick:(DDHidJoystick *)joystick buttonUp:(unsigned)buttonNumber 553 | { 554 | if (buttonNumber == XBUTTON) 555 | { 556 | 557 | 558 | } 559 | } 560 | 561 | int lastStickX = 0; 562 | int lastStickY = 0; 563 | 564 | 565 | - (void) ddhidJoystick: (DDHidJoystick *) joystick 566 | stick: (unsigned) stick 567 | otherAxis: (unsigned) otherAxis 568 | valueChanged: (int) value; 569 | { 570 | value/=SHRT_MAX/4; 571 | 572 | if (stick == 1) 573 | { 574 | 575 | if (otherAxis == 0) 576 | 577 | input.look.x = value; 578 | else 579 | input.look.y = value; 580 | 581 | } 582 | 583 | 584 | } 585 | 586 | - (void) ddhidJoystick: (DDHidJoystick *) joystick 587 | stick: (unsigned) stick 588 | xChanged: (int) value; 589 | { 590 | value/=SHRT_MAX; 591 | 592 | lastStickX = value; 593 | 594 | if (abs(lastStickY) > abs(lastStickX)) 595 | return; 596 | 597 | SCNVector4 movement = playerNode.movement; 598 | CGFloat delta = 4.; 599 | 600 | 601 | if (value == 0) 602 | { 603 | player.moving = NO; 604 | 605 | movement.y = 0; 606 | movement.w = 0; 607 | 608 | input.left = NO; 609 | input.right = NO; 610 | } 611 | else 612 | { 613 | input.forward = NO; 614 | input.backward = NO; 615 | 616 | movement.x = 0; 617 | movement.z = 0; 618 | 619 | if (value > 0 ) 620 | { 621 | input.right = YES; 622 | movement.w = delta; 623 | } 624 | else if (value < 0 ) 625 | { 626 | input.left = YES; 627 | movement.y = delta; 628 | } 629 | 630 | player.moving =YES; 631 | } 632 | 633 | [playerNode setMovement:movement]; 634 | 635 | } 636 | 637 | - (void) ddhidJoystick: (DDHidJoystick *) joystick 638 | stick: (unsigned) stick 639 | yChanged: (int) value; 640 | { 641 | value/=SHRT_MAX; 642 | CGFloat delta = 4.; 643 | 644 | SCNVector4 movement = playerNode.movement; 645 | 646 | lastStickY = value; 647 | 648 | if (abs(lastStickY) < abs(lastStickX)) 649 | return; 650 | 651 | if (value == 0) 652 | { 653 | player.moving = NO; 654 | input.forward = NO; 655 | input.backward = NO; 656 | 657 | movement.x = 0; 658 | movement.z = 0; 659 | } 660 | else 661 | { 662 | input.left = NO; 663 | input.right = NO; 664 | 665 | movement.y = 0; 666 | movement.w = 0; 667 | 668 | if (value > 0 ) 669 | { 670 | 671 | input.backward = YES; 672 | movement.z = delta; 673 | 674 | } 675 | else if (value < 0 ) 676 | { 677 | input.forward = YES; 678 | movement.x = delta; 679 | } 680 | 681 | player.moving = YES; 682 | } 683 | 684 | [playerNode setMovement:movement]; 685 | 686 | } 687 | 688 | #pragma mark - FPS Label 689 | 690 | NSDate *nextFrameCounterReset; 691 | NSUInteger frameCount; 692 | 693 | - (void)renderer:(id )aRenderer didRenderScene:(SCNScene *)scene atTime:(NSTimeInterval)time 694 | { 695 | 696 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 697 | NSDate *now = [NSDate date]; 698 | 699 | if (nextFrameCounterReset) { 700 | if (NSOrderedDescending == [now compare:nextFrameCounterReset]) { 701 | [CATransaction begin]; 702 | [CATransaction setDisableActions:YES]; 703 | frameRateLabel.string = [NSString stringWithFormat:@"%ld fps", frameCount]; 704 | [CATransaction commit]; 705 | frameCount = 0; 706 | nextFrameCounterReset = [now dateByAddingTimeInterval:1.0]; 707 | } 708 | } else { 709 | nextFrameCounterReset = [now dateByAddingTimeInterval:1.0]; 710 | } 711 | 712 | ++frameCount; 713 | }); 714 | 715 | } 716 | 717 | 718 | @end 719 | -------------------------------------------------------------------------------- /OpenWorldTest/OWTLevelGenerator.h: -------------------------------------------------------------------------------- 1 | // 2 | // OBLevelGenerator.h 3 | // onebutton 4 | // 5 | // Created by Steven Troughton-Smith on 24/12/2011. 6 | // Copyright (c) 2011 High Caffeine Content. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OWTLevelGenerator : NSObject 12 | { 13 | 14 | double values[MAP_BOUNDS*CHUNK_SIZE][MAP_BOUNDS*CHUNK_SIZE]; 15 | } 16 | 17 | -(void)gen:(int)featureSize; 18 | -(double)valueForX:(int)x Y:(int)y; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /OpenWorldTest/OWTLevelGenerator.m: -------------------------------------------------------------------------------- 1 | // 2 | // OBLevelGenerator.m 3 | // onebutton 4 | // 5 | // Created by Steven Troughton-Smith on 24/12/2011. 6 | // Copyright (c) 2011 High Caffeine Content. All rights reserved. 7 | // 8 | 9 | /* 10 | 11 | This is a Perlin-based noise generator using code from http://www.dreamincode.net/forums/topic/66480-perlin-noise/ 12 | 13 | */ 14 | 15 | #import "OWTLevelGenerator.h" 16 | 17 | const int NOISE_P_X = 1619; 18 | const int NOISE_P_Y = 31337; 19 | const int NOISE_P_SEED = 1013; 20 | 21 | int seed = 1; 22 | 23 | double interpolate1(double a,double b,double x) 24 | { 25 | double ft=x * M_PI; 26 | double f=(1.0-cos(ft))* 0.5; 27 | return a*(1.0-f)+b*f; 28 | } 29 | 30 | double findnoise2(double x,double y) 31 | { 32 | int n = (NOISE_P_X*(int)x + NOISE_P_Y*(int)y + NOISE_P_SEED * seed) & 0x7fffffff; 33 | 34 | n = (n >> 13) ^ n; 35 | n = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; 36 | return 1.0 - (double)n/1073741824; 37 | } 38 | 39 | double noise2(double x,double y) 40 | { 41 | double floorx=(double)((int)x);//This is kinda a cheap way to floor a double integer. 42 | double floory=(double)((int)y); 43 | double s,t,u,v;//Integer declaration 44 | s=findnoise2(floorx,floory); 45 | t=findnoise2(floorx+1,floory); 46 | u=findnoise2(floorx,floory+1);//Get the surrounding pixels to calculate the transition. 47 | v=findnoise2(floorx+1,floory+1); 48 | double int1=interpolate1(s,t,x-floorx);//Interpolate between the values. 49 | double int2=interpolate1(u,v,x-floorx);//Here we use x-floorx, to get 1st dimension. Don't mind the x-floorx thingie, it's part of the cosine formula. 50 | return interpolate1(int1,int2,y-floory);//Here we use y-floory, to get the 2nd dimension. 51 | } 52 | 53 | 54 | @implementation OWTLevelGenerator 55 | 56 | - (id)init { 57 | self = [super init]; 58 | if (self) { 59 | seed = arc4random()%INT32_MAX; 60 | } 61 | 62 | return self; 63 | } 64 | 65 | -(void)gen:(int)featureSize 66 | { 67 | // w and h speak for themselves, zoom well zoom in and out on it, I usually 68 | // use 75. P stands for persistence, this controls the roughness of the picture, i use 1/2 69 | 70 | int octaves=2; 71 | double p = 1/2; 72 | double zoom = (double)featureSize; 73 | 74 | for(int y=0;y255) 91 | color=255; 92 | if(color<0) 93 | color=0; 94 | 95 | values[x][y] = color; 96 | 97 | } 98 | } 99 | } 100 | 101 | -(double)valueForX:(int)x Y:(int)y 102 | { 103 | return values[x][y]; 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /OpenWorldTest/OWTPlayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PlayerNode.h 3 | // SceneKraft 4 | // 5 | // Created by Tom Irving on 09/09/2012. 6 | // Copyright (c) 2012 Tom Irving. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "OWTEntity.h" 11 | 12 | @interface OWTPlayer : OWTEntity { 13 | 14 | SCNVector4 movement; 15 | CGFloat rotationUpDown; 16 | CGFloat rotationLeftRight; 17 | } 18 | 19 | @property (nonatomic, assign) SCNVector4 movement; 20 | @property (nonatomic, assign, readonly) CGFloat rotationUpDown; 21 | @property (nonatomic, assign, readonly) CGFloat rotationLeftRight; 22 | 23 | + (OWTPlayer *)node; 24 | - (void)rotateByAmount:(CGSize)amount; 25 | 26 | @end -------------------------------------------------------------------------------- /OpenWorldTest/OWTPlayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // PlayerNode.m 3 | // SceneKraft 4 | // 5 | // Created by Tom Irving on 09/09/2012. 6 | // Copyright (c) 2012 Tom Irving. All rights reserved. 7 | // 8 | 9 | #import "OWTPlayer.h" 10 | 11 | @interface OWTPlayer () 12 | @property (nonatomic, assign) CGFloat rotationUpDown; 13 | @property (nonatomic, assign) CGFloat rotationLeftRight; 14 | @end 15 | 16 | @interface OWTPlayer (Private) 17 | - (void)buildPlayer; 18 | @end 19 | 20 | @implementation OWTPlayer 21 | @synthesize movement; 22 | @synthesize rotationUpDown; 23 | @synthesize rotationLeftRight; 24 | 25 | + (OWTPlayer *)node { 26 | OWTPlayer * node = (OWTPlayer *)[super node]; 27 | [node setMass:70]; 28 | 29 | SCNCamera * camera = [SCNCamera camera]; 30 | [camera setZNear:0.1]; 31 | camera.zFar = 64; 32 | [node setCamera:camera]; 33 | 34 | SCNLight * light = [SCNLight light]; 35 | [light setType:SCNLightTypeOmni]; 36 | [node setLight:light]; 37 | 38 | [node buildPlayer]; 39 | 40 | return node; 41 | } 42 | 43 | - (void)buildPlayer { 44 | [self setGeometry:[SCNBox boxWithWidth:1 height:1 length:1 chamferRadius:0]]; 45 | } 46 | 47 | - (void)rotateByAmount:(CGSize)amount { 48 | 49 | rotationLeftRight += amount.width; 50 | if (rotationLeftRight > M_PI * 2) rotationLeftRight -= M_PI * 2; 51 | else if (rotationLeftRight < 0) rotationLeftRight += M_PI * 2; 52 | 53 | rotationUpDown += amount.height; 54 | if (rotationUpDown > M_PI * 2) rotationUpDown -= M_PI * 2; 55 | else if (rotationUpDown < 0) rotationUpDown += M_PI * 2; 56 | 57 | CATransform3D rotation = CATransform3DRotate(self.transform, amount.height, 1, 0, 0); 58 | [self setTransform:CATransform3DRotate(rotation, amount.width, 0, sinf(rotationUpDown), cosf(rotationUpDown))]; 59 | } 60 | 61 | - (void)updatePositionWithRefreshPeriod:(CGFloat)refreshPeriod { 62 | [super updatePositionWithRefreshPeriod:refreshPeriod]; 63 | 64 | SCNVector3 position = self.position; 65 | position.x -= sinf(rotationLeftRight) * (movement.x - movement.z) * refreshPeriod; 66 | position.y += cosf(rotationLeftRight) * (movement.x - movement.z) * refreshPeriod; 67 | 68 | position.x -= cosf(rotationLeftRight) * (movement.y - movement.w) * refreshPeriod; 69 | position.y -= sinf(rotationLeftRight) * (movement.y - movement.w) * refreshPeriod; 70 | [self setPosition:position]; 71 | } 72 | 73 | @end -------------------------------------------------------------------------------- /OpenWorldTest/OpenWorldTest-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.highcaffeinecontent.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSApplicationCategoryType 26 | public.app-category.role-playing-games 27 | LSMinimumSystemVersion 28 | ${MACOSX_DEPLOYMENT_TARGET} 29 | NSHumanReadableCopyright 30 | Copyright © 2012 High Caffeine Content. All rights reserved. 31 | NSMainNibFile 32 | MainMenu 33 | NSPrincipalClass 34 | NSApplication 35 | 36 | 37 | -------------------------------------------------------------------------------- /OpenWorldTest/OpenWorldTest-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'OpenWorldTest' target in the 'OpenWorldTest' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | 9 | #define MAP_BOUNDS 768 10 | #define CHUNK_SIZE 16 11 | 12 | #define MCP_DEGREES_TO_RADIANS(x) (x * 180 / M_PI) 13 | 14 | #define GAME_DEPTH 32 // we scale Z in the map generator - change to 16 for mountains! 15 | -------------------------------------------------------------------------------- /OpenWorldTest/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /OpenWorldTest/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /OpenWorldTest/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // OpenWorldTest 4 | // 5 | // Created by Steven Troughton-Smith on 23/12/2012. 6 | // Copyright (c) 2012 High Caffeine Content. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | OpenWorldTest 2 | ============= 3 | 4 | 5 | [![](https://lh4.googleusercontent.com/-f62ZF5u1IIw/UPMZluT2lVI/AAAAAAAABAQ/dZnO8cYG_aI/s1409/Screen%2520Shot%25202013-01-12%2520at%252023.56.56.png)](https://lh4.googleusercontent.com/-f62ZF5u1IIw/UPMZluT2lVI/AAAAAAAABAQ/dZnO8cYG_aI/s1409/Screen%2520Shot%25202013-01-12%2520at%252023.56.56.png) 6 | 7 | 8 | WHAT IS THIS? 9 | ============= 10 | 11 | This is a SceneKit project that uses more advanced techniques like fullscreen shaders, procedural level generation, chunk loading/unloading, as well as mouse/joypad first-person controls. 12 | 13 | There are quite a few performance techniques that took me some time to work out in this project, so I thought it would be best to open source it - needs of the many, etc. 14 | 15 | 16 | THANKS 17 | ============= 18 | 19 | Many thanks go to the following people, without whom I'd never have got this far with SceneKit: 20 | 21 | Jeff LaMarche, Tom Irving, Wade Tregaskis, and Thomas Goossens -------------------------------------------------------------------------------- /libddhid.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steventroughtonsmith/OpenWorldTest/a07ae437f0465e4278e50911891a5cac71b761f0/libddhid.a -------------------------------------------------------------------------------- /libdhid/DDHidAppleRemote.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import 26 | 27 | #import "DDHidDevice.h" 28 | 29 | @class DDHidElement; 30 | 31 | enum DDHidAppleRemoteEventIdentifier 32 | { 33 | kDDHidRemoteButtonVolume_Plus=0, 34 | kDDHidRemoteButtonVolume_Minus, 35 | kDDHidRemoteButtonMenu, 36 | kDDHidRemoteButtonPlay, 37 | kDDHidRemoteButtonRight, 38 | kDDHidRemoteButtonLeft, 39 | kDDHidRemoteButtonRight_Hold, 40 | kDDHidRemoteButtonLeft_Hold, 41 | kDDHidRemoteButtonMenu_Hold, 42 | kDDHidRemoteButtonPlay_Sleep, 43 | kDDHidRemoteControl_Switched, 44 | kDDHidRemoteControl_Paired, 45 | }; 46 | typedef enum DDHidAppleRemoteEventIdentifier DDHidAppleRemoteEventIdentifier; 47 | 48 | @interface DDHidAppleRemote : DDHidDevice 49 | { 50 | NSMutableDictionary * mCookieToButtonMapping; 51 | NSArray * mButtonElements; 52 | DDHidElement * mIdElement; 53 | int mRemoteId; 54 | 55 | id mDelegate; 56 | } 57 | 58 | + (NSArray *) allRemotes; 59 | 60 | + (DDHidAppleRemote *) firstRemote; 61 | 62 | - (id) initWithDevice: (io_object_t) device error: (NSError **) error_; 63 | 64 | #pragma mark - 65 | #pragma mark Asynchronous Notification 66 | 67 | - (void) setDelegate: (id) delegate; 68 | 69 | - (void) addElementsToDefaultQueue; 70 | 71 | #pragma mark - 72 | #pragma mark Properties 73 | 74 | - (int) remoteId; 75 | - (void) setRemoteId: (int) theRemoteId; 76 | 77 | @end 78 | 79 | @interface NSObject (DDHidAppleRemoteDelegate) 80 | 81 | - (void) ddhidAppleRemoteButton: (DDHidAppleRemoteEventIdentifier) buttonIdentifier 82 | pressedDown: (BOOL) pressedDown; 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /libdhid/DDHidDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | @class DDHidUsage; 32 | @class DDHidElement; 33 | @class DDHidQueue; 34 | 35 | @interface DDHidDevice : NSObject 36 | { 37 | io_object_t mHidDevice; 38 | IOHIDDeviceInterface122** mDeviceInterface; 39 | 40 | NSMutableDictionary * mProperties; 41 | DDHidUsage * mPrimaryUsage; 42 | NSMutableArray * mUsages; 43 | NSArray * mElements; 44 | NSMutableDictionary * mElementsByCookie; 45 | BOOL mListenInExclusiveMode; 46 | DDHidQueue * mDefaultQueue; 47 | int mTag; 48 | int mLogicalDeviceNumber; 49 | } 50 | 51 | - (id) initWithDevice: (io_object_t) device error: (NSError **) error; 52 | - (id) initLogicalWithDevice: (io_object_t) device 53 | logicalDeviceNumber: (int) logicalDeviceNumber 54 | error: (NSError **) error; 55 | - (int) logicalDeviceCount; 56 | 57 | #pragma mark - 58 | #pragma mark Finding Devices 59 | 60 | + (NSArray *) allDevices; 61 | 62 | + (NSArray *) allDevicesMatchingUsagePage: (unsigned) usagePage 63 | usageId: (unsigned) usageId 64 | withClass: (Class) hidClass 65 | skipZeroLocations: (BOOL) emptyLocation; 66 | 67 | + (NSArray *) allDevicesMatchingCFDictionary: (CFDictionaryRef) matchDictionary 68 | withClass: (Class) hidClass 69 | skipZeroLocations: (BOOL) emptyLocation; 70 | 71 | #pragma mark - 72 | #pragma mark I/O Kit Objects 73 | 74 | - (io_object_t) ioDevice; 75 | - (IOHIDDeviceInterface122**) deviceInterface; 76 | 77 | #pragma mark - 78 | #pragma mark Operations 79 | 80 | - (void) open; 81 | - (void) openWithOptions: (UInt32) options; 82 | - (void) close; 83 | - (DDHidQueue *) createQueueWithSize: (unsigned) size; 84 | - (long) getElementValue: (DDHidElement *) element; 85 | 86 | #pragma mark - 87 | #pragma mark Asynchronous Notification 88 | 89 | - (BOOL) listenInExclusiveMode; 90 | - (void) setListenInExclusiveMode: (BOOL) flag; 91 | 92 | - (void) startListening; 93 | 94 | - (void) stopListening; 95 | 96 | - (BOOL) isListening; 97 | 98 | #pragma mark - 99 | #pragma mark Properties 100 | 101 | - (NSDictionary *) properties; 102 | 103 | - (NSArray *) elements; 104 | - (DDHidElement *) elementForCookie: (IOHIDElementCookie) cookie; 105 | 106 | - (NSString *) productName; 107 | - (NSString *) manufacturer; 108 | - (NSString *) serialNumber; 109 | - (NSString *) transport; 110 | - (long) vendorId; 111 | - (long) productId; 112 | - (long) version; 113 | - (long) locationId; 114 | - (long) usagePage; 115 | - (long) usage; 116 | - (DDHidUsage *) primaryUsage; 117 | - (NSArray *) usages; 118 | 119 | - (NSComparisonResult) compareByLocationId: (DDHidDevice *) device; 120 | 121 | - (int) tag; 122 | - (void) setTag: (int) theTag; 123 | 124 | @end 125 | 126 | @interface DDHidDevice (Protected) 127 | 128 | - (unsigned) sizeOfDefaultQueue; 129 | - (void) addElementsToDefaultQueue; 130 | 131 | @end 132 | -------------------------------------------------------------------------------- /libdhid/DDHidElement.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import 26 | #include 27 | 28 | @class DDHidUsage; 29 | 30 | @interface DDHidElement : NSObject 31 | { 32 | NSDictionary * mProperties; 33 | DDHidUsage * mUsage; 34 | NSArray * mElements; 35 | } 36 | 37 | + (NSArray *) elementsWithPropertiesArray: (NSArray *) propertiesArray; 38 | 39 | + (DDHidElement *) elementWithProperties: (NSDictionary *) properties; 40 | 41 | - (id) initWithProperties: (NSDictionary *) properties; 42 | 43 | - (NSDictionary *) properties; 44 | 45 | - (NSString *) stringForKey: (NSString *) key; 46 | 47 | - (NSString *) description; 48 | 49 | - (IOHIDElementCookie) cookie; 50 | - (unsigned) cookieAsUnsigned; 51 | 52 | - (NSArray *) elements; 53 | - (DDHidUsage *) usage; 54 | - (NSString *) name; 55 | - (BOOL) hasNullState; 56 | - (BOOL) hasPreferredState; 57 | - (BOOL) isArray; 58 | - (BOOL) isRelative; 59 | - (BOOL) isWrapping; 60 | - (long) maxValue; 61 | - (long) minValue; 62 | 63 | - (NSComparisonResult) compareByUsage: (DDHidElement *) device; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /libdhid/DDHidEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import 26 | #include 27 | 28 | @interface DDHidEvent : NSObject 29 | { 30 | IOHIDEventStruct mEvent; 31 | } 32 | 33 | + (DDHidEvent *) eventWithIOHIDEvent: (IOHIDEventStruct *) event; 34 | 35 | - (id) initWithIOHIDEvent: (IOHIDEventStruct *) event; 36 | 37 | - (IOHIDElementType) type; 38 | - (IOHIDElementCookie) elementCookie; 39 | - (unsigned) elementCookieAsUnsigned; 40 | - (SInt32) value; 41 | - (AbsoluteTime) timestamp; 42 | - (UInt32) longValueSize; 43 | - (void *) longValue; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /libdhid/DDHidJoystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import 26 | #import "DDHidDevice.h" 27 | 28 | @class DDHidElement; 29 | @class DDHidQueue; 30 | 31 | @interface DDHidJoystickStick : NSObject 32 | { 33 | DDHidElement * mXAxisElement; 34 | DDHidElement * mYAxisElement; 35 | NSMutableArray * mStickElements; 36 | // Point of view elements (i.e. hat switches) 37 | NSMutableArray * mPovElements; 38 | } 39 | 40 | - (DDHidElement *) xAxisElement; 41 | 42 | - (DDHidElement *) yAxisElement; 43 | 44 | #pragma mark - 45 | #pragma mark StickElements - indexed accessors 46 | 47 | - (unsigned int) countOfStickElements; 48 | - (DDHidElement *) objectInStickElementsAtIndex: (unsigned int)index; 49 | 50 | #pragma mark - 51 | #pragma mark PovElements - indexed accessors 52 | 53 | - (unsigned int) countOfPovElements; 54 | - (DDHidElement *) objectInPovElementsAtIndex: (unsigned int)index; 55 | 56 | - (NSArray *) allElements; 57 | 58 | - (BOOL) addElement: (DDHidElement *) element; 59 | 60 | @end 61 | 62 | @interface DDHidJoystick : DDHidDevice 63 | { 64 | NSMutableArray * mSticks; 65 | NSMutableArray * mButtonElements; 66 | NSMutableArray * mLogicalDeviceElements; 67 | 68 | id mDelegate; 69 | } 70 | 71 | + (NSArray *) allJoysticks; 72 | 73 | - (id) initLogicalWithDevice: (io_object_t) device 74 | logicalDeviceNumber: (int) logicalDeviceNumber 75 | error: (NSError **) error; 76 | 77 | - (int) logicalDeviceCount; 78 | 79 | #pragma mark - 80 | #pragma mark Joystick Elements 81 | 82 | - (unsigned) numberOfButtons; 83 | 84 | - (NSArray *) buttonElements; 85 | 86 | #pragma mark - 87 | #pragma mark Sticks - indexed accessors 88 | 89 | - (unsigned int) countOfSticks; 90 | - (DDHidJoystickStick *) objectInSticksAtIndex: (unsigned int)index; 91 | 92 | - (void) addElementsToQueue: (DDHidQueue *) queue; 93 | 94 | #pragma mark - 95 | #pragma mark Asynchronous Notification 96 | 97 | - (void) setDelegate: (id) delegate; 98 | 99 | - (void) addElementsToDefaultQueue; 100 | 101 | @end 102 | 103 | #define DDHID_JOYSTICK_VALUE_MIN -65536 104 | #define DDHID_JOYSTICK_VALUE_MAX 65536 105 | 106 | @interface NSObject (DDHidJoystickDelegate) 107 | 108 | - (void) ddhidJoystick: (DDHidJoystick *) joystick 109 | stick: (unsigned) stick 110 | xChanged: (int) value; 111 | 112 | - (void) ddhidJoystick: (DDHidJoystick *) joystick 113 | stick: (unsigned) stick 114 | yChanged: (int) value; 115 | 116 | - (void) ddhidJoystick: (DDHidJoystick *) joystick 117 | stick: (unsigned) stick 118 | otherAxis: (unsigned) otherAxis 119 | valueChanged: (int) value; 120 | 121 | - (void) ddhidJoystick: (DDHidJoystick *) joystick 122 | stick: (unsigned) stick 123 | povNumber: (unsigned) povNumber 124 | valueChanged: (int) value; 125 | 126 | - (void) ddhidJoystick: (DDHidJoystick *) joystick 127 | buttonDown: (unsigned) buttonNumber; 128 | 129 | - (void) ddhidJoystick: (DDHidJoystick *) joystick 130 | buttonUp: (unsigned) buttonNumber; 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /libdhid/DDHidKeyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import 26 | #import "DDHidDevice.h" 27 | 28 | @class DDHidElement; 29 | @class DDHidQueue; 30 | 31 | @interface DDHidKeyboard : DDHidDevice 32 | { 33 | NSMutableArray * mKeyElements; 34 | 35 | id mDelegate; 36 | } 37 | 38 | + (NSArray *) allKeyboards; 39 | 40 | - (id) initWithDevice: (io_object_t) device error: (NSError **) error_; 41 | 42 | #pragma mark - 43 | #pragma mark Keyboards Elements 44 | 45 | - (NSArray *) keyElements; 46 | 47 | - (unsigned) numberOfKeys; 48 | 49 | - (void) addElementsToQueue: (DDHidQueue *) queue; 50 | 51 | #pragma mark - 52 | #pragma mark Asynchronous Notification 53 | 54 | - (void) setDelegate: (id) delegate; 55 | 56 | - (void) addElementsToDefaultQueue; 57 | 58 | @end 59 | 60 | @interface NSObject (DDHidKeyboardDelegate) 61 | 62 | - (void) ddhidKeyboard: (DDHidKeyboard *) keyboard 63 | keyDown: (unsigned) usageId; 64 | 65 | - (void) ddhidKeyboard: (DDHidKeyboard *) keyboard 66 | keyUp: (unsigned) usageId; 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /libdhid/DDHidKeyboardBarcodeScanner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Dave Dribin, Lucas Newman 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import 26 | #import "DDHidDevice.h" 27 | 28 | @class DDHidElement; 29 | @class DDHidQueue; 30 | 31 | @interface DDHidKeyboardBarcodeScanner : DDHidDevice 32 | { 33 | NSMutableArray * mKeyElements; 34 | 35 | NSMutableString * mAccumulatedDigits; 36 | NSTimer *mBarcodeInputTimer; 37 | BOOL mIsLikelyKeyboardBarcodeScanner; 38 | 39 | id mDelegate; 40 | } 41 | 42 | + (NSArray *) allPossibleKeyboardBarcodeScanners; 43 | 44 | - (id) initWithDevice: (io_object_t) device error: (NSError **) error_; 45 | 46 | #pragma mark - 47 | #pragma mark Keyboard Elements 48 | 49 | - (NSArray *) keyElements; 50 | 51 | - (unsigned) numberOfKeys; 52 | 53 | - (void) addElementsToQueue: (DDHidQueue *) queue; 54 | 55 | #pragma mark - 56 | #pragma mark Asynchronous Notification 57 | 58 | - (void) setDelegate: (id) delegate; 59 | 60 | - (void) addElementsToDefaultQueue; 61 | 62 | #pragma mark - 63 | #pragma mark Properties 64 | 65 | - (BOOL) isLikelyKeyboardBarcodeScanner; 66 | 67 | @end 68 | 69 | @interface NSObject (DDHidKeyboardBarcodeScannerDelegate) 70 | 71 | - (void) ddhidKeyboardBarcodeScanner: (DDHidKeyboardBarcodeScanner *) keyboardBarcodeScanner 72 | gotBarcode: (NSString *) barcode; 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /libdhid/DDHidLib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import "DDHidDevice.h" 26 | #import "DDHidElement.h" 27 | #import "DDHidUsage.h" 28 | #import "DDHidQueue.h" 29 | #import "DDHidEvent.h" 30 | #import "DDHidUsageTables.h" 31 | #import "DDHidMouse.h" 32 | #import "DDHidJoystick.h" 33 | #import "DDHidKeyboard.h" 34 | #import "DDHidAppleRemote.h" 35 | #import "DDHidKeyboardBarcodeScanner.h" 36 | -------------------------------------------------------------------------------- /libdhid/DDHidMouse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import 26 | #import "DDHidDevice.h" 27 | 28 | @class DDHidElement; 29 | @class DDHidQueue; 30 | 31 | @interface DDHidMouse : DDHidDevice 32 | { 33 | DDHidElement * mXElement; 34 | DDHidElement * mYElement; 35 | DDHidElement * mWheelElement; 36 | NSMutableArray * mButtonElements; 37 | 38 | id mDelegate; 39 | } 40 | 41 | + (NSArray *) allMice; 42 | 43 | - (id) initWithDevice: (io_object_t) device error: (NSError **) error_; 44 | 45 | #pragma mark - 46 | #pragma mark Mouse Elements 47 | 48 | - (DDHidElement *) xElement; 49 | 50 | - (DDHidElement *) yElement; 51 | 52 | - (DDHidElement *) wheelElement; 53 | 54 | - (NSArray *) buttonElements; 55 | 56 | - (unsigned) numberOfButtons; 57 | 58 | - (void) addElementsToQueue: (DDHidQueue *) queue; 59 | 60 | #pragma mark - 61 | #pragma mark Asynchronous Notification 62 | 63 | - (void) setDelegate: (id) delegate; 64 | 65 | - (void) addElementsToDefaultQueue; 66 | 67 | @end 68 | 69 | @interface NSObject (DDHidMouseDelegate) 70 | 71 | - (void) ddhidMouse: (DDHidMouse *) mouse xChanged: (SInt32) deltaX; 72 | - (void) ddhidMouse: (DDHidMouse *) mouse yChanged: (SInt32) deltaY; 73 | - (void) ddhidMouse: (DDHidMouse *) mouse wheelChanged: (SInt32) deltaWheel; 74 | - (void) ddhidMouse: (DDHidMouse *) mouse buttonDown: (unsigned) buttonNumber; 75 | - (void) ddhidMouse: (DDHidMouse *) mouse buttonUp: (unsigned) buttonNumber; 76 | 77 | @end 78 | 79 | -------------------------------------------------------------------------------- /libdhid/DDHidQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import 26 | #include 27 | 28 | @class DDHidElement; 29 | @class DDHidEvent; 30 | 31 | @interface DDHidQueue : NSObject 32 | { 33 | IOHIDQueueInterface ** mQueue; 34 | NSRunLoop * mRunLoop; 35 | BOOL mStarted; 36 | 37 | id mDelegate; 38 | CFRunLoopSourceRef mEventSource; 39 | } 40 | 41 | - (id) initWithHIDQueue: (IOHIDQueueInterface **) queue 42 | size: (unsigned) size; 43 | 44 | - (void) addElement: (DDHidElement *) element; 45 | 46 | - (void) addElements: (NSArray *) elements; 47 | 48 | - (void) addElements: (NSArray *) elements recursively: (BOOL) recursively; 49 | 50 | - (void) setDelegate: (id) delegate; 51 | 52 | - (void) startOnCurrentRunLoop; 53 | 54 | - (void) startOnRunLoop: (NSRunLoop *) runLoop; 55 | 56 | - (void) stop; 57 | 58 | - (BOOL) isStarted; 59 | 60 | - (BOOL) getNextEvent: (IOHIDEventStruct *) event; 61 | 62 | - (DDHidEvent *) nextEvent; 63 | 64 | @end 65 | 66 | @interface NSObject (DDHidQueueDelegate) 67 | 68 | - (void) ddhidQueueHasEvents: (DDHidQueue *) hidQueue; 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /libdhid/DDHidUsage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import 26 | 27 | 28 | @interface DDHidUsage : NSObject 29 | { 30 | unsigned mUsagePage; 31 | unsigned mUsageId; 32 | } 33 | 34 | + (DDHidUsage *) usageWithUsagePage: (unsigned) usagePage 35 | usageId: (unsigned) usageId; 36 | 37 | - (id) initWithUsagePage: (unsigned) usagePage 38 | usageId: (unsigned) usageId; 39 | 40 | - (unsigned) usagePage; 41 | 42 | - (unsigned) usageId; 43 | 44 | - (NSString *) usageName; 45 | 46 | - (NSString *) usageNameWithIds; 47 | 48 | - (NSString *) description; 49 | 50 | - (BOOL) isEqualToUsagePage: (unsigned) usagePage usageId: (unsigned) usageId; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /libdhid/DDHidUsageTables.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import 26 | 27 | 28 | @interface DDHidUsageTables : NSObject 29 | { 30 | NSDictionary * mLookupTables; 31 | } 32 | 33 | + (DDHidUsageTables *) standardUsageTables; 34 | 35 | - (id) initWithLookupTables: (NSDictionary *) lookupTables; 36 | 37 | - (NSString *) descriptionForUsagePage: (unsigned) usagePage 38 | usage: (unsigned) usage; 39 | 40 | @end 41 | --------------------------------------------------------------------------------