mirror of
https://github.com/thes3m/XNI
synced 2024-12-26 13:26:06 +01:00
SoundEffect support implemented.
git-svn-id: http://xni.googlecode.com/svn/XNI@49 ac433895-eea3-a490-d80a-17149a75e588
This commit is contained in:
parent
796a3a85f3
commit
2f0bc9f91a
@ -12,6 +12,7 @@
|
||||
#import "Retronator.Xni.Framework.Content.h"
|
||||
#import "Retronator.Xni.Framework.Content.Pipeline.h"
|
||||
#import "Retronator.Xni.Framework.Content.Pipeline.Processors.h"
|
||||
#import "Retronator.Xni.Framework.Content.Pipeline.Audio.h"
|
||||
|
||||
@implementation ContentManager
|
||||
|
||||
@ -89,21 +90,35 @@
|
||||
// Compare lowercase extension.
|
||||
extension = [extension lowercaseString];
|
||||
|
||||
if ([extension isEqual:@"png"] || [extension isEqual:@"jpg"] || [extension isEqual:@"jpeg"] ||
|
||||
[extension isEqual:@"gif"] || [extension isEqual:@"tif"] || [extension isEqual:@"tiff"] ||
|
||||
[extension isEqual:@"ico"] || [extension isEqual:@"bmp"]) {
|
||||
// We have texture content
|
||||
if ([extension isEqualToString:@"png"] || [extension isEqualToString:@"jpg"] || [extension isEqualToString:@"jpeg"] ||
|
||||
[extension isEqualToString:@"gif"] || [extension isEqualToString:@"tif"] || [extension isEqualToString:@"tiff"] ||
|
||||
[extension isEqualToString:@"ico"] || [extension isEqualToString:@"bmp"]) {
|
||||
// Texture content
|
||||
TextureImporter *textureImporter = [[[TextureImporter alloc] init] autorelease];
|
||||
TextureContent *textureContent = [textureImporter importFile:absolutePath];
|
||||
input = [[ContentReader alloc] initWithContentManager:self Content:textureContent];
|
||||
|
||||
} else if ([extension isEqual:@"x"]) {
|
||||
// We have direct x model content
|
||||
} else if ([extension isEqualToString:@"x"]) {
|
||||
// Direct x model content
|
||||
XImporter *xImporter = [[[XImporter alloc] init] autorelease];
|
||||
NodeContent *root = [xImporter importFile:absolutePath];
|
||||
ModelProcessor *modelProcessor = [[[ModelProcessor alloc] init] autorelease];
|
||||
ModelContent *modelContent = [modelProcessor process:root];
|
||||
input = [[ContentReader alloc] initWithContentManager:self Content:modelContent];
|
||||
} else if ([extension isEqualToString:@"wav"]) {
|
||||
// Wave audio content
|
||||
WavImporter *wavImporter = [[[WavImporter alloc] init] autorelease];
|
||||
AudioContent *audioContent = [wavImporter importFile:absolutePath];
|
||||
SoundEffectProcessor *soundEffectProcessor = [[[SoundEffectProcessor alloc] init] autorelease];
|
||||
SoundEffectContent *soundEffectContent = [soundEffectProcessor process:audioContent];
|
||||
input = [[ContentReader alloc] initWithContentManager:self Content:soundEffectContent];
|
||||
} else if ([extension isEqualToString:@"mp3"]) {
|
||||
// Wave audio content
|
||||
WavImporter *wavImporter = [[[WavImporter alloc] init] autorelease];
|
||||
AudioContent *audioContent = [wavImporter importFile:absolutePath];
|
||||
SongProcessor *songProcessor = [[[SongProcessor alloc] init] autorelease];
|
||||
SongContent *songContent = [songProcessor process:audioContent];
|
||||
input = [[ContentReader alloc] initWithContentManager:self Content:songContent];
|
||||
} else {
|
||||
[NSException raise:@"InvalidArgumentException" format:@"Files with extension %@ are not supported", extension];
|
||||
}
|
||||
@ -114,7 +129,7 @@
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
ContentTypeReader *reader = [readerManager getTypeReaderFor:[input.content class]];
|
||||
id result = [reader readFromInput:input into:nil];
|
||||
id result = [[reader readFromInput:input into:nil] retain];
|
||||
|
||||
// Save the loaded asset for quick retreival.
|
||||
if (assetName) {
|
||||
@ -128,7 +143,7 @@
|
||||
[pool release];
|
||||
|
||||
// We are returning a retained object since the loaded asset is always used for a longer time.
|
||||
return [result retain];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) unload {
|
||||
|
@ -20,6 +20,7 @@
|
||||
VertexBufferReader *vertexBufferReader;
|
||||
ModelBoneReader *modelBoneReader;
|
||||
VertexDeclarationReader *vertexDeclarationReader;
|
||||
SoundEffectReader *soundEffectReader;
|
||||
}
|
||||
|
||||
- (ContentTypeReader*) getTypeReaderFor:(Class)targetType;
|
||||
|
@ -27,6 +27,7 @@
|
||||
vertexBufferReader = [[VertexBufferReader alloc] init];
|
||||
modelBoneReader = [[ModelBoneReader alloc] init];
|
||||
vertexDeclarationReader = [[VertexDeclarationReader alloc] init];
|
||||
soundEffectReader = [[SoundEffectReader alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -51,6 +52,8 @@
|
||||
return modelBoneReader;
|
||||
} else if (targetType == [VertexDeclarationContent class]) {
|
||||
return vertexDeclarationReader;
|
||||
} else if (targetType == [SoundEffectContent class]) {
|
||||
return soundEffectReader;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
|
@ -8,6 +8,8 @@
|
||||
@class ContentImporter;
|
||||
@class TextureImporter;
|
||||
@class XImporter;
|
||||
@class WavImporter;
|
||||
@class Mp3Importer;
|
||||
|
||||
@protocol IContentProcessor;
|
||||
@class ContentProcessor;
|
||||
|
@ -11,6 +11,8 @@
|
||||
#import "ContentImporter.h"
|
||||
#import "TextureImporter.h"
|
||||
#import "XImporter.h"
|
||||
#import "WavImporter.h"
|
||||
#import "Mp3Importer.h"
|
||||
|
||||
#import "IContentProcessor.h"
|
||||
#import "ContentProcessor.h"
|
@ -8,14 +8,10 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "Retronator.Xni.Framework.Content.Pipeline.Graphics.classes.h"
|
||||
|
||||
#import "ContentImporter.h"
|
||||
|
||||
@interface TextureImporter : ContentImporter {
|
||||
|
||||
}
|
||||
|
||||
- (TextureContent*) importFile:(NSString*)filename;
|
||||
|
||||
@end
|
||||
|
@ -3,4 +3,5 @@
|
||||
@class Texture2DReader;
|
||||
@class ModelReader, ModelMeshReader, ModelMeshPartReader;
|
||||
@class BasicEffectReader, IndexBufferReader, VertexBufferReader;
|
||||
@class ModelBoneReader, VertexDeclarationReader;
|
||||
@class ModelBoneReader, VertexDeclarationReader;
|
||||
@class SoundEffectReader;
|
@ -14,4 +14,6 @@
|
||||
#import "VertexBufferReader.h"
|
||||
|
||||
#import "ModelBoneReader.h"
|
||||
#import "VertexDeclarationReader.h"
|
||||
#import "VertexDeclarationReader.h"
|
||||
|
||||
#import "SoundEffectReader.h"
|
@ -14,6 +14,7 @@
|
||||
#import "TouchPanel+Internal.h"
|
||||
#import "GameWindow+Internal.h"
|
||||
#import "Guide+Internal.h"
|
||||
#import "SoundEffect+Internal.h"
|
||||
|
||||
@interface Game ()
|
||||
|
||||
@ -133,7 +134,7 @@ static NSArray *drawOrderSort;
|
||||
- (void) tick {
|
||||
// Sleep if inactive.
|
||||
if (!isActive) {
|
||||
//CFRunLoopRunInMode(kCFRunLoopDefaultMode, inactiveSleepTime, NO);
|
||||
CFRunLoopRunInMode(kCFRunLoopDefaultMode, inactiveSleepTime, NO);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -142,7 +143,7 @@ static NSArray *drawOrderSort;
|
||||
NSTimeInterval elapsedRealTime = [currentFrameTime timeIntervalSinceDate:lastFrameTime];
|
||||
|
||||
// Sleep if we're ahead of the target elapsed time.
|
||||
/*if (isFixedTimeStep) {
|
||||
if (isFixedTimeStep) {
|
||||
if (elapsedRealTime < targetElapsedTime) {
|
||||
NSTimeInterval sleepTime = targetElapsedTime - elapsedRealTime;
|
||||
CFRunLoopRunInMode(kCFRunLoopDefaultMode, sleepTime, NO);
|
||||
@ -155,7 +156,7 @@ static NSArray *drawOrderSort;
|
||||
} else {
|
||||
gameTime.isRunningSlowly = YES;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
// Store current time for next frame.
|
||||
[lastFrameTime release];
|
||||
@ -169,7 +170,7 @@ static NSArray *drawOrderSort;
|
||||
|
||||
// Update input.
|
||||
[[TouchPanel getInstance] update];
|
||||
|
||||
|
||||
// Update the game.
|
||||
[self updateWithGameTime:gameTime];
|
||||
|
||||
@ -183,6 +184,9 @@ static NSArray *drawOrderSort;
|
||||
}
|
||||
[enabledChangedComponents removeAllObjects];
|
||||
|
||||
// Update audio.
|
||||
[SoundEffect update];
|
||||
|
||||
// Draw to display.
|
||||
if ([self beginDraw]) {
|
||||
[self drawWithGameTime:gameTime];
|
||||
|
@ -39,7 +39,6 @@
|
||||
// Handle all the waiting event sources.
|
||||
do {
|
||||
runResult = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, YES);
|
||||
NSLog(@"Handling default mode");
|
||||
} while (runResult == kCFRunLoopRunHandledSource);
|
||||
|
||||
[game tick];
|
||||
|
Loading…
x
Reference in New Issue
Block a user