瀏覽代碼

Latest IOS stuff

Ivan Safrin 9 年之前
父節點
當前提交
1a41d5a749

二進制
assets/default/default.pak


+ 30 - 30
assets/default/default/DefaultShader.frag

@@ -1,24 +1,24 @@
 #ifdef GL_ES
-	precision mediump float;
+	precision mediump float;	
 #endif
 
-varying vec2 texCoordVar;
-varying vec3 varNormal;
-varying vec4 varPosition;
+varying lowp vec2 texCoordVar;
+varying lowp vec3 varNormal;
+varying lowp vec4 varPosition;
 
 uniform sampler2D diffuse;
-uniform vec4 diffuse_color;
-uniform vec4 specular_color;
-uniform vec4 entityColor;
+uniform lowp vec4 diffuse_color;
+uniform lowp vec4 specular_color;
+uniform lowp vec4 entityColor;
 uniform float shininess;
 
-#define MAX_LIGHTS 8
+#define MAX_LIGHTS 4
 
 struct LightInfo {
-	vec3 position;
-	vec3 direction;
-	vec4 specular;
-	vec4 diffuse;
+	lowp vec3 position;
+	lowp vec3 direction;
+	lowp vec4 specular;
+	lowp vec4 diffuse;
 
 	float spotExponent;
 	float spotCosCutoff;
@@ -38,19 +38,19 @@ float calculateAttenuation(in int i, in float dist)
 }
 
 void pointLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
+	lowp vec4 color = diffuse_color;
+	lowp vec4 matspec = specular_color;
 	float shininess = shininess;
-	vec4 lightspec = lights[i].specular;
-	vec4 lpos = vec4(lights[i].position, 1.0);
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
+	lowp vec4 lightspec = lights[i].specular;
+	lowp vec4 lpos = vec4(lights[i].position, 1.0);
+	lowp vec4 s = pos-lpos; 
+	lowp vec4 sn = -normalize(s);
 	
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
+	lowp vec3 light = sn.xyz;
+	lowp vec3 n = normalize(normal);
+	lowp vec3 r = -reflect(light, n);
 	r = normalize(r);
-	vec3 v = -pos.xyz;
+	lowp vec3 v = -pos.xyz;
 	v = normalize(v);
 
 	float nDotL = dot(n, sn.xyz);
