diff --git a/isgl3d.xcodeproj/project.pbxproj b/isgl3d.xcodeproj/project.pbxproj index c07e915..a7aea45 100644 --- a/isgl3d.xcodeproj/project.pbxproj +++ b/isgl3d.xcodeproj/project.pbxproj @@ -1396,6 +1396,33 @@ 8BDBA1D714CCFABE00BAEB8A /* PVRTShader.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BDBA1C714CCFABE00BAEB8A /* PVRTShader.h */; }; 8BDBA1D814CCFABE00BAEB8A /* PVRTTextureAPI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8BDBA1C814CCFABE00BAEB8A /* PVRTTextureAPI.cpp */; }; 8BDBA1D914CCFABE00BAEB8A /* PVRTTextureAPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BDBA1C914CCFABE00BAEB8A /* PVRTTextureAPI.h */; }; + 9B36749F14DEFBFC0086B496 /* NibDemo.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B36749414DEFBFB0086B496 /* NibDemo.h */; }; + 9B3674A014DEFBFC0086B496 /* NibDemo.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B36749514DEFBFC0086B496 /* NibDemo.m */; }; + 9B3674A714DEFBFC0086B496 /* TestViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B36749D14DEFBFC0086B496 /* TestViewController.h */; }; + 9B3674A814DEFBFC0086B496 /* TestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B36749E14DEFBFC0086B496 /* TestViewController.m */; }; + 9B3674B314DF017E0086B496 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17B7228312F8C8C000F80DFD /* UIKit.framework */; }; + 9B3674B414DF017E0086B496 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; + 9B3674B514DF017E0086B496 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17B7227D12F8C8C000F80DFD /* CoreGraphics.framework */; }; + 9B3674C914DF026C0086B496 /* NibDemo.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B36749514DEFBFC0086B496 /* NibDemo.m */; }; + 9B3674CA14DF026C0086B496 /* TestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B36749E14DEFBFC0086B496 /* TestViewController.m */; }; + 9B3674CB14DF026C0086B496 /* Isgl3dAppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1733546F13408C38000F26F0 /* Isgl3dAppDelegate.mm */; }; + 9B3674CC14DF026C0086B496 /* Isgl3dViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 17B720BF12F8BD7100F80DFD /* Isgl3dViewController.m */; }; + 9B3674CD14DF026C0086B496 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 17B71FE112F8B8F400F80DFD /* main.m */; }; + 9B3674CE14DF02920086B496 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17B7227F12F8C8C000F80DFD /* OpenGLES.framework */; }; + 9B3674CF14DF02B90086B496 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17B7228112F8C8C000F80DFD /* QuartzCore.framework */; }; + 9B3674D014DF02C20086B496 /* libisgl3d.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC07E0554694100DB518D /* libisgl3d.a */; }; + 9BC947A114DF03ED003F1FE6 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 175CD4DB13708A2100152EFE /* Default.png */; }; + 9BC947A214DF07C7003F1FE6 /* capture.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 17F7A8A012FA0EB800C7BB82 /* capture.fsh */; }; + 9BC947A314DF07C7003F1FE6 /* capture.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 17F7A8A112FA0EB800C7BB82 /* capture.vsh */; }; + 9BC947A414DF07C7003F1FE6 /* generic.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 17F7A8A212FA0EB800C7BB82 /* generic.fsh */; }; + 9BC947A514DF07C7003F1FE6 /* generic.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 17F7A8A312FA0EB800C7BB82 /* generic.vsh */; }; + 9BC947A614DF07C7003F1FE6 /* particle.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 17F7A8A412FA0EB800C7BB82 /* particle.fsh */; }; + 9BC947A714DF07C7003F1FE6 /* particle.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 17F7A8A512FA0EB800C7BB82 /* particle.vsh */; }; + 9BC947A814DF07C7003F1FE6 /* shadowMap.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 17F7A8A612FA0EB800C7BB82 /* shadowMap.fsh */; }; + 9BC947A914DF07C7003F1FE6 /* shadowMap.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 17F7A8A712FA0EB800C7BB82 /* shadowMap.vsh */; }; + 9BC947AA14DF07C7003F1FE6 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 175CD4DC13708A2100152EFE /* Icon.png */; }; + 9BC947AB14DF07C7003F1FE6 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 175CD4DD13708A2100152EFE /* Icon@2x.png */; }; + 9BDA587A14DF0A6E00DC1CCB /* TestView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9B36749C14DEFBFC0086B496 /* TestView.xib */; }; AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; /* End PBXBuildFile section */ @@ -1834,6 +1861,13 @@ remoteGlobalIDString = D2AAC07D0554694100DB518D; remoteInfo = isgl3d; }; + 9B3674C714DF01F50086B496 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = D2AAC07D0554694100DB518D; + remoteInfo = isgl3d; + }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -2647,6 +2681,12 @@ 8BDBA1C814CCFABE00BAEB8A /* PVRTTextureAPI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PVRTTextureAPI.cpp; sourceTree = ""; }; 8BDBA1C914CCFABE00BAEB8A /* PVRTTextureAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PVRTTextureAPI.h; sourceTree = ""; }; 8BDBA1DE14CD006200BAEB8A /* isgl3d-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "isgl3d-Prefix.pch"; sourceTree = ""; }; + 9B36749414DEFBFB0086B496 /* NibDemo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NibDemo.h; sourceTree = ""; }; + 9B36749514DEFBFC0086B496 /* NibDemo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NibDemo.m; sourceTree = ""; }; + 9B36749C14DEFBFC0086B496 /* TestView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TestView.xib; sourceTree = ""; }; + 9B36749D14DEFBFC0086B496 /* TestViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestViewController.h; sourceTree = ""; }; + 9B36749E14DEFBFC0086B496 /* TestViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestViewController.m; sourceTree = ""; }; + 9B3674B114DF017E0086B496 /* NibDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NibDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; D2AAC07E0554694100DB518D /* libisgl3d.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libisgl3d.a; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -3073,6 +3113,19 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 9B3674AE14DF017E0086B496 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B3674D014DF02C20086B496 /* libisgl3d.a in Frameworks */, + 9B3674CF14DF02B90086B496 /* QuartzCore.framework in Frameworks */, + 9B3674CE14DF02920086B496 /* OpenGLES.framework in Frameworks */, + 9B3674B314DF017E0086B496 /* UIKit.framework in Frameworks */, + 9B3674B414DF017E0086B496 /* Foundation.framework in Frameworks */, + 9B3674B514DF017E0086B496 /* CoreGraphics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; D2AAC07C0554694100DB518D /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -3122,6 +3175,7 @@ 17A481CE13F129880098AC3F /* ShaderMaterialDemo.app */, 17D0776413F4A643003F6E46 /* ActionsDemo.app */, 17C2F0D613F6CCEE0002C7D3 /* GesturesDemo.app */, + 9B3674B114DF017E0086B496 /* NibDemo.app */, ); name = Products; sourceTree = ""; @@ -3678,6 +3732,7 @@ 1731240412FD62B200861D84 /* ui */ = { isa = PBXGroup; children = ( + 9B36749314DEFBFB0086B496 /* nib */, 1731240512FD62B200861D84 /* UITestView.h */, 1731240612FD62B200861D84 /* UITestView.m */, ); @@ -4473,6 +4528,18 @@ path = OGLES2; sourceTree = ""; }; + 9B36749314DEFBFB0086B496 /* nib */ = { + isa = PBXGroup; + children = ( + 9B36749414DEFBFB0086B496 /* NibDemo.h */, + 9B36749514DEFBFC0086B496 /* NibDemo.m */, + 9B36749C14DEFBFC0086B496 /* TestView.xib */, + 9B36749D14DEFBFC0086B496 /* TestViewController.h */, + 9B36749E14DEFBFC0086B496 /* TestViewController.m */, + ); + path = nib; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -4481,6 +4548,8 @@ buildActionMask = 2147483647; files = ( 17EDE05D13743C0A00652E35 /* Isgl3dGLView.h in Headers */, + 9B36749F14DEFBFC0086B496 /* NibDemo.h in Headers */, + 9B3674A714DEFBFC0086B496 /* TestViewController.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5473,6 +5542,24 @@ productReference = 17F7A88412FA0D6100C7BB82 /* Lighting.app */; productType = "com.apple.product-type.application"; }; + 9B3674B014DF017E0086B496 /* NibDemo */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9B3674C214DF017F0086B496 /* Build configuration list for PBXNativeTarget "NibDemo" */; + buildPhases = ( + 9B3674AD14DF017E0086B496 /* Sources */, + 9B3674AE14DF017E0086B496 /* Frameworks */, + 9B3674AF14DF017E0086B496 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 9B3674C814DF01F50086B496 /* PBXTargetDependency */, + ); + name = NibDemo; + productName = NibDemo; + productReference = 9B3674B114DF017E0086B496 /* NibDemo.app */; + productType = "com.apple.product-type.application"; + }; D2AAC07D0554694100DB518D /* isgl3d */ = { isa = PBXNativeTarget; buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "isgl3d" */; @@ -5507,6 +5594,7 @@ Japanese, French, German, + en, ); mainGroup = 0867D691FE84028FC02AAC07 /* isgl3d */; productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; @@ -5547,6 +5635,7 @@ 17A481AD13F129880098AC3F /* ShaderMaterialDemo */, 17D0774313F4A643003F6E46 /* ActionsDemo */, 17C2F0B513F6CCEE0002C7D3 /* GesturesDemo */, + 9B3674B014DF017E0086B496 /* NibDemo */, ); }; /* End PBXProject section */ @@ -6197,6 +6286,25 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 9B3674AF14DF017E0086B496 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9BDA587A14DF0A6E00DC1CCB /* TestView.xib in Resources */, + 9BC947A214DF07C7003F1FE6 /* capture.fsh in Resources */, + 9BC947A314DF07C7003F1FE6 /* capture.vsh in Resources */, + 9BC947A414DF07C7003F1FE6 /* generic.fsh in Resources */, + 9BC947A514DF07C7003F1FE6 /* generic.vsh in Resources */, + 9BC947A614DF07C7003F1FE6 /* particle.fsh in Resources */, + 9BC947A714DF07C7003F1FE6 /* particle.vsh in Resources */, + 9BC947A814DF07C7003F1FE6 /* shadowMap.fsh in Resources */, + 9BC947A914DF07C7003F1FE6 /* shadowMap.vsh in Resources */, + 9BC947AA14DF07C7003F1FE6 /* Icon.png in Resources */, + 9BC947AB14DF07C7003F1FE6 /* Icon@2x.png in Resources */, + 9BC947A114DF03ED003F1FE6 /* Default.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -6459,6 +6567,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9B3674A014DEFBFC0086B496 /* NibDemo.m in Sources */, + 9B3674A814DEFBFC0086B496 /* TestViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -6696,6 +6806,18 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 9B3674AD14DF017E0086B496 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B3674C914DF026C0086B496 /* NibDemo.m in Sources */, + 9B3674CA14DF026C0086B496 /* TestViewController.m in Sources */, + 9B3674CB14DF026C0086B496 /* Isgl3dAppDelegate.mm in Sources */, + 9B3674CC14DF026C0086B496 /* Isgl3dViewController.m in Sources */, + 9B3674CD14DF026C0086B496 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; D2AAC07B0554694100DB518D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -7171,6 +7293,11 @@ target = D2AAC07D0554694100DB518D /* isgl3d */; targetProxy = 17F7A87212FA0D6100C7BB82 /* PBXContainerItemProxy */; }; + 9B3674C814DF01F50086B496 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = D2AAC07D0554694100DB518D /* isgl3d */; + targetProxy = 9B3674C714DF01F50086B496 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -8801,6 +8928,46 @@ }; name = Release; }; + 9B3674C314DF017F0086B496 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + INFOPLIST_FILE = Resources/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 4.3; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 9B3674C414DF017F0086B496 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + INFOPLIST_FILE = Resources/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 4.3; + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -9119,6 +9286,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 9B3674C214DF017F0086B496 /* Build configuration list for PBXNativeTarget "NibDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9B3674C314DF017F0086B496 /* Debug */, + 9B3674C414DF017F0086B496 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 0867D690FE84028FC02AAC07 /* Project object */; diff --git a/isgl3d.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/isgl3d.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..b827f98 --- /dev/null +++ b/isgl3d.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/isgl3d.xcodeproj/project.xcworkspace/xcuserdata/rudi.xcuserdatad/UserInterfaceState.xcuserstate b/isgl3d.xcodeproj/project.xcworkspace/xcuserdata/rudi.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..7d02d3f Binary files /dev/null and b/isgl3d.xcodeproj/project.xcworkspace/xcuserdata/rudi.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/isgl3d/actions/Isgl3dActionMove.m b/isgl3d/actions/Isgl3dActionMove.m index 1dd54d2..524b462 100644 --- a/isgl3d/actions/Isgl3dActionMove.m +++ b/isgl3d/actions/Isgl3dActionMove.m @@ -64,7 +64,7 @@ -(void) startWithTarget:(id)target { } - (void) update:(float)progress { - [_target setPosition:iv3(_initialPosition.x + progress * _vector.x, _initialPosition.y + progress * _vector.y, _initialPosition.z + progress * _vector.z)]; + [(Isgl3dNode*)_target setPosition:iv3(_initialPosition.x + progress * _vector.x, _initialPosition.y + progress * _vector.y, _initialPosition.z + progress * _vector.z)]; } @end @@ -102,7 +102,7 @@ -(void) startWithTarget:(id)target { } - (void) update:(float)progress { - [_target setPosition:iv3(_initialPosition.x + progress * _vector.x, _initialPosition.y + progress * _vector.y, _initialPosition.z + progress * _vector.z)]; + [(Isgl3dNode*)_target setPosition:iv3(_initialPosition.x + progress * _vector.x, _initialPosition.y + progress * _vector.y, _initialPosition.z + progress * _vector.z)]; } @end @@ -135,7 +135,7 @@ - (id) copyWithZone:(NSZone*)zone { } - (void) update:(float)progress { - [_target setPosition:_finalPosition]; + [(Isgl3dNode*)_target setPosition:_finalPosition]; } @end diff --git a/isgl3d/core/Isgl3dDirector.h b/isgl3d/core/Isgl3dDirector.h index f84e7c3..9f32939 100644 --- a/isgl3d/core/Isgl3dDirector.h +++ b/isgl3d/core/Isgl3dDirector.h @@ -255,6 +255,12 @@ @property (nonatomic) BOOL antiAliasingEnabled; +/** + * Returns the assigned views of the instance. + */ +@property (nonatomic, readonly) NSMutableArray * views; + + /** * Returns the singleton instance of the Isgl3dDirector. * @return The singleton instance of the Isgl3dDirector. diff --git a/isgl3d/core/Isgl3dDirector.m b/isgl3d/core/Isgl3dDirector.m index ce423eb..f8216a3 100644 --- a/isgl3d/core/Isgl3dDirector.m +++ b/isgl3d/core/Isgl3dDirector.m @@ -73,6 +73,8 @@ @implementation Isgl3dDirector @synthesize renderPhaseCallback = _renderPhaseCallback; @synthesize gestureManager = _gestureManager; +@synthesize views = _views; + - (id) init { NSLog(@"Isgl3dDirector::init should not be called on singleton. Instance should be accessed via sharedInstance"); @@ -226,19 +228,19 @@ - (void) setDeviceOrientation:(isgl3dOrientation)orientation { if (orientation != _deviceOrientation) { _deviceOrientation = orientation; if (_deviceOrientation == Isgl3dOrientation0) { - [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO]; + [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationPortrait animated:NO]; Isgl3dLog(Info, @"Isgl3dDirector : setting device orientation to portrait"); } else if (_deviceOrientation == Isgl3dOrientation180) { - [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortraitUpsideDown animated:NO]; + [[UIApplication sharedApplication] setStatusBarOrientation: (UIInterfaceOrientation)UIDeviceOrientationPortraitUpsideDown animated:NO]; Isgl3dLog(Info, @"Isgl3dDirector : setting device orientation to portrait upside down"); } else if (_deviceOrientation == Isgl3dOrientation90CounterClockwise) { - [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; + [[UIApplication sharedApplication] setStatusBarOrientation: (UIInterfaceOrientation)UIDeviceOrientationLandscapeLeft animated:NO]; Isgl3dLog(Info, @"Isgl3dDirector : setting device orientation to landscape left"); } else if (_deviceOrientation == Isgl3dOrientation90Clockwise) { - [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO]; + [[UIApplication sharedApplication] setStatusBarOrientation: (UIInterfaceOrientation)UIDeviceOrientationLandscapeRight animated:NO]; Isgl3dLog(Info, @"Isgl3dDirector : setting device orientation to landscape right"); } else { diff --git a/isgl3d/core/Isgl3dGLMesh.m b/isgl3d/core/Isgl3dGLMesh.m index 91362d6..c43fb9a 100644 --- a/isgl3d/core/Isgl3dGLMesh.m +++ b/isgl3d/core/Isgl3dGLMesh.m @@ -108,7 +108,7 @@ - (void) setVertexData:(unsigned char *)vertexData withSize:(unsigned int)vertex free(_vertexData); } - _vertexData = malloc(vertexDataSize); + _vertexData = (unsigned char*)malloc(vertexDataSize); memcpy(_vertexData, vertexData, vertexDataSize); _vertexDataSize = vertexDataSize; } @@ -122,7 +122,7 @@ - (void) setIndices:(unsigned char *)indices withSize:(unsigned int)indexDataSiz free(_indices); } - _indices = malloc(indexDataSize); + _indices = (unsigned char*)malloc(indexDataSize); memcpy(_indices, indices, indexDataSize); _indexDataSize = indexDataSize; _numberOfElements = numberOfElements; @@ -160,7 +160,7 @@ - (void) setVertices:(unsigned char *)vertexData withVertexDataSize:(unsigned in free(_vertexData); } - _vertexData = malloc(vertexDataSize); + _vertexData = (unsigned char*)malloc(vertexDataSize); memcpy(_vertexData, vertexData, vertexDataSize); _vertexDataSize = vertexDataSize; @@ -169,7 +169,7 @@ - (void) setVertices:(unsigned char *)vertexData withVertexDataSize:(unsigned in free(_indices); } - _indices = malloc(indexDataSize); + _indices = (unsigned char*)malloc(indexDataSize); memcpy(_indices, indices, indexDataSize); _indexDataSize = indexDataSize; _numberOfElements = numberOfElements; diff --git a/isgl3d/core/Isgl3dGLTextureFactory.m b/isgl3d/core/Isgl3dGLTextureFactory.m index d9ef7d4..99c58b9 100644 --- a/isgl3d/core/Isgl3dGLTextureFactory.m +++ b/isgl3d/core/Isgl3dGLTextureFactory.m @@ -376,17 +376,17 @@ - (Isgl3dGLTexture *) createCubemapTextureFromFiles:(NSArray *)files precision:( void * data = malloc(stride * 6); unsigned int offset = 0; - [self copyImage:posXImage toRawData:data + offset width:width height:height]; + [self copyImage:posXImage toRawData:(char*)data + offset width:width height:height]; offset += stride; - [self copyImage:negXImage toRawData:data + offset width:width height:height]; + [self copyImage:negXImage toRawData:(char*)data + offset width:width height:height]; offset += stride; - [self copyImage:posYImage toRawData:data + offset width:width height:height]; + [self copyImage:posYImage toRawData:(char*)data + offset width:width height:height]; offset += stride; - [self copyImage:negYImage toRawData:data + offset width:width height:height]; + [self copyImage:negYImage toRawData:(char*)data + offset width:width height:height]; offset += stride; - [self copyImage:posZImage toRawData:data + offset width:width height:height]; + [self copyImage:posZImage toRawData:(char*)data + offset width:width height:height]; offset += stride; - [self copyImage:negZImage toRawData:data + offset width:width height:height]; + [self copyImage:negZImage toRawData:(char*)data + offset width:width height:height]; unsigned int textureId = [_state createCubemapTextureFromRawData:data width:width mipmap:YES precision:precision repeatX:repeatX repeatY:repeatY]; @@ -491,8 +491,9 @@ - (BOOL) imageIsHD:(NSString *)path { NSString * extension = [path pathExtension]; NSString * origFileName = [path stringByDeletingPathExtension]; + NSString * fileName = origFileName; if ([Isgl3dDirector sharedInstance].retinaDisplayEnabled) { - NSString *fileName = [origFileName stringByAppendingString:@"-hd"]; + fileName = [origFileName stringByAppendingString:@"-hd"]; NSString * filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:extension]; if (filePath && [[NSFileManager defaultManager] fileExistsAtPath:filePath]) { diff --git a/isgl3d/core/v2.0/Isgl3dGLTextureFactoryState2.m b/isgl3d/core/v2.0/Isgl3dGLTextureFactoryState2.m index 4d6f1fd..4ab7798 100644 --- a/isgl3d/core/v2.0/Isgl3dGLTextureFactoryState2.m +++ b/isgl3d/core/v2.0/Isgl3dGLTextureFactoryState2.m @@ -124,17 +124,17 @@ - (unsigned int) createCubemapTextureFromRawData:(void *)data width:(int)width m unsigned int stride = width * width * 4; unsigned int offset = 0; - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, data + offset); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, (char*)data + offset); offset += stride; - glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, data + offset); + glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, (char*)data + offset); offset += stride; - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, data + offset); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, (char*)data + offset); offset += stride; - glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, data + offset); + glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, (char*)data + offset); offset += stride; - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, data + offset); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, (char*)data + offset); offset += stride; - glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, data + offset); + glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, (char*)data + offset); [self handleParameters:GL_TEXTURE_CUBE_MAP precision:precision repeatX:repeatX repeatY:repeatY]; diff --git a/isgl3d/importers/Isgl3dPODImporter.h b/isgl3d/importers/Isgl3dPODImporter.h index d690912..9e7dcf8 100644 --- a/isgl3d/importers/Isgl3dPODImporter.h +++ b/isgl3d/importers/Isgl3dPODImporter.h @@ -88,6 +88,8 @@ class CPVRTModelPOD; BOOL _meshesAndMaterialsComplete; } +@property CPVRTModelPOD* podScene; + /** * Allocates and initialises (autorelease) importer with the POD data file path. * @param path The path to the POD data file. @@ -129,6 +131,10 @@ class CPVRTModelPOD; */ - (unsigned int) numberOfFrames; +- (unsigned int) numberOfTextures; + +- (NSString*) nameOfTexture:(unsigned int)index; + /** * Builds all the scene objects in the POD file without adding them to the scene. The POD objects can * then be used afterwards by retreiving them with the necessary accessors. @@ -178,6 +184,16 @@ class CPVRTModelPOD; */ - (Isgl3dMeshNode *) meshNodeWithName:(NSString *)nodeName; + +/** + * Returns the Isgl3dMeshNode corresponding to a node index (as defined in the POD file). + * All node indices can be obtained via printPODInfo. + * @param meshNodeIndex the index of the node as defined in the POD file. + * @return The Corresponding Isgl3dMeshNode. + */ +- (Isgl3dMeshNode *) meshNodeAtIndex:(unsigned int)meshNodeIndex; + + /** * Returns the Isgl3dMaterial corresponding to a material name (as defined in the POD file). * All material names can be obtained via printPODInfo. @@ -186,6 +202,14 @@ class CPVRTModelPOD; */ - (Isgl3dMaterial *) materialWithName:(NSString *)materialName; + +/** + * Get the indexed material. + * @param materialIndex the index of the material. + * @return The Corresponding Isgl3dMaterial. + */ +- (Isgl3dMaterial *) materialWithIndex:(unsigned int)materialIndex; + /** * Returns the Isgl3dCamera corresponding to a camera index (as defined in the POD file). * All camera indices can be obtained via printPODInfo. diff --git a/isgl3d/importers/Isgl3dPODImporter.mm b/isgl3d/importers/Isgl3dPODImporter.mm index 11d5621..2875d9f 100644 --- a/isgl3d/importers/Isgl3dPODImporter.mm +++ b/isgl3d/importers/Isgl3dPODImporter.mm @@ -39,6 +39,8 @@ #import "isgl3dArray.h" #import "Isgl3dLog.h" +#include "PVRTTrans.h" + @interface Isgl3dPODImporter (PrivateMethods) /** @@ -65,6 +67,8 @@ - (void) buildMeshNodes; @implementation Isgl3dPODImporter +@synthesize podScene = _podScene; + + (id) podImporterWithFile:(NSString *)path { return [[[self alloc] initWithFile:path] autorelease]; } @@ -216,6 +220,21 @@ - (unsigned int) numberOfFrames { return _podScene->nNumFrame; } +- (unsigned int) numberOfTextures +{ + return _podScene->nNumTexture; +} + +- (NSString*) nameOfTexture:(unsigned int)index +{ + if (index >= _podScene->nNumTexture) { + return nil; + } + + SPODTexture & textureInfo = _podScene->pTexture[index]; + NSString * textureFileName = [NSString stringWithUTF8String:textureInfo.pszName]; + return textureFileName; +} - (void) addMeshesToScene:(Isgl3dNode *)scene { @@ -229,7 +248,7 @@ - (void) addMeshesToScene:(Isgl3dNode *)scene { for (int i = 0; i < _podScene->nNumMeshNode; i++) { SPODNode & nodeInfo = _podScene->pNode[i]; - NSLog(@"Adding node: %s:", nodeInfo.pszName); + NSLog(@"Adding node: %s: parent index:%i", nodeInfo.pszName, nodeInfo.nIdxParent); Isgl3dNode * node = [_meshNodes objectForKey:[NSString stringWithUTF8String:nodeInfo.pszName]]; @@ -240,6 +259,8 @@ - (void) addMeshesToScene:(Isgl3dNode *)scene { if (parent) { [parent addChild:node]; + if([scene.children containsObject:parent] == FALSE) + [scene addChild:parent]; } else { } } @@ -259,6 +280,15 @@ - (Isgl3dMeshNode *) meshNodeWithName:(NSString *)nodeName { return node; } +- (Isgl3dMeshNode *) meshNodeAtIndex:(unsigned int)meshNodeIndex { + if (meshNodeIndex >= _podScene->nNumMeshNode) { + NSLog(@"Mesh at index %i not available: POD scene contains %i meshses", meshNodeIndex, _podScene->nNumMeshNode); + return nil; + } + return [_meshNodes.allValues objectAtIndex:meshNodeIndex]; +} + + - (Isgl3dGLMesh *) meshFromNodeWithName:(NSString *)nodeName { Isgl3dMeshNode * meshNode = [self meshNodeWithName:nodeName]; if (meshNode) { @@ -298,6 +328,22 @@ - (Isgl3dMaterial *) materialWithName:(NSString *)materialName { } + +- (Isgl3dMaterial *) materialWithIndex:(unsigned int)materialIndex { + Isgl3dMaterial * material; + + if (materialIndex < [_materials count]) { + material = [_materials objectAtIndex:materialIndex]; + } + + if (!material) { + NSLog(@"Unable to find material with index: %i", materialIndex); + } + return material; +} + + + - (Isgl3dCamera *) cameraAtIndex:(unsigned int)cameraIndex { if (!_buildSceneObjectsComplete) { [self buildSceneObjects]; @@ -427,7 +473,15 @@ - (void) buildMeshesAndMaterials { if (!materialInfo.pszEffectFile) { if (materialInfo.nIdxTexDiffuse >= 0 && materialInfo.nIdxTexDiffuse < [_textures count]) { NSString * textureFileName = [_textures objectAtIndex:materialInfo.nIdxTexDiffuse]; - + + NSFileManager *fileManager = [[NSFileManager alloc] init]; + BOOL exists = [fileManager fileExistsAtPath:textureFileName]; + if (!exists) { + textureFileName = [NSString stringWithFormat:@"%@/%@", [_podPath stringByDeletingLastPathComponent], textureFileName]; + exists = [fileManager fileExistsAtPath:textureFileName]; + } + [fileManager release]; + material = [Isgl3dTextureMaterial materialWithTextureFile:textureFileName shininess:0 precision:Isgl3dTexturePrecisionMedium repeatX:YES repeatY:YES]; } else { @@ -556,6 +610,7 @@ - (void) buildMeshNodes { [_meshNodes setObject:node forKey:[NSString stringWithUTF8String:meshNodeInfo.pszName]]; } + NSLog(@"IndexedNode mesh node: %s: index:%i", meshNodeInfo.pszName, meshNodeInfo.nIdx); [_indexedNodes setObject:node forKey:[NSNumber numberWithInteger:meshNodeInfo.nIdx]]; // Add node alpha @@ -574,12 +629,20 @@ - (void) buildMeshNodes { // Create all non-mesh nodes for (int i = 0; i < _podScene->nNumNode; i++) { SPODNode & nodeInfo = _podScene->pNode[i]; + NSLog(@"Node mesh node: %s: index:%i parent:%i", nodeInfo.pszName, nodeInfo.nIdx, nodeInfo.nIdxParent); // See if node already exists as a mesh node, otherise create simple node if (![_indexedNodes objectForKey:[NSNumber numberWithInteger:nodeInfo.nIdx]]) { Isgl3dNode * node = [Isgl3dNode node]; + NSLog(@"Additional IndexedNode mesh node: %s: index:%i", nodeInfo.pszName, nodeInfo.nIdx); [_indexedNodes setObject:node forKey:[NSNumber numberWithInteger:nodeInfo.nIdx]]; - } + } else if (nodeInfo.nIdxParent != -1 && ![_indexedNodes objectForKey:[NSNumber numberWithInteger:nodeInfo.nIdxParent]]) + { + // add the parent node + Isgl3dNode * node = [Isgl3dNode node]; + NSLog(@"Additional IndexedNode mesh node: %s: parent index:%i", nodeInfo.pszName, nodeInfo.nIdxParent); + [_indexedNodes setObject:node forKey:[NSNumber numberWithInteger:nodeInfo.nIdxParent]]; + } } diff --git a/isgl3d/math/Isgl3dMatrix.h b/isgl3d/math/Isgl3dMatrix.h index e0ae83a..8b3955d 100644 --- a/isgl3d/math/Isgl3dMatrix.h +++ b/isgl3d/math/Isgl3dMatrix.h @@ -39,10 +39,10 @@ #pragma mark - GLKit compatible definitions # -#define Isgl3dMatrix4Transpose GLKitMatrix4Transpose -#define Isgl3dMatrix4Multiply GLKitMatrix4Multiply -#define Isgl3dMatrix4Add GLKitMatrix4Add -#define Isgl3dMatrix4Subtract GLKitMatrix4Subtract +#define Isgl3dMatrix4Transpose GLKMatrix4Transpose +#define Isgl3dMatrix4Multiply GLKMatrix4Multiply +#define Isgl3dMatrix4Add GLKMatrix4Add +#define Isgl3dMatrix4Subtract GLKMatrix4Subtract #else diff --git a/isgl3d/primitives/Isgl3dPlane.m b/isgl3d/primitives/Isgl3dPlane.m index 2b3a319..e5110b6 100644 --- a/isgl3d/primitives/Isgl3dPlane.m +++ b/isgl3d/primitives/Isgl3dPlane.m @@ -41,7 +41,7 @@ + (id) meshWithGeometry:(float)width height:(float)height nx:(int)nx ny:(int)ny return [[[self alloc] initWithGeometry:width height:height nx:nx ny:ny] autorelease]; } -+ (id) meshWithGeometryAndUVMap:(float)width height:(float)height nx:(int)nx ny:(int)ny uvMap:(Isgl3dUVMap *)uvMap { ++ (id) meshWithGeometryAndUVMap:(float)width height:(float)height nx:(int)nx ny:(int)ny uvMap:(const Isgl3dUVMap *)uvMap { return [[[self alloc] initWithGeometryAndUVMap:width height:height nx:nx ny:ny uvMap:uvMap] autorelease]; } @@ -54,7 +54,7 @@ - (id) initWithGeometry:(float)width height:(float)height nx:(int)nx ny:(int)ny return self; } -- (id) initWithGeometryAndUVMap:(float)width height:(float)height nx:(int)nx ny:(int)ny uvMap:(Isgl3dUVMap *)uvMap { +- (id) initWithGeometryAndUVMap:(float)width height:(float)height nx:(int)nx ny:(int)ny uvMap:(const Isgl3dUVMap *)uvMap { if ((self = [super init])) { _width = width; _height = height; @@ -62,9 +62,9 @@ - (id) initWithGeometryAndUVMap:(float)width height:(float)height nx:(int)nx ny: _ny = ny; if (uvMap) { - _uvMap = [uvMap retain]; + _uvMap = (Isgl3dUVMap*)[uvMap retain]; } else { - _uvMap = [[Isgl3dUVMap standardUVMap] retain]; + _uvMap = (Isgl3dUVMap*)[[Isgl3dUVMap standardUVMap] retain]; } [self constructVBOData]; diff --git a/isgl3d/primitives/Isgl3dTerrainMesh.m b/isgl3d/primitives/Isgl3dTerrainMesh.m index b276d1f..1e42b2a 100644 --- a/isgl3d/primitives/Isgl3dTerrainMesh.m +++ b/isgl3d/primitives/Isgl3dTerrainMesh.m @@ -73,7 +73,7 @@ - (void) fillVertexData:(Isgl3dFloatArray *)vertexData andIndices:(Isgl3dUShortA // Get raw data from image unsigned int imageWidth = terrainDataImage.size.width; unsigned int imageHeight = terrainDataImage.size.height; - unsigned char * pixelData = malloc(imageWidth * imageHeight * 4); + unsigned char * pixelData = (unsigned char*)(malloc(imageWidth * imageHeight * 4)); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(pixelData, imageWidth, imageHeight, 8, imageWidth * 4, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); @@ -86,7 +86,7 @@ - (void) fillVertexData:(Isgl3dFloatArray *)vertexData andIndices:(Isgl3dUShortA unsigned int heightDataNx = _nx + 1; unsigned int heightDataNy = _nz + 1; - float * terrainHeightData = malloc(heightDataNx * heightDataNy * sizeof(float)); + float * terrainHeightData = (float*)(malloc(heightDataNx * heightDataNy * sizeof(float))); // Iterate once to get all terrain data needed in a simple array for (int j = 0; j <= _nz; j++) { diff --git a/isgl3d/view/Isgl3dView.m b/isgl3d/view/Isgl3dView.m index fa7f81d..b6d2233 100644 --- a/isgl3d/view/Isgl3dView.m +++ b/isgl3d/view/Isgl3dView.m @@ -74,8 +74,7 @@ - (id) init { self.backgroundColorString = [Isgl3dDirector sharedInstance].backgroundColorString; - _isEventCaptureEnabled = YES; - + _isEventCaptureEnabled = YES; _sceneAmbient = @"333333ff"; } @@ -137,7 +136,7 @@ - (isgl3dOrientation) viewOrientation { - (void) setViewOrientation:(isgl3dOrientation)orientation { _viewOrientation = orientation; - _deviceViewOrientation = ([Isgl3dDirector sharedInstance].deviceOrientation - _viewOrientation) % 4; + _deviceViewOrientation = (isgl3dOrientation)(([Isgl3dDirector sharedInstance].deviceOrientation - _viewOrientation) % 4); // Update camera orientation if (_camera) { diff --git a/tests/Isgl3dAppDelegate.h b/tests/Isgl3dAppDelegate.h index 21e97b4..9dbcc88 100644 --- a/tests/Isgl3dAppDelegate.h +++ b/tests/Isgl3dAppDelegate.h @@ -33,6 +33,7 @@ } @property (nonatomic, retain) UIWindow * window; +@property (nonatomic, retain) Isgl3dViewController * viewController; - (void) createViews; diff --git a/tests/Isgl3dAppDelegate.mm b/tests/Isgl3dAppDelegate.mm index 572fcba..b85cfab 100644 --- a/tests/Isgl3dAppDelegate.mm +++ b/tests/Isgl3dAppDelegate.mm @@ -23,13 +23,15 @@ * */ +#import "Isgl3d.h" #import "Isgl3dAppDelegate.h" #import "Isgl3dViewController.h" -#import "Isgl3d.h" + @implementation Isgl3dAppDelegate @synthesize window = _window; +@synthesize viewController = _viewController; - (void) applicationDidFinishLaunching:(UIApplication*)application { diff --git a/tests/ui/nib/NibDemo.h b/tests/ui/nib/NibDemo.h new file mode 100644 index 0000000..4ed1a4a --- /dev/null +++ b/tests/ui/nib/NibDemo.h @@ -0,0 +1,64 @@ +/* + * iSGL3D: http://isgl3d.com + * + * Copyright (c) 2010-2011 Stuart Caunt + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#import "isgl3d.h" + +@class Isgl3dDemoCameraController; + +@interface UIHUDView : Isgl3dBasic2DView { +} + +@end + + +@interface NibDemo : Isgl3dBasic3DView { + +@private + Isgl3dMultiMaterialCube * _cube; +} + +@end + + +/* + * Principal class to be instantiated in main.h. + */ +#import "Isgl3dAppDelegate.h" + +@class TestViewController; + +@interface AppDelegate : Isgl3dAppDelegate +{ +@private + TestViewController* _testViewController; +} + +@property (nonatomic, retain) TestViewController *testViewController; + + +- (void) switchViews; +@end + + diff --git a/tests/ui/nib/NibDemo.m b/tests/ui/nib/NibDemo.m new file mode 100644 index 0000000..ed13c26 --- /dev/null +++ b/tests/ui/nib/NibDemo.m @@ -0,0 +1,210 @@ +/* + * iSGL3D: http://isgl3d.com + * + * Copyright (c) 2010-2011 Stuart Caunt + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#import "NibDemo.h" +#import "TestViewController.h" +#import "Isgl3dViewController.h" + + +#pragma mark UIHUDView + +@implementation UIHUDView + +- (id) init { + + if ((self = [super init])) { + Isgl3dGLUIButton * button = [Isgl3dGLUIButton buttonWithMaterial:nil]; + [self.scene addChild:button]; + [button setX:8 andY:self.viewport.size.height/2]; + [button addEvent3DListener:self method:@selector(buttonPressed:) forEventType:TOUCH_EVENT]; + + } + + return self; +} + +- (void) dealloc { + + [super dealloc]; +} + +- (void) buttonPressed:(Isgl3dEvent3D *)event { + NSLog(@"Button pressed"); + AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; + if (appDelegate) { + [appDelegate switchViews]; + } +} + + +@end + + +#pragma mark NibDemoe + +@implementation NibDemo + +- (id) init { + + + if ((self = [super init])) { + + // Translate the camera. + [self.camera setPosition:iv3(0, 3, 7)]; + + // Create an Isgl3dMultiMaterialCube with random colors. + _cube = [Isgl3dMultiMaterialCube cubeWithDimensionsAndRandomColors:3 height:3 depth:3 nSegmentWidth:2 nSegmentHeight:2 nSegmentDepth:2]; + + // Add the cube to the scene. + [self.scene addChild:_cube]; + + [self schedule:@selector(tick:)]; + } + + + return self; +} + +- (void) dealloc { + [super dealloc]; +} + + +- (void) tick:(float)dt { + // Rotate the cube around the y axis + _cube.rotationY += 1; + +} + + +@end + + + +#pragma mark AppDelegate + +@implementation AppDelegate + +@synthesize testViewController = _testViewController; + + +- (void) applicationDidFinishLaunching:(UIApplication*)application { + + // Instantiate the Isgl3dDirector and set background color + [Isgl3dDirector sharedInstance].backgroundColorString = @"333333ff"; + + // Set the device orientation + [Isgl3dDirector sharedInstance].deviceOrientation = Isgl3dOrientationLandscapeLeft; + + // Set the director to display the FPS + [Isgl3dDirector sharedInstance].displayFPS = YES; + + + // Specify auto-rotation strategy if required (for example via the UIViewController and only landscape) + [Isgl3dDirector sharedInstance].autoRotationStrategy = Isgl3dAutoRotationByUIViewController; + [Isgl3dDirector sharedInstance].allowedAutoRotations = Isgl3dAllowedAutoRotationsLandscapeOnly; + + // Enable retina display : uncomment if desired + // [[Isgl3dDirector sharedInstance] enableRetinaDisplay:YES]; + + // Enables anti aliasing (MSAA) : uncomment if desired (note may not be available on all devices and can have performance cost) + // [Isgl3dDirector sharedInstance].antiAliasingEnabled = YES; + + // Set the animation frame rate + [[Isgl3dDirector sharedInstance] setAnimationInterval:1.0/60]; + + + // Create the UIWindow + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + + + // Create the controller with the provided nib file TestView.xib + self.testViewController = [[TestViewController alloc] initWithNibName:@"TestView" bundle:nil]; + self.testViewController.wantsFullScreenLayout = YES; + // Add the view of the controller to the window and make it visible + [self.window addSubview:self.testViewController.view]; + [self.window makeKeyAndVisible]; + + + // Run the director + [[Isgl3dDirector sharedInstance] run]; +} + + +- (void) dealloc { + [_testViewController release]; + [super dealloc]; +} + + + + +/** A very simple method to show how interaction between a isgl3d and + * a UIViewController can be implemented. This method just switch between + * the TestViewController and the UIViewController that has the Isgl3dEAGLView instance + * assigned. + */ +- (void) switchViews +{ + if (self.viewController == nil || self.viewController.view.superview == nil) { + [self.testViewController.view removeFromSuperview]; + + if (!self.viewController) + { + // Create the UIViewController + self.viewController = [[Isgl3dViewController alloc] initWithNibName:nil bundle:nil]; + self.viewController.wantsFullScreenLayout = YES; + + // Create OpenGL view (here for OpenGL ES 1.1) + Isgl3dEAGLView * glView = [Isgl3dEAGLView viewWithFrameForES1:[self.window bounds]]; + + // Set view in director + [Isgl3dDirector sharedInstance].openGLView = glView; + + // Add the OpenGL view to the view controller + self.viewController.view = glView; + + // Creates the view and adds them to the director + [[Isgl3dDirector sharedInstance] addView:[NibDemo view]]; + + // Create UI and add to Isgl3dDirector + Isgl3dView * ui = [UIHUDView view]; + [[Isgl3dDirector sharedInstance] addView:ui]; + } + [self.window addSubview:self.viewController.view]; + [self.window bringSubviewToFront:self.viewController.view]; + + + } else + { + [self.viewController.view removeFromSuperview]; + + [self.window addSubview:self.testViewController.view]; + [self.window bringSubviewToFront:self.testViewController.view]; + } +} + + +@end diff --git a/tests/ui/nib/TestView.xib b/tests/ui/nib/TestView.xib new file mode 100644 index 0000000..96454f5 --- /dev/null +++ b/tests/ui/nib/TestView.xib @@ -0,0 +1,189 @@ + + + + 1280 + 11D50b + 1938 + 1138.32 + 568.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 933 + + + IBProxyObject + IBUIView + IBUIButton + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + + + + 292 + {{204, 131}, {72, 37}} + + + + _NS:225 + NO + IBCocoaTouchFramework + 0 + 0 + 1 + + 3 + MQA + + + 1 + MC4xOTYwNzg0MzE0IDAuMzA5ODAzOTIxNiAwLjUyMTU2ODYyNzUAA + + + 3 + MC41AA + + + 2 + 2 + + + Helvetica-Bold + 18 + 16 + + + + {480, 300} + + + + + 3 + MQA + + 2 + + + + 3 + 3 + + IBCocoaTouchFramework + + + + + + + view + + + + 4 + + + + buttonPressed + + + 7 + + 7 + + + + + + 0 + + + + + + 1 + + + + + + + + -1 + + + File's Owner + + + -2 + + + + + 6 + + + + + + + TestViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 8 + + + + + TestViewController + UIViewController + + buttonPressed + id + + + buttonPressed + + buttonPressed + id + + + + IBProjectSource + ./Classes/TestViewController.h + + + + + 0 + IBCocoaTouchFramework + YES + 3 + 933 + + diff --git a/tests/ui/nib/TestViewController.h b/tests/ui/nib/TestViewController.h new file mode 100644 index 0000000..eb44c12 --- /dev/null +++ b/tests/ui/nib/TestViewController.h @@ -0,0 +1,15 @@ +// +// TestViewController.h +// Isgl3dXIBSample +// +// Created by Nemrude Verzano on 14.01.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import + +@interface TestViewController : UIViewController + +- (IBAction)buttonPressed; + +@end diff --git a/tests/ui/nib/TestViewController.m b/tests/ui/nib/TestViewController.m new file mode 100644 index 0000000..aa81102 --- /dev/null +++ b/tests/ui/nib/TestViewController.m @@ -0,0 +1,111 @@ +// +// TestViewController.m +// Isgl3dXIBSample +// +// Created by Nemrude Verzano on 14.01.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import "TestViewController.h" +#import "NibDemo.h" + +#import "isgl3d.h" + +@implementation TestViewController + +- (void)dealloc { + [super dealloc]; +} + + +- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + + isgl3dAllowedAutoRotations allowedAutoRotations = [Isgl3dDirector sharedInstance].allowedAutoRotations; + if ([Isgl3dDirector sharedInstance].autoRotationStrategy == Isgl3dAutoRotationNone) { + return NO; + + } else if ([Isgl3dDirector sharedInstance].autoRotationStrategy == Isgl3dAutoRotationByIsgl3dDirector) { + + if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft && allowedAutoRotations != Isgl3dAllowedAutoRotationsPortraitOnly) { + [Isgl3dDirector sharedInstance].deviceOrientation = Isgl3dOrientationLandscapeRight; + + } else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight && allowedAutoRotations != Isgl3dAllowedAutoRotationsPortraitOnly) { + [Isgl3dDirector sharedInstance].deviceOrientation = Isgl3dOrientationLandscapeLeft; + + } else if (interfaceOrientation == UIInterfaceOrientationPortrait && allowedAutoRotations != Isgl3dAllowedAutoRotationsLandscapeOnly) { + [Isgl3dDirector sharedInstance].deviceOrientation = Isgl3dOrientationPortrait; + + } else if (interfaceOrientation == UIDeviceOrientationPortraitUpsideDown && allowedAutoRotations != Isgl3dAllowedAutoRotationsLandscapeOnly) { + [Isgl3dDirector sharedInstance].deviceOrientation = Isgl3dOrientationPortraitUpsideDown; + } + + // Return true only for portrait + return (interfaceOrientation == UIInterfaceOrientationPortrait); + + } else if ([Isgl3dDirector sharedInstance].autoRotationStrategy == Isgl3dAutoRotationByUIViewController) { + if (UIInterfaceOrientationIsLandscape(interfaceOrientation) && allowedAutoRotations != Isgl3dAllowedAutoRotationsPortraitOnly) { + return YES; + + } else if (UIInterfaceOrientationIsPortrait(interfaceOrientation) && allowedAutoRotations != Isgl3dAllowedAutoRotationsLandscapeOnly) { + return YES; + + } else { + return NO; + } + + } else { + NSLog(@"Isgl3dViewController:: ERROR : Unknown auto rotation strategy of Isgl3dDirector."); + return NO; + } +} + +- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { + + if ([Isgl3dDirector sharedInstance].autoRotationStrategy == Isgl3dAutoRotationByUIViewController) { + CGRect screenRect = [[UIScreen mainScreen] bounds]; + CGRect rect = CGRectZero; + + if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { + rect = screenRect; + + } else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { + rect.size = CGSizeMake( screenRect.size.height, screenRect.size.width ); + } + + UIView * glView = [Isgl3dDirector sharedInstance].openGLView; + float contentScaleFactor = [Isgl3dDirector sharedInstance].contentScaleFactor; + + if (contentScaleFactor != 1) { + rect.size.width *= contentScaleFactor; + rect.size.height *= contentScaleFactor; + } + glView.frame = rect; + } +} + +- (void) viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; +} + +- (void) viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; +} + +- (void) viewDidUnload { + [super viewDidUnload]; +} + +- (void) didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + + +- (IBAction)buttonPressed +{ + AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; + if (appDelegate) { + [appDelegate switchViews]; + } +} + +@end