From e56e8064810cefe148758e7b0e4f5df6760b6c07 Mon Sep 17 00:00:00 2001 From: Matej Jan Date: Mon, 24 Oct 2011 11:22:32 +0000 Subject: [PATCH] Fixed bug on iOS5 and .x model loading git-svn-id: http://xni.googlecode.com/svn/XNI@102 ac433895-eea3-a490-d80a-17149a75e588 --- Classes/Retronator/Xni/Framework/Color.m | 8 +-- .../Xni/Framework/Content/ContentManager.m | 15 ++--- .../Content/Pipeline/Graphics/VertexContent.m | 4 +- .../Processors/FontTextureProcessor.m | 2 +- .../Framework/Content/Pipeline/XImporter.m | 5 ++ .../Xni/Framework/Content/SongReader.m | 4 +- Classes/Retronator/Xni/Framework/Game.m | 2 +- Classes/Retronator/Xni/Framework/GameHost.m | 3 +- .../Xni/Framework/Graphics/GraphicsEnums.h | 2 +- .../Xni/Framework/Graphics/SpriteBatch.m | 2 + .../Xni/Framework/GraphicsDeviceManager.h | 16 ++--- .../Xni/Framework/GraphicsDeviceManager.m | 10 +-- .../Xni/Framework/Retronator.Xni.Framework.h | 66 +++++++++---------- XNI.xcodeproj/project.pbxproj | 16 ++--- 14 files changed, 80 insertions(+), 75 deletions(-) diff --git a/Classes/Retronator/Xni/Framework/Color.m b/Classes/Retronator/Xni/Framework/Color.m index 729954f..ac907d0 100644 --- a/Classes/Retronator/Xni/Framework/Color.m +++ b/Classes/Retronator/Xni/Framework/Color.m @@ -66,16 +66,16 @@ // PROPERTIES - (Byte) r {return (Byte)packedValue;} -- (void) setR:(Byte)value {packedValue = packedValue & 0xffffff00 | value;} +- (void) setR:(Byte)value {packedValue = (packedValue & 0xffffff00) | value;} - (Byte) g {return (Byte)(packedValue >> 8);} -- (void) setG:(Byte)value {packedValue = packedValue & 0xffff00ff | ((uint)value << 8);} +- (void) setG:(Byte)value {packedValue = (packedValue & 0xffff00ff) | ((uint)value << 8);} - (Byte) b {return (Byte)(packedValue >> 16);} -- (void) setB:(Byte)value {packedValue = packedValue & 0xff00ffff | ((uint)value << 16);} +- (void) setB:(Byte)value {packedValue = (packedValue & 0xff00ffff) | ((uint)value << 16);} - (Byte) a {return (Byte)(packedValue >> 24);} -- (void) setA:(Byte)value {packedValue = packedValue & 0x00ffffff | ((uint)value << 24);} +- (void) setA:(Byte)value {packedValue = (packedValue & 0x00ffffff) | ((uint)value << 24);} @synthesize packedValue; diff --git a/Classes/Retronator/Xni/Framework/Content/ContentManager.m b/Classes/Retronator/Xni/Framework/Content/ContentManager.m index 0824a8b..b2825a6 100644 --- a/Classes/Retronator/Xni/Framework/Content/ContentManager.m +++ b/Classes/Retronator/Xni/Framework/Content/ContentManager.m @@ -92,9 +92,6 @@ NSString *extension = [filePath pathExtension]; NSString *absolutePath = [[NSBundle mainBundle] pathForResource:fileName ofType:extension inDirectory:rootDirectory]; - // Bug in NSBundle - we are returned an object that doesn't have an object count 0, so we release it ourselves to avoid a leak. - [absolutePath autorelease]; - if (!absolutePath) { [NSException raise:@"InvalidArgumentException" format:@"Could not locate file '%@' in directory '%@'", filePath, rootDirectory]; } @@ -131,12 +128,12 @@ processor = [[[SoundEffectProcessor alloc] init] autorelease]; } } else if ([extension isEqualToString:@"mp3"]) { - // Mp3 audio content + // Mp3 audio content if (!importer) { - importer = [[[Mp3Importer alloc] init] autorelease]; + importer = [[[Mp3Importer alloc] init] autorelease]; } if (!processor) { - processor = [[[SongProcessor alloc] init] autorelease]; + processor = [[[SongProcessor alloc] init] autorelease]; } } @@ -147,12 +144,12 @@ // Import content. id content = [importer importFile:absolutePath]; - + // Process content if we have a processor. if (processor) { content = [processor process:content]; } - + // Create a reader for converting into realtime data. input = [[ContentReader alloc] initWithContentManager:self Content:content]; @@ -172,7 +169,7 @@ [loadedFiles setObject:result forKey:filePath]; [input release]; - + [pool release]; return [result autorelease]; diff --git a/Classes/Retronator/Xni/Framework/Content/Pipeline/Graphics/VertexContent.m b/Classes/Retronator/Xni/Framework/Content/Pipeline/Graphics/VertexContent.m index 024afbe..80b4df6 100644 --- a/Classes/Retronator/Xni/Framework/Content/Pipeline/Graphics/VertexContent.m +++ b/Classes/Retronator/Xni/Framework/Content/Pipeline/Graphics/VertexContent.m @@ -20,7 +20,9 @@ self = [super init]; if (self != nil) { channels = [[VertexChannelCollection alloc] initWithParent:self]; - positionIndices = [[IndexCollection alloc] init]; + positionIndices = [[VertexChannel alloc] initWithElementType:[NSNumber class] + name:[VertexChannelNames encodeUsage:VertexElementUsagePosition usageIndex:0] + channelData:nil]; positions = [[IndirectPositionCollection alloc] initWithPositionIndices:positionIndices positions:thePositions]; } return self; diff --git a/Classes/Retronator/Xni/Framework/Content/Pipeline/Processors/FontTextureProcessor.m b/Classes/Retronator/Xni/Framework/Content/Pipeline/Processors/FontTextureProcessor.m index 548b03a..d171901 100644 --- a/Classes/Retronator/Xni/Framework/Content/Pipeline/Processors/FontTextureProcessor.m +++ b/Classes/Retronator/Xni/Framework/Content/Pipeline/Processors/FontTextureProcessor.m @@ -123,7 +123,7 @@ static inline BOOL IsOnBlack(Byte *color) { for (int y = 0; y < bitmap.height; y++) { Byte *color = [bitmap getPixelAtX:x Y:y]; - if (!IsOnCharacter(color) || !usesAlpha && IsOnBlack(color)) { + if (!IsOnCharacter(color) || (!usesAlpha && IsOnBlack(color))) { // If the sprite font does not use an alpha channel we should key the black color. // Always also key the separator color. for (int i = 0; i < 4; i++) { diff --git a/Classes/Retronator/Xni/Framework/Content/Pipeline/XImporter.m b/Classes/Retronator/Xni/Framework/Content/Pipeline/XImporter.m index d2b4f31..466f837 100644 --- a/Classes/Retronator/Xni/Framework/Content/Pipeline/XImporter.m +++ b/Classes/Retronator/Xni/Framework/Content/Pipeline/XImporter.m @@ -259,6 +259,11 @@ /*int materialIndex =*/ [reader readInt]; [reader skipNextNonWhitespace]; } + + // Handle an extra semicolon + if ([reader currentCharacter] == ';') { + [reader skipNextNonWhitespace]; + } for (int i = 0; i < materialCount; i++) { MaterialContent *material = [self readTemplateWithReader:reader]; diff --git a/Classes/Retronator/Xni/Framework/Content/SongReader.m b/Classes/Retronator/Xni/Framework/Content/SongReader.m index 890b061..bf8c103 100644 --- a/Classes/Retronator/Xni/Framework/Content/SongReader.m +++ b/Classes/Retronator/Xni/Framework/Content/SongReader.m @@ -20,8 +20,8 @@ - (id) readFromInput:(ContentReader *)input into:(id)existingInstance { SongContent *content = input.content; - - Song *song = [[[Song alloc] initWithUrl:content.url] autorelease]; + + Song *song = [[[Song alloc] initWithUrl:content.url] autorelease]; return song; } diff --git a/Classes/Retronator/Xni/Framework/Game.m b/Classes/Retronator/Xni/Framework/Game.m index 116794b..70245dd 100644 --- a/Classes/Retronator/Xni/Framework/Game.m +++ b/Classes/Retronator/Xni/Framework/Game.m @@ -57,7 +57,7 @@ static NSArray *drawOrderSort; // First it is used for constructing a list of components, that need to be initialized. // In run it is used to make a copy of enabled/visible components for enumerating over them. componentsList = [[NSMutableArray alloc] init]; - + initializedComponents = [[NSMutableSet alloc] init]; [components.componentAdded subscribeDelegate: diff --git a/Classes/Retronator/Xni/Framework/GameHost.m b/Classes/Retronator/Xni/Framework/GameHost.m index e8e45f2..4c00f6a 100644 --- a/Classes/Retronator/Xni/Framework/GameHost.m +++ b/Classes/Retronator/Xni/Framework/GameHost.m @@ -30,8 +30,7 @@ NSLog(@"Starting the game loop."); game = [self delegate]; - - + SInt32 runResult; isExiting = NO; diff --git a/Classes/Retronator/Xni/Framework/Graphics/GraphicsEnums.h b/Classes/Retronator/Xni/Framework/Graphics/GraphicsEnums.h index 3ed000a..f36d857 100644 --- a/Classes/Retronator/Xni/Framework/Graphics/GraphicsEnums.h +++ b/Classes/Retronator/Xni/Framework/Graphics/GraphicsEnums.h @@ -106,7 +106,7 @@ typedef enum { typedef enum { IndexElementSizeSixteenBits = 2, - //IndexElementSizeThrityTwoBits = 4, + //IndexElementSizeThirtyTwoBits = 4, } IndexElementSize; typedef enum { diff --git a/Classes/Retronator/Xni/Framework/Graphics/SpriteBatch.m b/Classes/Retronator/Xni/Framework/Graphics/SpriteBatch.m index da3a7bd..ed1c532 100644 --- a/Classes/Retronator/Xni/Framework/Graphics/SpriteBatch.m +++ b/Classes/Retronator/Xni/Framework/Graphics/SpriteBatch.m @@ -354,6 +354,8 @@ static VertexPositionColorTextureStruct vertices[4]; case SpriteSortModeFrontToBack: [sprites sortUsingDescriptors:frontToBackSort]; break; + default: + break; } // Apply the graphics device states. diff --git a/Classes/Retronator/Xni/Framework/GraphicsDeviceManager.h b/Classes/Retronator/Xni/Framework/GraphicsDeviceManager.h index 928b4e4..2a37b8b 100644 --- a/Classes/Retronator/Xni/Framework/GraphicsDeviceManager.h +++ b/Classes/Retronator/Xni/Framework/GraphicsDeviceManager.h @@ -18,10 +18,10 @@ GraphicsProfile graphicsProfile; BOOL isFullScreen; BOOL preferMultiSampling; - SurfaceFormat preferedSurfaceFormat; - int preferedBackBufferWidth; - int preferedBackBufferHeight; - DepthFormat preferedDepthStencilFormat; + SurfaceFormat preferredSurfaceFormat; + int preferredBackBufferWidth; + int preferredBackBufferHeight; + DepthFormat preferredDepthStencilFormat; DisplayOrientation supportedOrientations; Game *game; @@ -37,10 +37,10 @@ @property (nonatomic) GraphicsProfile graphicsProfile; @property (nonatomic) BOOL isFullScreen; @property (nonatomic) BOOL preferMultiSampling; -@property (nonatomic) SurfaceFormat preferedSurfaceFormat; -@property (nonatomic) int preferedBackBufferWidth; -@property (nonatomic) int preferedBackBufferHeight; -@property (nonatomic) DepthFormat preferedDepthStencilFormat; +@property (nonatomic) SurfaceFormat preferredSurfaceFormat; +@property (nonatomic) int preferredBackBufferWidth; +@property (nonatomic) int preferredBackBufferHeight; +@property (nonatomic) DepthFormat preferredDepthStencilFormat; @property (nonatomic) DisplayOrientation supportedOrientations; - (void) toggleFullscreen; diff --git a/Classes/Retronator/Xni/Framework/GraphicsDeviceManager.m b/Classes/Retronator/Xni/Framework/GraphicsDeviceManager.m index a74f7c8..9134d55 100644 --- a/Classes/Retronator/Xni/Framework/GraphicsDeviceManager.m +++ b/Classes/Retronator/Xni/Framework/GraphicsDeviceManager.m @@ -36,10 +36,10 @@ @synthesize graphicsProfile; @synthesize isFullScreen; @synthesize preferMultiSampling; -@synthesize preferedSurfaceFormat; -@synthesize preferedBackBufferWidth; -@synthesize preferedBackBufferHeight; -@synthesize preferedDepthStencilFormat; +@synthesize preferredSurfaceFormat; +@synthesize preferredBackBufferWidth; +@synthesize preferredBackBufferHeight; +@synthesize preferredDepthStencilFormat; @synthesize supportedOrientations; @synthesize graphicsDevice; @@ -72,7 +72,7 @@ - (void) applyChanges { [game.window setSupportedOrientations:supportedOrientations]; [game.window beginScreenDeviceChangeWithFullscreen:isFullScreen]; - [game.window endScreenDeviceChangeWithClientWidth:self.preferedBackBufferWidth clientHeight:self.preferedBackBufferHeight]; + [game.window endScreenDeviceChangeWithClientWidth:self.preferredBackBufferWidth clientHeight:self.preferredBackBufferHeight]; if (graphicsDevice != nil && graphicsDevice.graphicsProfile != graphicsProfile) { // Different graphics profile requested. diff --git a/Classes/Retronator/Xni/Framework/Retronator.Xni.Framework.h b/Classes/Retronator/Xni/Framework/Retronator.Xni.Framework.h index fc4de61..a23341c 100644 --- a/Classes/Retronator/Xni/Framework/Retronator.Xni.Framework.h +++ b/Classes/Retronator/Xni/Framework/Retronator.Xni.Framework.h @@ -1,34 +1,34 @@ -#import "FrameworkEnums.h" -#import "Protocols.h" - -// Data structures -#import "XniPoint.h" -#import "Rectangle.h" -#import "Color.h" - -// Game -#import "IGraphicsDeviceManager.h" -#import "Game.h" -#import "GameTime.h" -#import "GameServiceContainer.h" -#import "GraphicsDeviceManager.h" - -// Game host -#import "GameHost.h" -#import "GameWindow.h" - -// Game components -#import "IGameComponent.h" -#import "IUpdatable.h" -#import "IDrawable.h" -#import "GameComponent.h" -#import "DrawableGameComponent.h" -#import "GameComponentCollection.h" -#import "GameComponentCollectionEventArgs.h" - -// Linear algebra -#import "Vector2.h" -#import "Vector3.h" -#import "Vector4.h" -#import "Quaternion.h" +#import "FrameworkEnums.h" +#import "Protocols.h" + +// Data structures +#import "XniPoint.h" +#import "Rectangle.h" +#import "Color.h" + +// Game +#import "IGraphicsDeviceManager.h" +#import "Game.h" +#import "GameTime.h" +#import "GameServiceContainer.h" +#import "GraphicsDeviceManager.h" + +// Game host +#import "GameHost.h" +#import "GameWindow.h" + +// Game components +#import "IGameComponent.h" +#import "IUpdatable.h" +#import "IDrawable.h" +#import "GameComponent.h" +#import "DrawableGameComponent.h" +#import "GameComponentCollection.h" +#import "GameComponentCollectionEventArgs.h" + +// Linear algebra +#import "Vector2.h" +#import "Vector3.h" +#import "Vector4.h" +#import "Quaternion.h" #import "Matrix.h" \ No newline at end of file diff --git a/XNI.xcodeproj/project.pbxproj b/XNI.xcodeproj/project.pbxproj index 86adfe4..7e174e2 100644 --- a/XNI.xcodeproj/project.pbxproj +++ b/XNI.xcodeproj/project.pbxproj @@ -905,7 +905,7 @@ B56CC5C6123A928A00B72347 /* ContentTypeReaderManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContentTypeReaderManager.m; sourceTree = ""; }; B56CC5C9123A92BB00B72347 /* Texture2DReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Texture2DReader.h; sourceTree = ""; }; B56CC5CA123A92BB00B72347 /* Texture2DReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Texture2DReader.m; sourceTree = ""; }; - B570A31E13E1DC3B0085E85E /* libXNI copy.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libXNI copy.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + B570A31E13E1DC3B0085E85E /* libXNI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libXNI.a; sourceTree = BUILT_PRODUCTS_DIR; }; B572BC03130EB27A00B6DB47 /* Gamer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gamer.h; sourceTree = ""; }; B572BC04130EB27A00B6DB47 /* Gamer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Gamer.m; sourceTree = ""; }; B572BC07130EB32100B6DB47 /* SignedInGamerCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SignedInGamerCollection.h; sourceTree = ""; }; @@ -1200,7 +1200,7 @@ isa = PBXGroup; children = ( D2AAC07E0554694100DB518D /* libXNI.a */, - B570A31E13E1DC3B0085E85E /* libXNI copy.a */, + B570A31E13E1DC3B0085E85E /* libXNI.a */, ); name = Products; sourceTree = ""; @@ -2256,7 +2256,7 @@ ); name = "XNI Release"; productName = XNI; - productReference = B570A31E13E1DC3B0085E85E /* libXNI copy.a */; + productReference = B570A31E13E1DC3B0085E85E /* libXNI.a */; productType = "com.apple.product-type.library.static"; }; D2AAC07D0554694100DB518D /* XNI */ = { @@ -2282,7 +2282,7 @@ 0867D690FE84028FC02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0410; + LastUpgradeCheck = 0420; ORGANIZATIONNAME = Retronator; }; buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "XNI" */; @@ -2672,7 +2672,7 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XNI_Prefix.pch; - GCC_VERSION = com.apple.compilers.llvmgcc42; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)"; PRODUCT_NAME = XNI; PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include; @@ -2689,7 +2689,7 @@ GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XNI_Prefix.pch; - GCC_VERSION = com.apple.compilers.llvmgcc42; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)"; PRODUCT_NAME = XNI; PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include; @@ -2739,7 +2739,7 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XNI_Prefix.pch; - GCC_VERSION = com.apple.compilers.llvmgcc42; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)"; PRODUCT_NAME = XNI; PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include; @@ -2756,7 +2756,7 @@ GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = XNI_Prefix.pch; - GCC_VERSION = com.apple.compilers.llvmgcc42; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)"; PRODUCT_NAME = XNI; PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include;