Просмотр исходного кода

3D Physics module, minor fixes across the board.

Ivan Safrin 14 лет назад
Родитель
Сommit
8b1ae6d785
76 измененных файлов с 4187 добавлено и 2083 удалено
  1. 392 592
      Bindings/Build/Mac OS X/Bindings.xcodeproj/project.xcworkspace/xcuserdata/ivansafrin.xcuserdatad/UserInterfaceState.xcuserstate
  2. 0 1
      Bindings/Contents/LUA/API/Polycode.lua
  3. 2 0
      Bindings/Contents/LUA/API/defaults.lua
  4. 2 10
      Bindings/Contents/LUA/Include/PolycodeLUA.h
  5. 0 36
      Bindings/Contents/LUA/Include/PolycodeLUAWrappers.h
  6. 2 5
      Bindings/Contents/LUA/Source/PolycodeLUA.cpp
  7. BIN
      Bindings/Scripts/create_lua_library/.create_lua_library.py.swp
  8. 5 0
      Bindings/Scripts/create_lua_library/Makefile
  9. 400 375
      Bindings/Scripts/create_lua_library/create_lua_library.py
  10. 413 204
      Core/Build/Mac OS X/PolyCore.xcodeproj/project.xcworkspace/xcuserdata/ivansafrin.xcuserdatad/UserInterfaceState.xcuserstate
  11. 2 0
      Core/Contents/Include/PolyCoreServices.h
  12. 10 1
      Core/Contents/Source/PolyCoreServices.cpp
  13. 5 4
      Core/Contents/Source/PolyMesh.cpp
  14. 3 0
      Modules/Bindings/2DPhysics/API/Physics2D.lua
  15. 28 0
      Modules/Bindings/2DPhysics/API/Physics2D/PhysicsJoint.lua
  16. 217 0
      Modules/Bindings/2DPhysics/API/Physics2D/PhysicsScreen.lua
  17. 70 0
      Modules/Bindings/2DPhysics/API/Physics2D/PhysicsScreenEntity.lua
  18. 10 0
      Modules/Bindings/2DPhysics/Include/Physics2DLUA.h
  19. 484 0
      Modules/Bindings/2DPhysics/Include/Physics2DLUAWrappers.h
  20. 53 0
      Modules/Bindings/2DPhysics/Source/Physics2DLUA.cpp
  21. 5 0
      Modules/Bindings/3DPhysics/API/Physics3D.lua
  22. 189 0
      Modules/Bindings/3DPhysics/API/Physics3D/CollisionScene.lua
  23. 104 0
      Modules/Bindings/3DPhysics/API/Physics3D/CollisionSceneEntity.lua
  24. 48 0
      Modules/Bindings/3DPhysics/API/Physics3D/PhysicsCharacter.lua
  25. 73 0
      Modules/Bindings/3DPhysics/API/Physics3D/PhysicsScene.lua
  26. 79 0
      Modules/Bindings/3DPhysics/API/Physics3D/PhysicsSceneEntity.lua
  27. 10 0
      Modules/Bindings/3DPhysics/Include/Physics3DLUA.h
  28. 621 0
      Modules/Bindings/3DPhysics/Include/Physics3DLUAWrappers.h
  29. 66 0
      Modules/Bindings/3DPhysics/Source/Physics3DLUA.cpp
  30. 116 0
      Modules/Build/Mac OS X/Modules.xcodeproj/project.pbxproj
  31. 163 177
      Modules/Build/Mac OS X/Modules.xcodeproj/project.xcworkspace/xcuserdata/ivansafrin.xcuserdatad/UserInterfaceState.xcuserstate
  32. 16 0
      Modules/Build/Mac OS X/Modules.xcodeproj/xcuserdata/ivansafrin.xcuserdatad/xcschemes/Polycode3DPhysicsModule.xcscheme
  33. 35 17
      Modules/Contents/2DPhysics/Include/PolyPhysicsScreen.h
  34. 8 5
      Modules/Contents/2DPhysics/Include/PolyPhysicsScreenEntity.h
  35. 15 15
      Modules/Contents/2DPhysics/Source/PolyPhysicsScreen.cpp
  36. 4 4
      Modules/Contents/2DPhysics/Source/PolyPhysicsScreenEntity.cpp
  37. 4 4
      Modules/Contents/3DPhysics/Include/PolyCollisionScene.h
  38. 1 1
      Modules/Contents/3DPhysics/Include/PolyCollisionSceneEntity.h
  39. 3 3
      Modules/Contents/3DPhysics/Include/PolyPhysicsScene.h
  40. 4 4
      Modules/Contents/3DPhysics/Include/PolyPhysicsSceneEntity.h
  41. 6 6
      Modules/Contents/3DPhysics/Source/PolyCollisionScene.cpp
  42. 2 2
      Modules/Contents/3DPhysics/Source/PolyCollisionSceneEntity.cpp
  43. 4 4
      Modules/Contents/3DPhysics/Source/PolyPhysicsScene.cpp
  44. 12 2
      Modules/Contents/3DPhysics/Source/PolyPhysicsSceneEntity.cpp
  45. 3 3
      Modules/Contents/CgShading/Include/PolyCGProgram.h
  46. 6 6
      Modules/Contents/CgShading/Source/PolyCGProgram.cpp
  47. 4 4
      Modules/Contents/CgShading/Source/PolyCGShaderModule.cpp
  48. 3 4
      Modules/Contents/GLSL/Include/PolyGLSLProgram.h
  49. 6 6
      Modules/Contents/GLSL/Source/PolyGLSLProgram.cpp
  50. 4 4
      Modules/Contents/GLSL/Source/PolyGLSLShaderModule.cpp
  51. 1 1
      Modules/Contents/Kinect/Source/PolycodeKinect.cpp
  52. 6 6
      Modules/Contents/UI/Include/PolyUIBox.h
  53. 3 3
      Modules/Contents/UI/Include/PolyUIButton.h
  54. 9 9
      Modules/Contents/UI/Include/PolyUIHScrollBar.h
  55. 10 10
      Modules/Contents/UI/Include/PolyUIHSlider.h
  56. 7 7
      Modules/Contents/UI/Include/PolyUIScrollContainer.h
  57. 9 9
      Modules/Contents/UI/Include/PolyUITextInput.h
  58. 7 7
      Modules/Contents/UI/Include/PolyUITree.h
  59. 1 1
      Modules/Contents/UI/Include/PolyUITreeContainer.h
  60. 11 11
      Modules/Contents/UI/Include/PolyUIVScrollBar.h
  61. 5 5
      Modules/Contents/UI/Include/PolyUIWindow.h
  62. 2 2
      Modules/Contents/UI/Source/PolyUIBox.cpp
  63. 5 5
      Modules/Contents/UI/Source/PolyUIButton.cpp
  64. 9 9
      Modules/Contents/UI/Source/PolyUIHScrollBar.cpp
  65. 3 3
      Modules/Contents/UI/Source/PolyUIHSlider.cpp
  66. 5 5
      Modules/Contents/UI/Source/PolyUIScrollContainer.cpp
  67. 16 16
      Modules/Contents/UI/Source/PolyUITextInput.cpp
  68. 12 12
      Modules/Contents/UI/Source/PolyUITree.cpp
  69. 7 7
      Modules/Contents/UI/Source/PolyUITreeContainer.cpp
  70. 13 13
      Modules/Contents/UI/Source/PolyUIVScrollBar.cpp
  71. 7 7
      Modules/Contents/UI/Source/PolyUIWindow.cpp
  72. 6 0
      Player/Build/Mac OS X/Polycode Player.xcodeproj/project.pbxproj
  73. 227 433
      Player/Build/Mac OS X/Polycode Player.xcodeproj/project.xcworkspace/xcuserdata/ivansafrin.xcuserdatad/UserInterfaceState.xcuserstate
  74. 3 0
      Player/Contents/Include/PolycodePlayer.h
  75. 56 2
      Player/Contents/Source/PolycodePlayer.mm
  76. 35 1
      Tools/Contents/polybuild/Source/polybuild.cpp

Разница между файлами не показана из-за своего большого размера
+ 392 - 592
Bindings/Build/Mac OS X/Bindings.xcodeproj/project.xcworkspace/xcuserdata/ivansafrin.xcuserdatad/UserInterfaceState.xcuserstate


+ 0 - 1
Bindings/Contents/LUA/API/Polycode.lua

@@ -19,7 +19,6 @@ require "Polycode/FixedShader"
 require "Polycode/FixedShaderBinding"
 require "Polycode/Font"
 require "Polycode/FontManager"
-require "Polycode/OpenGLCubemap"
 require "Polycode/Image"
 require "Polycode/InputEvent"
 require "Polycode/Label"

+ 2 - 0
Bindings/Contents/LUA/API/defaults.lua

@@ -4,6 +4,8 @@ _G["count"]=_G["getn"]
 
 _G["print"] = _G["debugPrint"]
 
+__core__services__instance = Polycore.CoreServices_getInstance()
+
 Polycore.__ptr_lookup = {}
 
 Services = {}

+ 2 - 10
Bindings/Contents/LUA/Include/PolycodeLUA.h

@@ -1,18 +1,10 @@
-
 #pragma once
-
-
 #include <Polycode.h>
 #include "PolycodeLUAWrappers.h"