@@ -105,25 +105,25 @@ void spotLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout
 
 void doLights(in int numLights, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
 	for (int i = 0; i < numLights; i++) {
-		if (lights[i].spotCosCutoff == 180.0) {
+		//if (lights[i].spotCosCutoff == 180.0) {
 			pointLight(i, normal, pos, diffuse, specular);
-		} else {
-			spotLight(i, normal, pos, diffuse, specular);
-		}
+		//} else {
+		//	spotLight(i, normal, pos, diffuse, specular);
+		//}
     }
 }
 
 
 void main()
 {
-	vec4 diffuse_val  = vec4(0.0);
-	vec4 specular_val = vec4(0.0);
+	lowp vec4 diffuse_val  = vec4(0.0);
+	lowp vec4 specular_val = vec4(0.0);
 
 	doLights(MAX_LIGHTS, varNormal, varPosition, diffuse_val, specular_val);
 		
-	vec4 texColor = texture2D(diffuse, texCoordVar);		
+	lowp vec4 texColor = texture2D(diffuse, texCoordVar);		
 		
-    vec4 color = diffuse_val; 	           
+    lowp vec4 color = diffuse_val; 	           
     color = clamp((color*entityColor*texColor) + specular_val, 0.0, 1.0);  
 
 	color.a = entityColor.a * texColor.a * diffuse_color.a;	

+ 8 - 8
assets/default/default/DefaultShader.vert

@@ -2,17 +2,17 @@
 	precision mediump float;
 #endif
 
-attribute vec4 position;
-attribute vec3 normal;
-attribute vec2 texCoord;
+attribute lowp vec4 position;
+attribute lowp vec3 normal;
+attribute lowp vec2 texCoord;
 
 uniform mat4 modelMatrix;
 uniform mat4 viewMatrix;
 uniform mat4 projectionMatrix;
 
-varying vec2 texCoordVar;
-varying vec3 varNormal;
-varying vec4 varPosition;
+varying lowp vec2 texCoordVar;
+varying lowp vec3 varNormal;
+varying lowp vec4 varPosition;
 
 mat3 mat3_emu(mat4 m4) {
   return mat3(
@@ -24,9 +24,9 @@ mat3 mat3_emu(mat4 m4) {
 void main()
 {
 	mat4 modelViewMatrix = viewMatrix * modelMatrix;
-	vec4 p = modelViewMatrix  * position;
+	lowp vec4 p = modelViewMatrix  * position;
 
-	mat3 rotN = mat3_emu(modelViewMatrix);
+	lowp mat3 rotN = mat3_emu(modelViewMatrix);
 	varNormal = normalize(rotN * normal);
 
 	varPosition = modelViewMatrix  * position;

+ 1 - 1
assets/default/default/LightCube.vert

@@ -1,5 +1,5 @@
 #ifdef GL_ES
-	precision mediump float;
+   precision mediump float;
 #endif
 
 attribute vec4 position;

+ 59 - 0
assets/default/default/LightcubeAngular.frag

@@ -0,0 +1,59 @@
+#ifdef GL_ES
+   precision mediump float;
+#endif
+
+uniform sampler2D angularMap;
+varying vec4 vertexColor;
+varying vec3 normal;
+uniform vec4 ambient_color;
+varying vec3 worldNormal;
+
+uniform float lightFactor;
+
+vec3 hash3( float n )
+{
+    return fract(sin(vec3(n,n+1.0,n+2.0))*vec3(43758.5453123,22578.1459123,19642.3490423));
+}
+
+void main()
+{
+	vec3 col = vec3(0.0);
+	for( int i=0; i<32; i++ )
+	{			
+		vec3 rr = normalize(-1.0 + 2.0*hash3(float(i)*123.5463));
+		rr = normalize( worldNormal + 7.0*rr );
+		rr = rr * sign(dot(worldNormal,rr));
+
+
+		float m = 2. * sqrt( 
+        pow( rr.x, 2. ) + 
+        pow( rr.y, 2. ) + 
+        pow( rr.z + 1., 2. ) 
+ 	   );
+	
+		vec2 vN = rr.xy / m + .5;
+        col += pow( texture2D( angularMap, vN).xyz, vec3(1.0) ) * dot(rr,worldNormal);
+	}
+
+	col = col * lightFactor / 32.0;
+
+    vec4 texColor = vec4(col, 1.0);
+
+    vec4 color = vec4(1.0,1.0,1.0,1.0) + ambient_color; 	           
+    color = clamp((color*vertexColor*texColor), 0.0, 1.0);  
+
+    // fog
+	const float LOG2 = 1.442695;
+	float z = gl_FragCoord.z / gl_FragCoord.w;
+	float fogFactor = exp2( -gl_Fog.density * 
+				   gl_Fog.density * 
+				   z * 
+				   z * 
+				   LOG2 );
+
+	fogFactor = clamp(fogFactor, 0.0, 1.0);
+	color = mix(gl_Fog.color, color, fogFactor );   
+
+	color.a = vertexColor.a * texColor.a;    
+    gl_FragColor = color;
+}

+ 45 - 0
assets/default/default/LightcubePolar.frag

@@ -0,0 +1,45 @@
+#ifdef GL_ES
+   precision mediump float;
+#endif
+
+uniform sampler2D polarMap;
+uniform sampler2D diffuse;
+uniform vec4 entityColor;
+
+varying vec3 varNormal;
+varying vec3 worldNormal;
+varying vec2 texCoordVar;
+uniform float lightFactor;
+
+const float PI = 3.14159265359;
+
+vec2 sphere_map(vec3 n) {
+	return vec2(atan(n.z,n.x)/(2.0 * PI), acos(-n.y) / (PI));
+}
+
+vec3 hash3( float n )
+{
+    return fract(sin(vec3(n,n+1.0,n+2.0))*vec3(43758.5453123,22578.1459123,19642.3490423));
+}
+
+void main()
+{
+	vec3 col = vec3(0.0);
+	for( int i=0; i<32; i++ )
+	{			
+		vec3 rr = normalize(-1.0 + 2.0*hash3(float(i)*123.5463));
+		rr = normalize( worldNormal +7.0*rr );
+		rr = rr * sign(dot(worldNormal,rr));
+		vec2 vN = sphere_map(rr);
+
+        col += pow( texture2D( polarMap, vN).xyz, vec3(1.0) ) * dot(rr,worldNormal);
+	}
+
+	col = col / 32.0 * lightFactor;
+
+	vec4 texColor = texture2D(diffuse, texCoordVar);
+    vec4 color = mix(entityColor,texColor, texColor.a);
+    color.xyz = color.xyz * col;
+	color.a = 1.0;
+    gl_FragColor = color;
+}

+ 42 - 0
assets/default/default/SkyboxAngular.frag

@@ -0,0 +1,42 @@
+#ifdef GLES2
+	precision mediump float;
+#endif
+
+uniform sampler2D angularMap;
+varying vec4 vertexColor;
+varying vec3 normal;
+uniform vec4 ambient_color;
+varying vec3 worldNormal;
+
+void main()
+{
+
+	float m = 2. * sqrt( 
+        pow( worldNormal.x, 2. ) + 
+        pow( worldNormal.y, 2. ) + 
+        pow( worldNormal.z + 1., 2. ) 
+    );
+
+	vec2 vN = worldNormal.xy / m + .5;
+
+    vec4 texColor = texture2D(angularMap, vN);
+
+    vec4 color = vec4(1.0,1.0,1.0,1.0) + ambient_color; 	           
+    color = clamp((color*vertexColor*texColor), 0.0, 1.0);  
+
+    // fog
+	const float LOG2 = 1.442695;
+	float z = gl_FragCoord.z / gl_FragCoord.w;
+	float fogFactor = exp2( -gl_Fog.density * 
+				   gl_Fog.density * 
+				   z * 
+				   z * 
+				   LOG2 );
+
+	fogFactor = clamp(fogFactor, 0.0, 1.0);
+	color = mix(gl_Fog.color, color, fogFactor );   
+
+	color.a = vertexColor.a * texColor.a;    
+    gl_FragColor = color;
+
+}

+ 41 - 0
assets/default/default/SkyboxPolar.frag

@@ -0,0 +1,41 @@
+#ifdef GLES2
+	precision mediump float;
+#endif
+
+uniform sampler2D polarMap;
+varying vec4 vertexColor;
+varying vec3 normal;
+uniform vec4 ambient_color;
+varying vec3 worldNormal;
+
+const float PI = 3.14159265359;
+
+vec2 sphere_map(vec3 n) {
+	return vec2(atan(n.z,n.x)/(2.0 * PI), acos(-n.y) / (PI));
+}
+
+void main()
+{
+	
+	vec2 vN = sphere_map(worldNormal);
+
+    vec4 texColor = texture2D(polarMap, vN);
+
+    vec4 color = vec4(1.0,1.0,1.0,1.0) + ambient_color; 	           
+    color = clamp((color*vertexColor*texColor), 0.0, 1.0);  
+
+    // fog
+	const float LOG2 = 1.442695;
+	float z = gl_FragCoord.z / gl_FragCoord.w;
+	float fogFactor = exp2( -gl_Fog.density * 
+				   gl_Fog.density * 
+				   z * 
+				   z * 
+				   LOG2 );
+
+	fogFactor = clamp(fogFactor, 0.0, 1.0);
+	color = mix(gl_Fog.color, color, fogFactor );   
+
+	color.a = vertexColor.a * texColor.a;    
+    gl_FragColor = color;
+}

+ 8 - 0
assets/default/default/default.mat

@@ -44,6 +44,14 @@
 		<shader type="glsl" name="BlurVShader" screen="true">		
 			<vp source="default/ScreenShader.vert"/>
 			<fp source="default/BlurV.frag"/>
+		</shader>
+		<shader type="glsl" name="LightcubePolar" numPointLights="0" numSpotLights="0">
+			<vp source="default/LightCube.vert"/>
+			<fp source="default/LightcubePolar.frag"/>
+		</shader>
+		<shader type="glsl" name="LightcubeAngular" numPointLights="0" numSpotLights="0">
+			<vp source="default/LightCube.vert"/>
+			<fp source="default/LightcubeAngular.frag"/>
 		</shader>		
 	</shaders>	
 	<materials>

+ 3 - 0
build/ios/Polycode.xcworkspace/contents.xcworkspacedata

@@ -1,6 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Workspace
    version = "1.0">
+   <FileRef
+      location = "group:Polycode3DPhysics/Polycode3DPhysics.xcodeproj">
+   </FileRef>
    <FileRef
       location = "group:PolycodeCore/PolycodeCore.xcodeproj">
    </FileRef>

+ 305 - 0
build/ios/Polycode3DPhysics/Polycode3DPhysics.xcodeproj/project.pbxproj

@@ -0,0 +1,305 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 46;
+	objects = {
+
+/* Begin PBXBuildFile section */
+		6D1992BD1CD6971200DE01FA /* PolyCollisionScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D1992B81CD6971200DE01FA /* PolyCollisionScene.cpp */; };
+		6D1992BE1CD6971200DE01FA /* PolyCollisionSceneEntity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D1992B91CD6971200DE01FA /* PolyCollisionSceneEntity.cpp */; };
+		6D1992BF1CD6971200DE01FA /* PolyPhysicsConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D1992BA1CD6971200DE01FA /* PolyPhysicsConstraint.cpp */; };
+		6D1992C01CD6971200DE01FA /* PolyPhysicsScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D1992BB1CD6971200DE01FA /* PolyPhysicsScene.cpp */; };
+		6D1992C11CD6971200DE01FA /* PolyPhysicsSceneEntity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D1992BC1CD6971200DE01FA /* PolyPhysicsSceneEntity.cpp */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+		6D1992AA1CD6970200DE01FA /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = "include/$(PRODUCT_NAME)";
+			dstSubfolderSpec = 16;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+		6D1992AC1CD6970200DE01FA /* libPolycode3DPhysics.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPolycode3DPhysics.a; sourceTree = BUILT_PRODUCTS_DIR; };
+		6D1992B81CD6971200DE01FA /* PolyCollisionScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyCollisionScene.cpp; path = ../../../../src/modules/physics3D/PolyCollisionScene.cpp; sourceTree = "<group>"; };
+		6D1992B91CD6971200DE01FA /* PolyCollisionSceneEntity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyCollisionSceneEntity.cpp; path = ../../../../src/modules/physics3D/PolyCollisionSceneEntity.cpp; sourceTree = "<group>"; };
+		6D1992BA1CD6971200DE01FA /* PolyPhysicsConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyPhysicsConstraint.cpp; path = ../../../../src/modules/physics3D/PolyPhysicsConstraint.cpp; sourceTree = "<group>"; };
+		6D1992BB1CD6971200DE01FA /* PolyPhysicsScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyPhysicsScene.cpp; path = ../../../../src/modules/physics3D/PolyPhysicsScene.cpp; sourceTree = "<group>"; };
+		6D1992BC1CD6971200DE01FA /* PolyPhysicsSceneEntity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyPhysicsSceneEntity.cpp; path = ../../../../src/modules/physics3D/PolyPhysicsSceneEntity.cpp; sourceTree = "<group>"; };
+		6D1992C31CD6974200DE01FA /* Polycode3DPhysics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Polycode3DPhysics.h; path = ../../../include/polycode/modules/physics3D/Polycode3DPhysics.h; sourceTree = "<group>"; };
+		6D1992C41CD6974200DE01FA /* PolyCollisionScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyCollisionScene.h; path = ../../../include/polycode/modules/physics3D/PolyCollisionScene.h; sourceTree = "<group>"; };
+		6D1992C51CD6974200DE01FA /* PolyCollisionSceneEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyCollisionSceneEntity.h; path = ../../../include/polycode/modules/physics3D/PolyCollisionSceneEntity.h; sourceTree = "<group>"; };
+		6D1992C61CD6974200DE01FA /* PolyPhysicsConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyPhysicsConstraint.h; path = ../../../include/polycode/modules/physics3D/PolyPhysicsConstraint.h; sourceTree = "<group>"; };
+		6D1992C71CD6974200DE01FA /* PolyPhysicsScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyPhysicsScene.h; path = ../../../include/polycode/modules/physics3D/PolyPhysicsScene.h; sourceTree = "<group>"; };
+		6D1992C81CD6974200DE01FA /* PolyPhysicsSceneEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyPhysicsSceneEntity.h; path = ../../../include/polycode/modules/physics3D/PolyPhysicsSceneEntity.h; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		6D1992A91CD6970200DE01FA /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		6D1992A31CD6970200DE01FA = {
+			isa = PBXGroup;
+			children = (
+				6D1992C21CD6973400DE01FA /* include */,
+				6D1992AE1CD6970200DE01FA /* src */,
+				6D1992AD1CD6970200DE01FA /* Products */,
+			);
+			sourceTree = "<group>";
+		};
+		6D1992AD1CD6970200DE01FA /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				6D1992AC1CD6970200DE01FA /* libPolycode3DPhysics.a */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		6D1992AE1CD6970200DE01FA /* src */ = {
+			isa = PBXGroup;
+			children = (
+				6D1992B81CD6971200DE01FA /* PolyCollisionScene.cpp */,
+				6D1992B91CD6971200DE01FA /* PolyCollisionSceneEntity.cpp */,
+				6D1992BA1CD6971200DE01FA /* PolyPhysicsConstraint.cpp */,
+				6D1992BB1CD6971200DE01FA /* PolyPhysicsScene.cpp */,
+				6D1992BC1CD6971200DE01FA /* PolyPhysicsSceneEntity.cpp */,
+			);
+			name = src;
+			path = Polycode3DPhysics;
+			sourceTree = "<group>";
+		};
+		6D1992C21CD6973400DE01FA /* include */ = {
+			isa = PBXGroup;
+			children = (
+				6D1992C31CD6974200DE01FA /* Polycode3DPhysics.h */,
+				6D1992C41CD6974200DE01FA /* PolyCollisionScene.h */,
+				6D1992C51CD6974200DE01FA /* PolyCollisionSceneEntity.h */,
+				6D1992C61CD6974200DE01FA /* PolyPhysicsConstraint.h */,
+				6D1992C71CD6974200DE01FA /* PolyPhysicsScene.h */,
+				6D1992C81CD6974200DE01FA /* PolyPhysicsSceneEntity.h */,
+			);
+			name = include;
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+		6D1992AB1CD6970200DE01FA /* Polycode3DPhysics */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 6D1992B51CD6970200DE01FA /* Build configuration list for PBXNativeTarget "Polycode3DPhysics" */;
+			buildPhases = (
+				6D1992A81CD6970200DE01FA /* Sources */,
+				6D1992A91CD6970200DE01FA /* Frameworks */,
+				6D1992AA1CD6970200DE01FA /* CopyFiles */,
+				6D1992C91CD697C400DE01FA /* ShellScript */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = Polycode3DPhysics;
+			productName = Polycode3DPhysics;
+			productReference = 6D1992AC1CD6970200DE01FA /* libPolycode3DPhysics.a */;
+			productType = "com.apple.product-type.library.static";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		6D1992A41CD6970200DE01FA /* Project object */ = {
+			isa = PBXProject;
+			attributes = {
+				LastUpgradeCheck = 0720;
+				ORGANIZATIONNAME = "Ivan Safrin";
+				TargetAttributes = {
+					6D1992AB1CD6970200DE01FA = {
+						CreatedOnToolsVersion = 7.2;
+					};
+				};
+			};
+			buildConfigurationList = 6D1992A71CD6970200DE01FA /* Build configuration list for PBXProject "Polycode3DPhysics" */;
+			compatibilityVersion = "Xcode 3.2";
+			developmentRegion = English;
+			hasScannedForEncodings = 0;
+			knownRegions = (
+				en,
+			);
+			mainGroup = 6D1992A31CD6970200DE01FA;
+			productRefGroup = 6D1992AD1CD6970200DE01FA /* Products */;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				6D1992AB1CD6970200DE01FA /* Polycode3DPhysics */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXShellScriptBuildPhase section */
+		6D1992C91CD697C400DE01FA /* ShellScript */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			inputPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+			shellPath = /bin/sh;
+			shellScript = "cp $TARGET_BUILD_DIR//$EXECUTABLE_NAME ../../../lib/ios/${PLATFORM_NAME}";
+		};
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+		6D1992A81CD6970200DE01FA /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				6D1992BD1CD6971200DE01FA /* PolyCollisionScene.cpp in Sources */,
+				6D1992C01CD6971200DE01FA /* PolyPhysicsScene.cpp in Sources */,
+				6D1992BF1CD6971200DE01FA /* PolyPhysicsConstraint.cpp in Sources */,
+				6D1992BE1CD6971200DE01FA /* PolyCollisionSceneEntity.cpp in Sources */,
+				6D1992C11CD6971200DE01FA /* PolyPhysicsSceneEntity.cpp in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+		6D1992B31CD6970200DE01FA /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_ENABLE_MODULES = YES;
+				CLANG_ENABLE_OBJC_ARC = YES;
+				CLANG_WARN_BOOL_CONVERSION = YES;
+				CLANG_WARN_CONSTANT_CONVERSION = YES;
+				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+				CLANG_WARN_EMPTY_BODY = YES;
+				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INT_CONVERSION = YES;
+				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+				CLANG_WARN_UNREACHABLE_CODE = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+				COPY_PHASE_STRIP = NO;
+				DEBUG_INFORMATION_FORMAT = dwarf;
+				ENABLE_STRICT_OBJC_MSGSEND = YES;
+				ENABLE_TESTABILITY = YES;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_NO_COMMON_BLOCKS = YES;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+				GCC_WARN_UNDECLARED_SELECTOR = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+				GCC_WARN_UNUSED_FUNCTION = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				IPHONEOS_DEPLOYMENT_TARGET = 9.2;
+				MTL_ENABLE_DEBUG_INFO = YES;
+				ONLY_ACTIVE_ARCH = YES;
+				SDKROOT = iphoneos;
+			};
+			name = Debug;
+		};
+		6D1992B41CD6970200DE01FA /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_ENABLE_MODULES = YES;
+				CLANG_ENABLE_OBJC_ARC = YES;
+				CLANG_WARN_BOOL_CONVERSION = YES;
+				CLANG_WARN_CONSTANT_CONVERSION = YES;
+				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+				CLANG_WARN_EMPTY_BODY = YES;
+				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INT_CONVERSION = YES;
+				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+				CLANG_WARN_UNREACHABLE_CODE = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+				COPY_PHASE_STRIP = NO;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				ENABLE_NS_ASSERTIONS = NO;
+				ENABLE_STRICT_OBJC_MSGSEND = YES;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_NO_COMMON_BLOCKS = YES;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+				GCC_WARN_UNDECLARED_SELECTOR = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+				GCC_WARN_UNUSED_FUNCTION = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				IPHONEOS_DEPLOYMENT_TARGET = 9.2;
+				MTL_ENABLE_DEBUG_INFO = NO;
+				SDKROOT = iphoneos;
+				VALIDATE_PRODUCT = YES;
+			};
+			name = Release;
+		};
+		6D1992B61CD6970200DE01FA /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../../include\"";
+				OTHER_LDFLAGS = "-ObjC";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SKIP_INSTALL = YES;
+			};
+			name = Debug;
+		};
+		6D1992B71CD6970200DE01FA /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../../include\"";
+				OTHER_LDFLAGS = "-ObjC";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SKIP_INSTALL = YES;
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		6D1992A71CD6970200DE01FA /* Build configuration list for PBXProject "Polycode3DPhysics" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				6D1992B31CD6970200DE01FA /* Debug */,
+				6D1992B41CD6970200DE01FA /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		6D1992B51CD6970200DE01FA /* Build configuration list for PBXNativeTarget "Polycode3DPhysics" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				6D1992B61CD6970200DE01FA /* Debug */,
+				6D1992B71CD6970200DE01FA /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = 6D1992A41CD6970200DE01FA /* Project object */;
+}

+ 17 - 1
build/ios/TemplateApp/TemplateApp.xcodeproj/project.pbxproj

@@ -7,6 +7,10 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		6D1992381CD692ED00DE01FA /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D1992341CD692ED00DE01FA /* QuartzCore.framework */; };
+		6D1992391CD692ED00DE01FA /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D1992351CD692ED00DE01FA /* CoreMotion.framework */; };
+		6D19923A1CD692ED00DE01FA /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D1992361CD692ED00DE01FA /* UIKit.framework */; };
+		6D19923B1CD692ED00DE01FA /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D1992371CD692ED00DE01FA /* OpenGLES.framework */; };
 		6D90505D1CCBFFD400D0E80A /* liblua.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D90505C1CCBFFD400D0E80A /* liblua.a */; };
 		8A0F80641BF536C800E24F9B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A0F80631BF536C800E24F9B /* AppDelegate.m */; };
 		8A0F80671BF536C800E24F9B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A0F80661BF536C800E24F9B /* ViewController.m */; };
