From 161d27ab5f18739a924f739adc88715d376d92a6 Mon Sep 17 00:00:00 2001 From: chsieh Date: Mon, 9 May 2011 20:24:31 -0700 Subject: [PATCH] Moving files to new location. --- src/references/Box2DAppDelegate.h | 24 ++ src/references/Box2DAppDelegate.mm | 62 ++++ src/references/Box2DView.h | 63 ++++ src/references/Box2DView.mm | 295 +++++++++++++++++++ src/references/Delegates.h | 14 + src/references/GLES-Render.h | 58 ++++ src/references/GLES-Render.mm | 149 ++++++++++ src/references/TestEntriesViewController.h | 19 ++ src/references/TestEntriesViewController.mm | 75 +++++ src/references/iPhoneTest.h | 185 ++++++++++++ src/references/iPhoneTest.mm | 411 +++++++++++++++++++++++++++ src/references/iPhoneTestEntries.mm | 92 ++++++ src/render/Box2DAppDelegate.h | 24 -- src/render/Box2DAppDelegate.mm | 62 ---- src/render/Box2DView.h | 63 ---- src/render/Box2DView.mm | 295 ------------------- src/render/Delegates.h | 14 - src/render/GLES-Render.h | 58 ---- src/render/GLES-Render.mm | 149 ---------- src/render/TestEntriesViewController.h | 19 -- src/render/TestEntriesViewController.mm | 75 ----- src/render/iPhoneTest.h | 185 ------------ src/render/iPhoneTest.mm | 411 --------------------------- src/render/iPhoneTestEntries.mm | 92 ------ tanks.xcodeproj/project.pbxproj | 84 ++++-- 25 files changed, 1503 insertions(+), 1475 deletions(-) create mode 100644 src/references/Box2DAppDelegate.h create mode 100644 src/references/Box2DAppDelegate.mm create mode 100644 src/references/Box2DView.h create mode 100644 src/references/Box2DView.mm create mode 100644 src/references/Delegates.h create mode 100644 src/references/GLES-Render.h create mode 100644 src/references/GLES-Render.mm create mode 100644 src/references/TestEntriesViewController.h create mode 100644 src/references/TestEntriesViewController.mm create mode 100644 src/references/iPhoneTest.h create mode 100644 src/references/iPhoneTest.mm create mode 100644 src/references/iPhoneTestEntries.mm delete mode 100644 src/render/Box2DAppDelegate.h delete mode 100644 src/render/Box2DAppDelegate.mm delete mode 100644 src/render/Box2DView.h delete mode 100644 src/render/Box2DView.mm delete mode 100644 src/render/Delegates.h delete mode 100644 src/render/GLES-Render.h delete mode 100644 src/render/GLES-Render.mm delete mode 100644 src/render/TestEntriesViewController.h delete mode 100644 src/render/TestEntriesViewController.mm delete mode 100644 src/render/iPhoneTest.h delete mode 100644 src/render/iPhoneTest.mm delete mode 100644 src/render/iPhoneTestEntries.mm diff --git a/src/references/Box2DAppDelegate.h b/src/references/Box2DAppDelegate.h new file mode 100644 index 0000000..f081ba3 --- /dev/null +++ b/src/references/Box2DAppDelegate.h @@ -0,0 +1,24 @@ +// +// Box2DAppDelegate.h +// Box2D +// +// Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com +// + +#import +#import "TestEntriesViewController.h" +#import "Delegates.h" + +@class Box2DView; + +@interface Box2DAppDelegate : NSObject { + UIWindow *window; + Box2DView *glView; + TestEntriesViewController *testEntriesView; +} + +@property (nonatomic, retain) IBOutlet UIWindow *window; +@property (nonatomic, retain) IBOutlet Box2DView *glView; + +@end + diff --git a/src/references/Box2DAppDelegate.mm b/src/references/Box2DAppDelegate.mm new file mode 100644 index 0000000..e04a09e --- /dev/null +++ b/src/references/Box2DAppDelegate.mm @@ -0,0 +1,62 @@ +// +// Box2DAppDelegate.m +// Box2D +// +// Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com +// + +#import +#import "Box2DAppDelegate.h" +#import "Box2DView.h" + +@implementation Box2DAppDelegate + +@synthesize window; +@synthesize glView; + +- (void)applicationDidFinishLaunching:(UIApplication *)application { + [application setStatusBarHidden:true]; + + [glView removeFromSuperview]; + + glView.animationInterval = 1.0 / 60.0; + + testEntriesView=[[TestEntriesViewController alloc] initWithStyle:UITableViewStylePlain]; + [testEntriesView setDelegate:self]; + [glView setDelegate:self]; + + [window addSubview:[testEntriesView view]]; +} + +-(void) selectTest:(int) testIndex +{ + [[testEntriesView view] removeFromSuperview]; + [window addSubview:glView]; + [glView startAnimation]; + [glView selectTestEntry:testIndex]; +} + +-(void) leaveTest +{ + [glView stopAnimation]; + [glView removeFromSuperview]; + [window addSubview:[testEntriesView view]]; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + glView.animationInterval = 1.0 / 5.0; +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + glView.animationInterval = 1.0 / 60.0; +} + + +- (void)dealloc { + [window release]; + [glView release]; + [super dealloc]; +} + +@end diff --git a/src/references/Box2DView.h b/src/references/Box2DView.h new file mode 100644 index 0000000..81d50b3 --- /dev/null +++ b/src/references/Box2DView.h @@ -0,0 +1,63 @@ +// +// Box2DView.h +// Box2D OpenGL View +// +// Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com +// + + +#import +#import +#import +#import + +#import "iPhoneTest.h" +#import "Delegates.h" + +/* +This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. +The view content is basically an EAGL surface you render your OpenGL scene into. +Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. +*/ +@interface Box2DView : UIView { + +@private + /* The pixel dimensions of the backbuffer */ + GLint backingWidth; + GLint backingHeight; + + EAGLContext *context; + + /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ + GLuint viewRenderbuffer, viewFramebuffer; + + /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ + GLuint depthRenderbuffer; + + NSTimer *animationTimer; + NSTimeInterval animationInterval; + + TestEntry* entry; + Test* test; + + // Position offset and scale + float sceneScale; + CGPoint positionOffset; + CGPoint lastWorldTouch; + CGPoint lastScreenTouch; + + bool panning; + int doubleClickValidCountdown; + + id _delegate; + +} +@property(assign) id delegate; +@property NSTimeInterval animationInterval; + +- (void)startAnimation; +- (void)stopAnimation; +- (void)drawView; +-(void) selectTestEntry:(int) testIndex; + +@end diff --git a/src/references/Box2DView.mm b/src/references/Box2DView.mm new file mode 100644 index 0000000..11743b0 --- /dev/null +++ b/src/references/Box2DView.mm @@ -0,0 +1,295 @@ +// +// Box2DView.mm +// Box2D OpenGL View +// +// Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com +// + +#import +#import + +#import "Box2DView.h" + +#define USE_DEPTH_BUFFER 0 +#define kAccelerometerFrequency 30 +#define FRAMES_BETWEEN_PRESSES_FOR_DOUBLE_CLICK 10 + +Settings settings; + +// A class extension to declare private methods +@interface Box2DView () + +@property (nonatomic, retain) EAGLContext *context; +@property (nonatomic, assign) NSTimer *animationTimer; + +- (BOOL) createFramebuffer; +- (void) destroyFramebuffer; + +@end + + +@implementation Box2DView + +@synthesize context; +@synthesize animationTimer; +@synthesize animationInterval; +@synthesize delegate=_delegate; + +// You must implement this method ++ (Class)layerClass { + return [CAEAGLLayer class]; +} + + +//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: +- (id)initWithCoder:(NSCoder*)coder { + + if ((self = [super initWithCoder:coder])) { + // Get the layer + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; + + eaglLayer.opaque = YES; + eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; + + context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; + + if (!context || ![EAGLContext setCurrentContext:context]) { + [self release]; + return nil; + } + + animationInterval = 1.0 / 60.0; + sceneScale=10.0f; + positionOffset=CGPointMake(0, 0); + lastWorldTouch=CGPointMake(0, 0); + + [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)]; + [[UIAccelerometer sharedAccelerometer] setDelegate:self]; + } + + + return self; +} + +-(void) selectTestEntry:(int) testIndex +{ + // Destroy existing scene + delete test; + + entry = g_testEntries + testIndex; + test = entry->createFcn(); + + doubleClickValidCountdown=0; + + sceneScale=10.0f; + positionOffset=CGPointMake(0, 0); + lastWorldTouch=CGPointMake(0, 0); +} + + + +- (void)drawView { + + + + if (doubleClickValidCountdown>0) doubleClickValidCountdown--; + + [EAGLContext setCurrentContext:context]; + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); + glViewport(0, 0, backingWidth, backingHeight); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + glOrthof(-sceneScale, sceneScale, -sceneScale*1.5f, sceneScale*1.5f, -1.0f, 1.0f); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(positionOffset.x, positionOffset.y,0); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glEnableClientState(GL_VERTEX_ARRAY); + + test->Step(&settings); + + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context presentRenderbuffer:GL_RENDERBUFFER_OES]; +} + + +- (void)layoutSubviews { + [EAGLContext setCurrentContext:context]; + [self destroyFramebuffer]; + [self createFramebuffer]; + [self drawView]; +} + + +- (BOOL)createFramebuffer { + + glGenFramebuffersOES(1, &viewFramebuffer); + glGenRenderbuffersOES(1, &viewRenderbuffer); + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); + + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); + + if (USE_DEPTH_BUFFER) { + glGenRenderbuffersOES(1, &depthRenderbuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); + glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight); + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); + } + + if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { + NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); + return NO; + } + + return YES; +} + + +- (void)destroyFramebuffer { + + glDeleteFramebuffersOES(1, &viewFramebuffer); + viewFramebuffer = 0; + glDeleteRenderbuffersOES(1, &viewRenderbuffer); + viewRenderbuffer = 0; + + if(depthRenderbuffer) { + glDeleteRenderbuffersOES(1, &depthRenderbuffer); + depthRenderbuffer = 0; + } +} + + +- (void)startAnimation { + self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; +} + + +- (void)stopAnimation { + self.animationTimer = nil; +} + + +- (void)setAnimationTimer:(NSTimer *)newTimer { + [animationTimer invalidate]; + animationTimer = newTimer; +} + + +- (void)setAnimationInterval:(NSTimeInterval)interval { + + animationInterval = interval; + if (animationTimer) { + [self stopAnimation]; + [self startAnimation]; + } +} + + +- (void)dealloc { + + [self stopAnimation]; + + if ([EAGLContext currentContext] == context) { + [EAGLContext setCurrentContext:nil]; + } + + [context release]; + [super dealloc]; +} + +-(CGPoint) screenSpaceToWorldSpace:(CGPoint) screenLocation +{ + screenLocation.x-=160; + screenLocation.y-=240; + screenLocation.x/=160; + screenLocation.y/=160; + screenLocation.x*=sceneScale; + screenLocation.y*=-sceneScale; + + screenLocation.x-=positionOffset.x; + screenLocation.y-=positionOffset.y; + return screenLocation; +} + +- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event +{ + + if (doubleClickValidCountdown>0) + { + [_delegate leaveTest]; + return; + } + + doubleClickValidCountdown=FRAMES_BETWEEN_PRESSES_FOR_DOUBLE_CLICK; + + + panning=false; + for (UITouch *touch in touches) + { + CGPoint touchLocation=[touch locationInView:self]; + CGPoint worldPosition=[self screenSpaceToWorldSpace:touchLocation]; + //printf("Screen touched %f,%f -> %f,%f\n",touchLocation.x,touchLocation.y,worldPosition.x,worldPosition.y); + lastScreenTouch=touchLocation; + lastWorldTouch=worldPosition; + test->MouseDown(b2Vec2(lastWorldTouch.x,lastWorldTouch.y)); + + if (!test->m_mouseJoint) panning=true; + } +} + +- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event +{ + for (UITouch *touch in touches) + { + CGPoint touchLocation=[touch locationInView:self]; + CGPoint worldPosition=[self screenSpaceToWorldSpace:touchLocation]; + //printf("Screen touched %f,%f -> %f,%f\n",touchLocation.x,touchLocation.y,worldPosition.x,worldPosition.y); + + + CGPoint screenDistanceMoved=CGPointMake(touchLocation.x-lastScreenTouch.x,touchLocation.y-lastScreenTouch.y); + if (panning) + { + screenDistanceMoved.x/=160; + screenDistanceMoved.y/=160; + screenDistanceMoved.x*=sceneScale; + screenDistanceMoved.y*=-sceneScale; + positionOffset.x+=screenDistanceMoved.x; + positionOffset.y+=screenDistanceMoved.y; + } + + lastScreenTouch=touchLocation; + lastWorldTouch=worldPosition; + test->MouseMove(b2Vec2(lastWorldTouch.x,lastWorldTouch.y)); + + } +} +- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event +{ + test->MouseUp(b2Vec2(lastWorldTouch.x,lastWorldTouch.y)); +} + +- (void) accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration +{ + // Only run for valid values + if (acceleration.y!=0 && acceleration.x!=0) + { + if (test) test->SetGravity(acceleration.x,acceleration.y); + } +} + +@end diff --git a/src/references/Delegates.h b/src/references/Delegates.h new file mode 100644 index 0000000..b4b7976 --- /dev/null +++ b/src/references/Delegates.h @@ -0,0 +1,14 @@ +/* + * Delegates.h + * Box2D + * + * Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com + * + * + */ + +@protocol TestSelectDelegate + -(void) selectTest:(int) testIndex; + -(void) leaveTest; + +@end \ No newline at end of file diff --git a/src/references/GLES-Render.h b/src/references/GLES-Render.h new file mode 100644 index 0000000..2551666 --- /dev/null +++ b/src/references/GLES-Render.h @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com +* +* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef RENDER_H +#define RENDER_H + +#import +#import +#import +#import + +#include + +struct b2AABB; + +// This class implements debug drawing callbacks that are invoked +// inside b2World::Step. +class GLESDebugDraw : public b2DebugDraw +{ +public: + void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); + + void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); + + void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color); + + void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color); + + void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color); + + void DrawTransform(const b2Transform& xf); + + void DrawPoint(const b2Vec2& p, float32 size, const b2Color& color); + + void DrawString(int x, int y, const char* string, ...); + + void DrawAABB(b2AABB* aabb, const b2Color& color); +}; + + +#endif diff --git a/src/references/GLES-Render.mm b/src/references/GLES-Render.mm new file mode 100644 index 0000000..abf5c57 --- /dev/null +++ b/src/references/GLES-Render.mm @@ -0,0 +1,149 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com +* +* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "GLES-Render.h" + + +#include +#include + +#include + +void GLESDebugDraw::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) +{ + glColor4f(color.r, color.g, color.b,1); + glVertexPointer(2, GL_FLOAT, 0, vertices); + glDrawArrays(GL_LINE_LOOP, 0, vertexCount); +} + +void GLESDebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) +{ + glVertexPointer(2, GL_FLOAT, 0, vertices); + + glColor4f(color.r, color.g, color.b,0.5f); + glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); + + glColor4f(color.r, color.g, color.b,1); + glDrawArrays(GL_LINE_LOOP, 0, vertexCount); +} + +void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) +{ + const float32 k_segments = 16.0f; + int vertexCount=16; + const float32 k_increment = 2.0f * b2_pi / k_segments; + float32 theta = 0.0f; + + GLfloat glVertices[vertexCount*2]; + for (int32 i = 0; i < k_segments; ++i) + { + b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); + glVertices[i*2]=v.x; + glVertices[i*2+1]=v.y; + theta += k_increment; + } + + glColor4f(color.r, color.g, color.b,1); + glVertexPointer(2, GL_FLOAT, 0, glVertices); + + glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); +} + +void GLESDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) +{ + const float32 k_segments = 16.0f; + int vertexCount=16; + const float32 k_increment = 2.0f * b2_pi / k_segments; + float32 theta = 0.0f; + + GLfloat glVertices[vertexCount*2]; + for (int32 i = 0; i < k_segments; ++i) + { + b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); + glVertices[i*2]=v.x; + glVertices[i*2+1]=v.y; + theta += k_increment; + } + + glColor4f(color.r, color.g, color.b,0.5f); + glVertexPointer(2, GL_FLOAT, 0, glVertices); + glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); + glColor4f(color.r, color.g, color.b,1); + glDrawArrays(GL_LINE_LOOP, 0, vertexCount); + + // Draw the axis line + DrawSegment(center,center+radius*axis,color); +} + +void GLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) +{ + glColor4f(color.r, color.g, color.b,1); + GLfloat glVertices[] = { + p1.x,p1.y,p2.x,p2.y + }; + glVertexPointer(2, GL_FLOAT, 0, glVertices); + glDrawArrays(GL_LINES, 0, 2); +} + +void GLESDebugDraw::DrawTransform(const b2Transform& xf) +{ + b2Vec2 p1 = xf.position, p2; + const float32 k_axisScale = 0.4f; + + p2 = p1 + k_axisScale * xf.R.col1; + DrawSegment(p1,p2,b2Color(1,0,0)); + + p2 = p1 + k_axisScale * xf.R.col2; + DrawSegment(p1,p2,b2Color(0,1,0)); +} + +void GLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& color) +{ + glColor4f(color.r, color.g, color.b,1); + glPointSize(size); + GLfloat glVertices[] = { + p.x,p.y + }; + glVertexPointer(2, GL_FLOAT, 0, glVertices); + glDrawArrays(GL_POINTS, 0, 1); + glPointSize(1.0f); +} + +void GLESDebugDraw::DrawString(int x, int y, const char *string, ...) +{ + + /* Unsupported as yet. Could replace with bitmap font renderer at a later date */ +} + +void GLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& c) +{ + + glColor4f(c.r, c.g, c.b,1); + + GLfloat glVertices[] = { + aabb->lowerBound.x, aabb->lowerBound.y, + aabb->upperBound.x, aabb->lowerBound.y, + aabb->upperBound.x, aabb->upperBound.y, + aabb->lowerBound.x, aabb->upperBound.y + }; + glVertexPointer(2, GL_FLOAT, 0, glVertices); + glDrawArrays(GL_LINE_LOOP, 0, 8); + +} diff --git a/src/references/TestEntriesViewController.h b/src/references/TestEntriesViewController.h new file mode 100644 index 0000000..d28a655 --- /dev/null +++ b/src/references/TestEntriesViewController.h @@ -0,0 +1,19 @@ +// +// TestEntriesViewController.h +// Box2D +// +// Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com +// + +#import +#import "iPhoneTest.h" +#import "Delegates.h" + +@interface TestEntriesViewController : UITableViewController { + int32 testCount; + id _delegate; +} + +@property(assign) id delegate; + +@end diff --git a/src/references/TestEntriesViewController.mm b/src/references/TestEntriesViewController.mm new file mode 100644 index 0000000..2e016b3 --- /dev/null +++ b/src/references/TestEntriesViewController.mm @@ -0,0 +1,75 @@ +// +// TestEntriesViewController.m +// Box2D +// +// Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com +// + +#import "TestEntriesViewController.h" + + +@implementation TestEntriesViewController + +@synthesize delegate=_delegate; + +- (id)initWithStyle:(UITableViewStyle)style { + if ((self = [super initWithStyle:style])) { + testCount = 0; + TestEntry* e = g_testEntries; + while (e->createFcn) + { + ++testCount; + ++e; + } + } + return self; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview + // Release anything that's not essential, such as cached data +} + +#pragma mark Table view methods + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + + +// Customize the number of rows in the table view. +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return testCount; +} + + +// Customize the appearance of table view cells. +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; + } + + // Set up the cell... + TestEntry* e = g_testEntries; + e+=indexPath.row; + + [cell.textLabel setText:[NSString stringWithCString:e->name encoding:NSUTF8StringEncoding]]; + return cell; +} + + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [_delegate selectTest:indexPath.row]; +} + +- (void)dealloc { + [super dealloc]; +} + + +@end + diff --git a/src/references/iPhoneTest.h b/src/references/iPhoneTest.h new file mode 100644 index 0000000..dc82ed5 --- /dev/null +++ b/src/references/iPhoneTest.h @@ -0,0 +1,185 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com +* +* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +#ifndef TEST_H +#define TEST_H + +#import +#include +#include "GLES-Render.h" + +#include + +class Test; +struct Settings; + +typedef Test* TestCreateFcn(); + +#define RAND_LIMIT 32767 + +/// Random number in range [-1,1] +inline float32 RandomFloat() +{ + float32 r = (float32)(rand() & (RAND_LIMIT)); + r /= RAND_LIMIT; + r = 2.0f * r - 1.0f; + return r; +} + +/// Random floating point number in range [lo, hi] +inline float32 RandomFloat(float32 lo, float32 hi) +{ + float32 r = (float32)(rand() & (RAND_LIMIT)); + r /= RAND_LIMIT; + r = (hi - lo) * r + lo; + return r; +} + +/// Test settings. Some can be controlled in the GUI. +struct Settings +{ + Settings() : + hz(60.0f), + velocityIterations(10), + positionIterations(4), + drawStats(0), + drawShapes(1), + drawJoints(1), + drawAABBs(0), + drawPairs(0), + drawContactPoints(0), + drawContactNormals(0), + drawContactForces(0), + drawFrictionForces(0), + drawCOMs(0), + enableWarmStarting(1), + enableContinuous(1), + pause(0), + singleStep(0) + {} + + float32 hz; + int32 velocityIterations; + int32 positionIterations; + int32 drawShapes; + int32 drawJoints; + int32 drawAABBs; + int32 drawPairs; + int32 drawContactPoints; + int32 drawContactNormals; + int32 drawContactForces; + int32 drawFrictionForces; + int32 drawCOMs; + int32 drawStats; + int32 enableWarmStarting; + int32 enableContinuous; + int32 pause; + int32 singleStep; +}; + +struct TestEntry +{ + const char *name; + TestCreateFcn *createFcn; +}; + +extern TestEntry g_testEntries[]; +// This is called when a joint in the world is implicitly destroyed +// because an attached body is destroyed. This gives us a chance to +// nullify the mouse joint. +class DestructionListener : public b2DestructionListener + { + public: + void SayGoodbye(b2Fixture* fixture) { B2_NOT_USED(fixture); } + void SayGoodbye(b2Joint* joint); + + Test* test; + }; + +const int32 k_maxContactPoints = 2048; + +struct ContactPoint +{ + b2Fixture* fixtureA; + b2Fixture* fixtureB; + b2Vec2 normal; + b2Vec2 position; + b2PointState state; +}; + +class Test : public b2ContactListener + { + public: + + Test(); + virtual ~Test(); + + void SetGravity(float x,float y); + void SetTextLine(int32 line) { m_textLine = line; } + void DrawTitle(int x, int y, const char *string); + virtual void Step(Settings* settings); + virtual void Keyboard(unsigned char key) { B2_NOT_USED(key); } + void ShiftMouseDown(const b2Vec2& p); + virtual void MouseDown(const b2Vec2& p); + virtual void MouseUp(const b2Vec2& p); + void MouseMove(const b2Vec2& p); + void LaunchBomb(); + void LaunchBomb(const b2Vec2& position, const b2Vec2& velocity); + + void SpawnBomb(const b2Vec2& worldPt); + void CompleteBombSpawn(const b2Vec2& p); + + // Let derived tests know that a joint was destroyed. + virtual void JointDestroyed(b2Joint* joint) { B2_NOT_USED(joint); } + + // Callbacks for derived classes. + virtual void BeginContact(b2Contact* contact) { B2_NOT_USED(contact); } + virtual void EndContact(b2Contact* contact) { B2_NOT_USED(contact); } + virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold); + virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) + { + B2_NOT_USED(contact); + B2_NOT_USED(impulse); + } + + protected: + friend class DestructionListener; + friend class BoundaryListener; + friend class ContactListener; + + b2Body* m_groundBody; + b2AABB m_worldAABB; + ContactPoint m_points[k_maxContactPoints]; + int32 m_pointCount; + DestructionListener m_destructionListener; + GLESDebugDraw m_debugDraw; + int32 m_textLine; + b2World* m_world; + b2Body* m_bomb; + b2MouseJoint* m_mouseJoint; + b2Vec2 m_bombSpawnPoint; + bool m_bombSpawning; + b2Vec2 m_mouseWorld; + int32 m_stepCount; + }; + +#endif diff --git a/src/references/iPhoneTest.mm b/src/references/iPhoneTest.mm new file mode 100644 index 0000000..16cc5da --- /dev/null +++ b/src/references/iPhoneTest.mm @@ -0,0 +1,411 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com +* +* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "iPhoneTest.h" +#include "GLES-Render.h" + +#include + +void DestructionListener::SayGoodbye(b2Joint* joint) +{ + if (test->m_mouseJoint == joint) + { + test->m_mouseJoint = NULL; + } + else + { + test->JointDestroyed(joint); + } +} + +Test::Test() +: m_debugDraw() +{ + b2Vec2 gravity; + gravity.Set(0.0f, -10.0f); + bool doSleep = true; + m_world = new b2World(gravity, doSleep); + m_bomb = NULL; + m_textLine = 30; + m_mouseJoint = NULL; + m_pointCount = 0; + + m_destructionListener.test = this; + m_world->SetDestructionListener(&m_destructionListener); + m_world->SetContactListener(this); + m_world->SetDebugDraw(&m_debugDraw); + + m_bombSpawning = false; + + m_stepCount = 0; + + b2BodyDef bodyDef; + m_groundBody = m_world->CreateBody(&bodyDef); +} + +Test::~Test() +{ + // By deleting the world, we delete the bomb, mouse joint, etc. + delete m_world; + m_world = NULL; + +} + +void Test::SetGravity( float x, float y) +{ + float tVectorLength=sqrt(x*x+y*y); + float newGravityX=9.81f*x/tVectorLength; + float newGravityY=9.81f*y/tVectorLength; + m_world->SetGravity(b2Vec2(newGravityX,newGravityY)); +} + +void Test::PreSolve(b2Contact* contact, const b2Manifold* oldManifold) +{ + const b2Manifold* manifold = contact->GetManifold(); + + if (manifold->pointCount == 0) + { + return; + } + + b2Fixture* fixtureA = contact->GetFixtureA(); + b2Fixture* fixtureB = contact->GetFixtureB(); + + b2PointState state1[b2_maxManifoldPoints], state2[b2_maxManifoldPoints]; + b2GetPointStates(state1, state2, oldManifold, manifold); + + b2WorldManifold worldManifold; + contact->GetWorldManifold(&worldManifold); + + for (int32 i = 0; i < manifold->pointCount && m_pointCount < k_maxContactPoints; ++i) + { + ContactPoint* cp = m_points + m_pointCount; + cp->fixtureA = fixtureA; + cp->fixtureB = fixtureB; + cp->position = worldManifold.points[i]; + cp->normal = worldManifold.normal; + cp->state = state2[i]; + ++m_pointCount; + } +} + +void Test::DrawTitle(int x, int y, const char *string) +{ + m_debugDraw.DrawString(x, y, string); +} + +class QueryCallback : public b2QueryCallback + { + public: + QueryCallback(const b2Vec2& point) + { + m_point = point; + m_fixture = NULL; + } + + bool ReportFixture(b2Fixture* fixture) + { + b2Body* body = fixture->GetBody(); + if (body->GetType() == b2_dynamicBody) + { + bool inside = fixture->TestPoint(m_point); + if (inside) + { + m_fixture = fixture; + + // We are done, terminate the query. + return false; + } + } + + // Continue the query. + return true; + } + + b2Vec2 m_point; + b2Fixture* m_fixture; + }; + + +void Test::MouseDown(const b2Vec2& p) +{ + m_mouseWorld = p; + + if (m_mouseJoint != NULL) + { + return; + } + + // Make a small box. + b2AABB aabb; + b2Vec2 d; + d.Set(0.001f, 0.001f); + aabb.lowerBound = p - d; + aabb.upperBound = p + d; + + // Query the world for overlapping shapes. + QueryCallback callback(p); + m_world->QueryAABB(&callback, aabb); + + if (callback.m_fixture) + { + b2Body* body = callback.m_fixture->GetBody(); + b2MouseJointDef md; + md.bodyA = m_groundBody; + md.bodyB = body; + md.target = p; +#ifdef TARGET_FLOAT32_IS_FIXED + md.maxForce = (body->GetMass() < 16.0)? + (1000.0f * body->GetMass()) : float32(16000.0); +#else + md.maxForce = 1000.0f * body->GetMass(); +#endif + m_mouseJoint = (b2MouseJoint*)m_world->CreateJoint(&md); + body->SetAwake(true); + } +} + +void Test::SpawnBomb(const b2Vec2& worldPt) +{ + m_bombSpawnPoint = worldPt; + m_bombSpawning = true; +} + +void Test::CompleteBombSpawn(const b2Vec2& p) +{ + if (m_bombSpawning == false) + { + return; + } + + const float multiplier = 30.0f; + b2Vec2 vel = m_bombSpawnPoint - p; + vel *= multiplier; + LaunchBomb(m_bombSpawnPoint,vel); + m_bombSpawning = false; +} + +void Test::ShiftMouseDown(const b2Vec2& p) +{ + m_mouseWorld = p; + + if (m_mouseJoint != NULL) + { + return; + } + + SpawnBomb(p); +} + +void Test::MouseUp(const b2Vec2& p) +{ + if (m_mouseJoint) + { + m_world->DestroyJoint(m_mouseJoint); + m_mouseJoint = NULL; + } + + if (m_bombSpawning) + { + CompleteBombSpawn(p); + } +} + +void Test::MouseMove(const b2Vec2& p) +{ + m_mouseWorld = p; + + if (m_mouseJoint) + { + m_mouseJoint->SetTarget(p); + } +} + +void Test::LaunchBomb() +{ + b2Vec2 p(RandomFloat(-15.0f, 15.0f), 30.0f); + b2Vec2 v = -5.0f * p; + LaunchBomb(p, v); +} + +void Test::LaunchBomb(const b2Vec2& position, const b2Vec2& velocity) +{ + if (m_bomb) + { + m_world->DestroyBody(m_bomb); + m_bomb = NULL; + } + + b2BodyDef bd; + bd.type = b2_dynamicBody; + bd.position = position; + bd.bullet = true; + m_bomb = m_world->CreateBody(&bd); + m_bomb->SetLinearVelocity(velocity); + + b2CircleShape circle; + circle.m_radius = 0.3f; + + b2FixtureDef fd; + fd.shape = &circle; + fd.density = 20.0f; + fd.restitution = 0.1f; + + b2Vec2 minV = position - b2Vec2(0.3f,0.3f); + b2Vec2 maxV = position + b2Vec2(0.3f,0.3f); + + b2AABB aabb; + aabb.lowerBound = minV; + aabb.upperBound = maxV; + + m_bomb->CreateFixture(&fd); +} + +void Test::Step(Settings* settings) +{ + float32 timeStep = settings->hz > 0.0f ? 1.0f / settings->hz : float32(0.0f); + + if (settings->pause) + { + if (settings->singleStep) + { + settings->singleStep = 0; + } + else + { + timeStep = 0.0f; + } + + m_debugDraw.DrawString(5, m_textLine, "****PAUSED****"); + m_textLine += 15; + } + + uint32 flags = 0; + flags += settings->drawShapes * b2DebugDraw::e_shapeBit; + flags += settings->drawJoints * b2DebugDraw::e_jointBit; + flags += settings->drawAABBs * b2DebugDraw::e_aabbBit; + flags += settings->drawPairs * b2DebugDraw::e_pairBit; + flags += settings->drawCOMs * b2DebugDraw::e_centerOfMassBit; + m_debugDraw.SetFlags(flags); + + m_world->SetWarmStarting(settings->enableWarmStarting > 0); + m_world->SetContinuousPhysics(settings->enableContinuous > 0); + + m_pointCount = 0; + + m_world->Step(timeStep, settings->velocityIterations, settings->positionIterations); + + m_world->DrawDebugData(); + + if (timeStep > 0.0f) + { + ++m_stepCount; + } + + if (settings->drawStats) + { + m_debugDraw.DrawString(5, m_textLine, "bodies/contacts/joints/proxies = %d/%d/%d", + m_world->GetBodyCount(), m_world->GetContactCount(), m_world->GetJointCount(), m_world->GetProxyCount()); + m_textLine += 15; + +// m_debugDraw.DrawString(5, m_textLine, "heap bytes = %d", b2_byteCount); +// m_textLine += 15; + } + + if (m_mouseJoint) + { +// b2Body* body = m_mouseJoint->GetBodyB(); +// b2Vec2 p1 = body->GetWorldPoint(m_mouseJoint->m_localAnchor); +// b2Vec2 p2 = m_mouseJoint->m_target; +// +// glPointSize(4.0f); +// glColor3f(0.0f, 1.0f, 0.0f); +// glBegin(GL_POINTS); +// glVertex2f(p1.x, p1.y); +// glVertex2f(p2.x, p2.y); +// glEnd(); +// glPointSize(1.0f); +// +// glColor3f(0.8f, 0.8f, 0.8f); +// glBegin(GL_LINES); +// glVertex2f(p1.x, p1.y); +// glVertex2f(p2.x, p2.y); +// glEnd(); + } + + if (m_bombSpawning) + { +// glPointSize(4.0f); +// glColor3f(0.0f, 0.0f, 1.0f); +// glBegin(GL_POINTS); +// glColor3f(0.0f, 0.0f, 1.0f); +// glVertex2f(m_bombSpawnPoint.x, m_bombSpawnPoint.y); +// glEnd(); +// +// glColor3f(0.8f, 0.8f, 0.8f); +// glBegin(GL_LINES); +// glVertex2f(m_mouseWorld.x, m_mouseWorld.y); +// glVertex2f(m_bombSpawnPoint.x, m_bombSpawnPoint.y); +// glEnd(); + } + + if (settings->drawContactPoints) + { + //const float32 k_impulseScale = 0.1f; + const float32 k_axisScale = 0.3f; + + for (int32 i = 0; i < m_pointCount; ++i) + { + ContactPoint* point = m_points + i; + + if (point->state == b2_addState) + { + // Add + m_debugDraw.DrawPoint(point->position, 10.0f, b2Color(0.3f, 0.95f, 0.3f)); + } + else if (point->state == b2_persistState) + { + // Persist + m_debugDraw.DrawPoint(point->position, 5.0f, b2Color(0.3f, 0.3f, 0.95f)); + } + + if (settings->drawContactNormals == 1) + { + b2Vec2 p1 = point->position; + b2Vec2 p2 = p1 + k_axisScale * point->normal; + m_debugDraw.DrawSegment(p1, p2, b2Color(0.4f, 0.9f, 0.4f)); + } + else if (settings->drawContactForces == 1) + { + //b2Vec2 p1 = point->position; + //b2Vec2 p2 = p1 + k_forceScale * point->normalForce * point->normal; + //DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.3f)); + } + + if (settings->drawFrictionForces == 1) + { + //b2Vec2 tangent = b2Cross(point->normal, 1.0f); + //b2Vec2 p1 = point->position; + //b2Vec2 p2 = p1 + k_forceScale * point->tangentForce * tangent; + //DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.3f)); + } + } + } +} diff --git a/src/references/iPhoneTestEntries.mm b/src/references/iPhoneTestEntries.mm new file mode 100644 index 0000000..02da5f5 --- /dev/null +++ b/src/references/iPhoneTestEntries.mm @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#include "iPhoneTest.h" +//#include "GLES-Render.h" + +#include "ApplyForce.h" +#include "BodyTypes.h" + +#include "Breakable.h" +#include "Bridge.h" +#include "Chain.h" +#include "CollisionFiltering.h" +#include "CollisionProcessing.h" +#include "CompoundShapes.h" +#include "Confined.h" +#include "DistanceTest.h" +#include "Dominos.h" +#include "DynamicTreeTest.h" +#include "Gears.h" +#include "LineJoint.h" +#include "OneSidedPlatform.h" +#include "PolyCollision.h" +#include "PolyShapes.h" +#include "Prismatic.h" +#include "Pulleys.h" +#include "Pyramid.h" +#include "RayCast.h" +#include "Revolute.h" +#include "SensorTest.h" +#include "ShapeEditing.h" +#include "SliderCrank.h" +#include "SphereStack.h" +#include "TheoJansen.h" +#include "TimeOfImpact.h" +#include "VaryingFriction.h" +#include "VaryingRestitution.h" +#include "VerticalStack.h" +#include "Web.h" + +TestEntry g_testEntries[] = +{ +{"Body Types", BodyTypes::Create}, +{"SphereStack", SphereStack::Create}, +{"Vertical Stack", VerticalStack::Create}, +{"Confined", Confined::Create}, +{"Bridge", Bridge::Create}, +{"Breakable", Breakable::Create}, +{"Varying Restitution", VaryingRestitution::Create}, +{"Ray-Cast", RayCast::Create}, +{"Pyramid", Pyramid::Create}, +{"PolyCollision", PolyCollision::Create}, +{"One-Sided Platform", OneSidedPlatform::Create}, +{"Apply Force", ApplyForce::Create}, +{"Chain", Chain::Create}, +{"Collision Filtering", CollisionFiltering::Create}, +{"Collision Processing", CollisionProcessing::Create}, +{"Compound Shapes", CompoundShapes::Create}, +{"Distance Test", DistanceTest::Create}, +{"Dominos", Dominos::Create}, +{"Dynamic Tree", DynamicTreeTest::Create}, +{"Gears", Gears::Create}, +{"Line Joint", LineJoint::Create}, +{"Polygon Shapes", PolyShapes::Create}, +{"Prismatic", Prismatic::Create}, +{"Pulleys", Pulleys::Create}, +{"Revolute", Revolute::Create}, +{"Sensor Test", SensorTest::Create}, +{"Shape Editing", ShapeEditing::Create}, +{"Slider Crank", SliderCrank::Create}, +{"Theo Jansen's Walker", TheoJansen::Create}, +{"Time of Impact", TimeOfImpact::Create}, +{"Varying Friction", VaryingFriction::Create}, +{"Web", Web::Create}, +{NULL, NULL} + +}; diff --git a/src/render/Box2DAppDelegate.h b/src/render/Box2DAppDelegate.h deleted file mode 100644 index f081ba3..0000000 --- a/src/render/Box2DAppDelegate.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// Box2DAppDelegate.h -// Box2D -// -// Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -// - -#import -#import "TestEntriesViewController.h" -#import "Delegates.h" - -@class Box2DView; - -@interface Box2DAppDelegate : NSObject { - UIWindow *window; - Box2DView *glView; - TestEntriesViewController *testEntriesView; -} - -@property (nonatomic, retain) IBOutlet UIWindow *window; -@property (nonatomic, retain) IBOutlet Box2DView *glView; - -@end - diff --git a/src/render/Box2DAppDelegate.mm b/src/render/Box2DAppDelegate.mm deleted file mode 100644 index e04a09e..0000000 --- a/src/render/Box2DAppDelegate.mm +++ /dev/null @@ -1,62 +0,0 @@ -// -// Box2DAppDelegate.m -// Box2D -// -// Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -// - -#import -#import "Box2DAppDelegate.h" -#import "Box2DView.h" - -@implementation Box2DAppDelegate - -@synthesize window; -@synthesize glView; - -- (void)applicationDidFinishLaunching:(UIApplication *)application { - [application setStatusBarHidden:true]; - - [glView removeFromSuperview]; - - glView.animationInterval = 1.0 / 60.0; - - testEntriesView=[[TestEntriesViewController alloc] initWithStyle:UITableViewStylePlain]; - [testEntriesView setDelegate:self]; - [glView setDelegate:self]; - - [window addSubview:[testEntriesView view]]; -} - --(void) selectTest:(int) testIndex -{ - [[testEntriesView view] removeFromSuperview]; - [window addSubview:glView]; - [glView startAnimation]; - [glView selectTestEntry:testIndex]; -} - --(void) leaveTest -{ - [glView stopAnimation]; - [glView removeFromSuperview]; - [window addSubview:[testEntriesView view]]; -} - -- (void)applicationWillResignActive:(UIApplication *)application { - glView.animationInterval = 1.0 / 5.0; -} - - -- (void)applicationDidBecomeActive:(UIApplication *)application { - glView.animationInterval = 1.0 / 60.0; -} - - -- (void)dealloc { - [window release]; - [glView release]; - [super dealloc]; -} - -@end diff --git a/src/render/Box2DView.h b/src/render/Box2DView.h deleted file mode 100644 index 81d50b3..0000000 --- a/src/render/Box2DView.h +++ /dev/null @@ -1,63 +0,0 @@ -// -// Box2DView.h -// Box2D OpenGL View -// -// Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -// - - -#import -#import -#import -#import - -#import "iPhoneTest.h" -#import "Delegates.h" - -/* -This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. -The view content is basically an EAGL surface you render your OpenGL scene into. -Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. -*/ -@interface Box2DView : UIView { - -@private - /* The pixel dimensions of the backbuffer */ - GLint backingWidth; - GLint backingHeight; - - EAGLContext *context; - - /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ - GLuint viewRenderbuffer, viewFramebuffer; - - /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ - GLuint depthRenderbuffer; - - NSTimer *animationTimer; - NSTimeInterval animationInterval; - - TestEntry* entry; - Test* test; - - // Position offset and scale - float sceneScale; - CGPoint positionOffset; - CGPoint lastWorldTouch; - CGPoint lastScreenTouch; - - bool panning; - int doubleClickValidCountdown; - - id _delegate; - -} -@property(assign) id delegate; -@property NSTimeInterval animationInterval; - -- (void)startAnimation; -- (void)stopAnimation; -- (void)drawView; --(void) selectTestEntry:(int) testIndex; - -@end diff --git a/src/render/Box2DView.mm b/src/render/Box2DView.mm deleted file mode 100644 index 11743b0..0000000 --- a/src/render/Box2DView.mm +++ /dev/null @@ -1,295 +0,0 @@ -// -// Box2DView.mm -// Box2D OpenGL View -// -// Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -// - -#import -#import - -#import "Box2DView.h" - -#define USE_DEPTH_BUFFER 0 -#define kAccelerometerFrequency 30 -#define FRAMES_BETWEEN_PRESSES_FOR_DOUBLE_CLICK 10 - -Settings settings; - -// A class extension to declare private methods -@interface Box2DView () - -@property (nonatomic, retain) EAGLContext *context; -@property (nonatomic, assign) NSTimer *animationTimer; - -- (BOOL) createFramebuffer; -- (void) destroyFramebuffer; - -@end - - -@implementation Box2DView - -@synthesize context; -@synthesize animationTimer; -@synthesize animationInterval; -@synthesize delegate=_delegate; - -// You must implement this method -+ (Class)layerClass { - return [CAEAGLLayer class]; -} - - -//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: -- (id)initWithCoder:(NSCoder*)coder { - - if ((self = [super initWithCoder:coder])) { - // Get the layer - CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; - - eaglLayer.opaque = YES; - eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; - - context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; - - if (!context || ![EAGLContext setCurrentContext:context]) { - [self release]; - return nil; - } - - animationInterval = 1.0 / 60.0; - sceneScale=10.0f; - positionOffset=CGPointMake(0, 0); - lastWorldTouch=CGPointMake(0, 0); - - [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)]; - [[UIAccelerometer sharedAccelerometer] setDelegate:self]; - } - - - return self; -} - --(void) selectTestEntry:(int) testIndex -{ - // Destroy existing scene - delete test; - - entry = g_testEntries + testIndex; - test = entry->createFcn(); - - doubleClickValidCountdown=0; - - sceneScale=10.0f; - positionOffset=CGPointMake(0, 0); - lastWorldTouch=CGPointMake(0, 0); -} - - - -- (void)drawView { - - - - if (doubleClickValidCountdown>0) doubleClickValidCountdown--; - - [EAGLContext setCurrentContext:context]; - - glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); - glViewport(0, 0, backingWidth, backingHeight); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glOrthof(-sceneScale, sceneScale, -sceneScale*1.5f, sceneScale*1.5f, -1.0f, 1.0f); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(positionOffset.x, positionOffset.y,0); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glEnableClientState(GL_VERTEX_ARRAY); - - test->Step(&settings); - - glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); - [context presentRenderbuffer:GL_RENDERBUFFER_OES]; -} - - -- (void)layoutSubviews { - [EAGLContext setCurrentContext:context]; - [self destroyFramebuffer]; - [self createFramebuffer]; - [self drawView]; -} - - -- (BOOL)createFramebuffer { - - glGenFramebuffersOES(1, &viewFramebuffer); - glGenRenderbuffersOES(1, &viewRenderbuffer); - - glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); - [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); - - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); - - if (USE_DEPTH_BUFFER) { - glGenRenderbuffersOES(1, &depthRenderbuffer); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); - glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight); - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); - } - - if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { - NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); - return NO; - } - - return YES; -} - - -- (void)destroyFramebuffer { - - glDeleteFramebuffersOES(1, &viewFramebuffer); - viewFramebuffer = 0; - glDeleteRenderbuffersOES(1, &viewRenderbuffer); - viewRenderbuffer = 0; - - if(depthRenderbuffer) { - glDeleteRenderbuffersOES(1, &depthRenderbuffer); - depthRenderbuffer = 0; - } -} - - -- (void)startAnimation { - self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; -} - - -- (void)stopAnimation { - self.animationTimer = nil; -} - - -- (void)setAnimationTimer:(NSTimer *)newTimer { - [animationTimer invalidate]; - animationTimer = newTimer; -} - - -- (void)setAnimationInterval:(NSTimeInterval)interval { - - animationInterval = interval; - if (animationTimer) { - [self stopAnimation]; - [self startAnimation]; - } -} - - -- (void)dealloc { - - [self stopAnimation]; - - if ([EAGLContext currentContext] == context) { - [EAGLContext setCurrentContext:nil]; - } - - [context release]; - [super dealloc]; -} - --(CGPoint) screenSpaceToWorldSpace:(CGPoint) screenLocation -{ - screenLocation.x-=160; - screenLocation.y-=240; - screenLocation.x/=160; - screenLocation.y/=160; - screenLocation.x*=sceneScale; - screenLocation.y*=-sceneScale; - - screenLocation.x-=positionOffset.x; - screenLocation.y-=positionOffset.y; - return screenLocation; -} - -- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event -{ - - if (doubleClickValidCountdown>0) - { - [_delegate leaveTest]; - return; - } - - doubleClickValidCountdown=FRAMES_BETWEEN_PRESSES_FOR_DOUBLE_CLICK; - - - panning=false; - for (UITouch *touch in touches) - { - CGPoint touchLocation=[touch locationInView:self]; - CGPoint worldPosition=[self screenSpaceToWorldSpace:touchLocation]; - //printf("Screen touched %f,%f -> %f,%f\n",touchLocation.x,touchLocation.y,worldPosition.x,worldPosition.y); - lastScreenTouch=touchLocation; - lastWorldTouch=worldPosition; - test->MouseDown(b2Vec2(lastWorldTouch.x,lastWorldTouch.y)); - - if (!test->m_mouseJoint) panning=true; - } -} - -- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event -{ - for (UITouch *touch in touches) - { - CGPoint touchLocation=[touch locationInView:self]; - CGPoint worldPosition=[self screenSpaceToWorldSpace:touchLocation]; - //printf("Screen touched %f,%f -> %f,%f\n",touchLocation.x,touchLocation.y,worldPosition.x,worldPosition.y); - - - CGPoint screenDistanceMoved=CGPointMake(touchLocation.x-lastScreenTouch.x,touchLocation.y-lastScreenTouch.y); - if (panning) - { - screenDistanceMoved.x/=160; - screenDistanceMoved.y/=160; - screenDistanceMoved.x*=sceneScale; - screenDistanceMoved.y*=-sceneScale; - positionOffset.x+=screenDistanceMoved.x; - positionOffset.y+=screenDistanceMoved.y; - } - - lastScreenTouch=touchLocation; - lastWorldTouch=worldPosition; - test->MouseMove(b2Vec2(lastWorldTouch.x,lastWorldTouch.y)); - - } -} -- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event -{ - test->MouseUp(b2Vec2(lastWorldTouch.x,lastWorldTouch.y)); -} - -- (void) accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration -{ - // Only run for valid values - if (acceleration.y!=0 && acceleration.x!=0) - { - if (test) test->SetGravity(acceleration.x,acceleration.y); - } -} - -@end diff --git a/src/render/Delegates.h b/src/render/Delegates.h deleted file mode 100644 index b4b7976..0000000 --- a/src/render/Delegates.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Delegates.h - * Box2D - * - * Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com - * - * - */ - -@protocol TestSelectDelegate - -(void) selectTest:(int) testIndex; - -(void) leaveTest; - -@end \ No newline at end of file diff --git a/src/render/GLES-Render.h b/src/render/GLES-Render.h deleted file mode 100644 index 2551666..0000000 --- a/src/render/GLES-Render.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com -* -* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef RENDER_H -#define RENDER_H - -#import -#import -#import -#import - -#include - -struct b2AABB; - -// This class implements debug drawing callbacks that are invoked -// inside b2World::Step. -class GLESDebugDraw : public b2DebugDraw -{ -public: - void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); - - void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); - - void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color); - - void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color); - - void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color); - - void DrawTransform(const b2Transform& xf); - - void DrawPoint(const b2Vec2& p, float32 size, const b2Color& color); - - void DrawString(int x, int y, const char* string, ...); - - void DrawAABB(b2AABB* aabb, const b2Color& color); -}; - - -#endif diff --git a/src/render/GLES-Render.mm b/src/render/GLES-Render.mm deleted file mode 100644 index abf5c57..0000000 --- a/src/render/GLES-Render.mm +++ /dev/null @@ -1,149 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com -* -* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "GLES-Render.h" - - -#include -#include - -#include - -void GLESDebugDraw::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) -{ - glColor4f(color.r, color.g, color.b,1); - glVertexPointer(2, GL_FLOAT, 0, vertices); - glDrawArrays(GL_LINE_LOOP, 0, vertexCount); -} - -void GLESDebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) -{ - glVertexPointer(2, GL_FLOAT, 0, vertices); - - glColor4f(color.r, color.g, color.b,0.5f); - glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); - - glColor4f(color.r, color.g, color.b,1); - glDrawArrays(GL_LINE_LOOP, 0, vertexCount); -} - -void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) -{ - const float32 k_segments = 16.0f; - int vertexCount=16; - const float32 k_increment = 2.0f * b2_pi / k_segments; - float32 theta = 0.0f; - - GLfloat glVertices[vertexCount*2]; - for (int32 i = 0; i < k_segments; ++i) - { - b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); - glVertices[i*2]=v.x; - glVertices[i*2+1]=v.y; - theta += k_increment; - } - - glColor4f(color.r, color.g, color.b,1); - glVertexPointer(2, GL_FLOAT, 0, glVertices); - - glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); -} - -void GLESDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) -{ - const float32 k_segments = 16.0f; - int vertexCount=16; - const float32 k_increment = 2.0f * b2_pi / k_segments; - float32 theta = 0.0f; - - GLfloat glVertices[vertexCount*2]; - for (int32 i = 0; i < k_segments; ++i) - { - b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); - glVertices[i*2]=v.x; - glVertices[i*2+1]=v.y; - theta += k_increment; - } - - glColor4f(color.r, color.g, color.b,0.5f); - glVertexPointer(2, GL_FLOAT, 0, glVertices); - glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); - glColor4f(color.r, color.g, color.b,1); - glDrawArrays(GL_LINE_LOOP, 0, vertexCount); - - // Draw the axis line - DrawSegment(center,center+radius*axis,color); -} - -void GLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) -{ - glColor4f(color.r, color.g, color.b,1); - GLfloat glVertices[] = { - p1.x,p1.y,p2.x,p2.y - }; - glVertexPointer(2, GL_FLOAT, 0, glVertices); - glDrawArrays(GL_LINES, 0, 2); -} - -void GLESDebugDraw::DrawTransform(const b2Transform& xf) -{ - b2Vec2 p1 = xf.position, p2; - const float32 k_axisScale = 0.4f; - - p2 = p1 + k_axisScale * xf.R.col1; - DrawSegment(p1,p2,b2Color(1,0,0)); - - p2 = p1 + k_axisScale * xf.R.col2; - DrawSegment(p1,p2,b2Color(0,1,0)); -} - -void GLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& color) -{ - glColor4f(color.r, color.g, color.b,1); - glPointSize(size); - GLfloat glVertices[] = { - p.x,p.y - }; - glVertexPointer(2, GL_FLOAT, 0, glVertices); - glDrawArrays(GL_POINTS, 0, 1); - glPointSize(1.0f); -} - -void GLESDebugDraw::DrawString(int x, int y, const char *string, ...) -{ - - /* Unsupported as yet. Could replace with bitmap font renderer at a later date */ -} - -void GLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& c) -{ - - glColor4f(c.r, c.g, c.b,1); - - GLfloat glVertices[] = { - aabb->lowerBound.x, aabb->lowerBound.y, - aabb->upperBound.x, aabb->lowerBound.y, - aabb->upperBound.x, aabb->upperBound.y, - aabb->lowerBound.x, aabb->upperBound.y - }; - glVertexPointer(2, GL_FLOAT, 0, glVertices); - glDrawArrays(GL_LINE_LOOP, 0, 8); - -} diff --git a/src/render/TestEntriesViewController.h b/src/render/TestEntriesViewController.h deleted file mode 100644 index d28a655..0000000 --- a/src/render/TestEntriesViewController.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// TestEntriesViewController.h -// Box2D -// -// Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -// - -#import -#import "iPhoneTest.h" -#import "Delegates.h" - -@interface TestEntriesViewController : UITableViewController { - int32 testCount; - id _delegate; -} - -@property(assign) id delegate; - -@end diff --git a/src/render/TestEntriesViewController.mm b/src/render/TestEntriesViewController.mm deleted file mode 100644 index 2e016b3..0000000 --- a/src/render/TestEntriesViewController.mm +++ /dev/null @@ -1,75 +0,0 @@ -// -// TestEntriesViewController.m -// Box2D -// -// Box2D iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -// - -#import "TestEntriesViewController.h" - - -@implementation TestEntriesViewController - -@synthesize delegate=_delegate; - -- (id)initWithStyle:(UITableViewStyle)style { - if ((self = [super initWithStyle:style])) { - testCount = 0; - TestEntry* e = g_testEntries; - while (e->createFcn) - { - ++testCount; - ++e; - } - } - return self; -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview - // Release anything that's not essential, such as cached data -} - -#pragma mark Table view methods - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 1; -} - - -// Customize the number of rows in the table view. -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return testCount; -} - - -// Customize the appearance of table view cells. -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - - static NSString *CellIdentifier = @"Cell"; - - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; - if (cell == nil) { - cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; - } - - // Set up the cell... - TestEntry* e = g_testEntries; - e+=indexPath.row; - - [cell.textLabel setText:[NSString stringWithCString:e->name encoding:NSUTF8StringEncoding]]; - return cell; -} - - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - [_delegate selectTest:indexPath.row]; -} - -- (void)dealloc { - [super dealloc]; -} - - -@end - diff --git a/src/render/iPhoneTest.h b/src/render/iPhoneTest.h deleted file mode 100644 index dc82ed5..0000000 --- a/src/render/iPhoneTest.h +++ /dev/null @@ -1,185 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com -* -* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - - - -#ifndef TEST_H -#define TEST_H - -#import -#include -#include "GLES-Render.h" - -#include - -class Test; -struct Settings; - -typedef Test* TestCreateFcn(); - -#define RAND_LIMIT 32767 - -/// Random number in range [-1,1] -inline float32 RandomFloat() -{ - float32 r = (float32)(rand() & (RAND_LIMIT)); - r /= RAND_LIMIT; - r = 2.0f * r - 1.0f; - return r; -} - -/// Random floating point number in range [lo, hi] -inline float32 RandomFloat(float32 lo, float32 hi) -{ - float32 r = (float32)(rand() & (RAND_LIMIT)); - r /= RAND_LIMIT; - r = (hi - lo) * r + lo; - return r; -} - -/// Test settings. Some can be controlled in the GUI. -struct Settings -{ - Settings() : - hz(60.0f), - velocityIterations(10), - positionIterations(4), - drawStats(0), - drawShapes(1), - drawJoints(1), - drawAABBs(0), - drawPairs(0), - drawContactPoints(0), - drawContactNormals(0), - drawContactForces(0), - drawFrictionForces(0), - drawCOMs(0), - enableWarmStarting(1), - enableContinuous(1), - pause(0), - singleStep(0) - {} - - float32 hz; - int32 velocityIterations; - int32 positionIterations; - int32 drawShapes; - int32 drawJoints; - int32 drawAABBs; - int32 drawPairs; - int32 drawContactPoints; - int32 drawContactNormals; - int32 drawContactForces; - int32 drawFrictionForces; - int32 drawCOMs; - int32 drawStats; - int32 enableWarmStarting; - int32 enableContinuous; - int32 pause; - int32 singleStep; -}; - -struct TestEntry -{ - const char *name; - TestCreateFcn *createFcn; -}; - -extern TestEntry g_testEntries[]; -// This is called when a joint in the world is implicitly destroyed -// because an attached body is destroyed. This gives us a chance to -// nullify the mouse joint. -class DestructionListener : public b2DestructionListener - { - public: - void SayGoodbye(b2Fixture* fixture) { B2_NOT_USED(fixture); } - void SayGoodbye(b2Joint* joint); - - Test* test; - }; - -const int32 k_maxContactPoints = 2048; - -struct ContactPoint -{ - b2Fixture* fixtureA; - b2Fixture* fixtureB; - b2Vec2 normal; - b2Vec2 position; - b2PointState state; -}; - -class Test : public b2ContactListener - { - public: - - Test(); - virtual ~Test(); - - void SetGravity(float x,float y); - void SetTextLine(int32 line) { m_textLine = line; } - void DrawTitle(int x, int y, const char *string); - virtual void Step(Settings* settings); - virtual void Keyboard(unsigned char key) { B2_NOT_USED(key); } - void ShiftMouseDown(const b2Vec2& p); - virtual void MouseDown(const b2Vec2& p); - virtual void MouseUp(const b2Vec2& p); - void MouseMove(const b2Vec2& p); - void LaunchBomb(); - void LaunchBomb(const b2Vec2& position, const b2Vec2& velocity); - - void SpawnBomb(const b2Vec2& worldPt); - void CompleteBombSpawn(const b2Vec2& p); - - // Let derived tests know that a joint was destroyed. - virtual void JointDestroyed(b2Joint* joint) { B2_NOT_USED(joint); } - - // Callbacks for derived classes. - virtual void BeginContact(b2Contact* contact) { B2_NOT_USED(contact); } - virtual void EndContact(b2Contact* contact) { B2_NOT_USED(contact); } - virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold); - virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) - { - B2_NOT_USED(contact); - B2_NOT_USED(impulse); - } - - protected: - friend class DestructionListener; - friend class BoundaryListener; - friend class ContactListener; - - b2Body* m_groundBody; - b2AABB m_worldAABB; - ContactPoint m_points[k_maxContactPoints]; - int32 m_pointCount; - DestructionListener m_destructionListener; - GLESDebugDraw m_debugDraw; - int32 m_textLine; - b2World* m_world; - b2Body* m_bomb; - b2MouseJoint* m_mouseJoint; - b2Vec2 m_bombSpawnPoint; - bool m_bombSpawning; - b2Vec2 m_mouseWorld; - int32 m_stepCount; - }; - -#endif diff --git a/src/render/iPhoneTest.mm b/src/render/iPhoneTest.mm deleted file mode 100644 index 16cc5da..0000000 --- a/src/render/iPhoneTest.mm +++ /dev/null @@ -1,411 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com -* -* iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "iPhoneTest.h" -#include "GLES-Render.h" - -#include - -void DestructionListener::SayGoodbye(b2Joint* joint) -{ - if (test->m_mouseJoint == joint) - { - test->m_mouseJoint = NULL; - } - else - { - test->JointDestroyed(joint); - } -} - -Test::Test() -: m_debugDraw() -{ - b2Vec2 gravity; - gravity.Set(0.0f, -10.0f); - bool doSleep = true; - m_world = new b2World(gravity, doSleep); - m_bomb = NULL; - m_textLine = 30; - m_mouseJoint = NULL; - m_pointCount = 0; - - m_destructionListener.test = this; - m_world->SetDestructionListener(&m_destructionListener); - m_world->SetContactListener(this); - m_world->SetDebugDraw(&m_debugDraw); - - m_bombSpawning = false; - - m_stepCount = 0; - - b2BodyDef bodyDef; - m_groundBody = m_world->CreateBody(&bodyDef); -} - -Test::~Test() -{ - // By deleting the world, we delete the bomb, mouse joint, etc. - delete m_world; - m_world = NULL; - -} - -void Test::SetGravity( float x, float y) -{ - float tVectorLength=sqrt(x*x+y*y); - float newGravityX=9.81f*x/tVectorLength; - float newGravityY=9.81f*y/tVectorLength; - m_world->SetGravity(b2Vec2(newGravityX,newGravityY)); -} - -void Test::PreSolve(b2Contact* contact, const b2Manifold* oldManifold) -{ - const b2Manifold* manifold = contact->GetManifold(); - - if (manifold->pointCount == 0) - { - return; - } - - b2Fixture* fixtureA = contact->GetFixtureA(); - b2Fixture* fixtureB = contact->GetFixtureB(); - - b2PointState state1[b2_maxManifoldPoints], state2[b2_maxManifoldPoints]; - b2GetPointStates(state1, state2, oldManifold, manifold); - - b2WorldManifold worldManifold; - contact->GetWorldManifold(&worldManifold); - - for (int32 i = 0; i < manifold->pointCount && m_pointCount < k_maxContactPoints; ++i) - { - ContactPoint* cp = m_points + m_pointCount; - cp->fixtureA = fixtureA; - cp->fixtureB = fixtureB; - cp->position = worldManifold.points[i]; - cp->normal = worldManifold.normal; - cp->state = state2[i]; - ++m_pointCount; - } -} - -void Test::DrawTitle(int x, int y, const char *string) -{ - m_debugDraw.DrawString(x, y, string); -} - -class QueryCallback : public b2QueryCallback - { - public: - QueryCallback(const b2Vec2& point) - { - m_point = point; - m_fixture = NULL; - } - - bool ReportFixture(b2Fixture* fixture) - { - b2Body* body = fixture->GetBody(); - if (body->GetType() == b2_dynamicBody) - { - bool inside = fixture->TestPoint(m_point); - if (inside) - { - m_fixture = fixture; - - // We are done, terminate the query. - return false; - } - } - - // Continue the query. - return true; - } - - b2Vec2 m_point; - b2Fixture* m_fixture; - }; - - -void Test::MouseDown(const b2Vec2& p) -{ - m_mouseWorld = p; - - if (m_mouseJoint != NULL) - { - return; - } - - // Make a small box. - b2AABB aabb; - b2Vec2 d; - d.Set(0.001f, 0.001f); - aabb.lowerBound = p - d; - aabb.upperBound = p + d; - - // Query the world for overlapping shapes. - QueryCallback callback(p); - m_world->QueryAABB(&callback, aabb); - - if (callback.m_fixture) - { - b2Body* body = callback.m_fixture->GetBody(); - b2MouseJointDef md; - md.bodyA = m_groundBody; - md.bodyB = body; - md.target = p; -#ifdef TARGET_FLOAT32_IS_FIXED - md.maxForce = (body->GetMass() < 16.0)? - (1000.0f * body->GetMass()) : float32(16000.0); -#else - md.maxForce = 1000.0f * body->GetMass(); -#endif - m_mouseJoint = (b2MouseJoint*)m_world->CreateJoint(&md); - body->SetAwake(true); - } -} - -void Test::SpawnBomb(const b2Vec2& worldPt) -{ - m_bombSpawnPoint = worldPt; - m_bombSpawning = true; -} - -void Test::CompleteBombSpawn(const b2Vec2& p) -{ - if (m_bombSpawning == false) - { - return; - } - - const float multiplier = 30.0f; - b2Vec2 vel = m_bombSpawnPoint - p; - vel *= multiplier; - LaunchBomb(m_bombSpawnPoint,vel); - m_bombSpawning = false; -} - -void Test::ShiftMouseDown(const b2Vec2& p) -{ - m_mouseWorld = p; - - if (m_mouseJoint != NULL) - { - return; - } - - SpawnBomb(p); -} - -void Test::MouseUp(const b2Vec2& p) -{ - if (m_mouseJoint) - { - m_world->DestroyJoint(m_mouseJoint); - m_mouseJoint = NULL; - } - - if (m_bombSpawning) - { - CompleteBombSpawn(p); - } -} - -void Test::MouseMove(const b2Vec2& p) -{ - m_mouseWorld = p; - - if (m_mouseJoint) - { - m_mouseJoint->SetTarget(p); - } -} - -void Test::LaunchBomb() -{ - b2Vec2 p(RandomFloat(-15.0f, 15.0f), 30.0f); - b2Vec2 v = -5.0f * p; - LaunchBomb(p, v); -} - -void Test::LaunchBomb(const b2Vec2& position, const b2Vec2& velocity) -{ - if (m_bomb) - { - m_world->DestroyBody(m_bomb); - m_bomb = NULL; - } - - b2BodyDef bd; - bd.type = b2_dynamicBody; - bd.position = position; - bd.bullet = true; - m_bomb = m_world->CreateBody(&bd); - m_bomb->SetLinearVelocity(velocity); - - b2CircleShape circle; - circle.m_radius = 0.3f; - - b2FixtureDef fd; - fd.shape = &circle; - fd.density = 20.0f; - fd.restitution = 0.1f; - - b2Vec2 minV = position - b2Vec2(0.3f,0.3f); - b2Vec2 maxV = position + b2Vec2(0.3f,0.3f); - - b2AABB aabb; - aabb.lowerBound = minV; - aabb.upperBound = maxV; - - m_bomb->CreateFixture(&fd); -} - -void Test::Step(Settings* settings) -{ - float32 timeStep = settings->hz > 0.0f ? 1.0f / settings->hz : float32(0.0f); - - if (settings->pause) - { - if (settings->singleStep) - { - settings->singleStep = 0; - } - else - { - timeStep = 0.0f; - } - - m_debugDraw.DrawString(5, m_textLine, "****PAUSED****"); - m_textLine += 15; - } - - uint32 flags = 0; - flags += settings->drawShapes * b2DebugDraw::e_shapeBit; - flags += settings->drawJoints * b2DebugDraw::e_jointBit; - flags += settings->drawAABBs * b2DebugDraw::e_aabbBit; - flags += settings->drawPairs * b2DebugDraw::e_pairBit; - flags += settings->drawCOMs * b2DebugDraw::e_centerOfMassBit; - m_debugDraw.SetFlags(flags); - - m_world->SetWarmStarting(settings->enableWarmStarting > 0); - m_world->SetContinuousPhysics(settings->enableContinuous > 0); - - m_pointCount = 0; - - m_world->Step(timeStep, settings->velocityIterations, settings->positionIterations); - - m_world->DrawDebugData(); - - if (timeStep > 0.0f) - { - ++m_stepCount; - } - - if (settings->drawStats) - { - m_debugDraw.DrawString(5, m_textLine, "bodies/contacts/joints/proxies = %d/%d/%d", - m_world->GetBodyCount(), m_world->GetContactCount(), m_world->GetJointCount(), m_world->GetProxyCount()); - m_textLine += 15; - -// m_debugDraw.DrawString(5, m_textLine, "heap bytes = %d", b2_byteCount); -// m_textLine += 15; - } - - if (m_mouseJoint) - { -// b2Body* body = m_mouseJoint->GetBodyB(); -// b2Vec2 p1 = body->GetWorldPoint(m_mouseJoint->m_localAnchor); -// b2Vec2 p2 = m_mouseJoint->m_target; -// -// glPointSize(4.0f); -// glColor3f(0.0f, 1.0f, 0.0f); -// glBegin(GL_POINTS); -// glVertex2f(p1.x, p1.y); -// glVertex2f(p2.x, p2.y); -// glEnd(); -// glPointSize(1.0f); -// -// glColor3f(0.8f, 0.8f, 0.8f); -// glBegin(GL_LINES); -// glVertex2f(p1.x, p1.y); -// glVertex2f(p2.x, p2.y); -// glEnd(); - } - - if (m_bombSpawning) - { -// glPointSize(4.0f); -// glColor3f(0.0f, 0.0f, 1.0f); -// glBegin(GL_POINTS); -// glColor3f(0.0f, 0.0f, 1.0f); -// glVertex2f(m_bombSpawnPoint.x, m_bombSpawnPoint.y); -// glEnd(); -// -// glColor3f(0.8f, 0.8f, 0.8f); -// glBegin(GL_LINES); -// glVertex2f(m_mouseWorld.x, m_mouseWorld.y); -// glVertex2f(m_bombSpawnPoint.x, m_bombSpawnPoint.y); -// glEnd(); - } - - if (settings->drawContactPoints) - { - //const float32 k_impulseScale = 0.1f; - const float32 k_axisScale = 0.3f; - - for (int32 i = 0; i < m_pointCount; ++i) - { - ContactPoint* point = m_points + i; - - if (point->state == b2_addState) - { - // Add - m_debugDraw.DrawPoint(point->position, 10.0f, b2Color(0.3f, 0.95f, 0.3f)); - } - else if (point->state == b2_persistState) - { - // Persist - m_debugDraw.DrawPoint(point->position, 5.0f, b2Color(0.3f, 0.3f, 0.95f)); - } - - if (settings->drawContactNormals == 1) - { - b2Vec2 p1 = point->position; - b2Vec2 p2 = p1 + k_axisScale * point->normal; - m_debugDraw.DrawSegment(p1, p2, b2Color(0.4f, 0.9f, 0.4f)); - } - else if (settings->drawContactForces == 1) - { - //b2Vec2 p1 = point->position; - //b2Vec2 p2 = p1 + k_forceScale * point->normalForce * point->normal; - //DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.3f)); - } - - if (settings->drawFrictionForces == 1) - { - //b2Vec2 tangent = b2Cross(point->normal, 1.0f); - //b2Vec2 p1 = point->position; - //b2Vec2 p2 = p1 + k_forceScale * point->tangentForce * tangent; - //DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.3f)); - } - } - } -} diff --git a/src/render/iPhoneTestEntries.mm b/src/render/iPhoneTestEntries.mm deleted file mode 100644 index 02da5f5..0000000 --- a/src/render/iPhoneTestEntries.mm +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - */ - -#include "iPhoneTest.h" -//#include "GLES-Render.h" - -#include "ApplyForce.h" -#include "BodyTypes.h" - -#include "Breakable.h" -#include "Bridge.h" -#include "Chain.h" -#include "CollisionFiltering.h" -#include "CollisionProcessing.h" -#include "CompoundShapes.h" -#include "Confined.h" -#include "DistanceTest.h" -#include "Dominos.h" -#include "DynamicTreeTest.h" -#include "Gears.h" -#include "LineJoint.h" -#include "OneSidedPlatform.h" -#include "PolyCollision.h" -#include "PolyShapes.h" -#include "Prismatic.h" -#include "Pulleys.h" -#include "Pyramid.h" -#include "RayCast.h" -#include "Revolute.h" -#include "SensorTest.h" -#include "ShapeEditing.h" -#include "SliderCrank.h" -#include "SphereStack.h" -#include "TheoJansen.h" -#include "TimeOfImpact.h" -#include "VaryingFriction.h" -#include "VaryingRestitution.h" -#include "VerticalStack.h" -#include "Web.h" - -TestEntry g_testEntries[] = -{ -{"Body Types", BodyTypes::Create}, -{"SphereStack", SphereStack::Create}, -{"Vertical Stack", VerticalStack::Create}, -{"Confined", Confined::Create}, -{"Bridge", Bridge::Create}, -{"Breakable", Breakable::Create}, -{"Varying Restitution", VaryingRestitution::Create}, -{"Ray-Cast", RayCast::Create}, -{"Pyramid", Pyramid::Create}, -{"PolyCollision", PolyCollision::Create}, -{"One-Sided Platform", OneSidedPlatform::Create}, -{"Apply Force", ApplyForce::Create}, -{"Chain", Chain::Create}, -{"Collision Filtering", CollisionFiltering::Create}, -{"Collision Processing", CollisionProcessing::Create}, -{"Compound Shapes", CompoundShapes::Create}, -{"Distance Test", DistanceTest::Create}, -{"Dominos", Dominos::Create}, -{"Dynamic Tree", DynamicTreeTest::Create}, -{"Gears", Gears::Create}, -{"Line Joint", LineJoint::Create}, -{"Polygon Shapes", PolyShapes::Create}, -{"Prismatic", Prismatic::Create}, -{"Pulleys", Pulleys::Create}, -{"Revolute", Revolute::Create}, -{"Sensor Test", SensorTest::Create}, -{"Shape Editing", ShapeEditing::Create}, -{"Slider Crank", SliderCrank::Create}, -{"Theo Jansen's Walker", TheoJansen::Create}, -{"Time of Impact", TimeOfImpact::Create}, -{"Varying Friction", VaryingFriction::Create}, -{"Web", Web::Create}, -{NULL, NULL} - -}; diff --git a/tanks.xcodeproj/project.pbxproj b/tanks.xcodeproj/project.pbxproj index 14c0a97..454199a 100644 --- a/tanks.xcodeproj/project.pbxproj +++ b/tanks.xcodeproj/project.pbxproj @@ -122,11 +122,21 @@ 49F2DADD13764ED6000B6B8C /* SPUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2DA8013764ED6000B6B8C /* SPUtils.h */; }; 49F2DADE13764ED6000B6B8C /* SPUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 49F2DA8113764ED6000B6B8C /* SPUtils.m */; }; 49F2DADF13764ED6000B6B8C /* Sparrow.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2DA1D13764ED5000B6B8C /* Sparrow.h */; }; - 49F2DAF213765004000B6B8C /* GLES-Render.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2DAE613765004000B6B8C /* GLES-Render.h */; }; - 49F2DAF313765004000B6B8C /* GLES-Render.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49F2DAE713765004000B6B8C /* GLES-Render.mm */; }; 49F2DB341376632E000B6B8C /* Unit.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F2DB321376632E000B6B8C /* Unit.h */; }; 49F2DB351376632E000B6B8C /* Unit.m in Sources */ = {isa = PBXBuildFile; fileRef = 49F2DB331376632E000B6B8C /* Unit.m */; }; 4B8B2A3213784D2D00CA4076 /* tank-pink.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B8B2A3113784D2D00CA4076 /* tank-pink.png */; }; + 4B8B2A411378E74700CA4076 /* Box2DAppDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B2A351378E74700CA4076 /* Box2DAppDelegate.h */; }; + 4B8B2A421378E74700CA4076 /* Box2DAppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B2A361378E74700CA4076 /* Box2DAppDelegate.mm */; }; + 4B8B2A431378E74700CA4076 /* Box2DView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B2A371378E74700CA4076 /* Box2DView.h */; }; + 4B8B2A441378E74700CA4076 /* Box2DView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B2A381378E74700CA4076 /* Box2DView.mm */; }; + 4B8B2A451378E74700CA4076 /* Delegates.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B2A391378E74700CA4076 /* Delegates.h */; }; + 4B8B2A461378E74700CA4076 /* GLES-Render.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B2A3A1378E74700CA4076 /* GLES-Render.h */; }; + 4B8B2A471378E74700CA4076 /* GLES-Render.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B2A3B1378E74700CA4076 /* GLES-Render.mm */; }; + 4B8B2A481378E74700CA4076 /* iPhoneTest.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B2A3C1378E74700CA4076 /* iPhoneTest.h */; }; + 4B8B2A491378E74700CA4076 /* iPhoneTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B2A3D1378E74700CA4076 /* iPhoneTest.mm */; }; + 4B8B2A4A1378E74700CA4076 /* iPhoneTestEntries.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B2A3E1378E74700CA4076 /* iPhoneTestEntries.mm */; }; + 4B8B2A4B1378E74700CA4076 /* TestEntriesViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B2A3F1378E74700CA4076 /* TestEntriesViewController.h */; }; + 4B8B2A4C1378E74700CA4076 /* TestEntriesViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B2A401378E74700CA4076 /* TestEntriesViewController.mm */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -266,21 +276,21 @@ 49F2DA7F13764ED6000B6B8C /* SPPoolObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPPoolObject.m; sourceTree = ""; }; 49F2DA8013764ED6000B6B8C /* SPUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUtils.h; sourceTree = ""; }; 49F2DA8113764ED6000B6B8C /* SPUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUtils.m; sourceTree = ""; }; - 49F2DAE113765004000B6B8C /* Box2DAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Box2DAppDelegate.h; sourceTree = ""; }; - 49F2DAE213765004000B6B8C /* Box2DAppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Box2DAppDelegate.mm; sourceTree = ""; }; - 49F2DAE313765004000B6B8C /* Box2DView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Box2DView.h; sourceTree = ""; }; - 49F2DAE413765004000B6B8C /* Box2DView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Box2DView.mm; sourceTree = ""; }; - 49F2DAE513765004000B6B8C /* Delegates.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Delegates.h; sourceTree = ""; }; - 49F2DAE613765004000B6B8C /* GLES-Render.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GLES-Render.h"; sourceTree = ""; }; - 49F2DAE713765004000B6B8C /* GLES-Render.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "GLES-Render.mm"; sourceTree = ""; }; - 49F2DAE813765004000B6B8C /* iPhoneTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iPhoneTest.h; sourceTree = ""; }; - 49F2DAE913765004000B6B8C /* iPhoneTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = iPhoneTest.mm; sourceTree = ""; }; - 49F2DAEA13765004000B6B8C /* iPhoneTestEntries.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = iPhoneTestEntries.mm; sourceTree = ""; }; - 49F2DAEB13765004000B6B8C /* TestEntriesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestEntriesViewController.h; sourceTree = ""; }; - 49F2DAEC13765004000B6B8C /* TestEntriesViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestEntriesViewController.mm; sourceTree = ""; }; 49F2DB321376632E000B6B8C /* Unit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Unit.h; sourceTree = ""; }; 49F2DB331376632E000B6B8C /* Unit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Unit.m; sourceTree = ""; }; 4B8B2A3113784D2D00CA4076 /* tank-pink.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "tank-pink.png"; path = "textures/tank-pink.png"; sourceTree = ""; }; + 4B8B2A351378E74700CA4076 /* Box2DAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Box2DAppDelegate.h; path = references/Box2DAppDelegate.h; sourceTree = ""; }; + 4B8B2A361378E74700CA4076 /* Box2DAppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Box2DAppDelegate.mm; path = references/Box2DAppDelegate.mm; sourceTree = ""; }; + 4B8B2A371378E74700CA4076 /* Box2DView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Box2DView.h; path = references/Box2DView.h; sourceTree = ""; }; + 4B8B2A381378E74700CA4076 /* Box2DView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Box2DView.mm; path = references/Box2DView.mm; sourceTree = ""; }; + 4B8B2A391378E74700CA4076 /* Delegates.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Delegates.h; path = references/Delegates.h; sourceTree = ""; }; + 4B8B2A3A1378E74700CA4076 /* GLES-Render.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "GLES-Render.h"; path = "references/GLES-Render.h"; sourceTree = ""; }; + 4B8B2A3B1378E74700CA4076 /* GLES-Render.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "GLES-Render.mm"; path = "references/GLES-Render.mm"; sourceTree = ""; }; + 4B8B2A3C1378E74700CA4076 /* iPhoneTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = iPhoneTest.h; path = references/iPhoneTest.h; sourceTree = ""; }; + 4B8B2A3D1378E74700CA4076 /* iPhoneTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = iPhoneTest.mm; path = references/iPhoneTest.mm; sourceTree = ""; }; + 4B8B2A3E1378E74700CA4076 /* iPhoneTestEntries.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = iPhoneTestEntries.mm; path = references/iPhoneTestEntries.mm; sourceTree = ""; }; + 4B8B2A3F1378E74700CA4076 /* TestEntriesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestEntriesViewController.h; path = references/TestEntriesViewController.h; sourceTree = ""; }; + 4B8B2A401378E74700CA4076 /* TestEntriesViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestEntriesViewController.mm; path = references/TestEntriesViewController.mm; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -350,6 +360,7 @@ 49F2D9AE13764666000B6B8C /* src */ = { isa = PBXGroup; children = ( + 4B8B2A341378E72700CA4076 /* references */, 49F2D9AF13764666000B6B8C /* display */, 49F2D9B013764666000B6B8C /* main.m */, 49F2D9B113764666000B6B8C /* physics */, @@ -380,18 +391,6 @@ 49F2D9B313764666000B6B8C /* render */ = { isa = PBXGroup; children = ( - 49F2DAE113765004000B6B8C /* Box2DAppDelegate.h */, - 49F2DAE213765004000B6B8C /* Box2DAppDelegate.mm */, - 49F2DAE313765004000B6B8C /* Box2DView.h */, - 49F2DAE413765004000B6B8C /* Box2DView.mm */, - 49F2DAE513765004000B6B8C /* Delegates.h */, - 49F2DAE613765004000B6B8C /* GLES-Render.h */, - 49F2DAE713765004000B6B8C /* GLES-Render.mm */, - 49F2DAE813765004000B6B8C /* iPhoneTest.h */, - 49F2DAE913765004000B6B8C /* iPhoneTest.mm */, - 49F2DAEA13765004000B6B8C /* iPhoneTestEntries.mm */, - 49F2DAEB13765004000B6B8C /* TestEntriesViewController.h */, - 49F2DAEC13765004000B6B8C /* TestEntriesViewController.mm */, ); path = render; sourceTree = ""; @@ -684,6 +683,25 @@ name = textures; sourceTree = ""; }; + 4B8B2A341378E72700CA4076 /* references */ = { + isa = PBXGroup; + children = ( + 4B8B2A351378E74700CA4076 /* Box2DAppDelegate.h */, + 4B8B2A361378E74700CA4076 /* Box2DAppDelegate.mm */, + 4B8B2A371378E74700CA4076 /* Box2DView.h */, + 4B8B2A381378E74700CA4076 /* Box2DView.mm */, + 4B8B2A391378E74700CA4076 /* Delegates.h */, + 4B8B2A3A1378E74700CA4076 /* GLES-Render.h */, + 4B8B2A3B1378E74700CA4076 /* GLES-Render.mm */, + 4B8B2A3C1378E74700CA4076 /* iPhoneTest.h */, + 4B8B2A3D1378E74700CA4076 /* iPhoneTest.mm */, + 4B8B2A3E1378E74700CA4076 /* iPhoneTestEntries.mm */, + 4B8B2A3F1378E74700CA4076 /* TestEntriesViewController.h */, + 4B8B2A401378E74700CA4076 /* TestEntriesViewController.mm */, + ); + name = references; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -745,8 +763,13 @@ 49F2DADB13764ED6000B6B8C /* SPPoolObject.h in Headers */, 49F2DADD13764ED6000B6B8C /* SPUtils.h in Headers */, 49F2DADF13764ED6000B6B8C /* Sparrow.h in Headers */, - 49F2DAF213765004000B6B8C /* GLES-Render.h in Headers */, 49F2DB341376632E000B6B8C /* Unit.h in Headers */, + 4B8B2A411378E74700CA4076 /* Box2DAppDelegate.h in Headers */, + 4B8B2A431378E74700CA4076 /* Box2DView.h in Headers */, + 4B8B2A451378E74700CA4076 /* Delegates.h in Headers */, + 4B8B2A461378E74700CA4076 /* GLES-Render.h in Headers */, + 4B8B2A481378E74700CA4076 /* iPhoneTest.h in Headers */, + 4B8B2A4B1378E74700CA4076 /* TestEntriesViewController.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -878,8 +901,13 @@ 49F2DADA13764ED6000B6B8C /* SPNSExtensions.m in Sources */, 49F2DADC13764ED6000B6B8C /* SPPoolObject.m in Sources */, 49F2DADE13764ED6000B6B8C /* SPUtils.m in Sources */, - 49F2DAF313765004000B6B8C /* GLES-Render.mm in Sources */, 49F2DB351376632E000B6B8C /* Unit.m in Sources */, + 4B8B2A421378E74700CA4076 /* Box2DAppDelegate.mm in Sources */, + 4B8B2A441378E74700CA4076 /* Box2DView.mm in Sources */, + 4B8B2A471378E74700CA4076 /* GLES-Render.mm in Sources */, + 4B8B2A491378E74700CA4076 /* iPhoneTest.mm in Sources */, + 4B8B2A4A1378E74700CA4076 /* iPhoneTestEntries.mm in Sources */, + 4B8B2A4C1378E74700CA4076 /* TestEntriesViewController.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; -- 1.7.0.4