-
-
-extern "C" {	
+extern "C" {
 #include <stdio.h>
 #include "lua.h"
 #include "lualib.h"
 #include "lauxlib.h"
-	
-	
-int luaopen_Polycode(lua_State *L);	
-	
+int luaopen_Polycode(lua_State *L);
 }

+ 0 - 36
Bindings/Contents/LUA/Include/PolycodeLUAWrappers.h

@@ -2,8 +2,6 @@
 
 #include <Polycode.h>
 
-#include <PolyGLRenderer.h>
-
 extern "C" {
 
 #include <stdio.h>
@@ -2751,40 +2749,6 @@ static int Polycore_delete_FontManager(lua_State *L) {
 	return 0;
 }
 
-static int Polycore_OpenGLCubemap(lua_State *L) {
-	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
-	Texture * t0 = (Texture *)lua_topointer(L, 1);
-	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
-	Texture * t1 = (Texture *)lua_topointer(L, 2);
-	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
-	Texture * t2 = (Texture *)lua_topointer(L, 3);
-	luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
-	Texture * t3 = (Texture *)lua_topointer(L, 4);
-	luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
-	Texture * t4 = (Texture *)lua_topointer(L, 5);
-	luaL_checktype(L, 6, LUA_TLIGHTUSERDATA);
-	Texture * t5 = (Texture *)lua_topointer(L, 6);
-	OpenGLCubemap *inst = new OpenGLCubemap(t0, t1, t2, t3, t4, t5);
-	lua_pushlightuserdata(L, (void*)inst);
-	return 1;
-}
-
-static int Polycore_OpenGLCubemap_getTextureID(lua_State *L) {
-	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
-	OpenGLCubemap *inst = (OpenGLCubemap*)lua_topointer(L, 1);
-	GLuint *retInst = new GLuint();
-	*retInst = inst->getTextureID();
-	lua_pushlightuserdata(L, retInst);
-	return 1;
-}
-
-static int Polycore_delete_OpenGLCubemap(lua_State *L) {
-	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
-	OpenGLCubemap *inst = (OpenGLCubemap*)lua_topointer(L, 1);
-	delete inst;
-	return 0;
-}
-
 static int Polycore_Image(lua_State *L) {
 	luaL_checktype(L, 1, LUA_TSTRING);
 	String fileName = String(lua_tostring(L, 1));

+ 2 - 5
Bindings/Contents/LUA/Source/PolycodeLUA.cpp

@@ -2,7 +2,7 @@
 #include "PolycodeLUAWrappers.h"
 
 int luaopen_Polycode(lua_State *L) {
-	static const struct luaL_reg polycodeLib [] = {		{"OSFILE_get_fileType", Polycore_OSFILE_get_fileType},
+	static const struct luaL_reg polycoreLib [] = {		{"OSFILE_get_fileType", Polycore_OSFILE_get_fileType},
 		{"OSFILE_set_fileType", Polycore_OSFILE_set_fileType},
 		{"OSFILE", Polycore_OSFILE},
 		{"OSFILE_debugDump", Polycore_OSFILE_debugDump},
@@ -317,9 +317,6 @@ int luaopen_Polycode(lua_State *L) {
 		{"FontManager_registerFont", Polycore_FontManager_registerFont},
 		{"FontManager_getFontByName", Polycore_FontManager_getFontByName},
 		{"delete_FontManager", Polycore_delete_FontManager},
-		{"OpenGLCubemap", Polycore_OpenGLCubemap},
-		{"OpenGLCubemap_getTextureID", Polycore_OpenGLCubemap_getTextureID},
-		{"delete_OpenGLCubemap", Polycore_delete_OpenGLCubemap},
 		{"Image", Polycore_Image},
 		{"Image_loadImage", Polycore_Image_loadImage},
 		{"Image_loadPNG", Polycore_Image_loadPNG},
@@ -1066,6 +1063,6 @@ int luaopen_Polycode(lua_State *L) {
 		{"delete_Vertex", Polycore_delete_Vertex},
 		{NULL, NULL}
 	};
-	luaL_openlib(L, "Polycore", polycodeLib, 0);
+	luaL_openlib(L, "Polycore", polycoreLib, 0);
 	return 1;
 }

BIN
Bindings/Scripts/create_lua_library/.create_lua_library.py.swp


+ 5 - 0
Bindings/Scripts/create_lua_library/Makefile

@@ -0,0 +1,5 @@
+default:
+	python create_lua_library.py ../../../Core/Contents/Include Polycode Polycode.h polycore Polycore ../../Contents/LUA/API ../../Contents/LUA/API/Polycode ../../Contents/LUA/Include ../../Contents/LUA/Source
+modules:
+	python create_lua_library.py ../../../Modules/Contents/2DPhysics/Include/ Physics2D Polycode2DPhysics.h physics2d Physics2D ../../../Modules/Bindings/2DPhysics/API ../../../Modules/Bindings/2DPhysics/API/Physics2D ../../../Modules/Bindings/2DPhysics/Include ../../../Modules/Bindings/2DPhysics/Source
+	python create_lua_library.py ../../../Modules/Contents/3DPhysics/Include/ Physics3D Polycode3DPhysics.h physics3d Physics3D ../../../Modules/Bindings/3DPhysics/API ../../../Modules/Bindings/3DPhysics/API/Physics3D ../../../Modules/Bindings/3DPhysics/Include ../../../Modules/Bindings/3DPhysics/Source

+ 400 - 375
Bindings/Scripts/create_lua_library/create_lua_library.py

@@ -2,395 +2,420 @@ import sys
 import CppHeaderParser
 import os
 
-out = ""
-sout = ""
 
-lfout = ""
-
-sout += "#include \"PolycodeLUA.h\"\n"
-sout += "#include \"PolycodeLUAWrappers.h\"\n\n"
-
-sout += "int luaopen_Polycode(lua_State *L) {\n"
-sout += "\tstatic const struct luaL_reg polycodeLib [] = {"
-
-out += "#pragma once\n\n"
-out += "#include <Polycode.h>\n\n"
-out += "#include <PolyGLRenderer.h>\n\n"
-
-out += "extern \"C\" {\n\n"
-out += "#include <stdio.h>\n"
-out += "#include \"lua.h\"\n"
-out += "#include \"lualib.h\"\n"
-out += "#include \"lauxlib.h\"\n\n"
-
-out += "class LuaEventHandler : public EventHandler {\n"
-out += "public:\n"
-out += "	LuaEventHandler() : EventHandler() {}\n"
-out += "	~LuaEventHandler();\n"
-out += "	void handleEvent(Event *e) {\n"
-out += "		lua_rawgeti( L, LUA_REGISTRYINDEX, wrapperIndex );\n"
-out += "		lua_getfield(L, -1, \"__handleEvent\");\n"
-out += "		lua_rawgeti( L, LUA_REGISTRYINDEX, wrapperIndex );\n"
-out += "		lua_pushlightuserdata(L, e);\n"
-out += "		lua_call(L, 2, 0);\n"
-out += "	}\n"
-out += "	int wrapperIndex;\n"
-out += "	lua_State *L;\n"
-out += "};\n"
-
-
-files = os.listdir("../../../Core/Contents/Include")
-for fileName in files:
-	ignore = ["PolyCocoaCore", "PolyAGLCore", "PolyGLES1Renderer", "PolyGLRenderer", "tinyxml", "tinystr", "PolyiPhoneCore", "PolyGLES1Texture", "PolyGLTexture", "PolyGLVertexBuffer", "PolyThreaded"]
-	if fileName.split(".")[1] == "h" and fileName.split(".")[0] not in ignore:
-		headerFile = "../../../Core/Contents/Include/%s" % fileName
-		print "Parsing %s" % fileName
-		try:
-			f = open(headerFile)
-			contents = f.read().replace("_PolyExport", "")
-			cppHeader = CppHeaderParser.CppHeader(contents, "string")
-			ignore_classes = ["PolycodeShaderModule", "Object", "Threaded"]
-			for ckey in cppHeader.classes:
-				c = cppHeader.classes[ckey]
-				lout = ""
-				inherits = False
-				if len(c["inherits"]) > 0:
-					if c["inherits"][0]["class"] not in ignore_classes:
-						lout += "require \"Polycode/%s\"\n\n" % (c["inherits"][0]["class"])
-						lout += "class \"%s\" (%s)\n\n" % (ckey, c["inherits"][0]["class"])
-						inherits = True
-				if inherits == False:
-					lout += "class \"%s\"\n\n" % ckey
-		
-				if len(c["methods"]["public"]) < 2 or ckey in ignore_classes:
-					continue
-
-				if ckey == "OSFileEntry":
-					print c["methods"]["public"]
-				parsed_methods = []
-				ignore_methods = ["readByte32", "readByte16", "getCustomEntitiesByType", "Core","ParticleEmitter", "Renderer", "Shader", "Texture", "handleEvent", "secondaryHandler"]
-				lout += "\n\n"
-
-				pps = []
-				for pp in c["properties"]["public"]:
-					if pp["type"].find("static ") != -1:
-						lout += "%s = %s\n" % (pp["name"], pp["defaltValue"])
-					else:
-						if pp["type"] == "Number" or  pp["type"] == "String" or pp["type"] == "int" or pp["type"] == "bool":
-							pps.append(pp)
-						#else:
-						#	print(">>> Skipping %s[%s %s]" % (ckey, pp["type"], pp["name"]))
-
-				pidx = 0
-				if len(pps) > 0:
-					lout += "function %s:__index__(name)\n" % ckey
-					for pp in pps:
-						if pidx == 0:
-							lout += "\tif name == \"%s\" then\n" % (pp["name"])
+def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, apiPath, apiClassPath, includePath, sourcePath):	
+	out = ""
+	sout = ""
+	
+	lfout = ""
+	
+	sout += "#include \"%sLUA.h\"\n" % (prefix)
+	sout += "#include \"%sLUAWrappers.h\"\n\n" % (prefix)
+	
+	sout += "int luaopen_%s(lua_State *L) {\n" % (prefix)
+	sout += "CoreServices *inst = (CoreServices*)lua_topointer(L, 1);\n"
+	sout += "CoreServices::setInstance(inst);\n"
+	sout += "\tstatic const struct luaL_reg %sLib [] = {" % (libSmallName)
+	
+	out += "#pragma once\n\n"
+	out += "#include <%s>\n\n" % (mainInclude)
+	
+	out += "extern \"C\" {\n\n"
+	out += "#include <stdio.h>\n"
+	out += "#include \"lua.h\"\n"
+	out += "#include \"lualib.h\"\n"
+	out += "#include \"lauxlib.h\"\n\n"
+	
+	if prefix == "Polycode":
+		out += "class LuaEventHandler : public EventHandler {\n"
+		out += "public:\n"
+		out += "	LuaEventHandler() : EventHandler() {}\n"
+		out += "	~LuaEventHandler();\n"
+		out += "	void handleEvent(Event *e) {\n"
+		out += "		lua_rawgeti( L, LUA_REGISTRYINDEX, wrapperIndex );\n"
+		out += "		lua_getfield(L, -1, \"__handleEvent\");\n"
+		out += "		lua_rawgeti( L, LUA_REGISTRYINDEX, wrapperIndex );\n"
+		out += "		lua_pushlightuserdata(L, e);\n"
+		out += "		lua_call(L, 2, 0);\n"
+		out += "	}\n"
+		out += "	int wrapperIndex;\n"
+		out += "	lua_State *L;\n"
+		out += "};\n"
+	
+	files = os.listdir(inputPath)
+	for fileName in files:
+		inheritInModule = ["PhysicsSceneEntity", "CollisionScene", "CollisionSceneEntity"]
+		ignore = ["PolyCocoaCore", "PolyAGLCore", "PolyGLES1Renderer", "PolyGLRenderer", "tinyxml", "tinystr", "OpenGLCubemap", "PolyiPhoneCore", "PolyGLES1Texture", "PolyGLTexture", "PolyGLVertexBuffer", "PolyThreaded"]
+		if fileName.split(".")[1] == "h" and fileName.split(".")[0] not in ignore:
+			headerFile = "%s/%s" % (inputPath, fileName)
+			print "Parsing %s" % fileName
+			try:
+				f = open(headerFile)
+				contents = f.read().replace("_PolyExport", "")
+				cppHeader = CppHeaderParser.CppHeader(contents, "string")
+				ignore_classes = ["PolycodeShaderModule", "Object", "Threaded", "OpenGLCubemap"]
+				for ckey in cppHeader.classes:
+					c = cppHeader.classes[ckey]
+					lout = ""
+					inherits = False
+					if len(c["inherits"]) > 0:
+						if c["inherits"][0]["class"] not in ignore_classes:	
+							if c["inherits"][0]["class"] in inheritInModule:
+								lout += "require \"%s/%s\"\n\n" % (prefix, c["inherits"][0]["class"])
+							else:
+								lout += "require \"Polycode/%s\"\n\n" % (c["inherits"][0]["class"])
+							lout += "class \"%s\" (%s)\n\n" % (ckey, c["inherits"][0]["class"])
+							inherits = True
+					if inherits == False:
+						lout += "class \"%s\"\n\n" % ckey
+			
+					if len(c["methods"]["public"]) < 2 or ckey in ignore_classes:
+						continue
+	
+					if ckey == "OSFileEntry":
+						print c["methods"]["public"]
+					parsed_methods = []
+					ignore_methods = ["readByte32", "readByte16", "getCustomEntitiesByType", "Core","ParticleEmitter", "Renderer", "Shader", "Texture", "handleEvent", "secondaryHandler"]
+					lout += "\n\n"
+	
+					pps = []
+					for pp in c["properties"]["public"]:
+						if pp["type"].find("static ") != -1:
+							lout += "%s = %s\n" % (pp["name"], pp["defaltValue"])
 						else:
-							lout += "\telseif name == \"%s\" then\n" % (pp["name"])
-						lout += "\t\treturn Polycore.%s_get_%s(self.__ptr)\n" % (ckey, pp["name"])
+							if pp["type"] == "Number" or  pp["type"] == "String" or pp["type"] == "int" or pp["type"] == "bool":
+								pps.append(pp)
+							#else:
+							#	print(">>> Skipping %s[%s %s]" % (ckey, pp["type"], pp["name"]))
+	
+					pidx = 0
+					if len(pps) > 0:
+						lout += "function %s:__index__(name)\n" % ckey
+						for pp in pps:
+							if pidx == 0:
+								lout += "\tif name == \"%s\" then\n" % (pp["name"])
+							else:
+								lout += "\telseif name == \"%s\" then\n" % (pp["name"])
+							lout += "\t\treturn %s.%s_get_%s(self.__ptr)\n" % (libName, ckey, pp["name"])
+							
+							sout += "\t\t{\"%s_get_%s\", %s_%s_get_%s},\n" % (ckey, pp["name"], libName, ckey, pp["name"])
+							out += "static int %s_%s_get_%s(lua_State *L) {\n" % (libName, ckey, pp["name"])
+							out += "\tluaL_checktype(L, 1, LUA_TLIGHTUSERDATA);\n"
+							out += "\t%s *inst = (%s*)lua_topointer(L, 1);\n" % (ckey.replace("Polygon", "Polycode::Polygon"), ckey.replace("Polygon", "Polycode::Polygon"))
+	
+							outfunc = "lua_pushlightuserdata"
+							retFunc = ""
+							if pp["type"] == "Number":
+								outfunc = "lua_pushnumber"
+							if pp["type"] == "String":
+								outfunc = "lua_pushstring"
+								retFunc = ".c_str()"
+							if pp["type"] == "int":
+								outfunc = "lua_pushinteger"
+							if pp["type"] == "bool":
+								outfunc = "lua_pushboolean"
+	
+							out += "\t%s(L, inst->%s%s);\n" % (outfunc, pp["name"], retFunc)
+	
+							out += "\treturn 1;\n"
+							out += "}\n\n"
+							pidx = pidx + 1
+	
+						lout += "\tend\n"
+						lout += "end\n"
+	
+					lout += "\n\n"
+					pidx = 0
+					if len(pps) > 0:
+						lout += "function %s:__set_callback(name,value)\n" % ckey
+						for pp in pps:
+							if pidx == 0:
+								lout += "\tif name == \"%s\" then\n" % (pp["name"])
+							else:
+								lout += "\telseif name == \"%s\" then\n" % (pp["name"])
+							lout += "\t\t%s.%s_set_%s(self.__ptr, value)\n" % (libName, ckey, pp["name"])
+							lout += "\t\treturn true\n"
+	
+							sout += "\t\t{\"%s_set_%s\", %s_%s_set_%s},\n" % (ckey, pp["name"], libName, ckey, pp["name"])
+							out += "static int %s_%s_set_%s(lua_State *L) {\n" % (libName, ckey, pp["name"])
+							out += "\tluaL_checktype(L, 1, LUA_TLIGHTUSERDATA);\n"
+							out += "\t%s *inst = (%s*)lua_topointer(L, 1);\n" % (ckey.replace("Polygon", "Polycode::Polygon"), ckey.replace("Polygon", "Polycode::Polygon"))
+	
+							outfunc = "lua_topointer"
+							if pp["type"] == "Number":
+								outfunc = "lua_tonumber"
+							if pp["type"] == "String":
+								outfunc = "lua_tostring"
+							if pp["type"] == "int":
+								outfunc = "lua_tointeger"
+							if pp["type"] == "bool":
+								outfunc = "lua_toboolean"
+	
+							out += "\t%s param = %s(L, 2);\n" % (pp["type"], outfunc)
+							out += "\tinst->%s = param;\n" % (pp["name"])
+	
+							out += "\treturn 0;\n"
+							out += "}\n\n"
+							pidx = pidx + 1
+	
+						lout += "\tend\n"
+						lout += "\treturn false\n"
+						lout += "end\n"
 						
-						sout += "\t\t{\"%s_get_%s\", Polycore_%s_get_%s},\n" % (ckey, pp["name"], ckey, pp["name"])
-						out += "static int Polycore_%s_get_%s(lua_State *L) {\n" % (ckey, pp["name"])
-						out += "\tluaL_checktype(L, 1, LUA_TLIGHTUSERDATA);\n"
-						out += "\t%s *inst = (%s*)lua_topointer(L, 1);\n" % (ckey.replace("Polygon", "Polycode::Polygon"), ckey.replace("Polygon", "Polycode::Polygon"))
-
-						outfunc = "lua_pushlightuserdata"
-						retFunc = ""
-						if pp["type"] == "Number":
-							outfunc = "lua_pushnumber"
-						if pp["type"] == "String":
-							outfunc = "lua_pushstring"
-							retFunc = ".c_str()"
-						if pp["type"] == "int":
-							outfunc = "lua_pushinteger"
-						if pp["type"] == "bool":
-							outfunc = "lua_pushboolean"
-
-						out += "\t%s(L, inst->%s%s);\n" % (outfunc, pp["name"], retFunc)
-
-						out += "\treturn 1;\n"
-						out += "}\n\n"
-						pidx = pidx + 1
-
-					lout += "\tend\n"
-					lout += "end\n"
-
-				lout += "\n\n"
-				pidx = 0
-				if len(pps) > 0:
-					lout += "function %s:__set_callback(name,value)\n" % ckey
-					for pp in pps:
-						if pidx == 0:
-							lout += "\tif name == \"%s\" then\n" % (pp["name"])
+	
+					lout += "\n\n"
+					for pm in c["methods"]["public"]:
+						if pm["name"] in parsed_methods or pm["name"].find("operator") > -1 or pm["name"] in ignore_methods:
+							continue 
+	
+						if pm["name"] == "~"+ckey or pm["rtnType"].find("<") > -1:
+							out += ""
 						else:
-							lout += "\telseif name == \"%s\" then\n" % (pp["name"])
-						lout += "\t\tPolycore.%s_set_%s(self.__ptr, value)\n" % (ckey, pp["name"])
-						lout += "\t\treturn true\n"
-
-						sout += "\t\t{\"%s_set_%s\", Polycore_%s_set_%s},\n" % (ckey, pp["name"], ckey, pp["name"])
-						out += "static int Polycore_%s_set_%s(lua_State *L) {\n" % (ckey, pp["name"])
-						out += "\tluaL_checktype(L, 1, LUA_TLIGHTUSERDATA);\n"
-						out += "\t%s *inst = (%s*)lua_topointer(L, 1);\n" % (ckey.replace("Polygon", "Polycode::Polygon"), ckey.replace("Polygon", "Polycode::Polygon"))
-
-						outfunc = "lua_topointer"
-						if pp["type"] == "Number":
-							outfunc = "lua_tonumber"
-						if pp["type"] == "String":
-							outfunc = "lua_tostring"
-						if pp["type"] == "int":
-							outfunc = "lua_tointeger"
-						if pp["type"] == "bool":
-							outfunc = "lua_toboolean"
-
-						out += "\t%s param = %s(L, 2);\n" % (pp["type"], outfunc)
-						out += "\tinst->%s = param;\n" % (pp["name"])
-
-						out += "\treturn 0;\n"
-						out += "}\n\n"
-						pidx = pidx + 1
-
-					lout += "\tend\n"
-					lout += "\treturn false\n"
-					lout += "end\n"
-					
-
-				lout += "\n\n"
-				for pm in c["methods"]["public"]:
-					if pm["name"] in parsed_methods or pm["name"].find("operator") > -1 or pm["name"] in ignore_methods:
-						continue 
-
-					if pm["name"] == "~"+ckey or pm["rtnType"].find("<") > -1:
-						out += ""
-					else:
-						basicType = False
-						voidRet = False
-						if pm["name"] == ckey:
-							sout += "\t\t{\"%s\", Polycore_%s},\n" % (ckey, ckey)
-							out += "static int Polycore_%s(lua_State *L) {\n" % (ckey)
-							idx = 1
-						else: 
-							sout += "\t\t{\"%s_%s\", Polycore_%s_%s},\n" % (ckey, pm["name"], ckey, pm["name"])
-							out += "static int Polycore_%s_%s(lua_State *L) {\n" % (ckey, pm["name"])
-
-							if pm["rtnType"].find("static ") == -1:
-								out += "\tluaL_checktype(L, 1, LUA_TLIGHTUSERDATA);\n"
-								out += "\t%s *inst = (%s*)lua_topointer(L, 1);\n" % (ckey.replace("Polygon", "Polycode::Polygon"), ckey.replace("Polygon", "Polycode::Polygon"))
-							idx = 2
-						paramlist = []
-						lparamlist = []
-						for param in pm["parameters"]:
-							if not param.has_key("type"):
-								continue
-							if param["type"] == "0":
-								continue
-
-							param["name"] = param["name"].replace("end", "_end").replace("repeat", "_repeat")
-							if"type" in param:
-								luatype = "LUA_TLIGHTUSERDATA"
-								checkfunc = "lua_islightuserdata"
-								if param["type"].find("*") > -1:
-									luafunc = "(%s)lua_topointer" % (param["type"].replace("Polygon", "Polycode::Polygon"))
-								elif param["type"].find("&") > -1:
-									luafunc = "*(%s*)lua_topointer" % (param["type"].replace("const", "").replace("&", "").replace("Polygon", "Polycode::Polygon"))
-								else:
-									luafunc = "*(%s*)lua_topointer" % (param["type"])
-								lend = ".__ptr"
-								if param["type"] == "int" or param["type"] == "unsigned int":
-									luafunc = "lua_tointeger"
-									luatype = "LUA_TNUMBER"
-									checkfunc = "lua_isnumber"
-									lend = ""
-								if param["type"] == "bool":
-									luafunc = "lua_toboolean"
-									luatype = "LUA_TBOOLEAN"
-									checkfunc = "lua_isboolean"
-									lend = ""
-								if param["type"] == "Number":
-									luatype = "LUA_TNUMBER"
-									luafunc = "lua_tonumber"
-									checkfunc = "lua_isnumber"
-									lend = ""
-								if param["type"] == "String":
-									luatype = "LUA_TSTRING"
-									luafunc = "lua_tostring"
-									checkfunc = "lua_isstring"
-									lend = ""
-								
-								param["type"] = param["type"].replace("Polygon", "Polycode::Polygon")
-
-								if "defaltValue" in param and checkfunc != "lua_islightuserdata":
-									param["defaltValue"] = param["defaltValue"].replace(" 0f", ".0f")
-									param["defaltValue"] = param["defaltValue"].replace(": :", "::")
-
-									out += "\t%s %s;\n" % (param["type"], param["name"])
-									out += "\tif(%s(L, %d)) {\n" % (checkfunc, idx)
-									out += "\t\t%s = %s(L, %d);\n" % (param["name"], luafunc, idx)
-									out += "\t} else {\n"
-									out += "\t\t%s = %s;\n" % (param["name"], param["defaltValue"])
-									out += "\t}\n"
-								else:
-									out += "\tluaL_checktype(L, %d, %s);\n" % (idx, luatype);
+							basicType = False
+							voidRet = False
+							if pm["name"] == ckey:
+								sout += "\t\t{\"%s\", %s_%s},\n" % (ckey, libName, ckey)
+								out += "static int %s_%s(lua_State *L) {\n" % (libName, ckey)
+								idx = 1
+							else: 
+								sout += "\t\t{\"%s_%s\", %s_%s_%s},\n" % (ckey, pm["name"], libName, ckey, pm["name"])
+								out += "static int %s_%s_%s(lua_State *L) {\n" % (libName, ckey, pm["name"])
+	
+								if pm["rtnType"].find("static ") == -1:
+									out += "\tluaL_checktype(L, 1, LUA_TLIGHTUSERDATA);\n"
+									out += "\t%s *inst = (%s*)lua_topointer(L, 1);\n" % (ckey.replace("Polygon", "Polycode::Polygon"), ckey.replace("Polygon", "Polycode::Polygon"))
+								idx = 2
+							paramlist = []
+							lparamlist = []
+							for param in pm["parameters"]:
+								if not param.has_key("type"):
+									continue
+								if param["type"] == "0":
+									continue
+	
+								param["name"] = param["name"].replace("end", "_end").replace("repeat", "_repeat")
+								if"type" in param:
+									luatype = "LUA_TLIGHTUSERDATA"
+									checkfunc = "lua_islightuserdata"
+									if param["type"].find("*") > -1:
+										luafunc = "(%s)lua_topointer" % (param["type"].replace("Polygon", "Polycode::Polygon"))
+									elif param["type"].find("&") > -1:
+										luafunc = "*(%s*)lua_topointer" % (param["type"].replace("const", "").replace("&", "").replace("Polygon", "Polycode::Polygon"))
+									else:
+										luafunc = "*(%s*)lua_topointer" % (param["type"])
+									lend = ".__ptr"
+									if param["type"] == "int" or param["type"] == "unsigned int":
+										luafunc = "lua_tointeger"
+										luatype = "LUA_TNUMBER"
+										checkfunc = "lua_isnumber"
+										lend = ""
+									if param["type"] == "bool":
+										luafunc = "lua_toboolean"
+										luatype = "LUA_TBOOLEAN"
+										checkfunc = "lua_isboolean"
+										lend = ""
+									if param["type"] == "Number" or param["type"] == "float" or param["type"] == "double":
+										luatype = "LUA_TNUMBER"
+										luafunc = "lua_tonumber"
+										checkfunc = "lua_isnumber"
+										lend = ""
 									if param["type"] == "String":
-										out += "\t%s %s = String(%s(L, %d));\n" % (param["type"], param["name"], luafunc, idx)
+										luatype = "LUA_TSTRING"
+										luafunc = "lua_tostring"
+										checkfunc = "lua_isstring"
+										lend = ""
+									
+									param["type"] = param["type"].replace("Polygon", "Polycode::Polygon")
+	
+									if "defaltValue" in param and checkfunc != "lua_islightuserdata":
+										param["defaltValue"] = param["defaltValue"].replace(" 0f", ".0f")
+										param["defaltValue"] = param["defaltValue"].replace(": :", "::")
+										param["defaltValue"] = param["defaltValue"].replace("0 ", "0.")
+	
+										out += "\t%s %s;\n" % (param["type"], param["name"])
+										out += "\tif(%s(L, %d)) {\n" % (checkfunc, idx)
+										out += "\t\t%s = %s(L, %d);\n" % (param["name"], luafunc, idx)
+										out += "\t} else {\n"
+										out += "\t\t%s = %s;\n" % (param["name"], param["defaltValue"])
+										out += "\t}\n"
 									else:
-										out += "\t%s %s = %s(L, %d);\n" % (param["type"], param["name"], luafunc, idx)
-								paramlist.append(param["name"])
-							
-								lparamlist.append(param["name"]+lend)
-								idx = idx +1
-					
-						if pm["name"] == ckey:
-							if ckey == "EventHandler":
-								out += "\tLuaEventHandler *inst = new LuaEventHandler();\n"
-								out += "\tinst->wrapperIndex = luaL_ref(L, LUA_REGISTRYINDEX );\n"
-								out += "\tinst->L = L;\n"
-							else:
-								out += "\t%s *inst = new %s(%s);\n" % (ckey.replace("Polygon", "Polycode::Polygon"), ckey.replace("Polygon", "Polycode::Polygon"), ", ".join(paramlist))
-							out += "\tlua_pushlightuserdata(L, (void*)inst);\n"
-							out += "\treturn 1;\n"
-						else:
-							if pm["rtnType"].find("static ") == -1:
-								call = "inst->%s(%s)" % (pm["name"], ", ".join(paramlist))
-							else:
-								call = "%s::%s(%s)" % (ckey, pm["name"], ", ".join(paramlist))
-							if pm["rtnType"] == "void" or pm["rtnType"] == "static void" or pm["rtnType"] == "virtual void" or pm["rtnType"] == "inline void":
-								out += "\t%s;\n" % (call)
-								basicType = True
-								voidRet = True
-								out += "\treturn 0;\n"
+										out += "\tluaL_checktype(L, %d, %s);\n" % (idx, luatype);
+										if param["type"] == "String":
+											out += "\t%s %s = String(%s(L, %d));\n" % (param["type"], param["name"], luafunc, idx)
+										else:
+											out += "\t%s %s = %s(L, %d);\n" % (param["type"], param["name"], luafunc, idx)
+									paramlist.append(param["name"])
+								
+									lparamlist.append(param["name"]+lend)
+									idx = idx +1
+						
+							if pm["name"] == ckey:
+								if ckey == "EventHandler":
+									out += "\tLuaEventHandler *inst = new LuaEventHandler();\n"
+									out += "\tinst->wrapperIndex = luaL_ref(L, LUA_REGISTRYINDEX );\n"
+									out += "\tinst->L = L;\n"
+								else:
+									out += "\t%s *inst = new %s(%s);\n" % (ckey.replace("Polygon", "Polycode::Polygon"), ckey.replace("Polygon", "Polycode::Polygon"), ", ".join(paramlist))
+								out += "\tlua_pushlightuserdata(L, (void*)inst);\n"
+								out += "\treturn 1;\n"
 							else:
-								outfunc = "lua_pushlightuserdata"
-								retFunc = ""
-								basicType = False
-								if pm["rtnType"] == "Number" or  pm["rtnType"] == "inline Number":
-									outfunc = "lua_pushnumber"
-									basicType = True
-								if pm["rtnType"] == "String" or pm["rtnType"] == "static String":
-									outfunc = "lua_pushstring"
-									basicType = True
-									retFunc = ".c_str()"
-								if pm["rtnType"] == "int" or pm["rtnType"] == "static int" or  pm["rtnType"] == "size_t" or pm["rtnType"] == "static size_t" or pm["rtnType"] == "long" or pm["rtnType"] == "unsigned int" or pm["rtnType"] == "static long":
-									outfunc = "lua_pushinteger"
-									basicType = True
-								if pm["rtnType"] == "bool" or pm["rtnType"] == "static bool" or pm["rtnType"] == "virtual bool":
-									outfunc = "lua_pushboolean"
+								if pm["rtnType"].find("static ") == -1:
+									call = "inst->%s(%s)" % (pm["name"], ", ".join(paramlist))
+								else:
+									call = "%s::%s(%s)" % (ckey, pm["name"], ", ".join(paramlist))
+								if pm["rtnType"] == "void" or pm["rtnType"] == "static void" or pm["rtnType"] == "virtual void" or pm["rtnType"] == "inline void":
+									out += "\t%s;\n" % (call)
 									basicType = True
-
-								if pm["rtnType"].find("*") > -1:
-									out += "\t%s(L, (void*)%s%s);\n" % (outfunc, call, retFunc)
-								elif basicType == True:
-									out += "\t%s(L, %s%s);\n" % (outfunc, call, retFunc)
+									voidRet = True
+									out += "\treturn 0;\n"
 								else:
-									className = pm["rtnType"].replace("const", "").replace("&", "").replace("inline", "").replace("virtual", "").replace("static", "")
-									if className == "Polygon":
-										className = "Polycode::Polygon"
-									out += "\t%s *retInst = new %s();\n" % (className, className)
-									out += "\t*retInst = %s;\n" % (call)
-									out += "\t%s(L, retInst);\n" % (outfunc)
-								out += "\treturn 1;\n"
-						out += "}\n\n"
-						
-						if pm["name"] == ckey:
-							lout += "function %s:%s(...)\n" % (ckey, ckey)
-							if inherits:
-								lout += "\tif type(arg[1]) == \"table\" and count(arg) == 1 then\n"
-								lout += "\t\tif \"\"..arg[1]:class() == \"%s\" then\n" % (c["inherits"][0]["class"])
-								lout += "\t\t\tself.__ptr = arg[1].__ptr\n"
-								lout += "\t\t\treturn\n"
+									outfunc = "lua_pushlightuserdata"
+									retFunc = ""
+									basicType = False
+									if pm["rtnType"] == "Number" or  pm["rtnType"] == "inline Number":
+										outfunc = "lua_pushnumber"
+										basicType = True
+									if pm["rtnType"] == "String" or pm["rtnType"] == "static String":
+										outfunc = "lua_pushstring"
+										basicType = True
+										retFunc = ".c_str()"
+									if pm["rtnType"] == "int" or pm["rtnType"] == "static int" or  pm["rtnType"] == "size_t" or pm["rtnType"] == "static size_t" or pm["rtnType"] == "long" or pm["rtnType"] == "unsigned int" or pm["rtnType"] == "static long":
+										outfunc = "lua_pushinteger"
+										basicType = True
+									if pm["rtnType"] == "bool" or pm["rtnType"] == "static bool" or pm["rtnType"] == "virtual bool":
+										outfunc = "lua_pushboolean"
+										basicType = True
+	
+									if pm["rtnType"].find("*") > -1:
+										out += "\t%s(L, (void*)%s%s);\n" % (outfunc, call, retFunc)
+									elif basicType == True:
+										out += "\t%s(L, %s%s);\n" % (outfunc, call, retFunc)
+									else:
+										className = pm["rtnType"].replace("const", "").replace("&", "").replace("inline", "").replace("virtual", "").replace("static", "")
+										if className == "Polygon":
+											className = "Polycode::Polygon"
+										out += "\t%s *retInst = new %s();\n" % (className, className)
+										out += "\t*retInst = %s;\n" % (call)
+										out += "\t%s(L, retInst);\n" % (outfunc)
+									out += "\treturn 1;\n"
+							out += "}\n\n"
+							
+							if pm["name"] == ckey:
+								lout += "function %s:%s(...)\n" % (ckey, ckey)
+								if inherits:
+									lout += "\tif type(arg[1]) == \"table\" and count(arg) == 1 then\n"
+									lout += "\t\tif \"\"..arg[1]:class() == \"%s\" then\n" % (c["inherits"][0]["class"])
+									lout += "\t\t\tself.__ptr = arg[1].__ptr\n"
+									lout += "\t\t\treturn\n"
+									lout += "\t\tend\n"
+									lout += "\tend\n"
+								lout += "\tfor k,v in pairs(arg) do\n"
+								lout += "\t\tif type(v) == \"table\" then\n"
+								lout += "\t\t\tif v.__ptr ~= nil then\n"
+								lout += "\t\t\t\targ[k] = v.__ptr\n"
+								lout += "\t\t\tend\n"
 								lout += "\t\tend\n"
 								lout += "\tend\n"
-							lout += "\tfor k,v in pairs(arg) do\n"
-							lout += "\t\tif type(v) == \"table\" then\n"
-							lout += "\t\t\tif v.__ptr ~= nil then\n"
-							lout += "\t\t\t\targ[k] = v.__ptr\n"
-							lout += "\t\t\tend\n"
-							lout += "\t\tend\n"
-							lout += "\tend\n"
-							lout += "\tif self.__ptr == nil and arg[1] ~= \"__skip_ptr__\" then\n"
-							if ckey == "EventHandler":
-								lout += "\t\tself.__ptr = Polycore.%s(self)\n" % (ckey)
-							else:
-								lout += "\t\tself.__ptr = Polycore.%s(unpack(arg))\n" % (ckey)
-							lout += "\t\tPolycore.__ptr_lookup[self.__ptr] = self\n"
-							lout += "\tend\n"
-							lout += "end\n\n"
-						else:
-							lout += "function %s:%s(%s)\n" % (ckey, pm["name"], ", ".join(paramlist))
-							if pm["rtnType"].find("static ") == -1:
-								if len(lparamlist):
-									lout += "\tlocal retVal = Polycore.%s_%s(self.__ptr, %s)\n" % (ckey, pm["name"], ", ".join(lparamlist))
+								lout += "\tif self.__ptr == nil and arg[1] ~= \"__skip_ptr__\" then\n"
+								if ckey == "EventHandler":
+									lout += "\t\tself.__ptr = %s.%s(self)\n" % (libName, ckey)
 								else:
-									lout += "\tlocal retVal =  Polycore.%s_%s(self.__ptr)\n" % (ckey, pm["name"])
+									lout += "\t\tself.__ptr = %s.%s(unpack(arg))\n" % (libName, ckey)
+								lout += "\t\tPolycore.__ptr_lookup[self.__ptr] = self\n"
+								lout += "\tend\n"
+								lout += "end\n\n"
 							else:
-								if len(lparamlist):
-									lout += "\tlocal retVal = Polycore.%s_%s(%s)\n" % (ckey, pm["name"], ", ".join(lparamlist))
-								else:
-									lout += "\tlocal retVal =  Polycore.%s_%s()\n" % (ckey, pm["name"])
-
-							if not voidRet:
-								if basicType == True:
-									lout += "\treturn retVal\n"
+								lout += "function %s:%s(%s)\n" % (ckey, pm["name"], ", ".join(paramlist))
+								if pm["rtnType"].find("static ") == -1:
+									if len(lparamlist):
+										lout += "\tlocal retVal = %s.%s_%s(self.__ptr, %s)\n" % (libName, ckey, pm["name"], ", ".join(lparamlist))
+									else:
+										lout += "\tlocal retVal =  %s.%s_%s(self.__ptr)\n" % (libName, ckey, pm["name"])
 								else:
-									className = pm["rtnType"].replace("const", "").replace("&", "").replace("inline", "").replace("virtual", "").replace("static", "").replace("*","").replace(" ", "")
-									lout += "\tif Polycore.__ptr_lookup[retVal] ~= nil then\n"
-									lout += "\t\treturn Polycore.__ptr_lookup[retVal]\n"
-									lout += "\telse\n"
-									lout += "\t\tPolycore.__ptr_lookup[retVal] = %s(\"__skip_ptr__\")\n" % (className)
-									lout += "\t\tPolycore.__ptr_lookup[retVal].__ptr = retVal\n"
-									lout += "\t\treturn Polycore.__ptr_lookup[retVal]\n"
-									lout += "\tend\n"
-							lout += "end\n\n"
-
-					parsed_methods.append(pm["name"])
-	
-				#cleanup
-				sout += "\t\t{\"delete_%s\", Polycore_delete_%s},\n" % (ckey, ckey)
-				out += "static int Polycore_delete_%s(lua_State *L) {\n" % (ckey)
-				out += "\tluaL_checktype(L, 1, LUA_TLIGHTUSERDATA);\n"
-				out += "\t%s *inst = (%s*)lua_topointer(L, 1);\n" % (ckey.replace("Polygon", "Polycode::Polygon"), ckey.replace("Polygon", "Polycode::Polygon"))
-				out += "\tdelete inst;\n"
-				out += "\treturn 0;\n"
-				out += "}\n\n"
-
-				lout += "\n\n"
-				lout += "function %s:__delete()\n" % (ckey)
-				lout += "\tPolycore.__ptr_lookup[self.__ptr] = nil\n"
-				lout += "\tPolycore.delete_%s(self.__ptr)\n" % (ckey)
-				lout += "end\n"
-				if ckey == "EventHandler":
+									if len(lparamlist):
+										lout += "\tlocal retVal = %s.%s_%s(%s)\n" % (libName, ckey, pm["name"], ", ".join(lparamlist))
+									else:
+										lout += "\tlocal retVal =  %s.%s_%s()\n" % (libName, ckey, pm["name"])
+	
+								if not voidRet:
+									if basicType == True:
+										lout += "\treturn retVal\n"
+									else:
+										className = pm["rtnType"].replace("const", "").replace("&", "").replace("inline", "").replace("virtual", "").replace("static", "").replace("*","").replace(" ", "")
+										lout += "\tif Polycore.__ptr_lookup[retVal] ~= nil then\n"
+										lout += "\t\treturn Polycore.__ptr_lookup[retVal]\n"
+										lout += "\telse\n"
+										lout += "\t\tPolycore.__ptr_lookup[retVal] = %s(\"__skip_ptr__\")\n" % (className)
+										lout += "\t\tPolycore.__ptr_lookup[retVal].__ptr = retVal\n"
+										lout += "\t\treturn Polycore.__ptr_lookup[retVal]\n"
+										lout += "\tend\n"
+								lout += "end\n\n"
+	
+						parsed_methods.append(pm["name"])
+		
+					#cleanup
+					sout += "\t\t{\"delete_%s\", %s_delete_%s},\n" % (ckey, libName, ckey)
+					out += "static int %s_delete_%s(lua_State *L) {\n" % (libName, ckey)
+					out += "\tluaL_checktype(L, 1, LUA_TLIGHTUSERDATA);\n"
+					out += "\t%s *inst = (%s*)lua_topointer(L, 1);\n" % (ckey.replace("Polygon", "Polycode::Polygon"), ckey.replace("Polygon", "Polycode::Polygon"))
+					out += "\tdelete inst;\n"
+					out += "\treturn 0;\n"
+					out += "}\n\n"
+	
 					lout += "\n\n"
-					lout += "function EventHandler:__handleEvent(event)\n"
-					lout += "\tevt = Event(\"__skip_ptr__\")\n"
-					lout += "\tevt.__ptr = event\n"
-					lout += "\tself:handleEvent(evt)\n"
-					#lout += "\tself:handleEvent(event)\n"
+					lout += "function %s:__delete()\n" % (ckey)
+					lout += "\tPolycore.__ptr_lookup[self.__ptr] = nil\n"
+					lout += "\t%s.delete_%s(self.__ptr)\n" % (libName, ckey)
 					lout += "end\n"
-				lfout += "require \"Polycode/%s\"\n" % ckey
-				fout = open("../../Contents/LUA/API/Polycode/%s.lua" % ckey, "w")
-				fout.write(lout)
-		except CppHeaderParser.CppParseError,  e:
-			print e
-			sys.exit(1)
-		
-out += "}"
-
-sout += "\t\t{NULL, NULL}\n"
-sout += "\t};\n"
-sout += "\tluaL_openlib(L, \"Polycore\", polycodeLib, 0);\n"
-sout += "\treturn 1;\n"
-sout += "}"
-
-
-fout = open("../../Contents/LUA/API/Polycode.lua", "w")
-fout.write(lfout)
-
-fout = open("../../Contents/LUA/Include/PolycodeLUAWrappers.h", "w")
-fout.write(out)
-
-fout = open("../../Contents/LUA/Source/PolycodeLUA.cpp", "w")
-fout.write(sout)
-
-#print cppHeader
+					if ckey == "EventHandler":
+						lout += "\n\n"
+						lout += "function EventHandler:__handleEvent(event)\n"
+						lout += "\tevt = Event(\"__skip_ptr__\")\n"
+						lout += "\tevt.__ptr = event\n"
+						lout += "\tself:handleEvent(evt)\n"
+						#lout += "\tself:handleEvent(event)\n"
+						lout += "end\n"
+					lfout += "require \"%s/%s\"\n" % (prefix, ckey)
+					fout = open("%s/%s.lua" % (apiClassPath, ckey), "w")
+					fout.write(lout)
+			except CppHeaderParser.CppParseError,  e:
+				print e
+				sys.exit(1)
+			
+	out += "}"
+	
+	sout += "\t\t{NULL, NULL}\n"
+	sout += "\t};\n"
+	sout += "\tluaL_openlib(L, \"%s\", %sLib, 0);\n" % (libName, libSmallName)
+	sout += "\treturn 1;\n"
+	sout += "}"
+	
+	
+	shout = ""
+	shout += "#pragma once\n"
+	shout += "#include <%s>\n" % (mainInclude)
+	shout += "#include \"%sLUAWrappers.h\"\n" % (prefix)
+	shout += "extern \"C\" {\n"
+	shout += "#include <stdio.h>\n"
+	shout += "#include \"lua.h\"\n"
+	shout += "#include \"lualib.h\"\n"
+	shout += "#include \"lauxlib.h\"\n"
+	shout += "int luaopen_%s(lua_State *L);\n" % (prefix)
+	shout += "}\n"
+	
+	fout = open("%s/%sLUA.h" % (includePath, prefix), "w")
+	fout.write(shout)
 
+	fout = open("%s/%s.lua" % (apiPath, prefix), "w")
+	fout.write(lfout)
+	
+	fout = open("%s/%sLUAWrappers.h" % (includePath, prefix), "w")
+	fout.write(out)
+	
+	fout = open("%s/%sLUA.cpp" % (sourcePath, prefix), "w")
+	fout.write(sout)
+	
+	#print cppHeader
+	
+createLUABindings(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7], sys.argv[8], sys.argv[9])
+	

Разница между файлами не показана из-за своего большого размера
+ 413 - 204
Core/Build/Mac OS X/PolyCore.xcodeproj/project.xcworkspace/xcuserdata/ivansafrin.xcuserdatad/UserInterfaceState.xcuserstate


+ 2 - 0
Core/Contents/Include/PolyCoreServices.h

@@ -63,6 +63,7 @@ namespace Polycode {
 			* Returns the singleton instance. NOTE: The singleton instance is unique to each thread and currently Polycode does not support multithreaded access to the core services. The reason for this is being able to run multiple cores in the same application and still have global singleton access to these services.
 			*/ 
 			static CoreServices *getInstance();		
+			static void setInstance(CoreServices *_instance);
 			static CoreMutex *getRenderMutex();
 			
 			void setRenderer(Renderer *renderer);
@@ -165,6 +166,7 @@ namespace Polycode {
 					
 		private:
 		
+			static CoreServices* overrideInstance;
 			static std::map <long, CoreServices*> instanceMap;
 			static CoreMutex *renderMutex;
 		

+ 10 - 1
Core/Contents/Source/PolyCoreServices.cpp

@@ -26,7 +26,7 @@ using namespace Polycode;
 
 std::map<long, CoreServices*> CoreServices::instanceMap;
 CoreMutex *CoreServices::renderMutex = 0;
-
+CoreServices* CoreServices::overrideInstance = NULL;
 
 CoreMutex *CoreServices::getRenderMutex() {
 	if(renderMutex == NULL) {
@@ -36,7 +36,16 @@ CoreMutex *CoreServices::getRenderMutex() {
 	return renderMutex;
 }
 
+void CoreServices::setInstance(CoreServices *_instance) {
+	overrideInstance = _instance;
+}
+
 CoreServices* CoreServices::getInstance() {
+
+	if(overrideInstance) {
+		return overrideInstance;
+	}
+
 	long threadID = getThreadID(); 
 	CoreServices *instance;
 	if(instanceMap.find(threadID) == instanceMap.end()) {

+ 5 - 4
Core/Contents/Source/PolyMesh.cpp

@@ -230,16 +230,17 @@ namespace Polycode {
 	
 	void Mesh::createPlane(Number w, Number h) { 
 		Polygon *imagePolygon = new Polygon();
+		imagePolygon->addVertex(0,0,h,0,0);	
+		imagePolygon->addVertex(w,0,h, 1, 0);			
+		imagePolygon->addVertex(w,0,0, 1, 1);		
 		imagePolygon->addVertex(0,0,0,0,1);
-		imagePolygon->addVertex(w,0,0, 1, 1);
-		imagePolygon->addVertex(w,h,0, 1, 0);
-		imagePolygon->addVertex(0,h,0,0,0);
+
 		addPolygon(imagePolygon);
 		
 		for(int i=0; i < polygons.size(); i++) {
 			for(int j=0; j < polygons[i]->getVertexCount(); j++) {
 				polygons[i]->getVertex(j)->x = polygons[i]->getVertex(j)->x - (w/2.0f);
-				polygons[i]->getVertex(j)->y = polygons[i]->getVertex(j)->y - (h/2.0f);
+				polygons[i]->getVertex(j)->z = polygons[i]->getVertex(j)->z - (h/2.0f);
 			}
 		}
 

+ 3 - 0
Modules/Bindings/2DPhysics/API/Physics2D.lua

@@ -0,0 +1,3 @@
+require "Physics2D/PhysicsScreen"
+require "Physics2D/PhysicsJoint"
+require "Physics2D/PhysicsScreenEntity"

+ 28 - 0
Modules/Bindings/2DPhysics/API/Physics2D/PhysicsJoint.lua

@@ -0,0 +1,28 @@
+class "PhysicsJoint"
+
+
+
+
+
+
+
+function PhysicsJoint:PhysicsJoint(...)
+	for k,v in pairs(arg) do
+		if type(v) == "table" then
+			if v.__ptr ~= nil then
+				arg[k] = v.__ptr
+			end
+		end
+	end
+	if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
+		self.__ptr = Physics2D.PhysicsJoint(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+
+
+function PhysicsJoint:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Physics2D.delete_PhysicsJoint(self.__ptr)
+end

+ 217 - 0
Modules/Bindings/2DPhysics/API/Physics2D/PhysicsScreen.lua

@@ -0,0 +1,217 @@
+require "Polycode/Screen"
+
+class "PhysicsScreen" (Screen)
+
+
+
+
+
+
+
+function PhysicsScreen:PhysicsScreen(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "Screen" then
+			self.__ptr = arg[1].__ptr
+			return
+		end
+	end
+	for k,v in pairs(arg) do
+		if type(v) == "table" then
+			if v.__ptr ~= nil then
+				arg[k] = v.__ptr
+			end
+		end
+	end
+	if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
+		self.__ptr = Physics2D.PhysicsScreen(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function PhysicsScreen:Update()
+	local retVal =  Physics2D.PhysicsScreen_Update(self.__ptr)
+end
+
+function PhysicsScreen:addPhysicsChild(newEntity, entType, friction, density, restitution, isSensor, fixedRotation)
+	local retVal = Physics2D.PhysicsScreen_addPhysicsChild(self.__ptr, newEntity.__ptr, entType, friction, density, restitution, isSensor, fixedRotation)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = PhysicsScreenEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsScreen:removePhysicsChild(entityToRemove)
+	local retVal = Physics2D.PhysicsScreen_removePhysicsChild(self.__ptr, entityToRemove.__ptr)
+end
+
+function PhysicsScreen:addCollisionChild(newEntity, entType)
+	local retVal = Physics2D.PhysicsScreen_addCollisionChild(self.__ptr, newEntity.__ptr, entType)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = PhysicsScreenEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsScreen:destroyJoint(joint)
+	local retVal = Physics2D.PhysicsScreen_destroyJoint(self.__ptr, joint.__ptr)
+end
+
+function PhysicsScreen:createDistanceJoint(ent1, ent2, collideConnected)
+	local retVal = Physics2D.PhysicsScreen_createDistanceJoint(self.__ptr, ent1.__ptr, ent2.__ptr, collideConnected)
+end
+
+function PhysicsScreen:createPrismaticJoint(ent1, ent2, collideConnected)
+	local retVal = Physics2D.PhysicsScreen_createPrismaticJoint(self.__ptr, ent1.__ptr, ent2.__ptr, collideConnected)
+end
+
+function PhysicsScreen:createRevoluteJoint(ent1, ent2, ax, ay, enableLimit, lowerLimit, upperLimit, motorEnabled, motorSpeed, maxTorque)
+	local retVal = Physics2D.PhysicsScreen_createRevoluteJoint(self.__ptr, ent1.__ptr, ent2.__ptr, ax, ay, enableLimit, lowerLimit, upperLimit, motorEnabled, motorSpeed, maxTorque)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = PhysicsJoint("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsScreen:applyForce(ent, fx, fy)
+	local retVal = Physics2D.PhysicsScreen_applyForce(self.__ptr, ent.__ptr, fx, fy)
+end
+
+function PhysicsScreen:applyImpulse(ent, fx, fy)
+	local retVal = Physics2D.PhysicsScreen_applyImpulse(self.__ptr, ent.__ptr, fx, fy)
+end
+
+function PhysicsScreen:setGravity(newGravity)
+	local retVal = Physics2D.PhysicsScreen_setGravity(self.__ptr, newGravity.__ptr)
+end
+
+function PhysicsScreen:setTransform(ent, pos, angle)
+	local retVal = Physics2D.PhysicsScreen_setTransform(self.__ptr, ent.__ptr, pos.__ptr, angle)
+end
+
+function PhysicsScreen:getPhysicsEntityByShape(shape)
+	local retVal = Physics2D.PhysicsScreen_getPhysicsEntityByShape(self.__ptr, shape.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = PhysicsScreenEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsScreen:getPhysicsEntityByFixture(fixture)
+	local retVal = Physics2D.PhysicsScreen_getPhysicsEntityByFixture(self.__ptr, fixture.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = PhysicsScreenEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsScreen:setVelocity(ent, fx, fy)
+	local retVal = Physics2D.PhysicsScreen_setVelocity(self.__ptr, ent.__ptr, fx, fy)
+end
+
+function PhysicsScreen:setVelocityX(ent, fx)
+	local retVal = Physics2D.PhysicsScreen_setVelocityX(self.__ptr, ent.__ptr, fx)
+end
+
+function PhysicsScreen:setVelocityY(ent, fy)
+	local retVal = Physics2D.PhysicsScreen_setVelocityY(self.__ptr, ent.__ptr, fy)
+end
+
+function PhysicsScreen:setSpin(ent, spin)
+	local retVal = Physics2D.PhysicsScreen_setSpin(self.__ptr, ent.__ptr, spin)
+end
+
+function PhysicsScreen:getVelocity(ent)
+	local retVal = Physics2D.PhysicsScreen_getVelocity(self.__ptr, ent.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = Vector2("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsScreen:BeginContact(contact)
+	local retVal = Physics2D.PhysicsScreen_BeginContact(self.__ptr, contact.__ptr)
+end
+
+function PhysicsScreen:EndContact(contact)
+	local retVal = Physics2D.PhysicsScreen_EndContact(self.__ptr, contact.__ptr)
+end
+
+function PhysicsScreen:wakeUp(ent)
+	local retVal = Physics2D.PhysicsScreen_wakeUp(self.__ptr, ent.__ptr)
+end
+
+function PhysicsScreen:getEntityCollisionNormal(ent1, ent2)
+	local retVal = Physics2D.PhysicsScreen_getEntityCollisionNormal(self.__ptr, ent1.__ptr, ent2.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = Vector2("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsScreen:areEntitiesColliding(ent1, ent2)
+	local retVal = Physics2D.PhysicsScreen_areEntitiesColliding(self.__ptr, ent1.__ptr, ent2.__ptr)
+	return retVal
+end
+
+function PhysicsScreen:getEntityAtPosition(x, y)
+	local retVal = Physics2D.PhysicsScreen_getEntityAtPosition(self.__ptr, x, y)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = ScreenEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsScreen:testEntityAtPosition(ent, x, y)
+	local retVal = Physics2D.PhysicsScreen_testEntityAtPosition(self.__ptr, ent.__ptr, x, y)
+	return retVal
+end
+
+function PhysicsScreen:Shutdown()
+	local retVal =  Physics2D.PhysicsScreen_Shutdown(self.__ptr)
+end
+
+function PhysicsScreen:getPhysicsByScreenEntity(ent)
+	local retVal = Physics2D.PhysicsScreen_getPhysicsByScreenEntity(self.__ptr, ent.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = PhysicsScreenEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsScreen:destroyMouseJoint(mJoint)
+	local retVal = Physics2D.PhysicsScreen_destroyMouseJoint(self.__ptr, mJoint.__ptr)
+end
+
+
+
+function PhysicsScreen:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Physics2D.delete_PhysicsScreen(self.__ptr)
+end

+ 70 - 0
Modules/Bindings/2DPhysics/API/Physics2D/PhysicsScreenEntity.lua

@@ -0,0 +1,70 @@
+class "PhysicsScreenEntity"
+
+
+
+ENTITY_RECT = 1
+ENTITY_CIRCLE = 2
+ENTITY_STATICRECT = 3
+function PhysicsScreenEntity:__index__(name)
+	if name == "collisionOnly" then
+		return Physics2D.PhysicsScreenEntity_get_collisionOnly(self.__ptr)
+	end
+end
+
+
+function PhysicsScreenEntity:__set_callback(name,value)
+	if name == "collisionOnly" then
+		Physics2D.PhysicsScreenEntity_set_collisionOnly(self.__ptr, value)
+		return true
+	end
+	return false
+end
+
+
+function PhysicsScreenEntity:PhysicsScreenEntity(...)
+	for k,v in pairs(arg) do
+		if type(v) == "table" then
+			if v.__ptr ~= nil then
+				arg[k] = v.__ptr
+			end
+		end
+	end
+	if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
+		self.__ptr = Physics2D.PhysicsScreenEntity(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function PhysicsScreenEntity:getScreenEntity()
+	local retVal =  Physics2D.PhysicsScreenEntity_getScreenEntity(self.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = ScreenEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsScreenEntity:applyTorque(torque)
+	local retVal = Physics2D.PhysicsScreenEntity_applyTorque(self.__ptr, torque)
+end
+
+function PhysicsScreenEntity:applyForce(force)
+	local retVal = Physics2D.PhysicsScreenEntity_applyForce(self.__ptr, force.__ptr)
+end
+
+function PhysicsScreenEntity:setTransform(pos, angle)
+	local retVal = Physics2D.PhysicsScreenEntity_setTransform(self.__ptr, pos.__ptr, angle)
+end
+
+function PhysicsScreenEntity:Update()
+	local retVal =  Physics2D.PhysicsScreenEntity_Update(self.__ptr)
+end
+
+
+
+function PhysicsScreenEntity:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Physics2D.delete_PhysicsScreenEntity(self.__ptr)
+end

+ 10 - 0
Modules/Bindings/2DPhysics/Include/Physics2DLUA.h

@@ -0,0 +1,10 @@
+#pragma once
+#include <Polycode2DPhysics.h>
+#include "Physics2DLUAWrappers.h"
+extern "C" {
+#include <stdio.h>
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+int luaopen_Physics2D(lua_State *L);
+}

+ 484 - 0
Modules/Bindings/2DPhysics/Include/Physics2DLUAWrappers.h

@@ -0,0 +1,484 @@
+#pragma once
+
+#include <Polycode2DPhysics.h>
+
+extern "C" {
+
+#include <stdio.h>
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+
+static int Physics2D_PhysicsScreen(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TNUMBER);
+	Number worldScale = lua_tonumber(L, 1);
+	luaL_checktype(L, 2, LUA_TNUMBER);
+	Number freq = lua_tonumber(L, 2);
+	PhysicsScreen *inst = new PhysicsScreen(worldScale, freq);
+	lua_pushlightuserdata(L, (void*)inst);
+	return 1;
+}
+
+static int Physics2D_PhysicsScreen_Update(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	inst->Update();
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_addPhysicsChild(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * newEntity = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	int entType = lua_tointeger(L, 3);
+	Number friction;
+	if(lua_isnumber(L, 4)) {
+		friction = lua_tonumber(L, 4);
+	} else {
+		friction = 0.1;
+	}
+	Number density;
+	if(lua_isnumber(L, 5)) {
+		density = lua_tonumber(L, 5);
+	} else {
+		density = 1;
+	}
+	Number restitution;
+	if(lua_isnumber(L, 6)) {
+		restitution = lua_tonumber(L, 6);
+	} else {
+		restitution = 0;
+	}
+	bool isSensor;
+	if(lua_isboolean(L, 7)) {
+		isSensor = lua_toboolean(L, 7);
+	} else {
+		isSensor = false;
+	}
+	bool fixedRotation;
+	if(lua_isboolean(L, 8)) {
+		fixedRotation = lua_toboolean(L, 8);
+	} else {
+		fixedRotation = false;
+	}
+	lua_pushlightuserdata(L, (void*)inst->addPhysicsChild(newEntity, entType, friction, density, restitution, isSensor, fixedRotation));
+	return 1;
+}
+
+static int Physics2D_PhysicsScreen_removePhysicsChild(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	PhysicsScreenEntity * entityToRemove = (PhysicsScreenEntity *)lua_topointer(L, 2);
+	inst->removePhysicsChild(entityToRemove);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_addCollisionChild(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * newEntity = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	int entType = lua_tointeger(L, 3);
+	lua_pushlightuserdata(L, (void*)inst->addCollisionChild(newEntity, entType));
+	return 1;
+}
+
+static int Physics2D_PhysicsScreen_destroyJoint(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	PhysicsJoint * joint = (PhysicsJoint *)lua_topointer(L, 2);
+	inst->destroyJoint(joint);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_createDistanceJoint(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent1 = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent2 = (ScreenEntity *)lua_topointer(L, 3);
+	luaL_checktype(L, 4, LUA_TBOOLEAN);
+	bool collideConnected = lua_toboolean(L, 4);
+	inst->createDistanceJoint(ent1, ent2, collideConnected);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_createPrismaticJoint(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent1 = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent2 = (ScreenEntity *)lua_topointer(L, 3);
+	luaL_checktype(L, 4, LUA_TBOOLEAN);
+	bool collideConnected = lua_toboolean(L, 4);
+	inst->createPrismaticJoint(ent1, ent2, collideConnected);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_createRevoluteJoint(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent1 = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent2 = (ScreenEntity *)lua_topointer(L, 3);
+	luaL_checktype(L, 4, LUA_TNUMBER);
+	Number ax = lua_tonumber(L, 4);
+	luaL_checktype(L, 5, LUA_TNUMBER);
+	Number ay = lua_tonumber(L, 5);
+	luaL_checktype(L, 6, LUA_TBOOLEAN);
+	bool enableLimit = lua_toboolean(L, 6);
+	luaL_checktype(L, 7, LUA_TNUMBER);
+	Number lowerLimit = lua_tonumber(L, 7);
+	luaL_checktype(L, 8, LUA_TNUMBER);
+	Number upperLimit = lua_tonumber(L, 8);
+	luaL_checktype(L, 9, LUA_TBOOLEAN);
+	bool motorEnabled = lua_toboolean(L, 9);
+	luaL_checktype(L, 10, LUA_TNUMBER);
+	Number motorSpeed = lua_tonumber(L, 10);
+	luaL_checktype(L, 11, LUA_TNUMBER);
+	Number maxTorque = lua_tonumber(L, 11);
+	lua_pushlightuserdata(L, (void*)inst->createRevoluteJoint(ent1, ent2, ax, ay, enableLimit, lowerLimit, upperLimit, motorEnabled, motorSpeed, maxTorque));
+	return 1;
+}
+
+static int Physics2D_PhysicsScreen_applyForce(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number fx = lua_tonumber(L, 3);
+	luaL_checktype(L, 4, LUA_TNUMBER);
+	Number fy = lua_tonumber(L, 4);
+	inst->applyForce(ent, fx, fy);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_applyImpulse(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number fx = lua_tonumber(L, 3);
+	luaL_checktype(L, 4, LUA_TNUMBER);
+	Number fy = lua_tonumber(L, 4);
+	inst->applyImpulse(ent, fx, fy);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_setGravity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	Vector2 newGravity = *(Vector2*)lua_topointer(L, 2);
+	inst->setGravity(newGravity);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_setTransform(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	Vector2 pos = *(Vector2*)lua_topointer(L, 3);
+	luaL_checktype(L, 4, LUA_TNUMBER);
+	Number angle = lua_tonumber(L, 4);
+	inst->setTransform(ent, pos, angle);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_getPhysicsEntityByShape(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	b2Shape * shape = (b2Shape *)lua_topointer(L, 2);
+	lua_pushlightuserdata(L, (void*)inst->getPhysicsEntityByShape(shape));
+	return 1;
+}
+
+static int Physics2D_PhysicsScreen_getPhysicsEntityByFixture(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	b2Fixture * fixture = (b2Fixture *)lua_topointer(L, 2);
+	lua_pushlightuserdata(L, (void*)inst->getPhysicsEntityByFixture(fixture));
+	return 1;
+}
+
+static int Physics2D_PhysicsScreen_setVelocity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number fx = lua_tonumber(L, 3);
+	luaL_checktype(L, 4, LUA_TNUMBER);
+	Number fy = lua_tonumber(L, 4);
+	inst->setVelocity(ent, fx, fy);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_setVelocityX(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number fx = lua_tonumber(L, 3);
+	inst->setVelocityX(ent, fx);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_setVelocityY(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number fy = lua_tonumber(L, 3);
+	inst->setVelocityY(ent, fy);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_setSpin(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number spin = lua_tonumber(L, 3);
+	inst->setSpin(ent, spin);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_getVelocity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent = (ScreenEntity *)lua_topointer(L, 2);
+	Vector2 *retInst = new Vector2();
+	*retInst = inst->getVelocity(ent);
+	lua_pushlightuserdata(L, retInst);
+	return 1;
+}
+
+static int Physics2D_PhysicsScreen_BeginContact(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	b2Contact * contact = (b2Contact *)lua_topointer(L, 2);
+	inst->BeginContact(contact);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_EndContact(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	b2Contact * contact = (b2Contact *)lua_topointer(L, 2);
+	inst->EndContact(contact);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_wakeUp(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent = (ScreenEntity *)lua_topointer(L, 2);
+	inst->wakeUp(ent);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_getEntityCollisionNormal(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent1 = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent2 = (ScreenEntity *)lua_topointer(L, 3);
+	Vector2 *retInst = new Vector2();
+	*retInst = inst->getEntityCollisionNormal(ent1, ent2);
+	lua_pushlightuserdata(L, retInst);
+	return 1;
+}
+
+static int Physics2D_PhysicsScreen_areEntitiesColliding(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent1 = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent2 = (ScreenEntity *)lua_topointer(L, 3);
+	lua_pushboolean(L, inst->areEntitiesColliding(ent1, ent2));
+	return 1;
+}
+
+static int Physics2D_PhysicsScreen_getEntityAtPosition(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TNUMBER);
+	Number x = lua_tonumber(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number y = lua_tonumber(L, 3);
+	lua_pushlightuserdata(L, (void*)inst->getEntityAtPosition(x, y));
+	return 1;
+}
+
+static int Physics2D_PhysicsScreen_testEntityAtPosition(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent = (ScreenEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number x = lua_tonumber(L, 3);
+	luaL_checktype(L, 4, LUA_TNUMBER);
+	Number y = lua_tonumber(L, 4);
+	lua_pushboolean(L, inst->testEntityAtPosition(ent, x, y));
+	return 1;
+}
+
+static int Physics2D_PhysicsScreen_Shutdown(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	inst->Shutdown();
+	return 0;
+}
+
+static int Physics2D_PhysicsScreen_getPhysicsByScreenEntity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	ScreenEntity * ent = (ScreenEntity *)lua_topointer(L, 2);
+	lua_pushlightuserdata(L, (void*)inst->getPhysicsByScreenEntity(ent));
+	return 1;
+}
+
+static int Physics2D_PhysicsScreen_destroyMouseJoint(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	b2MouseJoint * mJoint = (b2MouseJoint *)lua_topointer(L, 2);
+	inst->destroyMouseJoint(mJoint);
+	return 0;
+}
+
+static int Physics2D_delete_PhysicsScreen(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreen *inst = (PhysicsScreen*)lua_topointer(L, 1);
+	delete inst;
+	return 0;
+}
+
+static int Physics2D_PhysicsJoint(lua_State *L) {
+	PhysicsJoint *inst = new PhysicsJoint();
+	lua_pushlightuserdata(L, (void*)inst);
+	return 1;
+}
+
+static int Physics2D_delete_PhysicsJoint(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsJoint *inst = (PhysicsJoint*)lua_topointer(L, 1);
+	delete inst;
+	return 0;
+}
+
+static int Physics2D_PhysicsScreenEntity_get_collisionOnly(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreenEntity *inst = (PhysicsScreenEntity*)lua_topointer(L, 1);
+	lua_pushboolean(L, inst->collisionOnly);
+	return 1;
+}
+
+static int Physics2D_PhysicsScreenEntity_set_collisionOnly(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreenEntity *inst = (PhysicsScreenEntity*)lua_topointer(L, 1);
+	bool param = lua_toboolean(L, 2);
+	inst->collisionOnly = param;
+	return 0;
+}
+
+static int Physics2D_PhysicsScreenEntity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	ScreenEntity * entity = (ScreenEntity *)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	b2World * world = (b2World *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number worldScale = lua_tonumber(L, 3);
+	luaL_checktype(L, 4, LUA_TNUMBER);
+	int entType = lua_tointeger(L, 4);
+	luaL_checktype(L, 5, LUA_TNUMBER);
+	Number friction = lua_tonumber(L, 5);
+	luaL_checktype(L, 6, LUA_TNUMBER);
+	Number density = lua_tonumber(L, 6);
+	luaL_checktype(L, 7, LUA_TNUMBER);
+	Number restitution = lua_tonumber(L, 7);
+	luaL_checktype(L, 8, LUA_TBOOLEAN);
+	bool isSensor = lua_toboolean(L, 8);
+	luaL_checktype(L, 9, LUA_TBOOLEAN);
+	bool fixedRotation = lua_toboolean(L, 9);
+	PhysicsScreenEntity *inst = new PhysicsScreenEntity(entity, world, worldScale, entType, friction, density, restitution, isSensor, fixedRotation);
+	lua_pushlightuserdata(L, (void*)inst);
+	return 1;
+}
+
+static int Physics2D_PhysicsScreenEntity_getScreenEntity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreenEntity *inst = (PhysicsScreenEntity*)lua_topointer(L, 1);
+	lua_pushlightuserdata(L, (void*)inst->getScreenEntity());
+	return 1;
+}
+
+static int Physics2D_PhysicsScreenEntity_applyTorque(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreenEntity *inst = (PhysicsScreenEntity*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TNUMBER);
+	Number torque = lua_tonumber(L, 2);
+	inst->applyTorque(torque);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreenEntity_applyForce(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreenEntity *inst = (PhysicsScreenEntity*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	Vector2 force = *(Vector2*)lua_topointer(L, 2);
+	inst->applyForce(force);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreenEntity_setTransform(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreenEntity *inst = (PhysicsScreenEntity*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	Vector2 pos = *(Vector2*)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number angle = lua_tonumber(L, 3);
+	inst->setTransform(pos, angle);
+	return 0;
+}
+
+static int Physics2D_PhysicsScreenEntity_Update(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreenEntity *inst = (PhysicsScreenEntity*)lua_topointer(L, 1);
+	inst->Update();
+	return 0;
+}
+
+static int Physics2D_delete_PhysicsScreenEntity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScreenEntity *inst = (PhysicsScreenEntity*)lua_topointer(L, 1);
+	delete inst;
+	return 0;
+}
+
+}

+ 53 - 0
Modules/Bindings/2DPhysics/Source/Physics2DLUA.cpp

@@ -0,0 +1,53 @@
+#include "Physics2DLUA.h"
+#include "Physics2DLUAWrappers.h"
+
+int luaopen_Physics2D(lua_State *L) {
+CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
+CoreServices::setInstance(inst);
+	static const struct luaL_reg physics2dLib [] = {		{"PhysicsScreen", Physics2D_PhysicsScreen},
+		{"PhysicsScreen_Update", Physics2D_PhysicsScreen_Update},
+		{"PhysicsScreen_addPhysicsChild", Physics2D_PhysicsScreen_addPhysicsChild},
+		{"PhysicsScreen_removePhysicsChild", Physics2D_PhysicsScreen_removePhysicsChild},
+		{"PhysicsScreen_addCollisionChild", Physics2D_PhysicsScreen_addCollisionChild},
+		{"PhysicsScreen_destroyJoint", Physics2D_PhysicsScreen_destroyJoint},
+		{"PhysicsScreen_createDistanceJoint", Physics2D_PhysicsScreen_createDistanceJoint},
+		{"PhysicsScreen_createPrismaticJoint", Physics2D_PhysicsScreen_createPrismaticJoint},
+		{"PhysicsScreen_createRevoluteJoint", Physics2D_PhysicsScreen_createRevoluteJoint},
+		{"PhysicsScreen_applyForce", Physics2D_PhysicsScreen_applyForce},
+		{"PhysicsScreen_applyImpulse", Physics2D_PhysicsScreen_applyImpulse},
+		{"PhysicsScreen_setGravity", Physics2D_PhysicsScreen_setGravity},
+		{"PhysicsScreen_setTransform", Physics2D_PhysicsScreen_setTransform},
+		{"PhysicsScreen_getPhysicsEntityByShape", Physics2D_PhysicsScreen_getPhysicsEntityByShape},
+		{"PhysicsScreen_getPhysicsEntityByFixture", Physics2D_PhysicsScreen_getPhysicsEntityByFixture},
+		{"PhysicsScreen_setVelocity", Physics2D_PhysicsScreen_setVelocity},
+		{"PhysicsScreen_setVelocityX", Physics2D_PhysicsScreen_setVelocityX},
+		{"PhysicsScreen_setVelocityY", Physics2D_PhysicsScreen_setVelocityY},
+		{"PhysicsScreen_setSpin", Physics2D_PhysicsScreen_setSpin},
+		{"PhysicsScreen_getVelocity", Physics2D_PhysicsScreen_getVelocity},
+		{"PhysicsScreen_BeginContact", Physics2D_PhysicsScreen_BeginContact},
+		{"PhysicsScreen_EndContact", Physics2D_PhysicsScreen_EndContact},
+		{"PhysicsScreen_wakeUp", Physics2D_PhysicsScreen_wakeUp},
+		{"PhysicsScreen_getEntityCollisionNormal", Physics2D_PhysicsScreen_getEntityCollisionNormal},
+		{"PhysicsScreen_areEntitiesColliding", Physics2D_PhysicsScreen_areEntitiesColliding},
+		{"PhysicsScreen_getEntityAtPosition", Physics2D_PhysicsScreen_getEntityAtPosition},
+		{"PhysicsScreen_testEntityAtPosition", Physics2D_PhysicsScreen_testEntityAtPosition},
+		{"PhysicsScreen_Shutdown", Physics2D_PhysicsScreen_Shutdown},
+		{"PhysicsScreen_getPhysicsByScreenEntity", Physics2D_PhysicsScreen_getPhysicsByScreenEntity},
+		{"PhysicsScreen_destroyMouseJoint", Physics2D_PhysicsScreen_destroyMouseJoint},
+		{"delete_PhysicsScreen", Physics2D_delete_PhysicsScreen},
+		{"PhysicsJoint", Physics2D_PhysicsJoint},
+		{"delete_PhysicsJoint", Physics2D_delete_PhysicsJoint},
+		{"PhysicsScreenEntity_get_collisionOnly", Physics2D_PhysicsScreenEntity_get_collisionOnly},
+		{"PhysicsScreenEntity_set_collisionOnly", Physics2D_PhysicsScreenEntity_set_collisionOnly},
+		{"PhysicsScreenEntity", Physics2D_PhysicsScreenEntity},
+		{"PhysicsScreenEntity_getScreenEntity", Physics2D_PhysicsScreenEntity_getScreenEntity},
+		{"PhysicsScreenEntity_applyTorque", Physics2D_PhysicsScreenEntity_applyTorque},
+		{"PhysicsScreenEntity_applyForce", Physics2D_PhysicsScreenEntity_applyForce},
+		{"PhysicsScreenEntity_setTransform", Physics2D_PhysicsScreenEntity_setTransform},
+		{"PhysicsScreenEntity_Update", Physics2D_PhysicsScreenEntity_Update},
+		{"delete_PhysicsScreenEntity", Physics2D_delete_PhysicsScreenEntity},
+		{NULL, NULL}
+	};
+	luaL_openlib(L, "Physics2D", physics2dLib, 0);
+	return 1;
+}

+ 5 - 0
Modules/Bindings/3DPhysics/API/Physics3D.lua

@@ -0,0 +1,5 @@
+require "Physics3D/CollisionScene"
+require "Physics3D/CollisionSceneEntity"
+require "Physics3D/PhysicsScene"
+require "Physics3D/PhysicsSceneEntity"
+require "Physics3D/PhysicsCharacter"

+ 189 - 0
Modules/Bindings/3DPhysics/API/Physics3D/CollisionScene.lua

@@ -0,0 +1,189 @@
+require "Polycode/Scene"
+
+class "CollisionScene" (Scene)
+
+
+
+
+
+
+
+function CollisionScene:CollisionScene(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "Scene" then
+			self.__ptr = arg[1].__ptr
+			return
+		end
+	end
+	for k,v in pairs(arg) do
+		if type(v) == "table" then
+			if v.__ptr ~= nil then
+				arg[k] = v.__ptr
+			end
+		end
+	end
+	if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
+		self.__ptr = Physics3D.CollisionScene(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function CollisionScene:initCollisionScene()
+	local retVal =  Physics3D.CollisionScene_initCollisionScene(self.__ptr)
+end
+
+function CollisionScene:Update()
+	local retVal =  Physics3D.CollisionScene_Update(self.__ptr)
+end
+
+function CollisionScene:enableCollision(entity, val)
+	local retVal = Physics3D.CollisionScene_enableCollision(self.__ptr, entity.__ptr, val)
+end
+
+function CollisionScene:getCollisionEntityByObject(collisionObject)
+	local retVal = Physics3D.CollisionScene_getCollisionEntityByObject(self.__ptr, collisionObject.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = CollisionSceneEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionScene:getFirstEntityInRay(origin, dest)
+	local retVal = Physics3D.CollisionScene_getFirstEntityInRay(self.__ptr, origin.__ptr, dest.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = RayTestResult("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionScene:getCollisionByScreenEntity(ent)
+	local retVal = Physics3D.CollisionScene_getCollisionByScreenEntity(self.__ptr, ent.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = CollisionSceneEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionScene:testCollision(ent1, ent2)
+	local retVal = Physics3D.CollisionScene_testCollision(self.__ptr, ent1.__ptr, ent2.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = CollisionResult("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionScene:testCollisionOnCollisionChild(cEnt1, cEnt2)
+	local retVal = Physics3D.CollisionScene_testCollisionOnCollisionChild(self.__ptr, cEnt1.__ptr, cEnt2.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = CollisionResult("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionScene:testCollisionOnCollisionChild_Convex(cEnt1, cEnt2)
+	local retVal = Physics3D.CollisionScene_testCollisionOnCollisionChild_Convex(self.__ptr, cEnt1.__ptr, cEnt2.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = CollisionResult("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionScene:testCollisionOnCollisionChild_RayTest(cEnt1, cEnt2)
+	local retVal = Physics3D.CollisionScene_testCollisionOnCollisionChild_RayTest(self.__ptr, cEnt1.__ptr, cEnt2.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = CollisionResult("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionScene:getCollisionNormalFromCollisionEnts(cEnt1, cEnt2)
+	local retVal = Physics3D.CollisionScene_getCollisionNormalFromCollisionEnts(self.__ptr, cEnt1.__ptr, cEnt2.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionScene:getCollisionNormal(ent1, ent2)
+	local retVal = Physics3D.CollisionScene_getCollisionNormal(self.__ptr, ent1.__ptr, ent2.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = Vector3("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionScene:applyVelocity(entity, x, y, z)
+	local retVal = Physics3D.CollisionScene_applyVelocity(self.__ptr, entity.__ptr, x, y, z)
+end
+
+function CollisionScene:loadCollisionChild(entity, autoCollide, type)
+	local retVal = Physics3D.CollisionScene_loadCollisionChild(self.__ptr, entity.__ptr, autoCollide, type)
+end
+
+function CollisionScene:enableGravity(entity)
+	local retVal = Physics3D.CollisionScene_enableGravity(self.__ptr, entity.__ptr)
+end
+
+function CollisionScene:stopTrackingCollision(entity)
+	local retVal = Physics3D.CollisionScene_stopTrackingCollision(self.__ptr, entity.__ptr)
+end
+
+function CollisionScene:addCollisionChild(newEntity, autoCollide, type, group)
+	local retVal = Physics3D.CollisionScene_addCollisionChild(self.__ptr, newEntity.__ptr, autoCollide, type, group)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = CollisionSceneEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionScene:trackCollision(newEntity, autoCollide, type, group)
+	local retVal = Physics3D.CollisionScene_trackCollision(self.__ptr, newEntity.__ptr, autoCollide, type, group)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = CollisionSceneEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionScene:adjustForCollision(collisionEntity)
+	local retVal = Physics3D.CollisionScene_adjustForCollision(self.__ptr, collisionEntity.__ptr)
+end
+
+
+
+function CollisionScene:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Physics3D.delete_CollisionScene(self.__ptr)
+end

+ 104 - 0
Modules/Bindings/3DPhysics/API/Physics3D/CollisionSceneEntity.lua

@@ -0,0 +1,104 @@
+class "CollisionSceneEntity"
+
+
+
+SHAPE_BOX = 0
+SHAPE_TERRAIN = 1
+SHAPE_SPHERE = 2
+SHAPE_MESH = 3
+CHARACTER_CONTROLLER = 4
+SHAPE_CAPSULE = 5
+SHAPE_PLANE = 6
+function CollisionSceneEntity:__index__(name)
+	if name == "gravityEnabled" then
+		return Physics3D.CollisionSceneEntity_get_gravityEnabled(self.__ptr)
+	elseif name == "autoCollide" then
+		return Physics3D.CollisionSceneEntity_get_autoCollide(self.__ptr)
+	elseif name == "gravityStrength" then
+		return Physics3D.CollisionSceneEntity_get_gravityStrength(self.__ptr)
+	elseif name == "enabled" then
+		return Physics3D.CollisionSceneEntity_get_enabled(self.__ptr)
+	end
+end
+
+
+function CollisionSceneEntity:__set_callback(name,value)
+	if name == "gravityEnabled" then
+		Physics3D.CollisionSceneEntity_set_gravityEnabled(self.__ptr, value)
+		return true
+	elseif name == "autoCollide" then
+		Physics3D.CollisionSceneEntity_set_autoCollide(self.__ptr, value)
+		return true
+	elseif name == "gravityStrength" then
+		Physics3D.CollisionSceneEntity_set_gravityStrength(self.__ptr, value)
+		return true
+	elseif name == "enabled" then
+		Physics3D.CollisionSceneEntity_set_enabled(self.__ptr, value)
+		return true
+	end
+	return false
+end
+
+
+function CollisionSceneEntity:CollisionSceneEntity(...)
+	for k,v in pairs(arg) do
+		if type(v) == "table" then
+			if v.__ptr ~= nil then
+				arg[k] = v.__ptr
+			end
+		end
+	end
+	if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
+		self.__ptr = Physics3D.CollisionSceneEntity(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function CollisionSceneEntity:getSceneEntity()
+	local retVal =  Physics3D.CollisionSceneEntity_getSceneEntity(self.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = SceneEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionSceneEntity:Update()
+	local retVal =  Physics3D.CollisionSceneEntity_Update(self.__ptr)
+end
+
+function CollisionSceneEntity:getType()
+	local retVal =  Physics3D.CollisionSceneEntity_getType(self.__ptr)
+	return retVal
+end
+
+function CollisionSceneEntity:getConvexShape()
+	local retVal =  Physics3D.CollisionSceneEntity_getConvexShape(self.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = btConvexShape("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function CollisionSceneEntity:createCollisionShape(entity, type)
+	local retVal = Physics3D.CollisionSceneEntity_createCollisionShape(self.__ptr, entity.__ptr, type)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = btCollisionShape("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+
+
+function CollisionSceneEntity:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Physics3D.delete_CollisionSceneEntity(self.__ptr)
+end

+ 48 - 0
Modules/Bindings/3DPhysics/API/Physics3D/PhysicsCharacter.lua

@@ -0,0 +1,48 @@
+require "Physics3D/PhysicsSceneEntity"
+
+class "PhysicsCharacter" (PhysicsSceneEntity)
+
+
+
+
+
+
+
+function PhysicsCharacter:PhysicsCharacter(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "PhysicsSceneEntity" then
+			self.__ptr = arg[1].__ptr
+			return
+		end
+	end
+	for k,v in pairs(arg) do
+		if type(v) == "table" then
+			if v.__ptr ~= nil then
+				arg[k] = v.__ptr
+			end
+		end
+	end
+	if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
+		self.__ptr = Physics3D.PhysicsCharacter(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function PhysicsCharacter:setWalkDirection(direction)
+	local retVal = Physics3D.PhysicsCharacter_setWalkDirection(self.__ptr, direction.__ptr)
+end
+
+function PhysicsCharacter:jump()
+	local retVal =  Physics3D.PhysicsCharacter_jump(self.__ptr)
+end
+
+function PhysicsCharacter:Update()
+	local retVal =  Physics3D.PhysicsCharacter_Update(self.__ptr)
+end
+
+
+
+function PhysicsCharacter:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Physics3D.delete_PhysicsCharacter(self.__ptr)
+end

+ 73 - 0
Modules/Bindings/3DPhysics/API/Physics3D/PhysicsScene.lua

@@ -0,0 +1,73 @@
+require "Physics3D/CollisionScene"
+
+class "PhysicsScene" (CollisionScene)
+
+
+
+
+
+
+
+function PhysicsScene:PhysicsScene(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "CollisionScene" then
+			self.__ptr = arg[1].__ptr
+			return
+		end
+	end
+	for k,v in pairs(arg) do
+		if type(v) == "table" then
+			if v.__ptr ~= nil then
+				arg[k] = v.__ptr
+			end
+		end
+	end
+	if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
+		self.__ptr = Physics3D.PhysicsScene(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function PhysicsScene:Update()
+	local retVal =  Physics3D.PhysicsScene_Update(self.__ptr)
+end
+
+function PhysicsScene:addPhysicsChild(newEntity, type, mass, friction, restitution, group)
+	local retVal = Physics3D.PhysicsScene_addPhysicsChild(self.__ptr, newEntity.__ptr, type, mass, friction, restitution, group)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = PhysicsSceneEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsScene:trackPhysicsChild(newEntity, type, mass, friction, restitution, group)
+	local retVal = Physics3D.PhysicsScene_trackPhysicsChild(self.__ptr, newEntity.__ptr, type, mass, friction, restitution, group)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = PhysicsSceneEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsScene:addCharacterChild(newEntity, mass, friction, stepSize, group)
+	local retVal = Physics3D.PhysicsScene_addCharacterChild(self.__ptr, newEntity.__ptr, mass, friction, stepSize, group)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = PhysicsCharacter("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+
+
+function PhysicsScene:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Physics3D.delete_PhysicsScene(self.__ptr)
+end

+ 79 - 0
Modules/Bindings/3DPhysics/API/Physics3D/PhysicsSceneEntity.lua

@@ -0,0 +1,79 @@
+require "Physics3D/CollisionSceneEntity"
+
+class "PhysicsSceneEntity" (CollisionSceneEntity)
+
+
+
+SHAPE_BOX = 0
+SHAPE_TERRAIN = 1
+SHAPE_SPHERE = 2
+SHAPE_MESH = 3
+CHARACTER_CONTROLLER = 4
+SHAPE_CAPSULE = 5
+SHAPE_PLANE = 6
+function PhysicsSceneEntity:__index__(name)
+	if name == "enabled" then
+		return Physics3D.PhysicsSceneEntity_get_enabled(self.__ptr)
+	end
+end
+
+
+function PhysicsSceneEntity:__set_callback(name,value)
+	if name == "enabled" then
+		Physics3D.PhysicsSceneEntity_set_enabled(self.__ptr, value)
+		return true
+	end
+	return false
+end
+
+
+function PhysicsSceneEntity:PhysicsSceneEntity(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "CollisionSceneEntity" then
+			self.__ptr = arg[1].__ptr
+			return
+		end
+	end
+	for k,v in pairs(arg) do
+		if type(v) == "table" then
+			if v.__ptr ~= nil then
+				arg[k] = v.__ptr
+			end
+		end
+	end
+	if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
+		self.__ptr = Physics3D.PhysicsSceneEntity(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function PhysicsSceneEntity:getSceneEntity()
+	local retVal =  Physics3D.PhysicsSceneEntity_getSceneEntity(self.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = SceneEntity("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function PhysicsSceneEntity:Update()
+	local retVal =  Physics3D.PhysicsSceneEntity_Update(self.__ptr)
+end
+
+function PhysicsSceneEntity:setFriction(friction)
+	local retVal = Physics3D.PhysicsSceneEntity_setFriction(self.__ptr, friction)
+end
+
+function PhysicsSceneEntity:getType()
+	local retVal =  Physics3D.PhysicsSceneEntity_getType(self.__ptr)
+	return retVal
+end
+
+
+
+function PhysicsSceneEntity:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Physics3D.delete_PhysicsSceneEntity(self.__ptr)
+end

+ 10 - 0
Modules/Bindings/3DPhysics/Include/Physics3DLUA.h

@@ -0,0 +1,10 @@
+#pragma once
+#include <Polycode3DPhysics.h>
+#include "Physics3DLUAWrappers.h"
+extern "C" {
+#include <stdio.h>
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+int luaopen_Physics3D(lua_State *L);
+}

+ 621 - 0
Modules/Bindings/3DPhysics/Include/Physics3DLUAWrappers.h

@@ -0,0 +1,621 @@
+#pragma once
+
+#include <Polycode3DPhysics.h>
+
+extern "C" {
+
+#include <stdio.h>
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+
+static int Physics3D_CollisionScene(lua_State *L) {
+	CollisionScene *inst = new CollisionScene();
+	lua_pushlightuserdata(L, (void*)inst);
+	return 1;
+}
+
+static int Physics3D_CollisionScene_initCollisionScene(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	inst->initCollisionScene();
+	return 0;
+}
+
+static int Physics3D_CollisionScene_Update(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	inst->Update();
+	return 0;
+}
+
+static int Physics3D_CollisionScene_enableCollision(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * entity = (SceneEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TBOOLEAN);
+	bool val = lua_toboolean(L, 3);
+	inst->enableCollision(entity, val);
+	return 0;
+}
+
+static int Physics3D_CollisionScene_getCollisionEntityByObject(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	btCollisionObject * collisionObject = (btCollisionObject *)lua_topointer(L, 2);
+	lua_pushlightuserdata(L, (void*)inst->getCollisionEntityByObject(collisionObject));
+	return 1;
+}
+
+static int Physics3D_CollisionScene_getFirstEntityInRay(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	const Vector3 & origin = *( Vector3 *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	const Vector3 & dest = *( Vector3 *)lua_topointer(L, 3);
+	RayTestResult *retInst = new RayTestResult();
+	*retInst = inst->getFirstEntityInRay(origin, dest);
+	lua_pushlightuserdata(L, retInst);
+	return 1;
+}
+
+static int Physics3D_CollisionScene_getCollisionByScreenEntity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * ent = (SceneEntity *)lua_topointer(L, 2);
+	lua_pushlightuserdata(L, (void*)inst->getCollisionByScreenEntity(ent));
+	return 1;
+}
+
+static int Physics3D_CollisionScene_testCollision(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * ent1 = (SceneEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	SceneEntity * ent2 = (SceneEntity *)lua_topointer(L, 3);
+	CollisionResult *retInst = new CollisionResult();
+	*retInst = inst->testCollision(ent1, ent2);
+	lua_pushlightuserdata(L, retInst);
+	return 1;
+}
+
+static int Physics3D_CollisionScene_testCollisionOnCollisionChild(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity * cEnt1 = (CollisionSceneEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity * cEnt2 = (CollisionSceneEntity *)lua_topointer(L, 3);
+	CollisionResult *retInst = new CollisionResult();
+	*retInst = inst->testCollisionOnCollisionChild(cEnt1, cEnt2);
+	lua_pushlightuserdata(L, retInst);
+	return 1;
+}
+
+static int Physics3D_CollisionScene_testCollisionOnCollisionChild_Convex(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity * cEnt1 = (CollisionSceneEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity * cEnt2 = (CollisionSceneEntity *)lua_topointer(L, 3);
+	CollisionResult *retInst = new CollisionResult();
+	*retInst = inst->testCollisionOnCollisionChild_Convex(cEnt1, cEnt2);
+	lua_pushlightuserdata(L, retInst);
+	return 1;
+}
+
+static int Physics3D_CollisionScene_testCollisionOnCollisionChild_RayTest(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity * cEnt1 = (CollisionSceneEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity * cEnt2 = (CollisionSceneEntity *)lua_topointer(L, 3);
+	CollisionResult *retInst = new CollisionResult();
+	*retInst = inst->testCollisionOnCollisionChild_RayTest(cEnt1, cEnt2);
+	lua_pushlightuserdata(L, retInst);
+	return 1;
+}
+
+static int Physics3D_CollisionScene_getCollisionNormalFromCollisionEnts(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity * cEnt1 = (CollisionSceneEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity * cEnt2 = (CollisionSceneEntity *)lua_topointer(L, 3);
+	Vector3 *retInst = new Vector3();
+	*retInst = inst->getCollisionNormalFromCollisionEnts(cEnt1, cEnt2);
+	lua_pushlightuserdata(L, retInst);
+	return 1;
+}
+
+static int Physics3D_CollisionScene_getCollisionNormal(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * ent1 = (SceneEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
+	SceneEntity * ent2 = (SceneEntity *)lua_topointer(L, 3);
+	Vector3 *retInst = new Vector3();
+	*retInst = inst->getCollisionNormal(ent1, ent2);
+	lua_pushlightuserdata(L, retInst);
+	return 1;
+}
+
+static int Physics3D_CollisionScene_applyVelocity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * entity = (SceneEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number x = lua_tonumber(L, 3);
+	luaL_checktype(L, 4, LUA_TNUMBER);
+	Number y = lua_tonumber(L, 4);
+	luaL_checktype(L, 5, LUA_TNUMBER);
+	Number z = lua_tonumber(L, 5);
+	inst->applyVelocity(entity, x, y, z);
+	return 0;
+}
+
+static int Physics3D_CollisionScene_loadCollisionChild(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * entity = (SceneEntity *)lua_topointer(L, 2);
+	bool autoCollide;
+	if(lua_isboolean(L, 3)) {
+		autoCollide = lua_toboolean(L, 3);
+	} else {
+		autoCollide = false;
+	}
+	int type;
+	if(lua_isnumber(L, 4)) {
+		type = lua_tointeger(L, 4);
+	} else {
+		type = 0;
+	}
+	inst->loadCollisionChild(entity, autoCollide, type);
+	return 0;
+}
+
+static int Physics3D_CollisionScene_enableGravity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * entity = (SceneEntity *)lua_topointer(L, 2);
+	inst->enableGravity(entity);
+	return 0;
+}
+
+static int Physics3D_CollisionScene_stopTrackingCollision(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * entity = (SceneEntity *)lua_topointer(L, 2);
+	inst->stopTrackingCollision(entity);
+	return 0;
+}
+
+static int Physics3D_CollisionScene_addCollisionChild(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * newEntity = (SceneEntity *)lua_topointer(L, 2);
+	bool autoCollide;
+	if(lua_isboolean(L, 3)) {
+		autoCollide = lua_toboolean(L, 3);
+	} else {
+		autoCollide = false;
+	}
+	int type;
+	if(lua_isnumber(L, 4)) {
+		type = lua_tointeger(L, 4);
+	} else {
+		type = 0;
+	}
+	int group;
+	if(lua_isnumber(L, 5)) {
+		group = lua_tointeger(L, 5);
+	} else {
+		group = 0;
+	}
+	lua_pushlightuserdata(L, (void*)inst->addCollisionChild(newEntity, autoCollide, type, group));
+	return 1;
+}
+
+static int Physics3D_CollisionScene_trackCollision(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * newEntity = (SceneEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TBOOLEAN);
+	bool autoCollide = lua_toboolean(L, 3);
+	int type;
+	if(lua_isnumber(L, 4)) {
+		type = lua_tointeger(L, 4);
+	} else {
+		type = 0;
+	}
+	int group;
+	if(lua_isnumber(L, 5)) {
+		group = lua_tointeger(L, 5);
+	} else {
+		group = 0;
+	}
+	lua_pushlightuserdata(L, (void*)inst->trackCollision(newEntity, autoCollide, type, group));
+	return 1;
+}
+
+static int Physics3D_CollisionScene_adjustForCollision(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity * collisionEntity = (CollisionSceneEntity *)lua_topointer(L, 2);
+	inst->adjustForCollision(collisionEntity);
+	return 0;
+}
+
+static int Physics3D_delete_CollisionScene(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionScene *inst = (CollisionScene*)lua_topointer(L, 1);
+	delete inst;
+	return 0;
+}
+
+static int Physics3D_CollisionSceneEntity_get_gravityEnabled(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	lua_pushboolean(L, inst->gravityEnabled);
+	return 1;
+}
+
+static int Physics3D_CollisionSceneEntity_get_autoCollide(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	lua_pushboolean(L, inst->autoCollide);
+	return 1;
+}
+
+static int Physics3D_CollisionSceneEntity_get_gravityStrength(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	lua_pushnumber(L, inst->gravityStrength);
+	return 1;
+}
+
+static int Physics3D_CollisionSceneEntity_get_enabled(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	lua_pushboolean(L, inst->enabled);
+	return 1;
+}
+
+static int Physics3D_CollisionSceneEntity_set_gravityEnabled(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	bool param = lua_toboolean(L, 2);
+	inst->gravityEnabled = param;
+	return 0;
+}
+
+static int Physics3D_CollisionSceneEntity_set_autoCollide(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	bool param = lua_toboolean(L, 2);
+	inst->autoCollide = param;
+	return 0;
+}
+
+static int Physics3D_CollisionSceneEntity_set_gravityStrength(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	Number param = lua_tonumber(L, 2);
+	inst->gravityStrength = param;
+	return 0;
+}
+
+static int Physics3D_CollisionSceneEntity_set_enabled(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	bool param = lua_toboolean(L, 2);
+	inst->enabled = param;
+	return 0;
+}
+
+static int Physics3D_CollisionSceneEntity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	SceneEntity * entity = (SceneEntity *)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TBOOLEAN);
+	bool autoCollide = lua_toboolean(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	int type = lua_tointeger(L, 3);
+	CollisionSceneEntity *inst = new CollisionSceneEntity(entity, autoCollide, type);
+	lua_pushlightuserdata(L, (void*)inst);
+	return 1;
+}
+
+static int Physics3D_CollisionSceneEntity_getSceneEntity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	lua_pushlightuserdata(L, (void*)inst->getSceneEntity());
+	return 1;
+}
+
+static int Physics3D_CollisionSceneEntity_Update(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	inst->Update();
+	return 0;
+}
+
+static int Physics3D_CollisionSceneEntity_getType(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	lua_pushinteger(L, inst->getType());
+	return 1;
+}
+
+static int Physics3D_CollisionSceneEntity_getConvexShape(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	lua_pushlightuserdata(L, (void*)inst->getConvexShape());
+	return 1;
+}
+
+static int Physics3D_CollisionSceneEntity_createCollisionShape(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * entity = (SceneEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	int type = lua_tointeger(L, 3);
+	lua_pushlightuserdata(L, (void*)inst->createCollisionShape(entity, type));
+	return 1;
+}
+
+static int Physics3D_delete_CollisionSceneEntity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	CollisionSceneEntity *inst = (CollisionSceneEntity*)lua_topointer(L, 1);
+	delete inst;
+	return 0;
+}
+
+static int Physics3D_PhysicsScene(lua_State *L) {
+	PhysicsScene *inst = new PhysicsScene();
+	lua_pushlightuserdata(L, (void*)inst);
+	return 1;
+}
+
+static int Physics3D_PhysicsScene_Update(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScene *inst = (PhysicsScene*)lua_topointer(L, 1);
+	inst->Update();
+	return 0;
+}
+
+static int Physics3D_PhysicsScene_addPhysicsChild(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScene *inst = (PhysicsScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * newEntity = (SceneEntity *)lua_topointer(L, 2);
+	int type;
+	if(lua_isnumber(L, 3)) {
+		type = lua_tointeger(L, 3);
+	} else {
+		type = 0;
+	}
+	Number mass;
+	if(lua_isnumber(L, 4)) {
+		mass = lua_tonumber(L, 4);
+	} else {
+		mass = 0.0f;
+	}
+	Number friction;
+	if(lua_isnumber(L, 5)) {
+		friction = lua_tonumber(L, 5);
+	} else {
+		friction = 1;
+	}
+	Number restitution;
+	if(lua_isnumber(L, 6)) {
+		restitution = lua_tonumber(L, 6);
+	} else {
+		restitution = 0;
+	}
+	int group;
+	if(lua_isnumber(L, 7)) {
+		group = lua_tointeger(L, 7);
+	} else {
+		group = 1;
+	}
+	lua_pushlightuserdata(L, (void*)inst->addPhysicsChild(newEntity, type, mass, friction, restitution, group));
+	return 1;
+}
+
+static int Physics3D_PhysicsScene_trackPhysicsChild(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScene *inst = (PhysicsScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * newEntity = (SceneEntity *)lua_topointer(L, 2);
+	int type;
+	if(lua_isnumber(L, 3)) {
+		type = lua_tointeger(L, 3);
+	} else {
+		type = 0;
+	}
+	Number mass;
+	if(lua_isnumber(L, 4)) {
+		mass = lua_tonumber(L, 4);
+	} else {
+		mass = 0.0f;
+	}
+	Number friction;
+	if(lua_isnumber(L, 5)) {
+		friction = lua_tonumber(L, 5);
+	} else {
+		friction = 1;
+	}
+	Number restitution;
+	if(lua_isnumber(L, 6)) {
+		restitution = lua_tonumber(L, 6);
+	} else {
+		restitution = 0;
+	}
+	int group;
+	if(lua_isnumber(L, 7)) {
+		group = lua_tointeger(L, 7);
+	} else {
+		group = 1;
+	}
+	lua_pushlightuserdata(L, (void*)inst->trackPhysicsChild(newEntity, type, mass, friction, restitution, group));
+	return 1;
+}
+
+static int Physics3D_PhysicsScene_addCharacterChild(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScene *inst = (PhysicsScene*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	SceneEntity * newEntity = (SceneEntity *)lua_topointer(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number mass = lua_tonumber(L, 3);
+	luaL_checktype(L, 4, LUA_TNUMBER);
+	Number friction = lua_tonumber(L, 4);
+	luaL_checktype(L, 5, LUA_TNUMBER);
+	Number stepSize = lua_tonumber(L, 5);
+	int group;
+	if(lua_isnumber(L, 6)) {
+		group = lua_tointeger(L, 6);
+	} else {
+		group = 1;
+	}
+	lua_pushlightuserdata(L, (void*)inst->addCharacterChild(newEntity, mass, friction, stepSize, group));
+	return 1;
+}
+
+static int Physics3D_delete_PhysicsScene(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsScene *inst = (PhysicsScene*)lua_topointer(L, 1);
+	delete inst;
+	return 0;
+}
+
+static int Physics3D_PhysicsSceneEntity_get_enabled(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsSceneEntity *inst = (PhysicsSceneEntity*)lua_topointer(L, 1);
+	lua_pushboolean(L, inst->enabled);
+	return 1;
+}
+
+static int Physics3D_PhysicsSceneEntity_set_enabled(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsSceneEntity *inst = (PhysicsSceneEntity*)lua_topointer(L, 1);
+	bool param = lua_toboolean(L, 2);
+	inst->enabled = param;
+	return 0;
+}
+
+static int Physics3D_PhysicsSceneEntity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	SceneEntity * entity = (SceneEntity *)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TNUMBER);
+	int type = lua_tointeger(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number mass = lua_tonumber(L, 3);
+	luaL_checktype(L, 4, LUA_TNUMBER);
+	Number friction = lua_tonumber(L, 4);
+	luaL_checktype(L, 5, LUA_TNUMBER);
+	Number restitution = lua_tonumber(L, 5);
+	PhysicsSceneEntity *inst = new PhysicsSceneEntity(entity, type, mass, friction, restitution);
+	lua_pushlightuserdata(L, (void*)inst);
+	return 1;
+}
+
+static int Physics3D_PhysicsSceneEntity_getSceneEntity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsSceneEntity *inst = (PhysicsSceneEntity*)lua_topointer(L, 1);
+	lua_pushlightuserdata(L, (void*)inst->getSceneEntity());
+	return 1;
+}
+
+static int Physics3D_PhysicsSceneEntity_Update(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsSceneEntity *inst = (PhysicsSceneEntity*)lua_topointer(L, 1);
+	inst->Update();
+	return 0;
+}
+
+static int Physics3D_PhysicsSceneEntity_setFriction(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsSceneEntity *inst = (PhysicsSceneEntity*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TNUMBER);
+	Number friction = lua_tonumber(L, 2);
+	inst->setFriction(friction);
+	return 0;
+}
+
+static int Physics3D_PhysicsSceneEntity_getType(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsSceneEntity *inst = (PhysicsSceneEntity*)lua_topointer(L, 1);
+	lua_pushinteger(L, inst->getType());
+	return 1;
+}
+
+static int Physics3D_delete_PhysicsSceneEntity(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsSceneEntity *inst = (PhysicsSceneEntity*)lua_topointer(L, 1);
+	delete inst;
+	return 0;
+}
+
+static int Physics3D_PhysicsCharacter(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	SceneEntity * entity = (SceneEntity *)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TNUMBER);
+	Number mass = lua_tonumber(L, 2);
+	luaL_checktype(L, 3, LUA_TNUMBER);
+	Number friction = lua_tonumber(L, 3);
+	luaL_checktype(L, 4, LUA_TNUMBER);
+	Number stepSize = lua_tonumber(L, 4);
+	PhysicsCharacter *inst = new PhysicsCharacter(entity, mass, friction, stepSize);
+	lua_pushlightuserdata(L, (void*)inst);
+	return 1;
+}
+
+static int Physics3D_PhysicsCharacter_setWalkDirection(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsCharacter *inst = (PhysicsCharacter*)lua_topointer(L, 1);
+	luaL_checktype(L, 2, LUA_TLIGHTUSERDATA);
+	Vector3 direction = *(Vector3*)lua_topointer(L, 2);
+	inst->setWalkDirection(direction);
+	return 0;
+}
+
+static int Physics3D_PhysicsCharacter_jump(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsCharacter *inst = (PhysicsCharacter*)lua_topointer(L, 1);
+	inst->jump();
+	return 0;
+}
+
+static int Physics3D_PhysicsCharacter_Update(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsCharacter *inst = (PhysicsCharacter*)lua_topointer(L, 1);
+	inst->Update();
+	return 0;
+}
+
+static int Physics3D_delete_PhysicsCharacter(lua_State *L) {
+	luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
+	PhysicsCharacter *inst = (PhysicsCharacter*)lua_topointer(L, 1);
+	delete inst;
+	return 0;
+}
+
+}

+ 66 - 0
Modules/Bindings/3DPhysics/Source/Physics3DLUA.cpp

@@ -0,0 +1,66 @@
+#include "Physics3DLUA.h"
+#include "Physics3DLUAWrappers.h"
+
+int luaopen_Physics3D(lua_State *L) {
+CoreServices *inst = (CoreServices*)lua_topointer(L, 1);
+CoreServices::setInstance(inst);
+	static const struct luaL_reg physics3dLib [] = {		{"CollisionScene", Physics3D_CollisionScene},
+		{"CollisionScene_initCollisionScene", Physics3D_CollisionScene_initCollisionScene},
+		{"CollisionScene_Update", Physics3D_CollisionScene_Update},
+		{"CollisionScene_enableCollision", Physics3D_CollisionScene_enableCollision},
+		{"CollisionScene_getCollisionEntityByObject", Physics3D_CollisionScene_getCollisionEntityByObject},
+		{"CollisionScene_getFirstEntityInRay", Physics3D_CollisionScene_getFirstEntityInRay},
+		{"CollisionScene_getCollisionByScreenEntity", Physics3D_CollisionScene_getCollisionByScreenEntity},
+		{"CollisionScene_testCollision", Physics3D_CollisionScene_testCollision},
+		{"CollisionScene_testCollisionOnCollisionChild", Physics3D_CollisionScene_testCollisionOnCollisionChild},
+		{"CollisionScene_testCollisionOnCollisionChild_Convex", Physics3D_CollisionScene_testCollisionOnCollisionChild_Convex},
+		{"CollisionScene_testCollisionOnCollisionChild_RayTest", Physics3D_CollisionScene_testCollisionOnCollisionChild_RayTest},
+		{"CollisionScene_getCollisionNormalFromCollisionEnts", Physics3D_CollisionScene_getCollisionNormalFromCollisionEnts},
+		{"CollisionScene_getCollisionNormal", Physics3D_CollisionScene_getCollisionNormal},
+		{"CollisionScene_applyVelocity", Physics3D_CollisionScene_applyVelocity},
+		{"CollisionScene_loadCollisionChild", Physics3D_CollisionScene_loadCollisionChild},
+		{"CollisionScene_enableGravity", Physics3D_CollisionScene_enableGravity},
+		{"CollisionScene_stopTrackingCollision", Physics3D_CollisionScene_stopTrackingCollision},
+		{"CollisionScene_addCollisionChild", Physics3D_CollisionScene_addCollisionChild},
+		{"CollisionScene_trackCollision", Physics3D_CollisionScene_trackCollision},
+		{"CollisionScene_adjustForCollision", Physics3D_CollisionScene_adjustForCollision},
+		{"delete_CollisionScene", Physics3D_delete_CollisionScene},
+		{"CollisionSceneEntity_get_gravityEnabled", Physics3D_CollisionSceneEntity_get_gravityEnabled},
+		{"CollisionSceneEntity_get_autoCollide", Physics3D_CollisionSceneEntity_get_autoCollide},
+		{"CollisionSceneEntity_get_gravityStrength", Physics3D_CollisionSceneEntity_get_gravityStrength},
+		{"CollisionSceneEntity_get_enabled", Physics3D_CollisionSceneEntity_get_enabled},
+		{"CollisionSceneEntity_set_gravityEnabled", Physics3D_CollisionSceneEntity_set_gravityEnabled},
+		{"CollisionSceneEntity_set_autoCollide", Physics3D_CollisionSceneEntity_set_autoCollide},
+		{"CollisionSceneEntity_set_gravityStrength", Physics3D_CollisionSceneEntity_set_gravityStrength},
+		{"CollisionSceneEntity_set_enabled", Physics3D_CollisionSceneEntity_set_enabled},
+		{"CollisionSceneEntity", Physics3D_CollisionSceneEntity},
+		{"CollisionSceneEntity_getSceneEntity", Physics3D_CollisionSceneEntity_getSceneEntity},
+		{"CollisionSceneEntity_Update", Physics3D_CollisionSceneEntity_Update},
+		{"CollisionSceneEntity_getType", Physics3D_CollisionSceneEntity_getType},
+		{"CollisionSceneEntity_getConvexShape", Physics3D_CollisionSceneEntity_getConvexShape},
+		{"CollisionSceneEntity_createCollisionShape", Physics3D_CollisionSceneEntity_createCollisionShape},
+		{"delete_CollisionSceneEntity", Physics3D_delete_CollisionSceneEntity},
+		{"PhysicsScene", Physics3D_PhysicsScene},
+		{"PhysicsScene_Update", Physics3D_PhysicsScene_Update},
+		{"PhysicsScene_addPhysicsChild", Physics3D_PhysicsScene_addPhysicsChild},
+		{"PhysicsScene_trackPhysicsChild", Physics3D_PhysicsScene_trackPhysicsChild},
+		{"PhysicsScene_addCharacterChild", Physics3D_PhysicsScene_addCharacterChild},
+		{"delete_PhysicsScene", Physics3D_delete_PhysicsScene},
+		{"PhysicsSceneEntity_get_enabled", Physics3D_PhysicsSceneEntity_get_enabled},
+		{"PhysicsSceneEntity_set_enabled", Physics3D_PhysicsSceneEntity_set_enabled},
+		{"PhysicsSceneEntity", Physics3D_PhysicsSceneEntity},
+		{"PhysicsSceneEntity_getSceneEntity", Physics3D_PhysicsSceneEntity_getSceneEntity},
+		{"PhysicsSceneEntity_Update", Physics3D_PhysicsSceneEntity_Update},
+		{"PhysicsSceneEntity_setFriction", Physics3D_PhysicsSceneEntity_setFriction},
+		{"PhysicsSceneEntity_getType", Physics3D_PhysicsSceneEntity_getType},
+		{"delete_PhysicsSceneEntity", Physics3D_delete_PhysicsSceneEntity},
+		{"PhysicsCharacter", Physics3D_PhysicsCharacter},
+		{"PhysicsCharacter_setWalkDirection", Physics3D_PhysicsCharacter_setWalkDirection},
+		{"PhysicsCharacter_jump", Physics3D_PhysicsCharacter_jump},
+		{"PhysicsCharacter_Update", Physics3D_PhysicsCharacter_Update},
+		{"delete_PhysicsCharacter", Physics3D_delete_PhysicsCharacter},
+		{NULL, NULL}
+	};
+	luaL_openlib(L, "Physics3D", physics3dLib, 0);
+	return 1;
+}

+ 116 - 0
Modules/Build/Mac OS X/Modules.xcodeproj/project.pbxproj

@@ -7,6 +7,31 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		6D045377137CB38E0089C096 /* Physics3DLUA.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D045373137CB38E0089C096 /* Physics3DLUA.h */; };
+		6D045378137CB38E0089C096 /* Physics3DLUAWrappers.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D045374137CB38E0089C096 /* Physics3DLUAWrappers.h */; };
+		6D045379137CB38E0089C096 /* Physics3DLUA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D045376137CB38E0089C096 /* Physics3DLUA.cpp */; };
+		6D04537A137CB48B0089C096 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D26113213766DDC00745E74 /* OpenAL.framework */; };
+		6D04537B137CB48B0089C096 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D26113013766DD500745E74 /* OpenGL.framework */; };
+		6D04537C137CB48B0089C096 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D26112E13766DC900745E74 /* IOKit.framework */; };
+		6D04537D137CB48B0089C096 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D26112B13766DC300745E74 /* Cocoa.framework */; };
+		6D04537E137CB48B0089C096 /* libPolyCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D28013113766D4E00BD8D0D /* libPolyCore.a */; };
+		6D04537F137CB48B0089C096 /* libPolyCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D28013513766D9000BD8D0D /* libPolyCore.a */; };
+		6D045380137CB48B0089C096 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D28013713766D9C00BD8D0D /* libfreetype.a */; };
+		6D045381137CB48B0089C096 /* libogg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D28013813766D9C00BD8D0D /* libogg.a */; };
+		6D045382137CB48B0089C096 /* libphysfs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D28013913766D9C00BD8D0D /* libphysfs.a */; };
+		6D045383137CB48B0089C096 /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D28013A13766D9D00BD8D0D /* libpng.a */; };
+		6D045384137CB48B0089C096 /* liblua.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D26114D1376792000745E74 /* liblua.a */; };
+		6D045385137CB48B0089C096 /* libvorbis.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D28013B13766D9E00BD8D0D /* libvorbis.a */; };
+		6D045386137CB48B0089C096 /* libvorbisfile.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D28013C13766D9E00BD8D0D /* libvorbisfile.a */; };
+		6D045387137CB48B0089C096 /* libz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D28013D13766D9F00BD8D0D /* libz.a */; };
+		6D045388137CB48B0089C096 /* libBox2D.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D28013313766D7000BD8D0D /* libBox2D.a */; };
+		6D045389137CB4B60089C096 /* PolyCollisionScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D1B704C12C29AFE0076D5C4 /* PolyCollisionScene.cpp */; };
+		6D04538A137CB4B90089C096 /* PolyCollisionSceneEntity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D1B704D12C29AFE0076D5C4 /* PolyCollisionSceneEntity.cpp */; };
+		6D04538B137CB4BB0089C096 /* PolyPhysicsScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D1B704E12C29AFE0076D5C4 /* PolyPhysicsScene.cpp */; };
+		6D04538C137CB4BD0089C096 /* PolyPhysicsSceneEntity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D1B704F12C29AFE0076D5C4 /* PolyPhysicsSceneEntity.cpp */; };
+		6D04538E137CB7680089C096 /* libBulletCollision.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D04538D137CB7680089C096 /* libBulletCollision.a */; };
+		6D0F6D19137CB789007B8D2C /* libBulletDynamics.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D0F6D18137CB789007B8D2C /* libBulletDynamics.a */; };
+		6D0F6D1C137CB793007B8D2C /* libLinearMath.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D0F6D1B137CB793007B8D2C /* libLinearMath.a */; };
 		6D1B705012C29AFE0076D5C4 /* Polycode3DPhysics.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D1B704612C29AFE0076D5C4 /* Polycode3DPhysics.h */; };
 		6D1B705112C29AFE0076D5C4 /* PolyCollisionScene.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D1B704712C29AFE0076D5C4 /* PolyCollisionScene.h */; };
 		6D1B705212C29AFE0076D5C4 /* PolyCollisionSceneEntity.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D1B704812C29AFE0076D5C4 /* PolyCollisionSceneEntity.h */; };
@@ -87,6 +112,12 @@
 
 /* Begin PBXFileReference section */
 		6D045366137CB3740089C096 /* libPolycode3DPhysicsModule.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libPolycode3DPhysicsModule.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
+		6D045373137CB38E0089C096 /* Physics3DLUA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Physics3DLUA.h; sourceTree = "<group>"; };
+		6D045374137CB38E0089C096 /* Physics3DLUAWrappers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Physics3DLUAWrappers.h; sourceTree = "<group>"; };
+		6D045376137CB38E0089C096 /* Physics3DLUA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Physics3DLUA.cpp; sourceTree = "<group>"; };
+		6D04538D137CB7680089C096 /* libBulletCollision.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libBulletCollision.a; path = ../../../Core/Dependencies/bullet/src/BulletCollision/Debug/libBulletCollision.a; sourceTree = "<group>"; };
+		6D0F6D18137CB789007B8D2C /* libBulletDynamics.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libBulletDynamics.a; path = ../../../Core/Dependencies/bullet/src/BulletDynamics/Debug/libBulletDynamics.a; sourceTree = "<group>"; };
+		6D0F6D1B137CB793007B8D2C /* libLinearMath.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libLinearMath.a; path = ../../../Core/Dependencies/bullet/src/LinearMath/Debug/libLinearMath.a; sourceTree = "<group>"; };
 		6D1B704612C29AFE0076D5C4 /* Polycode3DPhysics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Polycode3DPhysics.h; sourceTree = "<group>"; };
 		6D1B704712C29AFE0076D5C4 /* PolyCollisionScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolyCollisionScene.h; sourceTree = "<group>"; };
 		6D1B704812C29AFE0076D5C4 /* PolyCollisionSceneEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolyCollisionSceneEntity.h; sourceTree = "<group>"; };
@@ -188,6 +219,24 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				6D04537A137CB48B0089C096 /* OpenAL.framework in Frameworks */,
+				6D04537B137CB48B0089C096 /* OpenGL.framework in Frameworks */,
+				6D04537C137CB48B0089C096 /* IOKit.framework in Frameworks */,
+				6D04537D137CB48B0089C096 /* Cocoa.framework in Frameworks */,
+				6D04538E137CB7680089C096 /* libBulletCollision.a in Frameworks */,
+				6D0F6D19137CB789007B8D2C /* libBulletDynamics.a in Frameworks */,
+				6D0F6D1C137CB793007B8D2C /* libLinearMath.a in Frameworks */,
+				6D04537E137CB48B0089C096 /* libPolyCore.a in Frameworks */,
+				6D04537F137CB48B0089C096 /* libPolyCore.a in Frameworks */,
+				6D045380137CB48B0089C096 /* libfreetype.a in Frameworks */,
+				6D045381137CB48B0089C096 /* libogg.a in Frameworks */,
+				6D045382137CB48B0089C096 /* libphysfs.a in Frameworks */,
+				6D045383137CB48B0089C096 /* libpng.a in Frameworks */,
+				6D045384137CB48B0089C096 /* liblua.a in Frameworks */,
+				6D045385137CB48B0089C096 /* libvorbis.a in Frameworks */,
+				6D045386137CB48B0089C096 /* libvorbisfile.a in Frameworks */,
+				6D045387137CB48B0089C096 /* libz.a in Frameworks */,
+				6D045388137CB48B0089C096 /* libBox2D.a in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -272,6 +321,9 @@
 				6D994C9E134D8FAA0044DD0B /* Frameworks */,
 				08FB7795FE84155DC02AAC07 /* Source */,
 				C6A0FF2B0290797F04C91782 /* Documentation */,
+				6D04538D137CB7680089C096 /* libBulletCollision.a */,
+				6D0F6D18137CB789007B8D2C /* libBulletDynamics.a */,
+				6D0F6D1B137CB793007B8D2C /* libLinearMath.a */,
 				1AB674ADFE9D54B511CA2CBB /* Products */,
 			);
 			name = Modules;
@@ -309,10 +361,31 @@
 		6D045359137CAFAA0089C096 /* Module */ = {
 			isa = PBXGroup;
 			children = (
+				6D045372137CB38E0089C096 /* Include */,
+				6D045375137CB38E0089C096 /* Source */,
 			);
 			name = Module;
 			sourceTree = "<group>";
 		};
+		6D045372137CB38E0089C096 /* Include */ = {
+			isa = PBXGroup;
+			children = (
+				6D045373137CB38E0089C096 /* Physics3DLUA.h */,
+				6D045374137CB38E0089C096 /* Physics3DLUAWrappers.h */,
+			);
+			name = Include;
+			path = ../../Bindings/3DPhysics/Include;
+			sourceTree = "<group>";
+		};
+		6D045375137CB38E0089C096 /* Source */ = {
+			isa = PBXGroup;
+			children = (
+				6D045376137CB38E0089C096 /* Physics3DLUA.cpp */,
+			);
+			name = Source;
+			path = ../../Bindings/3DPhysics/Source;
+			sourceTree = "<group>";
+		};
 		6D1B704412C29AFE0076D5C4 /* 3DPhysics */ = {
 			isa = PBXGroup;
 			children = (
@@ -547,6 +620,8 @@
 			isa = PBXHeadersBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				6D045377137CB38E0089C096 /* Physics3DLUA.h in Headers */,
+				6D045378137CB38E0089C096 /* Physics3DLUAWrappers.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -830,6 +905,11 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				6D045379137CB38E0089C096 /* Physics3DLUA.cpp in Sources */,
+				6D045389137CB4B60089C096 /* PolyCollisionScene.cpp in Sources */,
+				6D04538C137CB4BD0089C096 /* PolyPhysicsSceneEntity.cpp in Sources */,
+				6D04538B137CB4BB0089C096 /* PolyPhysicsScene.cpp in Sources */,
+				6D04538A137CB4B90089C096 /* PolyCollisionSceneEntity.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -974,6 +1054,31 @@
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				HEADER_SEARCH_PATHS = (
+					/usr/local/include/,
+					/usr/local/include/libfreenect,
+					../../../Core/Dependencies/box2d/Box2D,
+					../../../Core/Contents/Include,
+					../../../Core/Dependencies/bullet/src,
+					../../../Core/Dependencies/libvorbis/include,
+					../../../Core/Dependencies/libogg/include,
+					/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/OpenAL.framework/Versions/A/Headers,
+					../../../Core/Dependencies/freetype/include,
+					../../../Core/Dependencies/libpng,
+					../../../Core/Dependencies/physfs,
+					../../Contents/3DPhysics/Include,
+					../../../Core/Dependencies/luajit/src,
+				);
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/../../../Release/Mac OS X/Framework/Core/Lib\"",
+					"\"$(SRCROOT)/../../../Release/Mac OS X/Framework/Dependencies/Lib\"",
+					"\"$(SRCROOT)/../../../Core/Dependencies/lua/src\"",
+					"\"$(SRCROOT)/../../../Core/Dependencies/box2d/Box2D/Box2D/Debug\"",
+					"\"$(SRCROOT)/../../../Core/Dependencies/bullet/src/BulletCollision/Debug\"",
+					"\"$(SRCROOT)/../../../Core/Dependencies/bullet/src/BulletDynamics/Debug\"",
+					"\"$(SRCROOT)/../../../Core/Dependencies/bullet/src/LinearMath/Debug\"",
+				);
 				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SDKROOT = macosx;
@@ -990,6 +1095,16 @@
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
 				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/../../../Release/Mac OS X/Framework/Core/Lib\"",
+					"\"$(SRCROOT)/../../../Release/Mac OS X/Framework/Dependencies/Lib\"",
+					"\"$(SRCROOT)/../../../Core/Dependencies/lua/src\"",
+					"\"$(SRCROOT)/../../../Core/Dependencies/box2d/Box2D/Box2D/Debug\"",
+					"\"$(SRCROOT)/../../../Core/Dependencies/bullet/src/BulletCollision/Debug\"",
+					"\"$(SRCROOT)/../../../Core/Dependencies/bullet/src/BulletDynamics/Debug\"",
+					"\"$(SRCROOT)/../../../Core/Dependencies/bullet/src/LinearMath/Debug\"",
+				);
 				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SDKROOT = macosx;
@@ -1356,6 +1471,7 @@
 				6D045369137CB3740089C096 /* Release */,
 			);
 			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
 		};
 		6D28012D13766CE200BD8D0D /* Build configuration list for PBXNativeTarget "Polycode2DPhysicsModule" */ = {
 			isa = XCConfigurationList;

Разница между файлами не показана из-за своего большого размера
+ 163 - 177
Modules/Build/Mac OS X/Modules.xcodeproj/project.xcworkspace/xcuserdata/ivansafrin.xcuserdatad/UserInterfaceState.xcuserstate


+ 16 - 0
Modules/Build/Mac OS X/Modules.xcodeproj/xcuserdata/ivansafrin.xcuserdatad/xcschemes/Polycode3DPhysicsModule.xcscheme

@@ -4,6 +4,22 @@
    <BuildAction
       parallelizeBuildables = "YES"
       buildImplicitDependencies = "YES">
+      <BuildActionEntries>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "YES"
+            buildForProfiling = "YES"
+            buildForArchiving = "YES"
+            buildForAnalyzing = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "6D045365137CB3740089C096"
+               BuildableName = "libPolycode3DPhysicsModule.dylib"
+               BlueprintName = "Polycode3DPhysicsModule"
+               ReferencedContainer = "container:Modules.xcodeproj">
+            </BuildableReference>
+         </BuildActionEntry>
+      </BuildActionEntries>
    </BuildAction>
    <TestAction
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"

+ 35 - 17
Modules/Contents/2DPhysics/Include/PolyPhysicsScreen.h

@@ -72,17 +72,35 @@ public:
 	b2Joint *box2DJoint;
 	
 };
-	
+
+/**
+* A 2D Physics enabled screen. 
+*/	
 class _PolyExport PhysicsScreen : public Screen, b2ContactListener {
 
 public:
-	PhysicsScreen();
-	PhysicsScreen(float worldScale, float freq);
 
+	/**
+	*
+	*/ 
+	PhysicsScreen(Number worldScale, Number freq);
+	
+	/**
+	* Default constructor.
+	*/
+	PhysicsScreen();
+	
 	~PhysicsScreen();
 	
 	void Update();
-	PhysicsScreenEntity *addPhysicsChild(ScreenEntity *newEntity, int entType, float friction=0.1, float density=1, float restitution = 0, bool isSensor = false, bool fixedRotation = false);
+	
+	/**
+	* Adds a ScreenEntity as a physics enabled child. 
+	* @param newEntity Screen entity to add.
+	* @param entType Physics entity type to add as. Possible values are PhysicsScreenEntity::ENTITY_RECT, PhysicsScreenEntity::ENTITY_CIRCLE and PhysicsScreenEntity::ENTITY_STATICRECT
+	* @return The physics entity wrapper.
+	*/
+	PhysicsScreenEntity *addPhysicsChild(ScreenEntity *newEntity, int entType, Number friction=0.1, Number density=1, Number restitution = 0, bool isSensor = false, bool fixedRotation = false);
 	void removePhysicsChild(PhysicsScreenEntity *entityToRemove);
 	
 	PhysicsScreenEntity *addCollisionChild(ScreenEntity *newEntity, int entType);
@@ -90,22 +108,22 @@ public:
 	void destroyJoint(PhysicsJoint *joint);
 	void createDistanceJoint(ScreenEntity *ent1, ScreenEntity *ent2, bool collideConnected);
 	void createPrismaticJoint(ScreenEntity *ent1, ScreenEntity *ent2, bool collideConnected);
-	PhysicsJoint *createRevoluteJoint(ScreenEntity *ent1, ScreenEntity *ent2, float ax, float ay, bool enableLimit, float lowerLimit, float upperLimit, bool motorEnabled, float motorSpeed, float maxTorque);
+	PhysicsJoint *createRevoluteJoint(ScreenEntity *ent1, ScreenEntity *ent2, Number ax, Number ay, bool enableLimit, Number lowerLimit, Number upperLimit, bool motorEnabled, Number motorSpeed, Number maxTorque);
 //	b2MouseJoint *createMouseJoint(ScreenEntity *ent1, Vector2 *mp);
-	void applyForce(ScreenEntity *ent, float fx, float fy);
-	void applyImpulse(ScreenEntity *ent, float fx, float fy);
+	void applyForce(ScreenEntity *ent, Number fx, Number fy);
+	void applyImpulse(ScreenEntity *ent, Number fx, Number fy);
 	
 	void setGravity(Vector2 newGravity);
 	
-	void setTransform(ScreenEntity *ent, Vector2 pos, float angle);
+	void setTransform(ScreenEntity *ent, Vector2 pos, Number angle);
 	
 	PhysicsScreenEntity *getPhysicsEntityByShape(b2Shape *shape);
 	PhysicsScreenEntity *getPhysicsEntityByFixture(b2Fixture *fixture);
 	
-	void setVelocity(ScreenEntity *ent, float fx, float fy);	
-	void setVelocityX(ScreenEntity *ent, float fx);	
-	void setVelocityY(ScreenEntity *ent, float fy);	
-	void setSpin(ScreenEntity *ent, float spin);
+	void setVelocity(ScreenEntity *ent, Number fx, Number fy);	
+	void setVelocityX(ScreenEntity *ent, Number fx);	
+	void setVelocityY(ScreenEntity *ent, Number fy);	
+	void setSpin(ScreenEntity *ent, Number spin);
 	
 	Vector2 getVelocity(ScreenEntity *ent);
 			
@@ -119,8 +137,8 @@ public:
 	Vector2 getEntityCollisionNormal(ScreenEntity *ent1, ScreenEntity *ent2);
 	
 	bool areEntitiesColliding(ScreenEntity *ent1, ScreenEntity *ent2);
-	ScreenEntity *getEntityAtPosition(float x, float y);
-	bool testEntityAtPosition(ScreenEntity *ent, float x, float y);
+	ScreenEntity *getEntityAtPosition(Number x, Number y);
+	bool testEntityAtPosition(ScreenEntity *ent, Number x, Number y);
 	
 	void Shutdown();
 	
@@ -131,9 +149,9 @@ public:
 protected:
 	
 	
-	float worldScale;
+	Number worldScale;
 	
-	void init(float worldScale, float physicsTimeStep, int physicsIterations, Vector2 physicsGravity);
+	void init(Number worldScale, Number physicsTimeStep, int physicsIterations, Vector2 physicsGravity);
 
 	Timer *updateTimer;
 	vector <PhysicsScreenEntity*> physicsChildren;
@@ -142,7 +160,7 @@ protected:
 	int32 numContactPoints;
 	
 	b2World *world;
-	float32 timeStep;
+	Number timeStep;
 	int32 iterations;
 };
 

+ 8 - 5
Modules/Contents/2DPhysics/Include/PolyPhysicsScreenEntity.h

@@ -27,17 +27,20 @@ THE SOFTWARE.
 
 namespace Polycode {
 
+	/**
+	* A 2D Physics enabled screen entity. 
+	*/	
 	class _PolyExport PhysicsScreenEntity {
 		public:
-			PhysicsScreenEntity(ScreenEntity *entity, b2World *world, float worldScale, int entType, float friction, float density, float restitution, bool isSensor, bool fixedRotation);
+			PhysicsScreenEntity(ScreenEntity *entity, b2World *world, Number worldScale, int entType, Number friction, Number density, Number restitution, bool isSensor, bool fixedRotation);
 			~PhysicsScreenEntity();		
 			
 			ScreenEntity *getScreenEntity();
 			
-			void applyTorque(float torque);
+			void applyTorque(Number torque);
 			void applyForce(Vector2 force);
 		
-			void setTransform(Vector2 pos, float angle);
+			void setTransform(Vector2 pos, Number angle);
 			
 			void Update();
 			
@@ -54,9 +57,9 @@ namespace Polycode {
 		
 		protected:
 		
-		float worldScale;
+		Number worldScale;
 		Vector2 lastPosition;
-		float lastRotation;
+		Number lastRotation;
 			
 		ScreenEntity *screenEntity;
 	};

+ 15 - 15
Modules/Contents/2DPhysics/Source/PolyPhysicsScreen.cpp

@@ -91,11 +91,11 @@ PhysicsScreen::PhysicsScreen() : Screen() {
 	init(10.0f, 1.0f/60.0f,10,Vector2(0.0f, 10.0f));
 }
 
-PhysicsScreen::PhysicsScreen(float worldScale, float freq) : Screen() {
+PhysicsScreen::PhysicsScreen(Number worldScale, Number freq) : Screen() {
 	init(worldScale, 1.0f/freq,10,Vector2(0.0f, 10.0f));	
 }
 
-void PhysicsScreen::init(float worldScale, float physicsTimeStep, int physicsIterations, Vector2 physicsGravity) {
+void PhysicsScreen::init(Number worldScale, Number physicsTimeStep, int physicsIterations, Vector2 physicsGravity) {
 	
 	this->worldScale = worldScale;
 	
@@ -130,7 +130,7 @@ void PhysicsScreen::destroyJoint(PhysicsJoint *joint) {
 }
 
 
-PhysicsJoint *PhysicsScreen::createRevoluteJoint(ScreenEntity *ent1, ScreenEntity *ent2, float ax, float ay, bool enableLimit, float lowerLimit, float upperLimit, bool motorEnabled, float motorSpeed, float maxTorque) {
+PhysicsJoint *PhysicsScreen::createRevoluteJoint(ScreenEntity *ent1, ScreenEntity *ent2, Number ax, Number ay, bool enableLimit, Number lowerLimit, Number upperLimit, bool motorEnabled, Number motorSpeed, Number maxTorque) {
 	PhysicsScreenEntity *pEnt1 = getPhysicsByScreenEntity(ent1);
 	PhysicsScreenEntity *pEnt2 = getPhysicsByScreenEntity(ent2);
 	if(pEnt1 == NULL || pEnt2 == NULL)
@@ -176,7 +176,7 @@ Vector2 PhysicsScreen::getVelocity(ScreenEntity *ent) {
 	return Vector2(vec.x, vec.y);
 }
 
-void PhysicsScreen::setSpin(ScreenEntity *ent, float spin) {
+void PhysicsScreen::setSpin(ScreenEntity *ent, Number spin) {
 	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
 	if(pEnt == NULL)
 		return;
@@ -184,7 +184,7 @@ void PhysicsScreen::setSpin(ScreenEntity *ent, float spin) {
 	pEnt->body->SetAngularVelocity(spin);
 }
 
-void PhysicsScreen::setVelocity(ScreenEntity *ent, float fx, float fy) {
+void PhysicsScreen::setVelocity(ScreenEntity *ent, Number fx, Number fy) {
 	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
 	if(pEnt == NULL)
 		return;
@@ -199,7 +199,7 @@ void PhysicsScreen::setVelocity(ScreenEntity *ent, float fx, float fy) {
 	pEnt->body->SetLinearVelocity(f);
 }
 
-void PhysicsScreen::setVelocityX(ScreenEntity *ent, float fx) {
+void PhysicsScreen::setVelocityX(ScreenEntity *ent, Number fx) {
 	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
 	if(pEnt == NULL)
 		return;
@@ -211,7 +211,7 @@ void PhysicsScreen::setVelocityX(ScreenEntity *ent, float fx) {
 	
 }
 
-void PhysicsScreen::setVelocityY(ScreenEntity *ent, float fy) {
+void PhysicsScreen::setVelocityY(ScreenEntity *ent, Number fy) {
 	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
 	if(pEnt == NULL)
 		return;
@@ -230,14 +230,14 @@ PhysicsScreenEntity *PhysicsScreen::addCollisionChild(ScreenEntity *newEntity, i
 	return ret;
 }
 
-void PhysicsScreen::setTransform(ScreenEntity *ent, Vector2 pos, float angle) {
+void PhysicsScreen::setTransform(ScreenEntity *ent, Vector2 pos, Number angle) {
 	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
 	if(pEnt == NULL)
 		return;
 	pEnt->setTransform(pos, angle);
 }
 
-void PhysicsScreen::applyForce(ScreenEntity *ent, float fx, float fy) {
+void PhysicsScreen::applyForce(ScreenEntity *ent, Number fx, Number fy) {
 	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
 	if(pEnt == NULL)
 		return;
@@ -249,7 +249,7 @@ void PhysicsScreen::applyForce(ScreenEntity *ent, float fx, float fy) {
 	pEnt->body->ApplyForce(f, p);
 }
 
-void PhysicsScreen::applyImpulse(ScreenEntity *ent, float fx, float fy) {
+void PhysicsScreen::applyImpulse(ScreenEntity *ent, Number fx, Number fy) {
 	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);
 	if(pEnt == NULL)
 		return;
@@ -288,8 +288,8 @@ b2MouseJoint *PhysicsScreen::createMouseJoint(ScreenEntity *ent1, Vector2 *mp) {
 	
 	b2Vec2 mpos(mp->x/10.0f, mp->y/10.0f);
 	mj->target = mpos;
-#ifdef TARGET_FLOAT32_IS_FIXED
-	mj->maxForce = (pEnt1->body->GetMass() < 16.0)? (1000.0f * pEnt1->body->GetMass()) : float32(16000.0);
+#ifdef TARGET_Number_IS_FIXED
+	mj->maxForce = (pEnt1->body->GetMass() < 16.0)? (1000.0f * pEnt1->body->GetMass()) : Number(16000.0);
 #else
 	mj->maxForce = 1000.0f * pEnt1->body->GetMass();
 #endif
@@ -346,7 +346,7 @@ bool PhysicsScreen::areEntitiesColliding(ScreenEntity *ent1, ScreenEntity *ent2)
 	return false;
 }
 
-ScreenEntity *PhysicsScreen::getEntityAtPosition(float x, float y) {
+ScreenEntity *PhysicsScreen::getEntityAtPosition(Number x, Number y) {
 	ScreenEntity *ret = NULL;
 	
 	b2Vec2 mousePosition;
@@ -361,7 +361,7 @@ ScreenEntity *PhysicsScreen::getEntityAtPosition(float x, float y) {
 	return ret;
 }
 
-bool PhysicsScreen::testEntityAtPosition(ScreenEntity *ent, float x, float y) {
+bool PhysicsScreen::testEntityAtPosition(ScreenEntity *ent, Number x, Number y) {
 	PhysicsScreenEntity *pEnt = getPhysicsByScreenEntity(ent);	
 	
 	if(pEnt == NULL)
@@ -383,7 +383,7 @@ void PhysicsScreen::destroyMouseJoint(b2MouseJoint *mJoint) {
 		mJoint = NULL;
 }
 
-PhysicsScreenEntity *PhysicsScreen::addPhysicsChild(ScreenEntity *newEntity, int entType, float friction, float density, float restitution, bool isSensor, bool fixedRotation) {
+PhysicsScreenEntity *PhysicsScreen::addPhysicsChild(ScreenEntity *newEntity, int entType, Number friction, Number density, Number restitution, bool isSensor, bool fixedRotation) {
 	addChild(newEntity);
 	newEntity->setPositionMode(ScreenEntity::POSITION_CENTER);
 	PhysicsScreenEntity *newPhysicsEntity = new PhysicsScreenEntity(newEntity, world, worldScale, entType, friction, density, restitution, isSensor,fixedRotation);

+ 4 - 4
Modules/Contents/2DPhysics/Source/PolyPhysicsScreenEntity.cpp

@@ -26,7 +26,7 @@ THE SOFTWARE.
 
 using namespace Polycode;
 
-PhysicsScreenEntity::PhysicsScreenEntity(ScreenEntity *entity, b2World *world, float worldScale, int entType, float friction, float density, float restitution, bool isSensor, bool fixedRotation) {
+PhysicsScreenEntity::PhysicsScreenEntity(ScreenEntity *entity, b2World *world, Number worldScale, int entType, Number friction, Number density, Number restitution, bool isSensor, bool fixedRotation) {
 	
 	this->worldScale = worldScale;
 	
@@ -81,7 +81,7 @@ PhysicsScreenEntity::PhysicsScreenEntity(ScreenEntity *entity, b2World *world, f
 	collisionOnly = false;
 }
 
-void PhysicsScreenEntity::applyTorque(float torque) {
+void PhysicsScreenEntity::applyTorque(Number torque) {
 	body->ApplyTorque(torque);
 }
 
@@ -95,13 +95,13 @@ ScreenEntity *PhysicsScreenEntity::getScreenEntity() {
 }
 			
 
-void PhysicsScreenEntity::setTransform(Vector2 pos, float angle) {
+void PhysicsScreenEntity::setTransform(Vector2 pos, Number angle) {
 	body->SetTransform(b2Vec2(pos.x/worldScale, pos.y/worldScale), angle*(PI/180.0f));
 }
 
 void PhysicsScreenEntity::Update() {
 	b2Vec2 position = body->GetPosition();
-	float32 angle = body->GetAngle();
+	Number angle = body->GetAngle();
 
 	
 //	if(lastRotation != screenEntity->getRotation() || collisionOnly) {

+ 4 - 4
Modules/Contents/3DPhysics/Include/PolyCollisionScene.h

@@ -23,7 +23,7 @@ THE SOFTWARE.
 #pragma once
 #include "PolyLogger.h"
 #include "PolyGlobals.h"
-#include "PolyGenericScene.h"
+#include "PolyScene.h"
 #include "PolyCollisionSceneEntity.h"
 #include "btBulletCollisionCommon.h"
 #include "PolyVector3.h"
@@ -36,7 +36,7 @@ namespace Polycode {
 struct CollisionResult {
 	bool collided;
 	Vector3 colNormal;
-	float colDist;
+	Number colDist;
 	bool setOldPosition;
 	Vector3 newPos;
 };
@@ -48,7 +48,7 @@ struct CollisionResult {
 	};
 
 	
-	class _PolyExport CollisionScene : public GenericScene {
+	class _PolyExport CollisionScene : public Scene {
 		public:
 			CollisionScene();
 			CollisionScene(bool virtualScene);		
@@ -68,7 +68,7 @@ struct CollisionResult {
 			CollisionResult testCollisionOnCollisionChild_RayTest(CollisionSceneEntity *cEnt1, CollisionSceneEntity *cEnt2);					
 			Vector3 getCollisionNormalFromCollisionEnts(CollisionSceneEntity *cEnt1, CollisionSceneEntity *cEnt2);			
 			Vector3 getCollisionNormal(SceneEntity *ent1, SceneEntity *ent2);			
-			void applyVelocity(SceneEntity *entity, float x, float y, float z);			
+			void applyVelocity(SceneEntity *entity, Number x, Number y, Number z);			
 			void loadCollisionChild(SceneEntity *entity, bool autoCollide=false, int type=0);
 			void enableGravity(SceneEntity *entity);
 			

+ 1 - 1
Modules/Contents/3DPhysics/Include/PolyCollisionSceneEntity.h

@@ -48,7 +48,7 @@ namespace Polycode {
 			bool autoCollide;
 			Vector3 gravityVector;
 			Vector3 gVelocity;
-			float gravityStrength;
+			Number gravityStrength;
 		
 			Vector3 lastPosition;
 		

+ 3 - 3
Modules/Contents/3DPhysics/Include/PolyPhysicsScene.h

@@ -41,10 +41,10 @@ namespace Polycode {
 		
 		void Update();		
 		
-		PhysicsSceneEntity *addPhysicsChild(SceneEntity *newEntity, int type=0, float mass = 0.0f, float friction=1, float restitution=0, int group=1);		
-		PhysicsSceneEntity *trackPhysicsChild(SceneEntity *newEntity, int type=0, float mass = 0.0f, float friction=1, float restitution=0, int group=1);		
+		PhysicsSceneEntity *addPhysicsChild(SceneEntity *newEntity, int type=0, Number mass = 0.0f, Number friction=1, Number restitution=0, int group=1);		
+		PhysicsSceneEntity *trackPhysicsChild(SceneEntity *newEntity, int type=0, Number mass = 0.0f, Number friction=1, Number restitution=0, int group=1);		
 		
-		PhysicsCharacter *addCharacterChild(SceneEntity *newEntity, float mass, float friction, float stepSize, int group  = 1);
+		PhysicsCharacter *addCharacterChild(SceneEntity *newEntity, Number mass, Number friction, Number stepSize, int group  = 1);
 
 		
 	protected:

+ 4 - 4
Modules/Contents/3DPhysics/Include/PolyPhysicsSceneEntity.h

@@ -39,12 +39,12 @@ namespace Polycode {
 	
 	class _PolyExport PhysicsSceneEntity : public CollisionSceneEntity {
 	public:
-		PhysicsSceneEntity(SceneEntity *entity, int type, float mass, float friction, float restitution);
+		PhysicsSceneEntity(SceneEntity *entity, int type, Number mass, Number friction, Number restitution);
 		virtual ~PhysicsSceneEntity();
 		
 		SceneEntity *getSceneEntity();
 		virtual void Update();
-		void setFriction(float friction);
+		void setFriction(Number friction);
 		
 		int getType() { return type; }	
 		
@@ -62,13 +62,13 @@ namespace Polycode {
 		
 	protected:
 	
-		float mass;
+		Number mass;
 	};
 	
 	
 	class _PolyExport PhysicsCharacter : public PhysicsSceneEntity {
 		public:
-			PhysicsCharacter(SceneEntity *entity, float mass, float friction, float stepSize);
+			PhysicsCharacter(SceneEntity *entity, Number mass, Number friction, Number stepSize);
 			virtual ~PhysicsCharacter();
 	
 			void setWalkDirection(Vector3 direction);

+ 6 - 6
Modules/Contents/3DPhysics/Source/PolyCollisionScene.cpp

@@ -24,11 +24,11 @@ THE SOFTWARE.
 
 using namespace Polycode;
 
-CollisionScene::CollisionScene() : GenericScene() {
+CollisionScene::CollisionScene() : Scene() {
 	initCollisionScene();
 }
 
-CollisionScene::CollisionScene(bool virtualScene) : GenericScene(virtualScene) { 
+CollisionScene::CollisionScene(bool virtualScene) : Scene(virtualScene) { 
 	initCollisionScene();
 }
 
@@ -76,7 +76,7 @@ void CollisionScene::enableCollision(SceneEntity *entity, bool val) {
 
 void CollisionScene::adjustForCollision(CollisionSceneEntity *collisionEntity) {
 	CollisionResult result;
-//	float elapsed = CoreServices::getInstance()->getCore()->getElapsed();
+//	Number elapsed = CoreServices::getInstance()->getCore()->getElapsed();
 	result.collided = false;
 	for(int i=0; i < collisionChildren.size(); i++) {
 		if(collisionChildren[i] != collisionEntity) {
@@ -117,7 +117,7 @@ CollisionSceneEntity *CollisionScene::getCollisionByScreenEntity(SceneEntity *en
 
 }
 
-void CollisionScene::applyVelocity(SceneEntity *entity, float x, float y, float z) {
+void CollisionScene::applyVelocity(SceneEntity *entity, Number x, Number y, Number z) {
 	CollisionSceneEntity *cEnt1 = getCollisionByScreenEntity(entity);
 	if(!cEnt1)
 		return;
@@ -195,10 +195,10 @@ CollisionResult CollisionScene::testCollisionOnCollisionChild_Convex(CollisionSc
 	}
 	
 	if(numAdds > 0) {
-		result.colNormal = result.colNormal / (float)numAdds;
+		result.colNormal = result.colNormal / (Number)numAdds;
 		//		result.colNormal = Vector3(0,1,0);
 		//		result.colNormal.Normalize();
-		result.colDist  = result.colDist / (float)numAdds;
+		result.colDist  = result.colDist / (Number)numAdds;
 	}
 	
 	return result;

+ 2 - 2
Modules/Contents/3DPhysics/Source/PolyCollisionSceneEntity.cpp

@@ -115,7 +115,7 @@ void CollisionSceneEntity::Update() {
 	
 //	lastPosition = *getSceneEntity()->getPosition();	
 	if(gravityEnabled) {	
-		float elapsed = CoreServices::getInstance()->getCore()->getElapsed();
+		Number elapsed = CoreServices::getInstance()->getCore()->getElapsed();
 		Vector3 elapsedGrav = gravityVector;
 		elapsedGrav * elapsed * gravityStrength;
 		gVelocity = gVelocity+(elapsedGrav);
@@ -128,7 +128,7 @@ void CollisionSceneEntity::Update() {
 	collisionObject->getWorldTransform().setFromOpenGLMatrix((float*)sceneEntity->getConcatenatedMatrix().ml);
 
 /*	
-	float rads = PI/180.0f;
+	Number rads = PI/180.0f;
 	orn.setEuler(sceneEntity->getCombinedYaw()*rads,sceneEntity->getCombinedPitch()*rads,sceneEntity->getCombinedRoll()*rads);
 	collisionObject->getWorldTransform().setRotation(orn);
 	collisionObject->getWorldTransform().setOrigin(btVector3(sceneEntity->getCombinedPosition().x, sceneEntity->getCombinedPosition().y, sceneEntity->getCombinedPosition().z));

+ 4 - 4
Modules/Contents/3DPhysics/Source/PolyPhysicsScene.cpp

@@ -63,7 +63,7 @@ void PhysicsScene::Update() {
 	}
 	
 	
-	float elapsed = CoreServices::getInstance()->getCore()->getElapsed();
+	Number elapsed = CoreServices::getInstance()->getCore()->getElapsed();
 	physicsWorld->stepSimulation(elapsed);	
 
 	
@@ -71,7 +71,7 @@ void PhysicsScene::Update() {
 	
 }
 
-PhysicsCharacter *PhysicsScene::addCharacterChild(SceneEntity *newEntity,float mass, float friction, float stepSize, int group) {
+PhysicsCharacter *PhysicsScene::addCharacterChild(SceneEntity *newEntity,Number mass, Number friction, Number stepSize, int group) {
 	addEntity(newEntity);	
 	PhysicsCharacter *newPhysicsEntity = new PhysicsCharacter(newEntity, mass, friction, stepSize);
 	
@@ -90,7 +90,7 @@ PhysicsCharacter *PhysicsScene::addCharacterChild(SceneEntity *newEntity,float m
 	
 }
 
-PhysicsSceneEntity *PhysicsScene::trackPhysicsChild(SceneEntity *newEntity, int type, float mass, float friction, float restitution, int group) {
+PhysicsSceneEntity *PhysicsScene::trackPhysicsChild(SceneEntity *newEntity, int type, Number mass, Number friction, Number restitution, int group) {
 	PhysicsSceneEntity *newPhysicsEntity = new PhysicsSceneEntity(newEntity, type, mass, friction,restitution);
 	physicsWorld->addRigidBody(newPhysicsEntity->rigidBody, group, btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);	
 	//	newPhysicsEntity->rigidBody->setActivationState(ISLAND_SLEEPING);	
@@ -98,7 +98,7 @@ PhysicsSceneEntity *PhysicsScene::trackPhysicsChild(SceneEntity *newEntity, int
 	return newPhysicsEntity;	
 }
 
-PhysicsSceneEntity *PhysicsScene::addPhysicsChild(SceneEntity *newEntity, int type, float mass, float friction, float restitution, int group) {
+PhysicsSceneEntity *PhysicsScene::addPhysicsChild(SceneEntity *newEntity, int type, Number mass, Number friction, Number restitution, int group) {
 	addEntity(newEntity);	
 	return trackPhysicsChild(newEntity, type, mass, friction, restitution, group);	
 }

+ 12 - 2
Modules/Contents/3DPhysics/Source/PolyPhysicsSceneEntity.cpp

@@ -24,7 +24,7 @@ THE SOFTWARE.
 
 using namespace Polycode;
 
-PhysicsCharacter::PhysicsCharacter(SceneEntity *entity, float mass, float friction, float stepSize) : PhysicsSceneEntity(entity, PhysicsSceneEntity::CHARACTER_CONTROLLER, mass, friction, 1) {	
+PhysicsCharacter::PhysicsCharacter(SceneEntity *entity, Number mass, Number friction, Number stepSize) : PhysicsSceneEntity(entity, PhysicsSceneEntity::CHARACTER_CONTROLLER, mass, friction, 1) {	
 	ghostObject = new btPairCachingGhostObject();
 	
 	Vector3 pos = entity->getPosition();	
@@ -32,6 +32,9 @@ PhysicsCharacter::PhysicsCharacter(SceneEntity *entity, float mass, float fricti
 	transform.setIdentity();		
 	transform.setOrigin(btVector3(pos.x,pos.y,pos.z));	
 	
+	Quaternion q = entity->getRotationQuat();
+	transform.setRotation(btQuaternion(q.x,q.y,q.z,q.w));
+	
 	ghostObject->setWorldTransform(transform);	
 	ghostObject->setCollisionShape (shape);
 	
@@ -62,7 +65,7 @@ PhysicsCharacter::~PhysicsCharacter() {
 	
 }
 
-PhysicsSceneEntity::PhysicsSceneEntity(SceneEntity *entity, int type, float mass, float friction, float restitution) : CollisionSceneEntity(entity, false, type) {
+PhysicsSceneEntity::PhysicsSceneEntity(SceneEntity *entity, int type, Number mass, Number friction, Number restitution) : CollisionSceneEntity(entity, false, type) {
 
 	this->mass = mass;
 	btVector3 localInertia(0,0,0);
@@ -70,6 +73,9 @@ PhysicsSceneEntity::PhysicsSceneEntity(SceneEntity *entity, int type, float mass
 	btTransform transform;
 	transform.setIdentity();		
 	transform.setOrigin(btVector3(pos.x,pos.y,pos.z));
+	Quaternion q = entity->getRotationQuat();
+	transform.setRotation(btQuaternion(q.x,q.y,q.z,q.w));
+	
 	
 	if(mass != 0.0f) {
 		shape->calculateLocalInertia(mass,localInertia);
@@ -87,6 +93,10 @@ PhysicsSceneEntity::PhysicsSceneEntity(SceneEntity *entity, int type, float mass
 	}
 }
 
+void PhysicsSceneEntity::setFriction(Number friction) {
+		rigidBody->setFriction(friction);
+}
+
 void PhysicsSceneEntity::Update() {		
 	Matrix4 m;
 		

+ 3 - 3
Modules/Contents/CgShading/Include/PolyCGProgram.h

@@ -92,9 +92,9 @@ class _PolyExport CGProgramParam {
 	static const int TAU_SPOT_LIGHT_TEXTUREMATRIX_3 = 45;
 	
 	static const int PARAM_UNKNOWN = 0;	
-	static const int PARAM_FLOAT = 1;
-	static const int PARAM_FLOAT3 = 2;
-	static const int PARAM_FLOAT4 = 3;
+	static const int PARAM_Number = 1;
+	static const int PARAM_Number3 = 2;
+	static const int PARAM_Number4 = 3;
 	
 	};
 

+ 6 - 6
Modules/Contents/CgShading/Source/PolyCGProgram.cpp

@@ -46,21 +46,21 @@ void CGProgram::addParam(String name, bool isAuto, int autoID, int paramType, vo
 
 void *CGProgramParam::createParamData(int *retType, String type, String value) {
 		void *defaultData;
-		if(type == "float") {
-			*retType = CGProgramParam::PARAM_FLOAT;
-			float *val = new float();
+		if(type == "Number") {
+			*retType = CGProgramParam::PARAM_Number;
+			Number *val = new Number();
 			*val = atof(value.c_str());
 			defaultData = (void*)val;
 			return defaultData;			
-		} else if(type == "float3") {
-			*retType = CGProgramParam::PARAM_FLOAT3;
+		} else if(type == "Number3") {
+			*retType = CGProgramParam::PARAM_Number3;
 			Vector3 *val = new Vector3();
 			defaultData = (void*)val;
 			vector<String> values = value.split(" ");
 			if(values.size() == 3) {
 				val->set(atof(values[0].c_str()), atof(values[1].c_str()), atof(values[2].c_str()));
 			} else {
-				Logger::log("Error: A float3 must have 3 values (%d provided)!\n", values.size());
+				Logger::log("Error: A Number3 must have 3 values (%d provided)!\n", values.size());
 			}
 			return defaultData;
 		} else {

+ 4 - 4
Modules/Contents/CgShading/Source/PolyCGShaderModule.cpp

@@ -320,14 +320,14 @@ void CGShaderModule::updateCGParam(Renderer *renderer, CGProgramParam &param, Sh
 		if(localParam)
 			paramData = localParam->data;
 		
-		float *fval;
+		Number *fval;
 		
 		switch(param.paramType) {
-			case CGProgramParam::PARAM_FLOAT:
-				fval = (float*)paramData;
+			case CGProgramParam::PARAM_Number:
+				fval = (Number*)paramData;
 				cgGLSetParameter1f(param.cgParam, *fval);
 				break;
-			case CGProgramParam::PARAM_FLOAT3:
+			case CGProgramParam::PARAM_Number3:
 				Vector3 *fval3 = (Vector3*)paramData;
 				cgGLSetParameter3f(param.cgParam, fval3->x,fval3->y,fval3->z);
 				break;

+ 3 - 4
Modules/Contents/GLSL/Include/PolyGLSLProgram.h

@@ -29,7 +29,6 @@ THE SOFTWARE.
 #include "PolyLogger.h"
 #include "PolyResource.h"
 #include "PolyVector3.h"
-#include "PolyUtil.h"
 #include <vector>
 
 
@@ -103,9 +102,9 @@ class _PolyExport GLSLProgramParam {
 	static const int TAU_SPOT_LIGHT_TEXTUREMATRIX_3 = 45;
 	
 	static const int PARAM_UNKNOWN = 0;	
-	static const int PARAM_FLOAT = 1;
-	static const int PARAM_FLOAT3 = 2;
-	static const int PARAM_FLOAT4 = 3;
+	static const int PARAM_Number = 1;
+	static const int PARAM_Number3 = 2;
+	static const int PARAM_Number4 = 3;
 	
 	};
 

+ 6 - 6
Modules/Contents/GLSL/Source/PolyGLSLProgram.cpp

@@ -46,21 +46,21 @@ void GLSLProgram::addParam(String name, bool isAuto, int autoID, int paramType,
 
 void *GLSLProgramParam::createParamData(int *retType, String type, String value) {
 		void *defaultData;
-		if(type == "float") {
-			*retType = GLSLProgramParam::PARAM_FLOAT;
-			float *val = new float();
+		if(type == "Number") {
+			*retType = GLSLProgramParam::PARAM_Number;
+			Number *val = new Number();
 			*val = atof(value.c_str());
 			defaultData = (void*)val;
 			return defaultData;			
-		} else if(type == "float3") {
-			*retType = GLSLProgramParam::PARAM_FLOAT3;
+		} else if(type == "Number3") {
+			*retType = GLSLProgramParam::PARAM_Number3;
 			Vector3 *val = new Vector3();
 			defaultData = (void*)val;
 			vector<String> values = value.split(" ");
 			if(values.size() == 3) {
 				val->set(atof(values[0].c_str()), atof(values[1].c_str()), atof(values[2].c_str()));
 			} else {
-				Logger::log("Error: A float3 must have 3 values (%d provided)!\n", values.size());
+				Logger::log("Error: A Number3 must have 3 values (%d provided)!\n", values.size());
 			}
 			return defaultData;
 		} else {

+ 4 - 4
Modules/Contents/GLSL/Source/PolyGLSLShaderModule.cpp

@@ -298,14 +298,14 @@ void GLSLShaderModule::updateGLSLParam(Renderer *renderer, GLSLProgramParam &par
 		if(localParam)
 			paramData = localParam->data;
 		
-		float *fval;
+		Number *fval;
 		
 		switch(param.paramType) {
-			case GLSLProgramParam::PARAM_FLOAT:
-				fval = (float*)paramData;
+			case GLSLProgramParam::PARAM_Number:
+				fval = (Number*)paramData;
 //				cgGLSetParameter1f(param.cgParam, *fval);
 				break;
-			case GLSLProgramParam::PARAM_FLOAT3:
+			case GLSLProgramParam::PARAM_Number3:
 				Vector3 *fval3 = (Vector3*)paramData;
 //				cgGLSetParameter3f(param.cgParam, fval3->x,fval3->y,fval3->z);
 				break;

+ 1 - 1
Modules/Contents/Kinect/Source/PolycodeKinect.cpp

@@ -46,7 +46,7 @@ PolycodeRunner::PolycodeRunner() : Threaded() {
 	
 	int i;
 	for (i=0; i<2048; i++) {
-		float v = i/2048.0;
+		Number v = i/2048.0;
 		v = powf(v, 3)* 5;
 		t_gamma[i] = v*6*256;
 	}

+ 6 - 6
Modules/Contents/UI/Include/PolyUIBox.h

@@ -18,17 +18,17 @@ namespace Polycode {
 	
 	class _PolyExport UIBox : public ScreenEntity {
 	public:
-		UIBox(String imageFile, float t, float r, float b, float l, float boxWidth, float boxHeight);
+		UIBox(String imageFile, Number t, Number r, Number b, Number l, Number boxWidth, Number boxHeight);
 		~UIBox();
 		
-		void resizeBox(float newWidth, float newHeight);		
+		void resizeBox(Number newWidth, Number newHeight);		
 		
 	private:
 				
-		float t;
-		float r;
-		float b;
-		float l;
+		Number t;
+		Number r;
+		Number b;
+		Number l;
 		
 		ScreenImage *tlImage;
 		ScreenImage *trImage;		

+ 3 - 3
Modules/Contents/UI/Include/PolyUIButton.h

@@ -21,7 +21,7 @@ namespace Polycode {
 
 	class _PolyExport UIButton : public ScreenEntity {
 		public:
-			UIButton(String text, float width, float height = 26);
+			UIButton(String text, Number width, Number height = 26);
 			~UIButton();		
 			void handleEvent(Event *event);
 			
@@ -29,8 +29,8 @@ namespace Polycode {
 				
 		private:
 			
-			float labelXPos;
-			float labelYPos;
+			Number labelXPos;
+			Number labelYPos;
 			UIBox *buttonRect;
 			UIBox *buttonFocusedRect;		
 			ScreenLabel *buttonLabel;

+ 9 - 9
Modules/Contents/UI/Include/PolyUIHScrollBar.h

@@ -14,25 +14,25 @@ namespace Polycode {
 	
 	class _PolyExport UIHScrollBar : public ScreenEntity {
 	public:
-		UIHScrollBar(float width, float height, float initialRatio);
+		UIHScrollBar(Number width, Number height, Number initialRatio);
 		~UIHScrollBar();
 		
 		void Update();
-		float getScrollValue();
+		Number getScrollValue();
 		void handleEvent(Event *event);
 		
-		float minHandleSize;
+		Number minHandleSize;
 		
-		void setHandleRatio(float newRatio);
+		void setHandleRatio(Number newRatio);
 		
 	private:		
 		
 		
-		float padding;
-		float scrollValue;
-		float lastPositionX;
-		float scrollHandleWidth;	
-		float dragRectWidth;
+		Number padding;
+		Number scrollValue;
+		Number lastPositionX;
+		Number scrollHandleWidth;	
+		Number dragRectWidth;
 		
 		UIBox *bgBox;
 		UIBox *handleBox;

+ 10 - 10
Modules/Contents/UI/Include/PolyUIHSlider.h

@@ -20,30 +20,30 @@ namespace Polycode {
 
 	class _PolyExport UIHSlider : public ScreenEntity {
 		public:
-			UIHSlider(Font *font, float start, float end, float width);
+			UIHSlider(Font *font, Number start, Number end, Number width);
 			~UIHSlider();		
 			void handleEvent(Event *event);
 			void Update();
 			
-			void setSliderValue(float val);
-			float getSliderValue();
+			void setSliderValue(Number val);
+			Number getSliderValue();
 			
 			ScreenShape *getBgRect();
 			
 		private:
 		
-			float gripPos;
+			Number gripPos;
 			
-			float labelXPos;
-			float labelYPos;
+			Number labelXPos;
+			Number labelYPos;
 			ScreenShape *bgRect;
 			ScreenShape *gripRect;
 			ScreenShape *shadowRect;
 			
-			float sliderValue;
-			float startValue;
-			float endValue;
-			float sliderWidth;
+			Number sliderValue;
+			Number startValue;
+			Number endValue;
+			Number sliderWidth;
 			
 			ScreenLabel *buttonLabel;
 			bool pressedDown;

+ 7 - 7
Modules/Contents/UI/Include/PolyUIScrollContainer.h

@@ -18,24 +18,24 @@ namespace Polycode {
 	
 	class _PolyExport UIScrollContainer : public ScreenEntity {
 	public:
-		UIScrollContainer(ScreenEntity *scrolledEntity, bool hScroll, bool vScroll, float width, float height);
+		UIScrollContainer(ScreenEntity *scrolledEntity, bool hScroll, bool vScroll, Number width, Number height);
 		~UIScrollContainer();
 		
-		void setContentSize(float newContentWidth, float newContentHeight);
+		void setContentSize(Number newContentWidth, Number newContentHeight);
 		
 		void Resize(int x, int y);
 		
-		void onMouseWheelDown(float x, float y);
-		void onMouseWheelUp(float x, float y);		
+		void onMouseWheelDown(Number x, Number y);
+		void onMouseWheelUp(Number x, Number y);		
 		
 		void handleEvent(Event *event);
 		
 	private:		
 		
-		float defaultScrollSize;
+		Number defaultScrollSize;
 		
-		float contentWidth;
-		float contentHeight;
+		Number contentWidth;
+		Number contentHeight;
 		
 		ScreenEntity *scrollChild;		
 		ScreenShape *maskShape;		

+ 9 - 9
Modules/Contents/UI/Include/PolyUITextInput.h

@@ -24,7 +24,7 @@ namespace Polycode {
 
 	class _PolyExport UITextInput : public ScreenEntity {
 		public:
-			UITextInput(bool multiLine, float width, float height);
+			UITextInput(bool multiLine, Number width, Number height);
 			~UITextInput();
 		
 			void handleEvent(Event *event);
@@ -57,8 +57,8 @@ namespace Polycode {
 		
 			void selectLineFromOffset();
 			void updateCaretPosition();
-			void setCaretToMouse(float x, float y);
-			void dragSelectionTo(float x, float y);		
+			void setCaretToMouse(Number x, Number y);
+			void dragSelectionTo(Number x, Number y);		
 		
 			void selectWordAtCaret();
 		
@@ -70,8 +70,8 @@ namespace Polycode {
 			ScreenShape *selectorRectBottom;		
 			int numLines;
 			
-			float padding;
-			float lineSpacing;
+			Number padding;
+			Number lineSpacing;
 		
 			int selectionTop;
 			int selectionBottom;
@@ -83,7 +83,7 @@ namespace Polycode {
 		
 			bool draggingSelection;
 			bool hasSelection; 
-			float caretX,caretY;
+			Number caretX,caretY;
 		
 			int caretPosition;
 			bool doSelectToCaret;
@@ -93,12 +93,12 @@ namespace Polycode {
 			UIBox *inputRect;
 			ScreenShape *blinkerRect;
 		
-			float caretImagePosition;
+			Number caretImagePosition;
 		
 			String fontName;
-			float fontSize;
+			Number fontSize;
 		
-			float lineHeight;
+			Number lineHeight;
 		
 			int lineOffset;
 			ScreenLabel *currentLine;		

+ 7 - 7
Modules/Contents/UI/Include/PolyUITree.h

@@ -25,7 +25,7 @@ namespace Polycode {
 
 	class _PolyExport UITree : public ScreenEntity {
 		public:
-			UITree(String icon, String text, float treeWidth, float treeOffset=0);
+			UITree(String icon, String text, Number treeWidth, Number treeOffset=0);
 			~UITree();
 			
 			void handleEvent(Event *event);
@@ -33,7 +33,7 @@ namespace Polycode {
 			UITree *addTreeChild(String icon, String text, void *userData = NULL);
 			void Update();
 			void refreshTree();
-			float getTreeHeight();
+			Number getTreeHeight();
 			void setParent(UITree *parent);
 			void clearSelection(UITree *selectedNode);
 			bool isCollapsed();
@@ -52,8 +52,8 @@ namespace Polycode {
 		private:
 		
 			void *userData;
-			float treeWidth;
-			float treeOffset;
+			Number treeWidth;
+			Number treeOffset;
 			UITree *selectedNode;
 			UITree *parent;
 			UIBox *selection;
@@ -62,7 +62,7 @@ namespace Polycode {
 			ScreenLabel *textLabel;
 			ScreenImage *iconImage;
 			bool selected;
-			float treeHeight;
+			Number treeHeight;
 			vector<UITree*> treeChildren;
 			bool collapsed;
 			bool collapsing;
@@ -70,7 +70,7 @@ namespace Polycode {
 			String arrowIcon;
 			String fontName;
 			int size;
-			float cellHeight;
-			float cellPadding;
+			Number cellHeight;
+			Number cellPadding;
 	};
 }

+ 1 - 1
Modules/Contents/UI/Include/PolyUITreeContainer.h

@@ -19,7 +19,7 @@ namespace Polycode {
 	
 	class _PolyExport UITreeContainer : public ScreenEntity {
 	public:
-		UITreeContainer(String icon, String text, float treeWidth, float treeHeight);
+		UITreeContainer(String icon, String text, Number treeWidth, Number treeHeight);
 		~UITreeContainer();
 		
 		void handleEvent(Event *event);

+ 11 - 11
Modules/Contents/UI/Include/PolyUIVScrollBar.h

@@ -15,34 +15,34 @@ namespace Polycode {
 	
 	class _PolyExport UIVScrollBar : public ScreenEntity {
 	public:
-		UIVScrollBar(float width, float height, float initialRatio);
+		UIVScrollBar(Number width, Number height, Number initialRatio);
 		~UIVScrollBar();
 		
 		void Update();
-		float getScrollValue();
+		Number getScrollValue();
 		void handleEvent(Event *event);
 		
 		void Resize(int newHeight);
 		
-		void onMouseWheelDown(float x, float y);
-		void onMouseWheelUp(float x, float y);
+		void onMouseWheelDown(Number x, Number y);
+		void onMouseWheelUp(Number x, Number y);
 		
 		void scrollUpOneTick();
 		void scrollDownOneTick();
 		
-		float minHandleSize;
+		Number minHandleSize;
 		
-		void setHandleRatio(float newRatio);
+		void setHandleRatio(Number newRatio);
 
 		
 	private:		
 		
 		
-		float padding;
-		float scrollValue;
-		float lastPositionY;
-		float scrollHandleHeight;	
-		float dragRectHeight;
+		Number padding;
+		Number scrollValue;
+		Number lastPositionY;
+		Number scrollHandleHeight;	
+		Number dragRectHeight;
 		
 		UIBox *bgBox;
 		UIBox *handleBox;

+ 5 - 5
Modules/Contents/UI/Include/PolyUIWindow.h

@@ -25,7 +25,7 @@ namespace Polycode {
 
 	class _PolyExport UIWindow : public ScreenEntity {
 		public:
-			UIWindow(String windowName, float width, float height);
+			UIWindow(String windowName, Number width, Number height);
 			~UIWindow();
 			
 			void showWindow();
@@ -34,14 +34,14 @@ namespace Polycode {
 			virtual void onClose(){}
 			void onLoseFocus();
 			
-			void setWindowSize(float w, float h);
+			void setWindowSize(Number w, Number h);
 			
-			void onMouseDown(float x, float y);
+			void onMouseDown(Number x, Number y);
 					
 			virtual void handleEvent(Event *event);
 		
-			float padding;
-			float topPadding;
+			Number padding;
+			Number topPadding;
 		
 			bool closeOnEscape;
 		

+ 2 - 2
Modules/Contents/UI/Source/PolyUIBox.cpp

@@ -11,7 +11,7 @@
 
 using namespace Polycode;
 
-UIBox::UIBox(String imageFile, float t, float r, float b, float l, float boxWidth, float boxHeight) : ScreenEntity() {
+UIBox::UIBox(String imageFile, Number t, Number r, Number b, Number l, Number boxWidth, Number boxHeight) : ScreenEntity() {
 	
 	setPositionMode(ScreenEntity::POSITION_TOPLEFT);	
 	
@@ -76,7 +76,7 @@ UIBox::UIBox(String imageFile, float t, float r, float b, float l, float boxWidt
 	this->l = l;	
 }
 
-void UIBox::resizeBox(float newWidth, float newHeight) {
+void UIBox::resizeBox(Number newWidth, Number newHeight) {
 	brImage->setPosition(newWidth-brImage->getWidth(), newHeight-brImage->getHeight());
 	trImage->setPosition(newWidth-trImage->getWidth(), 0);
 	blImage->setPosition(0, newHeight-blImage->getHeight());

+ 5 - 5
Modules/Contents/UI/Source/PolyUIButton.cpp

@@ -12,17 +12,17 @@
 
 using namespace Polycode;
 
-UIButton::UIButton(String text, float width, float height) : ScreenEntity() {
+UIButton::UIButton(String text, Number width, Number height) : ScreenEntity() {
 
 	Config *conf = CoreServices::getInstance()->getConfig();	
 	
 	String fontName = conf->getStringValue("Polycode", "uiDefaultFontName");
 	int fontSize = conf->getNumericValue("Polycode", "uiButtonFontSize");	
 	
-	float st = conf->getNumericValue("Polycode", "uiButtonSkinT");
-	float sr = conf->getNumericValue("Polycode", "uiButtonSkinR");
-	float sb = conf->getNumericValue("Polycode", "uiButtonSkinB");
-	float sl = conf->getNumericValue("Polycode", "uiButtonSkinL");
+	Number st = conf->getNumericValue("Polycode", "uiButtonSkinT");
+	Number sr = conf->getNumericValue("Polycode", "uiButtonSkinR");
+	Number sb = conf->getNumericValue("Polycode", "uiButtonSkinB");
+	Number sl = conf->getNumericValue("Polycode", "uiButtonSkinL");
 	
 	
 	buttonRect = new UIBox(conf->getStringValue("Polycode", "uiButtonSkin"),

+ 9 - 9
Modules/Contents/UI/Source/PolyUIHScrollBar.cpp

@@ -12,7 +12,7 @@
 
 using namespace Polycode;
 
-UIHScrollBar::UIHScrollBar(float width, float height, float initialRatio) : ScreenEntity() {
+UIHScrollBar::UIHScrollBar(Number width, Number height, Number initialRatio) : ScreenEntity() {
 	
 	scrollValue = 0;
 	
@@ -20,10 +20,10 @@ UIHScrollBar::UIHScrollBar(float width, float height, float initialRatio) : Scre
 	
 	minHandleSize = conf->getNumericValue("Polycode", "uiScrollHandleMinSize");
 	
-	float st = conf->getNumericValue("Polycode", "uiScrollBgSkinT");
-	float sr = conf->getNumericValue("Polycode", "uiScrollBgSkinR");
-	float sb = conf->getNumericValue("Polycode", "uiScrollBgSkinB");
-	float sl = conf->getNumericValue("Polycode", "uiScrollBgSkinL");	
+	Number st = conf->getNumericValue("Polycode", "uiScrollBgSkinT");
+	Number sr = conf->getNumericValue("Polycode", "uiScrollBgSkinR");
+	Number sb = conf->getNumericValue("Polycode", "uiScrollBgSkinB");
+	Number sl = conf->getNumericValue("Polycode", "uiScrollBgSkinL");	
 	padding = conf->getNumericValue("Polycode", "uiScrollBgSkinPadding");		
 	
 	bgBox = new UIBox(conf->getStringValue("Polycode", "uiScrollBgSkin"),
@@ -79,7 +79,7 @@ void UIHScrollBar::Update() {
 	}
 }
 
-void UIHScrollBar::setHandleRatio(float newRatio) {
+void UIHScrollBar::setHandleRatio(Number newRatio) {
 	scrollHandleWidth = width*newRatio;	
 	
 	if(scrollHandleWidth < minHandleSize)
@@ -91,7 +91,7 @@ void UIHScrollBar::setHandleRatio(float newRatio) {
 	handleBox->setDragLimits(Rectangle(padding,padding,dragRectWidth, height-(padding*2)-(height-(padding*2))));	
 }
 
-float UIHScrollBar::getScrollValue() {
+Number UIHScrollBar::getScrollValue() {
 	return scrollValue;
 }
 
@@ -101,12 +101,12 @@ void UIHScrollBar::handleEvent(Event *event) {
 		switch(event->getEventCode()) {
 			case InputEvent::EVENT_MOUSEDOWN:
 				if(inputEvent->mousePosition.x < handleBox->getPosition().x)  {
-					float newPos = handleBox->getPosition().x - scrollHandleWidth;
+					Number newPos = handleBox->getPosition().x - scrollHandleWidth;
 					if(newPos < padding)
 						newPos = padding;
 					handleBox->setPositionX(newPos);
 				} else {
-					float newPos = handleBox->getPosition().x + scrollHandleWidth;
+					Number newPos = handleBox->getPosition().x + scrollHandleWidth;
 					if(newPos > dragRectWidth)
 						newPos = dragRectWidth;
 					handleBox->setPositionX(newPos);					

+ 3 - 3
Modules/Contents/UI/Source/PolyUIHSlider.cpp

@@ -12,7 +12,7 @@
 
 using namespace Polycode;
 
-UIHSlider::UIHSlider(Font *font, float start, float end, float width) {
+UIHSlider::UIHSlider(Font *font, Number start, Number end, Number width) {
 	bgRect = new ScreenShape(ScreenShape::SHAPE_RECT, width,8,0,0);
 	bgRect->setPosition(0,6);
 	bgRect->setColor(0.11f, 0.11f, 0.11f, 1.0f);
@@ -56,14 +56,14 @@ ScreenShape *UIHSlider::getBgRect() {
 	return bgRect;
 }
 
-void UIHSlider::setSliderValue(float val) {
+void UIHSlider::setSliderValue(Number val) {
 	if(val >= startValue && val <= endValue) {
 		gripRect->getPosition().x = sliderWidth * ((val-startValue)/(endValue-startValue));
 		shadowRect->getPosition().x = gripRect->getPosition().x;
 	}
 }
 
-float UIHSlider::getSliderValue() {
+Number UIHSlider::getSliderValue() {
 	return sliderValue;
 }
 			

+ 5 - 5
Modules/Contents/UI/Source/PolyUIScrollContainer.cpp

@@ -11,7 +11,7 @@
 
 using namespace Polycode;
 
-UIScrollContainer::UIScrollContainer(ScreenEntity *scrolledEntity, bool hScroll, bool vScroll, float width, float height) : ScreenEntity() {
+UIScrollContainer::UIScrollContainer(ScreenEntity *scrolledEntity, bool hScroll, bool vScroll, Number width, Number height) : ScreenEntity() {
 	
 	scrolledEntity->setPositionMode(ScreenEntity::POSITION_TOPLEFT);
 	
@@ -27,7 +27,7 @@ UIScrollContainer::UIScrollContainer(ScreenEntity *scrolledEntity, bool hScroll,
 	this->hitwidth = width;
 	this->hitheight = height;
 	
-	float uiScrollPanePadding = conf->getNumericValue("Polycode", "uiScrollPanePadding");			
+	Number uiScrollPanePadding = conf->getNumericValue("Polycode", "uiScrollPanePadding");			
 	
 	defaultScrollSize = conf->getNumericValue("Polycode", "uiScrollDefaultSize");			
 	
@@ -75,18 +75,18 @@ void UIScrollContainer::Resize(int x, int y) {
 	vScrollBar->setPositionY(0);
 }
 
-void UIScrollContainer::onMouseWheelUp(float x, float y) {
+void UIScrollContainer::onMouseWheelUp(Number x, Number y) {
 	if(vScrollBar->enabled)
 		vScrollBar->scrollUpOneTick();
 }
 
-void UIScrollContainer::onMouseWheelDown(float x, float y) {
+void UIScrollContainer::onMouseWheelDown(Number x, Number y) {
 	if(vScrollBar->enabled)
 		vScrollBar->scrollDownOneTick();
 }
 
 
-void UIScrollContainer::setContentSize(float newContentWidth, float newContentHeight) {
+void UIScrollContainer::setContentSize(Number newContentWidth, Number newContentHeight) {
 	
 	contentHeight = newContentHeight;
 	contentWidth = newContentWidth;

+ 16 - 16
Modules/Contents/UI/Source/PolyUITextInput.cpp

@@ -12,7 +12,7 @@
 
 using namespace Polycode;
 
-UITextInput::UITextInput(bool multiLine, float width, float height) : ScreenEntity() {
+UITextInput::UITextInput(bool multiLine, Number width, Number height) : ScreenEntity() {
 	this->multiLine = multiLine;
 	
 	draggingSelection = false;
@@ -38,17 +38,17 @@ UITextInput::UITextInput(bool multiLine, float width, float height) : ScreenEnti
 	
 	fontSize = conf->getNumericValue("Polycode", "uiTextInputFontSize");
 	
-	float rectHeight = height;
+	Number rectHeight = height;
 	if(!multiLine) {
 		rectHeight = fontSize+12;
 	} 
 	
 	lineSpacing = conf->getNumericValue("Polycode", "textEditLineSpacing");
 	
-	float st = conf->getNumericValue("Polycode", "textBgSkinT");
-	float sr = conf->getNumericValue("Polycode", "textBgSkinR");
-	float sb = conf->getNumericValue("Polycode", "textBgSkinB");
-	float sl = conf->getNumericValue("Polycode", "textBgSkinL");
+	Number st = conf->getNumericValue("Polycode", "textBgSkinT");
+	Number sr = conf->getNumericValue("Polycode", "textBgSkinR");
+	Number sb = conf->getNumericValue("Polycode", "textBgSkinB");
+	Number sl = conf->getNumericValue("Polycode", "textBgSkinL");
 	
 	padding = conf->getNumericValue("Polycode", "textBgSkinPadding");	
 	
@@ -157,12 +157,12 @@ void UITextInput::setSelection(int lineStart, int lineEnd, int colStart, int col
 	if(colStart+1 > topLine->getText().length())
 		return;
 	
-	float fColEnd  = colEnd;
+	Number fColEnd  = colEnd;
 	
 	if(colEnd > topLine->getText().length() || lineStart != lineEnd)
 		fColEnd = topLine->getText().length();
 
-	float topSize, topHeight, topX;
+	Number topSize, topHeight, topX;
 	
 	selectorRectTop->visible = true;	
 	topSize = topLine->getLabel()->getTextWidth(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), topLine->getText().substr(colStart,fColEnd-colStart), fontSize) - 4; 
@@ -179,16 +179,16 @@ void UITextInput::setSelection(int lineStart, int lineEnd, int colStart, int col
 	if(lineEnd > lineStart && lineEnd < lines.size()) {
 		ScreenLabel *bottomLine = lines[lineEnd];	
 		selectorRectBottom->visible = true;		
-		float bottomSize = bottomLine->getLabel()->getTextWidth(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), bottomLine->getText().substr(0,colEnd), fontSize) - 4; 
-		float bottomHeight = lineHeight+lineSpacing;
+		Number bottomSize = bottomLine->getLabel()->getTextWidth(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), bottomLine->getText().substr(0,colEnd), fontSize) - 4; 
+		Number bottomHeight = lineHeight+lineSpacing;
 		selectorRectBottom->setScale(bottomSize, bottomHeight);
 		selectorRectBottom->setPosition(padding + (bottomSize/2.0) + 1, padding + (lineEnd * (lineHeight+lineSpacing)) + (bottomHeight/2.0));
 		
 		if(lineEnd != lineStart+1) {
 			// need filler
 			selectorRectMiddle->visible = true;		
-			float midSize = this->width-padding;
-			float midHeight = 0;			
+			Number midSize = this->width-padding;
+			Number midHeight = 0;			
 			for(int i=lineStart+1; i < lineEnd;i++) {
 				midHeight += lineHeight+lineSpacing;
 			}
@@ -367,7 +367,7 @@ void UITextInput::selectLineFromOffset() {
 	}
 }
 
-void UITextInput::dragSelectionTo(float x, float y) {
+void UITextInput::dragSelectionTo(Number x, Number y) {
 	x -= padding;
 	y -= padding;
 	int lineOffset = y  / (lineHeight+lineSpacing);
@@ -377,7 +377,7 @@ void UITextInput::dragSelectionTo(float x, float y) {
 	ScreenLabel *selectToLine = lines[lineOffset];
 	
 	int len = selectToLine->getText().length();
-	float slen;
+	Number slen;
 	int caretPosition = selectToLine->getLabel()->getTextWidth(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), selectToLine->getText().substr(0,len), fontSize);
 	for(int i=0; i < len; i++) {
 		slen = selectToLine->getLabel()->getTextWidth(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), selectToLine->getText().substr(0,i), fontSize);
@@ -446,7 +446,7 @@ void UITextInput::selectWordAtCaret() {
 	setSelection(this->lineOffset, this->lineOffset, selectStart, selectEnd);
 }
 
-void UITextInput::setCaretToMouse(float x, float y) {
+void UITextInput::setCaretToMouse(Number x, Number y) {
 	clearSelection();
 	x -= padding;
 	y -= padding;
@@ -458,7 +458,7 @@ void UITextInput::setCaretToMouse(float x, float y) {
 	//}
 	
 	int len = currentLine->getText().length();
-	float slen;
+	Number slen;
 	for(int i=0; i < len; i++) {
 		slen = currentLine->getLabel()->getTextWidth(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), currentLine->getText().substr(0,i), fontSize);
 		if(slen > x) {

+ 12 - 12
Modules/Contents/UI/Source/PolyUITree.cpp

@@ -12,7 +12,7 @@
 
 using namespace Polycode;
 
-UITree::UITree(String icon, String text, float treeWidth, float treeOffset) : ScreenEntity() {
+UITree::UITree(String icon, String text, Number treeWidth, Number treeOffset) : ScreenEntity() {
 		
 	
 	Config *conf = CoreServices::getInstance()->getConfig();
@@ -33,12 +33,12 @@ UITree::UITree(String icon, String text, float treeWidth, float treeOffset) : Sc
 								Label::ANTIALIAS_FULL);
 
 /*	
-	float st = conf->getNumericValue("Polycode", "uiTreeCellSkinT");
-	float sr = conf->getNumericValue("Polycode", "uiTreeCellSkinR");
-	float sb = conf->getNumericValue("Polycode", "uiTreeCellSkinB");
-	float sl = conf->getNumericValue("Polycode", "uiTreeCellSkinL");	
+	Number st = conf->getNumericValue("Polycode", "uiTreeCellSkinT");
+	Number sr = conf->getNumericValue("Polycode", "uiTreeCellSkinR");
+	Number sb = conf->getNumericValue("Polycode", "uiTreeCellSkinB");
+	Number sl = conf->getNumericValue("Polycode", "uiTreeCellSkinL");	
 	
-	float padding = conf->getNumericValue("Polycode", "uiTreeCellSkinPadding");	
+	Number padding = conf->getNumericValue("Polycode", "uiTreeCellSkinPadding");	
 	
 	bgBox = new UIBox(conf->getStringValue("Polycode", "uiTreeCellSkin"),
 						  st,sr,sb,sl,
@@ -51,12 +51,12 @@ UITree::UITree(String icon, String text, float treeWidth, float treeOffset) : Sc
 	addChild(bgBox);
 	
 	
-	float st = conf->getNumericValue("Polycode", "uiTreeCellSelectorSkinT");
-	float sr = conf->getNumericValue("Polycode", "uiTreeCellSelectorSkinR");
-	float sb = conf->getNumericValue("Polycode", "uiTreeCellSelectorSkinB");
-	float sl = conf->getNumericValue("Polycode", "uiTreeCellSelectorSkinL");
+	Number st = conf->getNumericValue("Polycode", "uiTreeCellSelectorSkinT");
+	Number sr = conf->getNumericValue("Polycode", "uiTreeCellSelectorSkinR");
+	Number sb = conf->getNumericValue("Polycode", "uiTreeCellSelectorSkinB");
+	Number sl = conf->getNumericValue("Polycode", "uiTreeCellSelectorSkinL");
 	
-	float padding = conf->getNumericValue("Polycode", "uiTreeCellSelectorSkinPadding");	
+	Number padding = conf->getNumericValue("Polycode", "uiTreeCellSelectorSkinPadding");	
 	
 	selection = new UIBox(conf->getStringValue("Polycode", "uiTreeCellSelectorSkin"),
 						  st,sr,sb,sl,
@@ -215,7 +215,7 @@ void UITree::refreshTree() {
 	selection->visible = selected;
 }
 
-float UITree::getTreeHeight() {
+Number UITree::getTreeHeight() {
 	return treeHeight;
 }
 

+ 7 - 7
Modules/Contents/UI/Source/PolyUITreeContainer.cpp

@@ -11,17 +11,17 @@
 
 using namespace Polycode;
 
-UITreeContainer::UITreeContainer(String icon, String text, float treeWidth, float treeHeight) : ScreenEntity() {
+UITreeContainer::UITreeContainer(String icon, String text, Number treeWidth, Number treeHeight) : ScreenEntity() {
 	
 	Config *conf = CoreServices::getInstance()->getConfig();
 	
-	float st = conf->getNumericValue("Polycode", "uiTreeContainerSkinT");
-	float sr = conf->getNumericValue("Polycode", "uiTreeContainerSkinR");
-	float sb = conf->getNumericValue("Polycode", "uiTreeContainerSkinB");
-	float sl = conf->getNumericValue("Polycode", "uiTreeContainerSkinL");	
-	float padding = conf->getNumericValue("Polycode", "uiTreeContainerSkinPadding");	
+	Number st = conf->getNumericValue("Polycode", "uiTreeContainerSkinT");
+	Number sr = conf->getNumericValue("Polycode", "uiTreeContainerSkinR");
+	Number sb = conf->getNumericValue("Polycode", "uiTreeContainerSkinB");
+	Number sl = conf->getNumericValue("Polycode", "uiTreeContainerSkinL");	
+	Number padding = conf->getNumericValue("Polycode", "uiTreeContainerSkinPadding");	
 	
-//	float scrollBarOffset = conf->getNumericValue("Polycode", "uiTreeContainerScrollBarOffset");	
+//	Number scrollBarOffset = conf->getNumericValue("Polycode", "uiTreeContainerScrollBarOffset");	
 	
 	bgBox = new UIBox(conf->getStringValue("Polycode", "uiTreeContainerSkin"),
 						  st,sr,sb,sl,

+ 13 - 13
Modules/Contents/UI/Source/PolyUIVScrollBar.cpp

@@ -12,7 +12,7 @@
 
 using namespace Polycode;
 
-UIVScrollBar::UIVScrollBar(float width, float height, float initialRatio) : ScreenEntity() {
+UIVScrollBar::UIVScrollBar(Number width, Number height, Number initialRatio) : ScreenEntity() {
 
 	scrollValue = 0;
 	
@@ -20,10 +20,10 @@ UIVScrollBar::UIVScrollBar(float width, float height, float initialRatio) : Scre
 	
 	minHandleSize = conf->getNumericValue("Polycode", "uiScrollHandleMinSize");
 	
-	float st = conf->getNumericValue("Polycode", "uiScrollBgSkinT");
-	float sr = conf->getNumericValue("Polycode", "uiScrollBgSkinR");
-	float sb = conf->getNumericValue("Polycode", "uiScrollBgSkinB");
-	float sl = conf->getNumericValue("Polycode", "uiScrollBgSkinL");	
+	Number st = conf->getNumericValue("Polycode", "uiScrollBgSkinT");
+	Number sr = conf->getNumericValue("Polycode", "uiScrollBgSkinR");
+	Number sb = conf->getNumericValue("Polycode", "uiScrollBgSkinB");
+	Number sl = conf->getNumericValue("Polycode", "uiScrollBgSkinL");	
 	padding = conf->getNumericValue("Polycode", "uiScrollBgSkinPadding");		
 		
 	bgBox = new UIBox(conf->getStringValue("Polycode", "uiScrollBgSkin"),
@@ -90,7 +90,7 @@ void UIVScrollBar::Update() {
 	}
 }
 
-void UIVScrollBar::setHandleRatio(float newRatio) {
+void UIVScrollBar::setHandleRatio(Number newRatio) {
 	scrollHandleHeight = height*newRatio;	
 	
 	if(scrollHandleHeight < minHandleSize)
@@ -101,16 +101,16 @@ void UIVScrollBar::setHandleRatio(float newRatio) {
 	handleBox->setDragLimits(Rectangle(padding,padding,width-(padding*2)-(width-(padding*2)), dragRectHeight));	
 }
 
-void UIVScrollBar::onMouseWheelUp(float x, float y) {
+void UIVScrollBar::onMouseWheelUp(Number x, Number y) {
 	scrollUpOneTick();
 }
 
-void UIVScrollBar::onMouseWheelDown(float x, float y) {
+void UIVScrollBar::onMouseWheelDown(Number x, Number y) {
 	scrollDownOneTick();
 }
 
 void UIVScrollBar::scrollUpOneTick() {
-	float newPos = handleBox->getPosition().y - 5;
+	Number newPos = handleBox->getPosition().y - 5;
 	
 	if(newPos < padding)
 		newPos = padding;
@@ -119,7 +119,7 @@ void UIVScrollBar::scrollUpOneTick() {
 }
 
 void UIVScrollBar::scrollDownOneTick() {
-	float newPos = handleBox->getPosition().y + 5;	
+	Number newPos = handleBox->getPosition().y + 5;	
 	
 	if(newPos > dragRectHeight)
 		newPos = dragRectHeight;
@@ -128,7 +128,7 @@ void UIVScrollBar::scrollDownOneTick() {
 }
 
 
-float UIVScrollBar::getScrollValue() {
+Number UIVScrollBar::getScrollValue() {
 	return scrollValue;
 }
 
@@ -138,12 +138,12 @@ void UIVScrollBar::handleEvent(Event *event) {
 		switch(event->getEventCode()) {
 			case InputEvent::EVENT_MOUSEDOWN:
 				if(inputEvent->mousePosition.y < handleBox->getPosition().y)  {
-					float newPos = handleBox->getPosition().y - scrollHandleHeight;
+					Number newPos = handleBox->getPosition().y - scrollHandleHeight;
 					if(newPos < padding)
 						newPos = padding;
 					handleBox->setPositionY(newPos);
 				} else {
-					float newPos = handleBox->getPosition().y + scrollHandleHeight;
+					Number newPos = handleBox->getPosition().y + scrollHandleHeight;
 					if(newPos > dragRectHeight)
 						newPos = dragRectHeight;
 					handleBox->setPositionY(newPos);					

+ 7 - 7
Modules/Contents/UI/Source/PolyUIWindow.cpp

@@ -13,7 +13,7 @@
 using namespace Polycode;
 
 
-UIWindow::UIWindow(String windowName, float width, float height) : ScreenEntity() {
+UIWindow::UIWindow(String windowName, Number width, Number height) : ScreenEntity() {
 	
 	closeOnEscape = false;
 	
@@ -24,10 +24,10 @@ UIWindow::UIWindow(String windowName, float width, float height) : ScreenEntity(
 	String fontName = conf->getStringValue("Polycode", "uiWindowTitleFont");
 	int fontSize = conf->getNumericValue("Polycode", "uiWindowTitleFontSize");	
 	
-	float st = conf->getNumericValue("Polycode", "uiWindowSkinT");
-	float sr = conf->getNumericValue("Polycode", "uiWindowSkinR");
-	float sb = conf->getNumericValue("Polycode", "uiWindowSkinB");
-	float sl = conf->getNumericValue("Polycode", "uiWindowSkinL");
+	Number st = conf->getNumericValue("Polycode", "uiWindowSkinT");
+	Number sr = conf->getNumericValue("Polycode", "uiWindowSkinR");
+	Number sb = conf->getNumericValue("Polycode", "uiWindowSkinB");
+	Number sl = conf->getNumericValue("Polycode", "uiWindowSkinL");
 	
 	topPadding = st;
 	
@@ -65,7 +65,7 @@ UIWindow::UIWindow(String windowName, float width, float height) : ScreenEntity(
 	blockMouseInput = true;
 }
 
-void UIWindow::setWindowSize(float w, float h) {
+void UIWindow::setWindowSize(Number w, Number h) {
 //	windowRect->setScale(w/windowRect->getWidth(), h/windowRect->getHeight());
 //	shadowRect->setScale(w/shadowRect->getWidth(), h/shadowRect->getHeight());
 //	titlebarRect->setScale((w-4)/titlebarRect->getWidth(), 1.0f);
@@ -97,7 +97,7 @@ void UIWindow::onLoseFocus() {
 		}
 }
 
-void UIWindow::onMouseDown(float x, float y) {
+void UIWindow::onMouseDown(Number x, Number y) {
 	if(hasFocus)
 		return;
 	hasFocus = true;

+ 6 - 0
Player/Build/Mac OS X/Polycode Player.xcodeproj/project.pbxproj

@@ -13,6 +13,7 @@
 		6D34133512B7FC760034FA9B /* libphysfs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D34133412B7FC760034FA9B /* libphysfs.a */; };
 		6D34134112B7FCD00034FA9B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D34134012B7FCD00034FA9B /* IOKit.framework */; };
 		6D34153C12B82C7A0034FA9B /* liblua.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D34153B12B82C7A0034FA9B /* liblua.a */; };
+		6D3F98FF1380F973002AC8AE /* libPolycodeGLSL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3F98FE1380F973002AC8AE /* libPolycodeGLSL.a */; };
 		6DBAB07E12B6EAAD00986D01 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6DBAB07712B6EAAD00986D01 /* libfreetype.a */; };
 		6DBAB07F12B6EAAD00986D01 /* libz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6DBAB07812B6EAAD00986D01 /* libz.a */; };
 		6DBAB08012B6EAAD00986D01 /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6DBAB07912B6EAAD00986D01 /* libpng.a */; };
@@ -53,6 +54,7 @@
 		6D34133412B7FC760034FA9B /* libphysfs.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libphysfs.a; path = ../../../Core/Dependencies/physfs/Debug/libphysfs.a; sourceTree = SOURCE_ROOT; };
 		6D34134012B7FCD00034FA9B /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
 		6D34153B12B82C7A0034FA9B /* liblua.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua.a; path = ../../../Core/Dependencies/lua/src/liblua.a; sourceTree = SOURCE_ROOT; };
+		6D3F98FE1380F973002AC8AE /* libPolycodeGLSL.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libPolycodeGLSL.a; path = "../../../../../../Library/Developer/Xcode/DerivedData/Modules-epduxiffqrcazabvaazmexadjpgk/Build/Products/Debug/libPolycodeGLSL.a"; sourceTree = "<group>"; };
 		6DBAB07712B6EAAD00986D01 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfreetype.a; path = ../../../Core/Dependencies/freetype/libfreetype.a; sourceTree = SOURCE_ROOT; };
 		6DBAB07812B6EAAD00986D01 /* libz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libz.a; path = ../../../Core/Dependencies/zlib/libz.a; sourceTree = SOURCE_ROOT; };
 		6DBAB07912B6EAAD00986D01 /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng.a; path = ../../../Core/Dependencies/libpng/libpng.a; sourceTree = SOURCE_ROOT; };
@@ -185,6 +187,7 @@
 				6DD40F8413736CF200D602D3 /* libogg.a in Frameworks */,
 				6DD40F8613736CF900D602D3 /* libvorbis.a in Frameworks */,
 				6DD40F8A13736D0C00D602D3 /* libvorbisfile.a in Frameworks */,
+				6D3F98FF1380F973002AC8AE /* libPolycodeGLSL.a in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -281,6 +284,7 @@
 		2A37F4C3FDCFA73011CA2CEA /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				6D3F98FE1380F973002AC8AE /* libPolycodeGLSL.a */,
 				6DD40F8913736D0C00D602D3 /* libvorbisfile.a */,
 				6DD40F8513736CF900D602D3 /* libvorbis.a */,
 				6DD40F8313736CF200D602D3 /* libogg.a */,
@@ -585,6 +589,7 @@
 					"\"$(SRCROOT)/../../../../../../Library/Developer/Xcode/DerivedData/Ogg-dehvynarqzqpyfeqgzpikemxralf/Build/Products/Debug\"",
 					"\"$(SRCROOT)/../../../../../../Library/Developer/Xcode/DerivedData/Ogg-hciijcupphkumzcznsrkjblfzoze/Build/Products/Debug\"",
 					"\"$(SRCROOT)/../../../../../../Library/Developer/Xcode/DerivedData/Vorbis-ajdgxoyxsyfhmzbffuvabiolqjkv/Build/Products/Debug\"",
+					"\"$(SRCROOT)/../../../../../../Library/Developer/Xcode/DerivedData/Modules-epduxiffqrcazabvaazmexadjpgk/Build/Products/Debug\"",
 				);
 				PRODUCT_NAME = "Polycode Player";
 			};
@@ -618,6 +623,7 @@
 					"\"$(SRCROOT)/../../../../../../Library/Developer/Xcode/DerivedData/Ogg-dehvynarqzqpyfeqgzpikemxralf/Build/Products/Debug\"",
 					"\"$(SRCROOT)/../../../../../../Library/Developer/Xcode/DerivedData/Ogg-hciijcupphkumzcznsrkjblfzoze/Build/Products/Debug\"",
 					"\"$(SRCROOT)/../../../../../../Library/Developer/Xcode/DerivedData/Vorbis-ajdgxoyxsyfhmzbffuvabiolqjkv/Build/Products/Debug\"",
+					"\"$(SRCROOT)/../../../../../../Library/Developer/Xcode/DerivedData/Modules-epduxiffqrcazabvaazmexadjpgk/Build/Products/Debug\"",
 				);
 				ONLY_ACTIVE_ARCH = YES;
 				PRODUCT_NAME = "Polycode Player";

Разница между файлами не показана из-за своего большого размера
+ 227 - 433
Player/Build/Mac OS X/Polycode Player.xcodeproj/project.xcworkspace/xcuserdata/ivansafrin.xcuserdatad/UserInterfaceState.xcuserstate


+ 3 - 0
Player/Contents/Include/PolycodePlayer.h

@@ -27,6 +27,7 @@ THE SOFTWARE.
 
 #include "Polycode.h"
 #include "PolycodeLUA.h"
+#include "PolyGLSLShaderModule.h"
 
 extern "C" {	
 #include <stdio.h>
@@ -92,6 +93,8 @@ protected:
 	
 	lua_State *L;		
 	
+	std::vector<String> loadedModules;
+	
 	bool _knownArchive;
 	String fileToRun;
 	

+ 56 - 2
Player/Contents/Source/PolycodePlayer.mm

@@ -155,6 +155,29 @@ extern "C" {
 		lua_getfield(L, LUA_GLOBALSINDEX, "require");
 		lua_pushstring(L, "defaults");		
 		lua_call(L, 1, 0);
+		
+		for(int i=0; i < loadedModules.size(); i++) {
+			String moduleName = loadedModules[i];
+			String moduleDestPath = String("/tmp/") + moduleName+ String(".dylib");
+			String moduleLoadCall = String("luaopen_") + moduleName;
+			lua_getfield(L, LUA_GLOBALSINDEX, "require");
+			lua_pushstring(L, moduleName.c_str());		
+			lua_call(L, 1, 0);
+
+			lua_getfield(L, LUA_GLOBALSINDEX, "package");
+			lua_getfield(L, -1, "loadlib");	
+			lua_pushstring(L, moduleDestPath.c_str());
+			lua_pushstring(L, moduleLoadCall.c_str());			
+			lua_call(L, 2, 1);
+			lua_setfield(L, LUA_GLOBALSINDEX, "f");			
+			
+			lua_getfield(L, LUA_GLOBALSINDEX, "f");
+			lua_getfield(L, LUA_GLOBALSINDEX, "__core__services__instance");						
+			lua_call(L, 1, 0);			
+			//local f = package.loadlib("/Users/ivansafrin/Desktop/Workshop/HelloPolycodeLUA/libPolycode2DPhysicsModule.dylib", "luaopen_Physics2D")
+			//f(Polycore.CoreServices_getInstance())
+					
+		}
 
 		String fileData = "";
 
@@ -304,7 +327,38 @@ void PolycodePlayer::loadFile(const char *fileName) {
 				blue = (*color)["blue"]->NumberVal;
 				
 			}			
-		}		
+		}
+		ObjectEntry *modules = configFile.root["modules"];			
+		if(modules) {
+			for(int i=0; i < modules->length; i++) {			
+				String moduleName = (*modules)[i]->stringVal;
+				printf("Loading module: %s\n", moduleName.c_str());				
+				String moduleFileName = String("__lib/osx/") + moduleName+ String(".dylib");
+				String moduleDestPath = String("/tmp/") + moduleName+ String(".dylib");
+				
+				OSFILE *inFile = OSBasics::open(moduleFileName, "r");	
+				if(inFile) {
+					OSBasics::seek(inFile, 0, SEEK_END);	
+					long progsize = OSBasics::tell(inFile);
+					OSBasics::seek(inFile, 0, SEEK_SET);
+					char *buffer = (char*)malloc(progsize+1);
+					memset(buffer, 0, progsize+1);
+					OSBasics::read(buffer, progsize, 1, inFile);
+					
+					OSFILE *outFile = OSBasics::open(moduleDestPath, "w");						
+					OSBasics::write(buffer, progsize, 1, outFile);
+					OSBasics::close(outFile);	
+					
+					free(buffer);
+					OSBasics::close(inFile);	
+					
+					loadedModules.push_back(moduleName);
+				} else {
+					printf("Error loading module: %s\n", (*modules)[i]->stringVal.c_str());									
+				}
+			}
+
+		}			
 	}
 	
 	Logger::log("Mainfile: %s\n", mainFile.c_str());
@@ -321,7 +375,7 @@ void PolycodePlayer::loadFile(const char *fileName) {
 	CoreServices::getInstance()->getResourceManager()->addDirResource("default");
 	
 	
-//	CoreServices::getInstance()->installModule(new GLSLShaderModule());	
+	CoreServices::getInstance()->installModule(new GLSLShaderModule());	
 	
 	
 	if(configFile.root["packedItems"]) {

+ 35 - 1
Tools/Contents/polybuild/Source/polybuild.cpp

@@ -1,6 +1,7 @@
 
 #include "polybuild.h"
 #include "zip.h"
+#include <mach-o/dyld.h>
 
 vector<BuildArg> args;
 #define MAXFILENAME (256)
@@ -100,13 +101,28 @@ void addFolderToZip(zipFile z, String folderPath, String parentFolder, bool sile
 			addFileToZip(z, files[i].fullPath, pathInZip, silent);
 
 		} else {
-			addFolderToZip(z, files[i].fullPath.c_str(), files[i].name, silent);
+			if(parentFolder == "") {
+				addFolderToZip(z, files[i].fullPath.c_str(), files[i].name, silent);
+			} else {
+				addFolderToZip(z, files[i].fullPath.c_str(), parentFolder + "/" + files[i].name, silent);
+			}
 		}
 	}
 }
 
 int main(int argc, char **argv) {
 
+	char path[2048];
+	unsigned int size = sizeof(path);
+	_NSGetExecutablePath(path, &size);
+	String basePath = path;
+	vector<String> cpts = basePath.split("/");
+	String installPath = "";
+	for(int i=0; i < cpts.size() - 2; i++) {
+		installPath = installPath + cpts[i];
+		installPath += String("/");
+	}
+	
 	printf("Polycode build tool v0.1.1\n");
 
 	for(int i=0; i < argc; i++) {
@@ -240,6 +256,24 @@ int main(int argc, char **argv) {
 
 	addFileToZip(z, entryPoint, entryPoint, false);
 
+	if(configFile.root["modules"]) {
+		String modulesPath = installPath + "Modules/";
+		ObjectEntry *modules = configFile.root["modules"];
+		if(modules) {		
+			for(int i=0; i < modules->length; i++) {
+				printf("Adding module: %s\n", (*modules)[i]->stringVal.c_str());
+				String modulePath = modulesPath + (*modules)[i]->stringVal;
+				String moduleAPIPath = modulePath + "/API";
+				String moduleLibPath = modulePath + "/Lib";
+				addFolderToZip(z, moduleAPIPath, "", false);
+				addFolderToZip(z, moduleLibPath, "__lib", false);
+				
+				//String module = configFile.root["entryPoint"]->stringVal;
+			}
+			runInfo.root.addChild(configFile.root["modules"]);
+		}
+	}
+
 	if(configFile.root["packedItems"]) {
 		ObjectEntry *packed = configFile.root["packedItems"];
 		if(packed) {

Некоторые файлы не были показаны из-за большого количества измененных файлов