@@ -23,6 +27,10 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+		6D1992341CD692ED00DE01FA /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+		6D1992351CD692ED00DE01FA /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
+		6D1992361CD692ED00DE01FA /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+		6D1992371CD692ED00DE01FA /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
 		6D90505C1CCBFFD400D0E80A /* liblua.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua.a; path = ../../../../lib/ios/iphonesimulator/liblua.a; sourceTree = "<group>"; };
 		8A0F805C1BF536C800E24F9B /* TemplateApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TemplateApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		8A0F80621BF536C800E24F9B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -35,7 +43,7 @@
 		8A0F80701BF536C800E24F9B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		8A0F80791BF53DD200E24F9B /* PolycodeTemplateApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolycodeTemplateApp.h; sourceTree = "<group>"; };
 		8A0F807A1BF53DD200E24F9B /* PolycodeTemplateApp.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PolycodeTemplateApp.mm; sourceTree = "<group>"; };
-		8A0F81981BF56A2D00E24F9B /* PolycodeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PolycodeView.m; path = ../../../../src/view/ios/PolycodeView.m; sourceTree = "<group>"; };
+		8A0F81981BF56A2D00E24F9B /* PolycodeView.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp.preprocessed; fileEncoding = 4; name = PolycodeView.m; path = ../../../../src/view/ios/PolycodeView.m; sourceTree = "<group>"; };
 		8A35E14A1C877A8B00BF9EEA /* main.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp.preprocessed; fileEncoding = 4; path = main.m; sourceTree = "<group>"; };
 		8A35E14E1C877DDB00BF9EEA /* libFreetype2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libFreetype2.a; path = ../../../../lib/ios/iphonesimulator/libFreetype2.a; sourceTree = "<group>"; };
 		8A35E19E1C87A54A00BF9EEA /* PolycodeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolycodeView.h; path = ../../../../include/polycode/view/ios/PolycodeView.h; sourceTree = "<group>"; };
@@ -49,9 +57,13 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				6D1992381CD692ED00DE01FA /* QuartzCore.framework in Frameworks */,
+				6D1992391CD692ED00DE01FA /* CoreMotion.framework in Frameworks */,
 				6D90505D1CCBFFD400D0E80A /* liblua.a in Frameworks */,
