├── LICENSE ├── README.md ├── SceneKit Swift Moving Objects.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── SceneKit Swift Moving Objects ├── AppDelegate.swift ├── Base.lproj │ └── MainMenu.xib ├── GameScene.swift ├── GameView.swift ├── GameViewController.swift ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json └── Info.plist └── SceneKit Swift Moving ObjectsTests ├── Info.plist └── SceneKit_Swift_Moving_ObjectsTests.swift /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 ManuW 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies 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 included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SceneKit-Swift-Moving-Objects 2 | ============================= 3 | 4 | moving objects with mouse in Scene Kit and with Swift 5 | 6 | JUST AN EXAMPLE!!! 7 | JUST FOR TESTING!!! 8 | 9 | Build with Xcode 6.1.1 for OS X 10.10 10 | 11 | see also: https://www.youtube.com/watch?v=xn9Bt2PFp0g 12 | 13 | -------------------------------------------------------------------------------- /SceneKit Swift Moving Objects.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 2F93EBC81A46D23900EA6173 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F93EBC71A46D23900EA6173 /* AppDelegate.swift */; }; 11 | 2F93EBCA1A46D23900EA6173 /* GameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F93EBC91A46D23900EA6173 /* GameView.swift */; }; 12 | 2F93EBCC1A46D23900EA6173 /* GameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F93EBCB1A46D23900EA6173 /* GameViewController.swift */; }; 13 | 2F93EBD01A46D23900EA6173 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2F93EBCF1A46D23900EA6173 /* Images.xcassets */; }; 14 | 2F93EBD31A46D23900EA6173 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2F93EBD11A46D23900EA6173 /* MainMenu.xib */; }; 15 | 2F93EBDF1A46D23900EA6173 /* SceneKit_Swift_Moving_ObjectsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F93EBDE1A46D23900EA6173 /* SceneKit_Swift_Moving_ObjectsTests.swift */; }; 16 | 2F93EBE91A46D33100EA6173 /* GameScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F93EBE81A46D33100EA6173 /* GameScene.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | 2F93EBD91A46D23900EA6173 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = 2F93EBBA1A46D23900EA6173 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = 2F93EBC11A46D23900EA6173; 25 | remoteInfo = "SceneKit Swift Moving Objects"; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | 2F93EBC21A46D23900EA6173 /* SceneKit Swift Moving Objects.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SceneKit Swift Moving Objects.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | 2F93EBC61A46D23900EA6173 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 2F93EBC71A46D23900EA6173 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33 | 2F93EBC91A46D23900EA6173 /* GameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameView.swift; sourceTree = ""; }; 34 | 2F93EBCB1A46D23900EA6173 /* GameViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = ""; }; 35 | 2F93EBCF1A46D23900EA6173 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 36 | 2F93EBD21A46D23900EA6173 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 37 | 2F93EBD81A46D23900EA6173 /* SceneKit Swift Moving ObjectsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SceneKit Swift Moving ObjectsTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 2F93EBDD1A46D23900EA6173 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | 2F93EBDE1A46D23900EA6173 /* SceneKit_Swift_Moving_ObjectsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneKit_Swift_Moving_ObjectsTests.swift; sourceTree = ""; }; 40 | 2F93EBE81A46D33100EA6173 /* GameScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | 2F93EBBF1A46D23900EA6173 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | 2F93EBD51A46D23900EA6173 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | /* End PBXFrameworksBuildPhase section */ 59 | 60 | /* Begin PBXGroup section */ 61 | 2F93EBB91A46D23900EA6173 = { 62 | isa = PBXGroup; 63 | children = ( 64 | 2F93EBC41A46D23900EA6173 /* SceneKit Swift Moving Objects */, 65 | 2F93EBDB1A46D23900EA6173 /* SceneKit Swift Moving ObjectsTests */, 66 | 2F93EBC31A46D23900EA6173 /* Products */, 67 | ); 68 | sourceTree = ""; 69 | }; 70 | 2F93EBC31A46D23900EA6173 /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 2F93EBC21A46D23900EA6173 /* SceneKit Swift Moving Objects.app */, 74 | 2F93EBD81A46D23900EA6173 /* SceneKit Swift Moving ObjectsTests.xctest */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | 2F93EBC41A46D23900EA6173 /* SceneKit Swift Moving Objects */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 2F93EBC71A46D23900EA6173 /* AppDelegate.swift */, 83 | 2F93EBC91A46D23900EA6173 /* GameView.swift */, 84 | 2F93EBCB1A46D23900EA6173 /* GameViewController.swift */, 85 | 2F93EBE81A46D33100EA6173 /* GameScene.swift */, 86 | 2F93EBCF1A46D23900EA6173 /* Images.xcassets */, 87 | 2F93EBD11A46D23900EA6173 /* MainMenu.xib */, 88 | 2F93EBC51A46D23900EA6173 /* Supporting Files */, 89 | ); 90 | path = "SceneKit Swift Moving Objects"; 91 | sourceTree = ""; 92 | }; 93 | 2F93EBC51A46D23900EA6173 /* Supporting Files */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 2F93EBC61A46D23900EA6173 /* Info.plist */, 97 | ); 98 | name = "Supporting Files"; 99 | sourceTree = ""; 100 | }; 101 | 2F93EBDB1A46D23900EA6173 /* SceneKit Swift Moving ObjectsTests */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 2F93EBDE1A46D23900EA6173 /* SceneKit_Swift_Moving_ObjectsTests.swift */, 105 | 2F93EBDC1A46D23900EA6173 /* Supporting Files */, 106 | ); 107 | path = "SceneKit Swift Moving ObjectsTests"; 108 | sourceTree = ""; 109 | }; 110 | 2F93EBDC1A46D23900EA6173 /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 2F93EBDD1A46D23900EA6173 /* Info.plist */, 114 | ); 115 | name = "Supporting Files"; 116 | sourceTree = ""; 117 | }; 118 | /* End PBXGroup section */ 119 | 120 | /* Begin PBXNativeTarget section */ 121 | 2F93EBC11A46D23900EA6173 /* SceneKit Swift Moving Objects */ = { 122 | isa = PBXNativeTarget; 123 | buildConfigurationList = 2F93EBE21A46D23900EA6173 /* Build configuration list for PBXNativeTarget "SceneKit Swift Moving Objects" */; 124 | buildPhases = ( 125 | 2F93EBBE1A46D23900EA6173 /* Sources */, 126 | 2F93EBBF1A46D23900EA6173 /* Frameworks */, 127 | 2F93EBC01A46D23900EA6173 /* Resources */, 128 | ); 129 | buildRules = ( 130 | ); 131 | dependencies = ( 132 | ); 133 | name = "SceneKit Swift Moving Objects"; 134 | productName = "SceneKit Swift Moving Objects"; 135 | productReference = 2F93EBC21A46D23900EA6173 /* SceneKit Swift Moving Objects.app */; 136 | productType = "com.apple.product-type.application"; 137 | }; 138 | 2F93EBD71A46D23900EA6173 /* SceneKit Swift Moving ObjectsTests */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = 2F93EBE51A46D23900EA6173 /* Build configuration list for PBXNativeTarget "SceneKit Swift Moving ObjectsTests" */; 141 | buildPhases = ( 142 | 2F93EBD41A46D23900EA6173 /* Sources */, 143 | 2F93EBD51A46D23900EA6173 /* Frameworks */, 144 | 2F93EBD61A46D23900EA6173 /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | 2F93EBDA1A46D23900EA6173 /* PBXTargetDependency */, 150 | ); 151 | name = "SceneKit Swift Moving ObjectsTests"; 152 | productName = "SceneKit Swift Moving ObjectsTests"; 153 | productReference = 2F93EBD81A46D23900EA6173 /* SceneKit Swift Moving ObjectsTests.xctest */; 154 | productType = "com.apple.product-type.bundle.unit-test"; 155 | }; 156 | /* End PBXNativeTarget section */ 157 | 158 | /* Begin PBXProject section */ 159 | 2F93EBBA1A46D23900EA6173 /* Project object */ = { 160 | isa = PBXProject; 161 | attributes = { 162 | LastUpgradeCheck = 0610; 163 | ORGANIZATIONNAME = "example code by Manuel Wentenschuh"; 164 | TargetAttributes = { 165 | 2F93EBC11A46D23900EA6173 = { 166 | CreatedOnToolsVersion = 6.1.1; 167 | }; 168 | 2F93EBD71A46D23900EA6173 = { 169 | CreatedOnToolsVersion = 6.1.1; 170 | TestTargetID = 2F93EBC11A46D23900EA6173; 171 | }; 172 | }; 173 | }; 174 | buildConfigurationList = 2F93EBBD1A46D23900EA6173 /* Build configuration list for PBXProject "SceneKit Swift Moving Objects" */; 175 | compatibilityVersion = "Xcode 3.2"; 176 | developmentRegion = English; 177 | hasScannedForEncodings = 0; 178 | knownRegions = ( 179 | en, 180 | Base, 181 | ); 182 | mainGroup = 2F93EBB91A46D23900EA6173; 183 | productRefGroup = 2F93EBC31A46D23900EA6173 /* Products */; 184 | projectDirPath = ""; 185 | projectRoot = ""; 186 | targets = ( 187 | 2F93EBC11A46D23900EA6173 /* SceneKit Swift Moving Objects */, 188 | 2F93EBD71A46D23900EA6173 /* SceneKit Swift Moving ObjectsTests */, 189 | ); 190 | }; 191 | /* End PBXProject section */ 192 | 193 | /* Begin PBXResourcesBuildPhase section */ 194 | 2F93EBC01A46D23900EA6173 /* Resources */ = { 195 | isa = PBXResourcesBuildPhase; 196 | buildActionMask = 2147483647; 197 | files = ( 198 | 2F93EBD01A46D23900EA6173 /* Images.xcassets in Resources */, 199 | 2F93EBD31A46D23900EA6173 /* MainMenu.xib in Resources */, 200 | ); 201 | runOnlyForDeploymentPostprocessing = 0; 202 | }; 203 | 2F93EBD61A46D23900EA6173 /* Resources */ = { 204 | isa = PBXResourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | ); 208 | runOnlyForDeploymentPostprocessing = 0; 209 | }; 210 | /* End PBXResourcesBuildPhase section */ 211 | 212 | /* Begin PBXSourcesBuildPhase section */ 213 | 2F93EBBE1A46D23900EA6173 /* Sources */ = { 214 | isa = PBXSourcesBuildPhase; 215 | buildActionMask = 2147483647; 216 | files = ( 217 | 2F93EBCA1A46D23900EA6173 /* GameView.swift in Sources */, 218 | 2F93EBCC1A46D23900EA6173 /* GameViewController.swift in Sources */, 219 | 2F93EBE91A46D33100EA6173 /* GameScene.swift in Sources */, 220 | 2F93EBC81A46D23900EA6173 /* AppDelegate.swift in Sources */, 221 | ); 222 | runOnlyForDeploymentPostprocessing = 0; 223 | }; 224 | 2F93EBD41A46D23900EA6173 /* Sources */ = { 225 | isa = PBXSourcesBuildPhase; 226 | buildActionMask = 2147483647; 227 | files = ( 228 | 2F93EBDF1A46D23900EA6173 /* SceneKit_Swift_Moving_ObjectsTests.swift in Sources */, 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | /* End PBXSourcesBuildPhase section */ 233 | 234 | /* Begin PBXTargetDependency section */ 235 | 2F93EBDA1A46D23900EA6173 /* PBXTargetDependency */ = { 236 | isa = PBXTargetDependency; 237 | target = 2F93EBC11A46D23900EA6173 /* SceneKit Swift Moving Objects */; 238 | targetProxy = 2F93EBD91A46D23900EA6173 /* PBXContainerItemProxy */; 239 | }; 240 | /* End PBXTargetDependency section */ 241 | 242 | /* Begin PBXVariantGroup section */ 243 | 2F93EBD11A46D23900EA6173 /* MainMenu.xib */ = { 244 | isa = PBXVariantGroup; 245 | children = ( 246 | 2F93EBD21A46D23900EA6173 /* Base */, 247 | ); 248 | name = MainMenu.xib; 249 | sourceTree = ""; 250 | }; 251 | /* End PBXVariantGroup section */ 252 | 253 | /* Begin XCBuildConfiguration section */ 254 | 2F93EBE01A46D23900EA6173 /* Debug */ = { 255 | isa = XCBuildConfiguration; 256 | buildSettings = { 257 | ALWAYS_SEARCH_USER_PATHS = NO; 258 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 259 | CLANG_CXX_LIBRARY = "libc++"; 260 | CLANG_ENABLE_MODULES = YES; 261 | CLANG_ENABLE_OBJC_ARC = YES; 262 | CLANG_WARN_BOOL_CONVERSION = YES; 263 | CLANG_WARN_CONSTANT_CONVERSION = YES; 264 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 265 | CLANG_WARN_EMPTY_BODY = YES; 266 | CLANG_WARN_ENUM_CONVERSION = YES; 267 | CLANG_WARN_INT_CONVERSION = YES; 268 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 269 | CLANG_WARN_UNREACHABLE_CODE = YES; 270 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 271 | CODE_SIGN_IDENTITY = "-"; 272 | COPY_PHASE_STRIP = NO; 273 | ENABLE_STRICT_OBJC_MSGSEND = YES; 274 | GCC_C_LANGUAGE_STANDARD = gnu99; 275 | GCC_DYNAMIC_NO_PIC = NO; 276 | GCC_OPTIMIZATION_LEVEL = 0; 277 | GCC_PREPROCESSOR_DEFINITIONS = ( 278 | "DEBUG=1", 279 | "$(inherited)", 280 | ); 281 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 282 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 283 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 284 | GCC_WARN_UNDECLARED_SELECTOR = YES; 285 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 286 | GCC_WARN_UNUSED_FUNCTION = YES; 287 | GCC_WARN_UNUSED_VARIABLE = YES; 288 | MACOSX_DEPLOYMENT_TARGET = 10.10; 289 | MTL_ENABLE_DEBUG_INFO = YES; 290 | ONLY_ACTIVE_ARCH = YES; 291 | SDKROOT = macosx; 292 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 293 | }; 294 | name = Debug; 295 | }; 296 | 2F93EBE11A46D23900EA6173 /* Release */ = { 297 | isa = XCBuildConfiguration; 298 | buildSettings = { 299 | ALWAYS_SEARCH_USER_PATHS = NO; 300 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 301 | CLANG_CXX_LIBRARY = "libc++"; 302 | CLANG_ENABLE_MODULES = YES; 303 | CLANG_ENABLE_OBJC_ARC = YES; 304 | CLANG_WARN_BOOL_CONVERSION = YES; 305 | CLANG_WARN_CONSTANT_CONVERSION = YES; 306 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 307 | CLANG_WARN_EMPTY_BODY = YES; 308 | CLANG_WARN_ENUM_CONVERSION = YES; 309 | CLANG_WARN_INT_CONVERSION = YES; 310 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 311 | CLANG_WARN_UNREACHABLE_CODE = YES; 312 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 313 | CODE_SIGN_IDENTITY = "-"; 314 | COPY_PHASE_STRIP = YES; 315 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 316 | ENABLE_NS_ASSERTIONS = NO; 317 | ENABLE_STRICT_OBJC_MSGSEND = YES; 318 | GCC_C_LANGUAGE_STANDARD = gnu99; 319 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 320 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 321 | GCC_WARN_UNDECLARED_SELECTOR = YES; 322 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 323 | GCC_WARN_UNUSED_FUNCTION = YES; 324 | GCC_WARN_UNUSED_VARIABLE = YES; 325 | MACOSX_DEPLOYMENT_TARGET = 10.10; 326 | MTL_ENABLE_DEBUG_INFO = NO; 327 | SDKROOT = macosx; 328 | }; 329 | name = Release; 330 | }; 331 | 2F93EBE31A46D23900EA6173 /* Debug */ = { 332 | isa = XCBuildConfiguration; 333 | buildSettings = { 334 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 335 | COMBINE_HIDPI_IMAGES = YES; 336 | INFOPLIST_FILE = "SceneKit Swift Moving Objects/Info.plist"; 337 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 338 | PRODUCT_NAME = "$(TARGET_NAME)"; 339 | }; 340 | name = Debug; 341 | }; 342 | 2F93EBE41A46D23900EA6173 /* Release */ = { 343 | isa = XCBuildConfiguration; 344 | buildSettings = { 345 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 346 | COMBINE_HIDPI_IMAGES = YES; 347 | INFOPLIST_FILE = "SceneKit Swift Moving Objects/Info.plist"; 348 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 349 | PRODUCT_NAME = "$(TARGET_NAME)"; 350 | }; 351 | name = Release; 352 | }; 353 | 2F93EBE61A46D23900EA6173 /* Debug */ = { 354 | isa = XCBuildConfiguration; 355 | buildSettings = { 356 | BUNDLE_LOADER = "$(TEST_HOST)"; 357 | COMBINE_HIDPI_IMAGES = YES; 358 | FRAMEWORK_SEARCH_PATHS = ( 359 | "$(DEVELOPER_FRAMEWORKS_DIR)", 360 | "$(inherited)", 361 | ); 362 | GCC_PREPROCESSOR_DEFINITIONS = ( 363 | "DEBUG=1", 364 | "$(inherited)", 365 | ); 366 | INFOPLIST_FILE = "SceneKit Swift Moving ObjectsTests/Info.plist"; 367 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 368 | PRODUCT_NAME = "$(TARGET_NAME)"; 369 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SceneKit Swift Moving Objects.app/Contents/MacOS/SceneKit Swift Moving Objects"; 370 | }; 371 | name = Debug; 372 | }; 373 | 2F93EBE71A46D23900EA6173 /* Release */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | BUNDLE_LOADER = "$(TEST_HOST)"; 377 | COMBINE_HIDPI_IMAGES = YES; 378 | FRAMEWORK_SEARCH_PATHS = ( 379 | "$(DEVELOPER_FRAMEWORKS_DIR)", 380 | "$(inherited)", 381 | ); 382 | INFOPLIST_FILE = "SceneKit Swift Moving ObjectsTests/Info.plist"; 383 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 384 | PRODUCT_NAME = "$(TARGET_NAME)"; 385 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SceneKit Swift Moving Objects.app/Contents/MacOS/SceneKit Swift Moving Objects"; 386 | }; 387 | name = Release; 388 | }; 389 | /* End XCBuildConfiguration section */ 390 | 391 | /* Begin XCConfigurationList section */ 392 | 2F93EBBD1A46D23900EA6173 /* Build configuration list for PBXProject "SceneKit Swift Moving Objects" */ = { 393 | isa = XCConfigurationList; 394 | buildConfigurations = ( 395 | 2F93EBE01A46D23900EA6173 /* Debug */, 396 | 2F93EBE11A46D23900EA6173 /* Release */, 397 | ); 398 | defaultConfigurationIsVisible = 0; 399 | defaultConfigurationName = Release; 400 | }; 401 | 2F93EBE21A46D23900EA6173 /* Build configuration list for PBXNativeTarget "SceneKit Swift Moving Objects" */ = { 402 | isa = XCConfigurationList; 403 | buildConfigurations = ( 404 | 2F93EBE31A46D23900EA6173 /* Debug */, 405 | 2F93EBE41A46D23900EA6173 /* Release */, 406 | ); 407 | defaultConfigurationIsVisible = 0; 408 | }; 409 | 2F93EBE51A46D23900EA6173 /* Build configuration list for PBXNativeTarget "SceneKit Swift Moving ObjectsTests" */ = { 410 | isa = XCConfigurationList; 411 | buildConfigurations = ( 412 | 2F93EBE61A46D23900EA6173 /* Debug */, 413 | 2F93EBE71A46D23900EA6173 /* Release */, 414 | ); 415 | defaultConfigurationIsVisible = 0; 416 | }; 417 | /* End XCConfigurationList section */ 418 | }; 419 | rootObject = 2F93EBBA1A46D23900EA6173 /* Project object */; 420 | } 421 | -------------------------------------------------------------------------------- /SceneKit Swift Moving Objects.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SceneKit Swift Moving Objects/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SceneKit Swift Moving Objects 4 | // 5 | // Created by Manuel Wentenschuh on 21.Dec.14. 6 | // example code 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | @IBOutlet weak var window: NSWindow! 15 | 16 | func applicationDidFinishLaunching(aNotification: NSNotification) { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /SceneKit Swift Moving Objects/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 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 | 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 | 213 | 214 | 215 | 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 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | Default 523 | 524 | 525 | 526 | 527 | 528 | 529 | Left to Right 530 | 531 | 532 | 533 | 534 | 535 | 536 | Right to Left 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | Default 548 | 549 | 550 | 551 | 552 | 553 | 554 | Left to Right 555 | 556 | 557 | 558 | 559 | 560 | 561 | Right to Left 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | -------------------------------------------------------------------------------- /SceneKit Swift Moving Objects/GameScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GameScene.swift 3 | // SceneKit Swift Moving Objects 4 | // 5 | // Created by Manuel Wentenschuh on 21.Dec.14. 6 | // example code 7 | // 8 | 9 | import Foundation 10 | import SceneKit 11 | import QuartzCore 12 | 13 | 14 | class GameScene : SCNScene { 15 | 16 | override init() { 17 | super.init() 18 | 19 | let cameraNode = SCNNode() 20 | cameraNode.camera = SCNCamera() 21 | cameraNode.position = SCNVector3(x: 0, y: 0, z: 4) 22 | rootNode.addChildNode(cameraNode) 23 | 24 | let helloWorld = "Hello World!" 25 | var xPos = CGFloat(-5.0) 26 | let font = NSFont(name: "Menlo", size: 1.0) 27 | 28 | for character in helloWorld { 29 | 30 | let s = String(character) 31 | let geo = SCNText(string: s, extrusionDepth: 0.25) 32 | geo.font = font 33 | 34 | let mat = SCNMaterial() 35 | let hue : Double = Double(rand()) / Double(RAND_MAX) 36 | mat.diffuse.contents = NSColor(calibratedHue: CGFloat(hue), saturation: 1.0, brightness: 1.0, alpha: 1.0) 37 | geo.materials = [mat] 38 | 39 | let node = SCNNode(geometry: geo) 40 | node.position = SCNVector3(x: xPos, y: 0.0, z: 0.0) 41 | rootNode.addChildNode(node) 42 | 43 | xPos += 0.66 44 | } 45 | } 46 | 47 | required init(coder aDecoder: NSCoder) { 48 | super.init(coder: aDecoder) 49 | } 50 | } -------------------------------------------------------------------------------- /SceneKit Swift Moving Objects/GameView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GameView.swift 3 | // SceneKit Swift Moving Objects 4 | // 5 | // Created by Manuel Wentenschuh on 21.Dec.14. 6 | // example code 7 | // 8 | 9 | import SceneKit 10 | 11 | 12 | func round(val: SCNVector3) -> SCNVector3 { 13 | return SCNVector3(x: round(val.x), y: round(val.y), z: round(val.z)) 14 | } 15 | 16 | 17 | func + (left: SCNVector3, right: SCNVector3) -> SCNVector3 { 18 | return SCNVector3(x: left.x + right.x, y: left.y + right.y, z: left.z + right.z) 19 | } 20 | 21 | func - (left: SCNVector3, right: SCNVector3) -> SCNVector3 { 22 | return SCNVector3(x: left.x - right.x, y: left.y - right.y, z: left.z - right.z) 23 | } 24 | 25 | func * (left: SCNVector3, right: SCNVector3) -> CGFloat { 26 | return CGFloat(left.x * right.x + left.y * right.y + left.z * right.z) 27 | } 28 | 29 | 30 | func * (left: SCNVector3, right: CGFloat) -> SCNVector3 { 31 | return SCNVector3(x: left.x * right, y: left.y * right, z: left.z * right) 32 | } 33 | 34 | func * (left: CGFloat, right: SCNVector3) -> SCNVector3 { 35 | return SCNVector3(x: left * right.x, y: left * right.y, z: left * right.z) 36 | } 37 | 38 | 39 | class GameView: SCNView { 40 | 41 | var mark : SCNNode? = nil 42 | var selection : SCNHitTestResult? = nil 43 | var hitOld = SCNVector3Zero 44 | 45 | // mark an object (= selection) 46 | override func mouseDown(theEvent: NSEvent) { 47 | 48 | let p = self.convertPoint(theEvent.locationInWindow, fromView: nil) 49 | let options = [SCNHitTestSortResultsKey : NSNumber(bool: true), SCNHitTestBoundingBoxOnlyKey : NSNumber(bool: true)] 50 | 51 | if let hitResults = self.hitTest(p, options: options) { 52 | 53 | if (hitResults.count > 0){ 54 | let result: AnyObject = hitResults[0] 55 | if result is SCNHitTestResult { 56 | selection = result as? SCNHitTestResult 57 | } 58 | } 59 | } 60 | 61 | super.mouseDown(theEvent) 62 | } 63 | 64 | 65 | // if there is a marked object, clone it and move it 66 | override func mouseDragged(theEvent: NSEvent) { 67 | 68 | if selection != nil { 69 | let mouse = self.convertPoint(theEvent.locationInWindow, fromView: self) 70 | var unPoint = unprojectPoint(SCNVector3(x: mouse.x, y: mouse.y, z: 0.0)) 71 | let p1 = selection!.node.parentNode!.convertPosition(unPoint, fromNode: nil) 72 | unPoint = unprojectPoint(SCNVector3(x: mouse.x, y: mouse.y, z: 1.0)) 73 | let p2 = selection!.node.parentNode!.convertPosition(unPoint, fromNode: nil) 74 | let m = p2 - p1 75 | 76 | let e = selection!.localCoordinates 77 | let n = selection!.localNormal 78 | 79 | let t = ((e * n) - (p1 * n)) / (m * n) 80 | var hit = SCNVector3(x: p1.x + t * m.x, y: p1.y + t * m.y, z: p1.z + t * m.z) 81 | let offset = hit - hitOld 82 | hitOld = hit 83 | 84 | if mark != nil { 85 | mark!.position = mark!.position + offset 86 | 87 | } else { 88 | mark = selection!.node.clone() as? SCNNode 89 | mark!.opacity = 0.333 90 | mark!.position = selection!.node.position 91 | selection!.node.parentNode!.addChildNode(mark!) 92 | } 93 | 94 | } else { 95 | super.mouseDragged(theEvent) 96 | } 97 | } 98 | 99 | 100 | // when the mouse button is released 101 | // + an object was marked 102 | // + the CRTL button is pressed 103 | // = copy the object (means: don't remove the cloned object) 104 | override func mouseUp(theEvent: NSEvent) { 105 | 106 | if selection != nil { 107 | 108 | if theEvent.modifierFlags == NSEventModifierFlags.ControlKeyMask { 109 | mark!.opacity = 1.0 110 | 111 | } else { 112 | selection!.node.position = selection!.node.convertPosition(mark!.position, fromNode: selection!.node) 113 | mark!.removeFromParentNode() 114 | } 115 | 116 | selection = nil 117 | mark = nil 118 | 119 | } else { 120 | super.mouseUp(theEvent) 121 | } 122 | } 123 | 124 | } -------------------------------------------------------------------------------- /SceneKit Swift Moving Objects/GameViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GameViewController.swift 3 | // SceneKit Swift Moving Objects 4 | // 5 | // Created by Manuel Wentenschuh on 21.Dec.14. 6 | // example code 7 | // 8 | 9 | import SceneKit 10 | 11 | 12 | class GameViewController: NSViewController { 13 | 14 | @IBOutlet weak var gameView: GameView! 15 | 16 | override func awakeFromNib(){ 17 | let scene = GameScene() 18 | self.gameView!.scene = scene 19 | self.gameView!.allowsCameraControl = true 20 | self.gameView!.showsStatistics = true 21 | self.gameView!.autoenablesDefaultLighting = true 22 | self.gameView!.backgroundColor = NSColor(calibratedRed: 0.15, green: 0.15, blue: 0.15, alpha: 1.0) 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /SceneKit Swift Moving Objects/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /SceneKit Swift Moving Objects/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | MW.$(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 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2014 example code 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /SceneKit Swift Moving ObjectsTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | MW.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SceneKit Swift Moving ObjectsTests/SceneKit_Swift_Moving_ObjectsTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneKit_Swift_Moving_ObjectsTests.swift 3 | // SceneKit Swift Moving ObjectsTests 4 | // 5 | // Created by Manuel W. on 21.12.14. 6 | // Copyright (c) 2014 example code by Manuel Wentenschuh. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import XCTest 11 | 12 | class SceneKit_Swift_Moving_ObjectsTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------