+				6D19923B1CD692ED00DE01FA /* OpenGLES.framework in Frameworks */,
 				8A35E14F1C877DDB00BF9EEA /* libFreetype2.a in Frameworks */,
 				8A35E1C61C87B3BC00BF9EEA /* libphysfs.a in Frameworks */,
+				6D19923A1CD692ED00DE01FA /* UIKit.framework in Frameworks */,
 				8AD300AB1BF68290004D243B /* libPolycodeCore.a in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -78,6 +90,10 @@
 		8A0F805E1BF536C800E24F9B /* TemplateApp */ = {
 			isa = PBXGroup;
 			children = (
+				6D1992341CD692ED00DE01FA /* QuartzCore.framework */,
+				6D1992351CD692ED00DE01FA /* CoreMotion.framework */,
+				6D1992361CD692ED00DE01FA /* UIKit.framework */,
+				6D1992371CD692ED00DE01FA /* OpenGLES.framework */,
 				8A35E14E1C877DDB00BF9EEA /* libFreetype2.a */,
 				8A35E1C51C87B3BC00BF9EEA /* libphysfs.a */,
 				6D90505C1CCBFFD400D0E80A /* liblua.a */,

+ 4 - 4
build/osx/PolycodeStudio/PolycodeStudio.xcodeproj/project.pbxproj

@@ -8,6 +8,7 @@
 
 /* Begin PBXBuildFile section */
 		6D6FD3E31BF122A7005AA8E9 /* PolycodeView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6D6FD3E21BF122A7005AA8E9 /* PolycodeView.mm */; };
+		6D90506D1CCC058F00D0E80A /* liblua.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D90506C1CCC058F00D0E80A /* liblua.a */; };
 		8A22D92B1BCC67DE009EF0A6 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A22D92A1BCC67DE009EF0A6 /* OpenGL.framework */; };
 		8A22D92D1BCC67E6009EF0A6 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A22D92C1BCC67E6009EF0A6 /* AudioUnit.framework */; };
 		8A22D92F1BCC6809009EF0A6 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A22D92E1BCC6809009EF0A6 /* CoreAudio.framework */; };
@@ -55,7 +56,6 @@
 		8A36D31D1B8E6FD5009897D0 /* liblibvorbis.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A36D3131B8E6FD5009897D0 /* liblibvorbis.a */; };
 		8A36D31E1B8E6FD5009897D0 /* libportaudio.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A36D3141B8E6FD5009897D0 /* libportaudio.a */; };
 		8A36D31F1B8E6FD5009897D0 /* liblibvorbisfile.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A36D3151B8E6FD5009897D0 /* liblibvorbisfile.a */; };
-		8A36D3201B8E6FD5009897D0 /* liblua5.1.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A36D3161B8E6FD5009897D0 /* liblua5.1.a */; };
 		8A36D3211B8E6FD5009897D0 /* libphysfs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A36D3171B8E6FD5009897D0 /* libphysfs.a */; };
 		8A36D3231B8E6FD5009897D0 /* libPolycore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A36D3191B8E6FD5009897D0 /* libPolycore.a */; };
 		8A36D3241B8E6FD5009897D0 /* libz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A36D31A1B8E6FD5009897D0 /* libz.a */; };
@@ -65,6 +65,7 @@
 
 /* Begin PBXFileReference section */
 		6D6FD3E21BF122A7005AA8E9 /* PolycodeView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PolycodeView.mm; path = ../../../../src/view/osx/PolycodeView.mm; sourceTree = "<group>"; };
+		6D90506C1CCC058F00D0E80A /* liblua.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua.a; path = ../../../../lib/osx/liblua.a; sourceTree = "<group>"; };
 		6DE288271BE96D7100F7B42C /* PolycodeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolycodeView.h; path = ../../../../include/polycode/view/osx/PolycodeView.h; sourceTree = "<group>"; };
 		8A22D92A1BCC67DE009EF0A6 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
 		8A22D92C1BCC67E6009EF0A6 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = System/Library/Frameworks/AudioUnit.framework; sourceTree = SDKROOT; };
@@ -151,7 +152,6 @@
 		8A36D3131B8E6FD5009897D0 /* liblibvorbis.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblibvorbis.a; path = /Users/isafrin/Desktop/Workshop/PolycodeNoCmake/build/osx/TemplateApp/TemplateApp/../../../../lib/osx/liblibvorbis.a; sourceTree = "<absolute>"; };
 		8A36D3141B8E6FD5009897D0 /* libportaudio.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libportaudio.a; path = /Users/isafrin/Desktop/Workshop/PolycodeNoCmake/build/osx/TemplateApp/TemplateApp/../../../../lib/osx/libportaudio.a; sourceTree = "<absolute>"; };
 		8A36D3151B8E6FD5009897D0 /* liblibvorbisfile.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblibvorbisfile.a; path = /Users/isafrin/Desktop/Workshop/PolycodeNoCmake/build/osx/TemplateApp/TemplateApp/../../../../lib/osx/liblibvorbisfile.a; sourceTree = "<absolute>"; };
-		8A36D3161B8E6FD5009897D0 /* liblua5.1.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua5.1.a; path = /Users/isafrin/Desktop/Workshop/PolycodeNoCmake/build/osx/TemplateApp/TemplateApp/../../../../lib/osx/liblua5.1.a; sourceTree = "<absolute>"; };
 		8A36D3171B8E6FD5009897D0 /* libphysfs.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libphysfs.a; path = /Users/isafrin/Desktop/Workshop/PolycodeNoCmake/build/osx/TemplateApp/TemplateApp/../../../../lib/osx/libphysfs.a; sourceTree = "<absolute>"; };
 		8A36D3191B8E6FD5009897D0 /* libPolycore.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libPolycore.a; path = /Users/isafrin/Desktop/Workshop/PolycodeNoCmake/build/osx/TemplateApp/TemplateApp/../../../../lib/osx/libPolycore.a; sourceTree = "<absolute>"; };
 		8A36D31A1B8E6FD5009897D0 /* libz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libz.a; path = /Users/isafrin/Desktop/Workshop/PolycodeNoCmake/build/osx/TemplateApp/TemplateApp/../../../../lib/osx/libz.a; sourceTree = "<absolute>"; };
@@ -170,11 +170,11 @@
 				8A22D92B1BCC67DE009EF0A6 /* OpenGL.framework in Frameworks */,
 				8A36D31D1B8E6FD5009897D0 /* liblibvorbis.a in Frameworks */,
 				8A36D3231B8E6FD5009897D0 /* libPolycore.a in Frameworks */,
-				8A36D3201B8E6FD5009897D0 /* liblua5.1.a in Frameworks */,
 				8A36D31F1B8E6FD5009897D0 /* liblibvorbisfile.a in Frameworks */,
 				8A36D31E1B8E6FD5009897D0 /* libportaudio.a in Frameworks */,
 				8A36D3261B8E6FE7009897D0 /* libPolycodeUI.a in Frameworks */,
 				8A36D31B1B8E6FD5009897D0 /* libfreetype.a in Frameworks */,
+				6D90506D1CCC058F00D0E80A /* liblua.a in Frameworks */,
 				8A36D3211B8E6FD5009897D0 /* libphysfs.a in Frameworks */,
 				8A36D3241B8E6FD5009897D0 /* libz.a in Frameworks */,
 				8A36D31C1B8E6FD5009897D0 /* liblibogg.a in Frameworks */,
@@ -229,7 +229,7 @@
 				8A36D3131B8E6FD5009897D0 /* liblibvorbis.a */,
 				8A36D3141B8E6FD5009897D0 /* libportaudio.a */,
 				8A36D3151B8E6FD5009897D0 /* liblibvorbisfile.a */,
-				8A36D3161B8E6FD5009897D0 /* liblua5.1.a */,
+				6D90506C1CCC058F00D0E80A /* liblua.a */,
 				8A36D3171B8E6FD5009897D0 /* libphysfs.a */,
 				8A36D3251B8E6FE7009897D0 /* libPolycodeUI.a */,
 				8A36D3191B8E6FD5009897D0 /* libPolycore.a */,

+ 4 - 7
build/osx/TemplateApp/TemplateApp.xcodeproj/project.pbxproj

@@ -8,8 +8,8 @@
 
 /* Begin PBXBuildFile section */
 		6D6FD3E11BF122A2005AA8E9 /* PolycodeView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6D6FD3E01BF122A2005AA8E9 /* PolycodeView.mm */; };
-		6D904FD11CC2AAA500D0E80A /* liblua5.1.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D904FD01CC2AAA500D0E80A /* liblua5.1.a */; };
 		6D904FD31CC2AEB400D0E80A /* rotate.lua in Resources */ = {isa = PBXBuildFile; fileRef = 6D904FD21CC2AEB400D0E80A /* rotate.lua */; };
+		6D90506B1CCC057C00D0E80A /* liblua.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D90506A1CCC057C00D0E80A /* liblua.a */; };
 		6DCDD7251C724726007E90E1 /* main_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 6DCDD7241C724726007E90E1 /* main_icon.png */; };
 		6DD2D0B61BEEDC150026D85C /* libportaudio.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6DD2D0B51BEEDC150026D85C /* libportaudio.a */; };
 		8A825F271B82A2680039E823 /* libportaudio.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A825F261B82A2680039E823 /* libportaudio.a */; };
@@ -36,8 +36,8 @@
 
 /* Begin PBXFileReference section */
 		6D6FD3E01BF122A2005AA8E9 /* PolycodeView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PolycodeView.mm; path = ../../../../src/view/osx/PolycodeView.mm; sourceTree = "<group>"; };
-		6D904FD01CC2AAA500D0E80A /* liblua5.1.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua5.1.a; path = ../../../../lib/osx/liblua5.1.a; sourceTree = "<group>"; };
 		6D904FD21CC2AEB400D0E80A /* rotate.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rotate.lua; sourceTree = "<group>"; };
+		6D90506A1CCC057C00D0E80A /* liblua.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua.a; path = ../../../../lib/osx/liblua.a; sourceTree = "<group>"; };
 		6DCDD7241C724726007E90E1 /* main_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = main_icon.png; path = ../../../../assets/icons/main_icon.png; sourceTree = "<group>"; };
 		6DD2D0B51BEEDC150026D85C /* libportaudio.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libportaudio.a; path = ../../../../lib/osx/libportaudio.a; sourceTree = "<group>"; };
 		8A825F261B82A2680039E823 /* libportaudio.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libportaudio.a; path = ../../../../lib/osx/libportaudio.a; sourceTree = "<group>"; };
@@ -55,7 +55,6 @@
 		8A8653541B72949F009F94DD /* liblibogg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblibogg.a; path = ../../../../lib/osx/liblibogg.a; sourceTree = "<group>"; };
 		8A8653551B72949F009F94DD /* liblibvorbis.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblibvorbis.a; path = ../../../../lib/osx/liblibvorbis.a; sourceTree = "<group>"; };
 		8A8653561B72949F009F94DD /* liblibvorbisfile.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblibvorbisfile.a; path = ../../../../lib/osx/liblibvorbisfile.a; sourceTree = "<group>"; };
-		8A8653571B72949F009F94DD /* liblua5.1.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua5.1.a; path = ../../../../lib/osx/liblua5.1.a; sourceTree = "<group>"; };
 		8A8653581B72949F009F94DD /* libphysfs.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libphysfs.a; path = ../../../../lib/osx/libphysfs.a; sourceTree = "<group>"; };
 		8A86535A1B72949F009F94DD /* libPolycore.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libPolycore.a; path = ../../../../lib/osx/libPolycore.a; sourceTree = "<group>"; };
 		8A86535B1B72949F009F94DD /* libz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libz.a; path = ../../../../lib/osx/libz.a; sourceTree = "<group>"; };
@@ -78,15 +77,14 @@
 				8A825F291B82A29B0039E823 /* CoreAudio.framework in Frameworks */,
 				8A8653681B7294B7009F94DD /* OpenGL.framework in Frameworks */,
 				8A8653641B72949F009F94DD /* libz.a in Frameworks */,
-				6D904FD11CC2AAA500D0E80A /* liblua5.1.a in Frameworks */,
 				8A825F271B82A2680039E823 /* libportaudio.a in Frameworks */,
 				8A8653631B72949F009F94DD /* libPolycore.a in Frameworks */,
 				8A86535F1B72949F009F94DD /* liblibvorbisfile.a in Frameworks */,
 				8A86535E1B72949F009F94DD /* liblibvorbis.a in Frameworks */,
 				8A86535C1B72949F009F94DD /* libfreetype.a in Frameworks */,
+				6D90506B1CCC057C00D0E80A /* liblua.a in Frameworks */,
 				6DD2D0B61BEEDC150026D85C /* libportaudio.a in Frameworks */,
 				8A8653611B72949F009F94DD /* libphysfs.a in Frameworks */,
-				6D904FD11CC2AAA500D0E80A /* liblua5.1.a in Frameworks */,
 				8A86535D1B72949F009F94DD /* liblibogg.a in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -139,12 +137,11 @@
 			isa = PBXGroup;
 			children = (
 				8A8653531B72949F009F94DD /* libfreetype.a */,
-				6D904FD01CC2AAA500D0E80A /* liblua5.1.a */,
 				8A8653541B72949F009F94DD /* liblibogg.a */,
 				8A8653551B72949F009F94DD /* liblibvorbis.a */,
 				8A825F261B82A2680039E823 /* libportaudio.a */,
 				8A8653561B72949F009F94DD /* liblibvorbisfile.a */,
-				8A8653571B72949F009F94DD /* liblua5.1.a */,
+				6D90506A1CCC057C00D0E80A /* liblua.a */,
 				6DD2D0B51BEEDC150026D85C /* libportaudio.a */,
 				8A8653581B72949F009F94DD /* libphysfs.a */,
 				8A86535A1B72949F009F94DD /* libPolycore.a */,

+ 5 - 0
build/osx/polyimport/polyimport.xcodeproj/project.pbxproj

@@ -7,6 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		6D90506F1CCC0B0A00D0E80A /* liblua.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D90506E1CCC0B0A00D0E80A /* liblua.a */; };
 		8AE1F6B61CB82FDF0001557D /* polyimport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AE1F6B51CB82FDF0001557D /* polyimport.cpp */; };
 		8AE1F6B91CB837050001557D /* libassimp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8AE1F6B71CB837050001557D /* libassimp.a */; };
 		8AE1F6D41CB8391D0001557D /* libz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8AE1F6D31CB8391D0001557D /* libz.a */; };
@@ -38,6 +39,7 @@
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+		6D90506E1CCC0B0A00D0E80A /* liblua.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua.a; path = ../../../../lib/osx/liblua.a; sourceTree = "<group>"; };
 		8AE1F6AB1CB82FBD0001557D /* polyimport */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = polyimport; sourceTree = BUILT_PRODUCTS_DIR; };
 		8AE1F6B51CB82FDF0001557D /* polyimport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = polyimport.cpp; path = ../../../../src/tools/polyimport.cpp; sourceTree = "<group>"; };
 		8AE1F6B71CB837050001557D /* libassimp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libassimp.a; path = ../../../../lib/osx/libassimp.a; sourceTree = "<group>"; };
@@ -63,6 +65,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				6D90506F1CCC0B0A00D0E80A /* liblua.a in Frameworks */,
 				8AE1F7011CB83CFE0001557D /* liblibvorbis.a in Frameworks */,
 				8AE1F6FC1CB83CF00001557D /* AudioToolbox.framework in Frameworks */,
 				8AE1F6FA1CB83CE10001557D /* AudioUnit.framework in Frameworks */,
@@ -114,6 +117,7 @@
 				8AE1F6FD1CB83CFE0001557D /* liblibogg.a */,
 				8AE1F6FE1CB83CFE0001557D /* liblibvorbis.a */,
 				8AE1F6FF1CB83CFE0001557D /* liblibvorbisfile.a */,
+				6D90506E1CCC0B0A00D0E80A /* liblua.a */,
 				8AE1F6F11CB83C990001557D /* libphysfs.a */,
 				8AE1F6EB1CB83C720001557D /* libfreetype.a */,
 				8AE1F6D31CB8391D0001557D /* libz.a */,
@@ -330,6 +334,7 @@
 				8AE1F6B41CB82FBD0001557D /* Release */,
 			);
 			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
 		};
 /* End XCConfigurationList section */
 	};

+ 13 - 2
include/polycode/core/PolyCore.h

@@ -29,6 +29,7 @@ THE SOFTWARE.
 #include "polycode/core/PolyCoreInput.h"
 #include "polycode/core/PolyCoreServices.h"
 #include "polycode/core/PolyThreaded.h"
+#include "polycode/core/PolyQuaternion.h"
 #include "polycode/core/PolyCoreFileProvider.h"
 
 long getThreadID();
@@ -89,6 +90,11 @@ namespace Polycode {
         int anisotropyLevel;
         bool retinaSupport;
     };
+    
+    class CoreMotionEvent : public Event {
+        public:
+            Vector3 amount;
+    };
 
 	/**
 	* The main core of the framework. The core deals with system-level functions, such as window initialization and OS interaction. Each platform has its own implementation of this base class. NOTE: SOME OF THE FUNCTIONALITY IN THE CORE IS NOT FULLY IMPLEMENTED!!
@@ -381,7 +387,10 @@ namespace Polycode {
 		static const int EVENT_CUT = EVENTBASE_CORE+6;
 		static const int EVENT_SELECT_ALL = EVENTBASE_CORE+7;
 		static const int EVENT_PASTE = EVENTBASE_CORE+8;
-		
+        
+		static const int EVENT_GYRO_ROTATION = EVENTBASE_CORE+9;
+		static const int EVENT_ACCELEROMETER_MOTION = EVENTBASE_CORE+10;
+        
 		virtual String executeExternalCommand(String command, String args, String inDirectory) = 0;
 		
 		/**
@@ -423,7 +432,9 @@ namespace Polycode {
 		/**
 		* Default height of the desktop screen
 		*/		
-		int defaultScreenHeight;		
+		int defaultScreenHeight;
+        
+        Quaternion deviceAttitude;
 				
 	protected:	
 	

+ 4 - 2
include/polycode/core/PolyGlobals.h

@@ -50,8 +50,6 @@ typedef unsigned int PolyRendererIndexType;
     #ifndef NOMINMAX
 	#define NOMINMAX
     #endif
-
-
 #endif
 #include <stdint.h>
  
@@ -128,6 +126,10 @@ inline Number clampf(Number x, Number a, Number b)
 	#define MAX(a, b)  (((a) > (b)) ? (a) : (b))
 #endif
 
+#if PLATFORM == PLATFORM_IOS
+//    #define BGRA_TEXTURE_FORMAT
+#endif
+
 // Special flag read by create_lua_library parser, suppresses Lua bindings for item.
 #define POLYIGNORE
 

+ 28 - 2
include/polycode/core/PolyIOSCore.h

@@ -24,6 +24,7 @@ THE SOFTWARE.
 
 #include "polycode/core/PolyCore.h"
 #import "polycode/view/ios/PolycodeView.h"
+#include "polycode/core/PolyInputEvent.h"
 #include "polycode/core/PolyOpenGLGraphicsInterface.h"
 #include <pthread.h>
 
@@ -40,7 +41,26 @@ public:
     pthread_mutex_t pMutex;
 };
 
-
+class IOSEvent {
+    public:
+    int eventGroup;
+    int eventCode;
+    
+    int mouseX;
+    int mouseY;
+    
+    std::vector<TouchInfo> touches;
+    TouchInfo touch;
+    
+    PolyKEY keyCode;
+    wchar_t unicodeChar;
+    
+    char mouseButton;
+    
+    static const int EVENTBASE_PLATFORMEVENT = 0x300;
+    static const int INPUT_EVENT = EVENTBASE_PLATFORMEVENT+0;
+    static const int FOCUS_EVENT = EVENTBASE_PLATFORMEVENT+1;
+};
 
 namespace Polycode {
 
@@ -83,7 +103,12 @@ namespace Polycode {
 
 		Number getBackingXRes();
 		Number getBackingYRes();
-
+        
+        void _setAcceleration(const Vector3 &acceleration);
+        void _setGyroRotation(const Vector3 &rotation);
+        
+        std::vector<IOSEvent> iosEvents;
+        
 	private:
         
         CADisplayLink *displayLink;
@@ -91,6 +116,7 @@ namespace Polycode {
         GLuint colorRenderbuffer;
         GLuint depthRenderbuffer;
         GLuint defaultFBOName;
+        bool retinaSupport;
         
         EAGLContext *context;
         uint64_t initTime;

+ 4 - 4
include/polycode/core/PolyMaterialManager.h

@@ -50,10 +50,10 @@ namespace Polycode {
 			
 			void Update(int elapsed);
 
-			Texture *createTexture(int width, int height, char *imageData, bool clamp=false, bool createMipmaps = true, int type=Image::IMAGE_RGBA);
-			Texture *createNewTexture(int width, int height, bool clamp=false, bool createMipmaps = true, int type=Image::IMAGE_RGBA);
-			Texture *createTextureFromImage(Image *image, bool clamp=false, bool createMipmaps = true);
-			Texture *createTextureFromFile(const String& fileName, bool clamp=false, bool createMipmaps = true, ResourcePool *resourcePool = NULL);
+			Texture *createTexture(int width, int height, char *imageData, bool clamp=true, bool createMipmaps = false, int type=Image::IMAGE_RGBA);
+			Texture *createNewTexture(int width, int height, bool clamp=true, bool createMipmaps = false, int type=Image::IMAGE_RGBA);
+			Texture *createTextureFromImage(Image *image, bool clamp=true, bool createMipmaps = false);
+			Texture *createTextureFromFile(const String& fileName, bool clamp=true, bool createMipmaps = false, ResourcePool *resourcePool = NULL);
 			void deleteTexture(Texture *texture);
 		
 			void reloadTextures();

+ 1 - 1
include/polycode/core/PolyRenderer.h

@@ -35,7 +35,7 @@ THE SOFTWARE.
 #include <stack>
 #include <queue>  
 
-#define RENDERER_MAX_LIGHTS 12
+#define RENDERER_MAX_LIGHTS 4
 #define RENDERER_MAX_LIGHT_SHADOWS 2
 
 #define MAX_QUEUED_FRAMES 2

+ 7 - 2
include/polycode/view/ios/PolycodeView.h

@@ -1,12 +1,17 @@
 
 #import <UIKit/UIKit.h>
+#import <CoreMotion/CoreMotion.h>
+#include "polycode/core/PolyIOSCore.h"
+
+using namespace Polycode;
 
 @interface PolycodeView : UIView
 
+@property (nonatomic) Polycode::Core *core;
 @property (nonatomic) BOOL needsUpdate;
+@property (strong, nonatomic) CMMotionManager *motionManager;
 
 - (void) drawView:(id)sender;
-
-
+- (void) setCore: (Polycode::Core*) newCore;
 
 @end

+ 62 - 6
src/core/PolyIOSCore.mm

@@ -43,10 +43,13 @@ IOSCore::IOSCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool v
         
         initTime = mach_absolute_time();
         
+        eventMutex = createMutex();
+        
         fileProviders.push_back(new BasicFileProvider());
         fileProviders.push_back(new PhysFSFileProvider());
         
         glView = view;
+        [glView setCore:this];
         
         renderer = new Renderer();
                 
@@ -54,7 +57,9 @@ IOSCore::IOSCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool v
         renderer->setGraphicsInterface(this, interface);
         services->setRenderer(renderer);
         
-        setVideoMode([glView frame].size.width , [glView frame].size.height, fullScreen, vSync, aaLevel, anisotropyLevel, retinaSupport);
+        CGRect screenBounds = [[UIScreen mainScreen] bounds];
+        
+        setVideoMode(screenBounds.size.width, screenBounds.size.height, fullScreen, vSync, aaLevel, anisotropyLevel, retinaSupport);
 
 }
 
@@ -70,8 +75,29 @@ void IOSCore::Render() {
 }
 
 void IOSCore::checkEvents() {
-
-
+    lockMutex(eventMutex);    
+    for(int i=0; i < iosEvents.size(); i++) {
+        IOSEvent event = iosEvents[i];
+        switch(event.eventGroup) {
+            case IOSEvent::INPUT_EVENT:
+            {
+                    case InputEvent::EVENT_TOUCHES_BEGAN:
+                        input->touchesBegan(event.touch, event.touches, getTicks());
+                        break;
+                    case InputEvent::EVENT_TOUCHES_ENDED:
+                        input->touchesEnded(event.touch, event.touches, getTicks());
+                        break;
+                    case InputEvent::EVENT_TOUCHES_MOVED:
+                        input->touchesMoved(event.touch, event.touches, getTicks());
+                        break;
+            }
+            break;
+            case IOSEvent::FOCUS_EVENT:
+            break;
+        }
+    }
+    iosEvents.clear();
+    unlockMutex(eventMutex);
 }
 
 bool IOSCore::systemUpdate() {
@@ -150,12 +176,25 @@ String IOSCore::saveFilePicker(std::vector<CoreFileExtension> extensions) {
 	return "";
 }
 
+void IOSCore::_setAcceleration(const Vector3 &acceleration) {
+    CoreMotionEvent *event = new CoreMotionEvent();
+    event->amount = acceleration;
+    dispatchEvent(event, Core::EVENT_ACCELEROMETER_MOTION);
+}
+
+void IOSCore::_setGyroRotation(const Vector3 &rotation) {
+    CoreMotionEvent *event = new CoreMotionEvent();
+    event->amount = rotation;
+    dispatchEvent(event, Core::EVENT_GYRO_ROTATION);
+}
+
 void IOSCore::handleVideoModeChange(VideoModeChangeInfo *modeInfo) {
     
     // IOS_TODO: Implement CADisplayLink
     
     xRes = modeInfo->xRes;
     yRes = modeInfo->yRes;
+    retinaSupport = modeInfo->retinaSupport;
     
     CAEAGLLayer *eaglLayer = (CAEAGLLayer *)glView.layer;
     eaglLayer.opaque = TRUE;
@@ -170,12 +209,21 @@ void IOSCore::handleVideoModeChange(VideoModeChangeInfo *modeInfo) {
         return;
     }
 
+    CGFloat screenScale = 1.0;
+    if(modeInfo->retinaSupport) {
+        screenScale = [[UIScreen mainScreen] scale];
+        renderer->setBackingResolutionScale(screenScale, screenScale);
+    } else {
+        renderer->setBackingResolutionScale(1.0, 1.0);
+    }
+    
     glGenFramebuffers(1, &defaultFBOName);
     
     glGenRenderbuffers(1, &colorRenderbuffer);
     glBindFramebuffer(GL_FRAMEBUFFER, defaultFBOName);
     glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
     
+    glView.layer.contentsScale = screenScale;
     [context renderbufferStorage:GL_RENDERBUFFER fromDrawable: (id<EAGLDrawable>) glView.layer];
 
     glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
@@ -187,7 +235,7 @@ void IOSCore::handleVideoModeChange(VideoModeChangeInfo *modeInfo) {
     
     glGenRenderbuffers(1, &depthRenderbuffer);
     glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer);
-    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, modeInfo->xRes, modeInfo->yRes);
+    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, modeInfo->xRes * screenScale, modeInfo->yRes  * screenScale);
     glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer);
     
     if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
@@ -251,9 +299,17 @@ void IOSCore::setDeviceSize(Number x, Number y) {
 }
 
 Number IOSCore::getBackingXRes() {
-	return getXRes();
+    if(!retinaSupport) {
+        return getXRes();
+    } else {
+        return getXRes() * [[UIScreen mainScreen] scale];
+    }
 }
 
 Number IOSCore::getBackingYRes() {
-	return getYRes();
+    if(!retinaSupport) {
+        return getYRes();
+    } else {
+        return getYRes()  * [[UIScreen mainScreen] scale];
+    }
 }

+ 1 - 1
src/core/PolyMaterialManager.cpp

@@ -35,7 +35,7 @@ using std::vector;
 
 MaterialManager::MaterialManager() {
 	premultiplyAlphaOnLoad = false;
-	clampDefault = false;
+	clampDefault = true;
 	mipmapsDefault = true;
     keepTextureData = true;
     textureFilteringMode = Texture::FILTERING_LINEAR;

+ 14 - 2
src/core/PolyOpenGLGraphicsInterface.cpp

@@ -459,12 +459,20 @@ void OpenGLGraphicsInterface::createTexture(Texture *texture) {
     
     switch(texture->type) {
         case Image::IMAGE_RGB:
-            glTextureType = GL_RGB;
+#ifdef BGRA_TEXTURE_FORMAT
+            glTextureType = GL_BGRA;
+#else
+            glTextureType = GL_RGBA;
+#endif
             glTextureFormat = GL_RGB;
             pixelType = GL_UNSIGNED_BYTE;
             break;
         case Image::IMAGE_FP16:
+#ifdef BGRA_TEXTURE_FORMAT
+            glTextureType = GL_BGRA;
+#else
             glTextureType = GL_RGBA;
+#endif
 #if defined(GL_RGBA16F_EXT)
             glTextureFormat = GL_RGBA16F_EXT;
 #elif defined(GL_RGBA16F_ARB)
@@ -475,8 +483,12 @@ void OpenGLGraphicsInterface::createTexture(Texture *texture) {
             pixelType = GL_FLOAT;
             break;
         default:
+#ifdef BGRA_TEXTURE_FORMAT
+            glTextureType = GL_BGRA;
+#else
             glTextureType = GL_RGBA;
-            glTextureFormat = GL_RGBA;	
+#endif
+            glTextureFormat = GL_RGBA;
             pixelType = GL_UNSIGNED_BYTE;	
             break;
     }

+ 2 - 2
src/core/PolyRenderer.cpp

@@ -88,8 +88,6 @@ void RenderThread::runThread() {
             nextFrame = frameQueue.front();
             frameQueue.pop();
         }
-
-        Services()->getCore()->unlockMutex(jobQueueMutex);
            
         if(nextFrame) {
             while(nextFrame->jobQueue.size() > 0) {
@@ -99,6 +97,8 @@ void RenderThread::runThread() {
             }
             delete nextFrame;
         }
+           
+        Services()->getCore()->unlockMutex(jobQueueMutex);
     }
 }
 

+ 1 - 1
src/core/PolySceneLabel.cpp

@@ -116,7 +116,7 @@ void SceneLabel::updateFromLabel() {
 
     Texture *texture;
 	if(SceneLabel::createMipmapsForLabels) {
-		texture = materialManager->createTextureFromImage(label, materialManager->clampDefault, materialManager->mipmapsDefault);	
+		texture = materialManager->createTextureFromImage(label, materialManager->clampDefault, materialManager->mipmapsDefault);
 	} else {
 		texture = materialManager->createTextureFromImage(label, materialManager->clampDefault, false);		
 	}

+ 87 - 0
src/view/ios/PolycodeView.m

@@ -1,9 +1,12 @@
 
 #import "polycode/view/ios/PolycodeView.h"
+#import "polycode/core/PolyInputEvent.h"
+#import "polycode/core/PolyIOSCore.h"
 
 @interface PolycodeView ()
 {
     BOOL _needsUpdate;
+    Polycode::Core *_core;
 }
 @end
 
@@ -24,9 +27,93 @@
         [displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
     }
     
+    self.motionManager = [[CMMotionManager alloc] init];
+//    self.motionManager.accelerometerUpdateInterval = .2;
+//    self.motionManager.gyroUpdateInterval = .2;
+    
+    [self.motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryCorrectedZVertical
+                                                            toQueue: [NSOperationQueue currentQueue]
+                                                        withHandler: ^(CMDeviceMotion *motion, NSError *error) {
+                                                            [self handleDeviceMotion: motion];
+     }];
+    
+
+    [self.motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue currentQueue]
+          withHandler:^(CMAccelerometerData  *accelerometerData, NSError *error) {
+              [self outputAccelertionData:accelerometerData.acceleration];
+              if(error){
+                  NSLog(@"%@", error);
+              }
+          }];
+    
+    
+    [self.motionManager startGyroUpdatesToQueue:[NSOperationQueue currentQueue]
+                                    withHandler:^(CMGyroData *gyroData, NSError *error) {
+                                        [self outputRotationData:gyroData.rotationRate];
+    }];
+    
     return self;
 }
 
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
+    _core->eventMutex->lock();
+    for (UITouch *aTouch in touches) {
+        IOSEvent newEvent;
+        newEvent.eventCode = InputEvent::EVENT_TOUCHES_BEGAN;
+        newEvent.eventGroup = IOSEvent::INPUT_EVENT;
+//        newEvent.touches = touchInfos;
+//        newEvent.touch = touchInfos[index];
+        ((IOSCore*)_core)->iosEvents.push_back(newEvent);
+    }
+    _core->eventMutex->unlock();
+}
+
+- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
+    
+}
+
+- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
+    
+}
+
+- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
+    
+}
+
+-(void)handleDeviceMotion:(CMDeviceMotion*) motion
+{
+    
+    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
+    
+    Quaternion q;
+    q.set(motion.attitude.quaternion.w, motion.attitude.quaternion.x, motion.attitude.quaternion.y, motion.attitude.quaternion.z);
+    
+    Quaternion rQ;
+    rQ.fromAxes(-90.0, 00.0, 0.0);
+    
+    if(orientation == UIDeviceOrientationLandscapeRight) {
+        
+    } else {
+
+    }
+
+    
+    _core->deviceAttitude = rQ * q;
+}
+
+-(void)outputAccelertionData:(CMAcceleration)acceleration
+{
+    ((IOSCore*)_core)->_setAcceleration(Vector3(acceleration.x, acceleration.y, acceleration.z));
+}
+
+- (void) setCore: (Polycode::Core*) newCore {
+    _core = newCore;
+}
+-(void)outputRotationData:(CMRotationRate)rotation
+{
+    ((IOSCore*)_core)->_setGyroRotation(Vector3(rotation.x, rotation.y, rotation.z));
+}
+
 - (BOOL) needsUpdate
 {
     return _needsUpdate;