2
0
Эх сурвалжийг харах

Merge branch 'master' of github.com:ivansafrin/Polycode

Conflicts:
	.gitignore
Ivan Safrin 14 жил өмнө
parent
commit
dac22aba64
100 өөрчлөгдсөн 14788 нэмэгдсэн , 722 устгасан
  1. 2 0
      .gitignore
  2. BIN
      Assets/Default asset pack/default.pak
  3. 103 0
      Assets/Default asset pack/default/DefaultParticleShader.frag
  4. 11 0
      Assets/Default asset pack/default/DefaultParticleShader.vert
  5. 15 18
      Assets/Default asset pack/default/DefaultShader.frag
  6. 2 1
      Assets/Default asset pack/default/DefaultShader.vert
  7. 101 0
      Assets/Default asset pack/default/DefaultShaderNoTexture.frag
  8. 11 0
      Assets/Default asset pack/default/DefaultShaderNoTexture.vert
  9. 131 0
      Assets/Default asset pack/default/DefaultShaderShadows.frag
  10. 22 0
      Assets/Default asset pack/default/DefaultShaderShadows.vert
  11. 9 0
      Assets/Default asset pack/default/DefaultShaderVertex.frag
  12. 101 0
      Assets/Default asset pack/default/DefaultShaderVertex.vert
  13. 8 0
      Assets/Default asset pack/default/DefaultShaderVertexNoTexture.frag
  14. 100 0
      Assets/Default asset pack/default/DefaultShaderVertexNoTexture.vert
  15. 8 0
      Assets/Default asset pack/default/ScreenShader.vert
  16. 9 0
      Assets/Default asset pack/default/Unlit.frag
  17. 8 0
      Assets/Default asset pack/default/Unlit.vert
  18. 69 9
      Assets/Default asset pack/default/default.mat
  19. 11151 238
      Bindings/Build/Mac OS X/Bindings.xcodeproj/project.xcworkspace/xcuserdata/ivansafrin.xcuserdatad/UserInterfaceState.xcuserstate
  20. 5 0
      Bindings/Contents/LUA/API/Polycode.lua
  21. 3 0
      Bindings/Contents/LUA/API/Polycode/BezierCurve.lua
  22. 36 0
      Bindings/Contents/LUA/API/Polycode/Bone.lua
  23. 105 0
      Bindings/Contents/LUA/API/Polycode/BoneTrack.lua
  24. 4 0
      Bindings/Contents/LUA/API/Polycode/Camera.lua
  25. 1 0
      Bindings/Contents/LUA/API/Polycode/Config.lua
  26. 7 0
      Bindings/Contents/LUA/API/Polycode/Core.lua
  27. 3 0
      Bindings/Contents/LUA/API/Polycode/CoreInput.lua
  28. 17 0
      Bindings/Contents/LUA/API/Polycode/CoreServices.lua
  29. 1 0
      Bindings/Contents/LUA/API/Polycode/Data.lua
  30. 31 0
      Bindings/Contents/LUA/API/Polycode/Entity.lua
  31. 1 0
      Bindings/Contents/LUA/API/Polycode/Event.lua
  32. 1 0
      Bindings/Contents/LUA/API/Polycode/FixedShader.lua
  33. 1 0
      Bindings/Contents/LUA/API/Polycode/FixedShaderBinding.lua
  34. 1 0
      Bindings/Contents/LUA/API/Polycode/Font.lua
  35. 1 0
      Bindings/Contents/LUA/API/Polycode/FontManager.lua
  36. 54 0
      Bindings/Contents/LUA/API/Polycode/GLSLProgram.lua
  37. 47 0
      Bindings/Contents/LUA/API/Polycode/GLSLShader.lua
  38. 52 0
      Bindings/Contents/LUA/API/Polycode/GLSLShaderBinding.lua
  39. 73 0
      Bindings/Contents/LUA/API/Polycode/GLSLShaderModule.lua
  40. 2 0
      Bindings/Contents/LUA/API/Polycode/Image.lua
  41. 29 0
      Bindings/Contents/LUA/API/Polycode/InputEvent.lua
  42. 1 0
      Bindings/Contents/LUA/API/Polycode/Label.lua
  43. 3 0
      Bindings/Contents/LUA/API/Polycode/Material.lua
  44. 10 0
      Bindings/Contents/LUA/API/Polycode/MaterialManager.lua
  45. 4 0
      Bindings/Contents/LUA/API/Polycode/Matrix4.lua
  46. 17 0
      Bindings/Contents/LUA/API/Polycode/Mesh.lua
  47. 1 0
      Bindings/Contents/LUA/API/Polycode/OSBasics.lua
  48. 1 0
      Bindings/Contents/LUA/API/Polycode/ObjectEntry.lua
  49. 30 3
      Bindings/Contents/LUA/API/Polycode/Particle.lua
  50. 98 26
      Bindings/Contents/LUA/API/Polycode/ParticleEmitter.lua
  51. 28 0
      Bindings/Contents/LUA/API/Polycode/PolycodeViewBase.lua
  52. 4 0
      Bindings/Contents/LUA/API/Polycode/Polygon.lua
  53. 7 0
      Bindings/Contents/LUA/API/Polycode/Quaternion.lua
  54. 1 0
      Bindings/Contents/LUA/API/Polycode/QuaternionCurve.lua
  55. 51 3
      Bindings/Contents/LUA/API/Polycode/Renderer.lua
  56. 1 0
      Bindings/Contents/LUA/API/Polycode/ResourceManager.lua
  57. 37 3
      Bindings/Contents/LUA/API/Polycode/Scene.lua
  58. 1 0
      Bindings/Contents/LUA/API/Polycode/SceneLabel.lua
  59. 43 2
      Bindings/Contents/LUA/API/Polycode/SceneLight.lua
  60. 15 1
      Bindings/Contents/LUA/API/Polycode/SceneMesh.lua
  61. 13 0
      Bindings/Contents/LUA/API/Polycode/SceneParticleEmitter.lua
  62. 2 0
      Bindings/Contents/LUA/API/Polycode/ScenePrimitive.lua
  63. 3 0
      Bindings/Contents/LUA/API/Polycode/SceneRenderTexture.lua
  64. 52 0
      Bindings/Contents/LUA/API/Polycode/SceneSound.lua
  65. 40 0
      Bindings/Contents/LUA/API/Polycode/SceneSoundListener.lua
  66. 9 0
      Bindings/Contents/LUA/API/Polycode/Screen.lua
  67. 2 0
      Bindings/Contents/LUA/API/Polycode/ScreenEntity.lua
  68. 1 0
      Bindings/Contents/LUA/API/Polycode/ScreenLabel.lua
  69. 3 3
      Bindings/Contents/LUA/API/Polycode/ScreenLine.lua
  70. 2 0
      Bindings/Contents/LUA/API/Polycode/ScreenMesh.lua
  71. 13 0
      Bindings/Contents/LUA/API/Polycode/ScreenParticleEmitter.lua
  72. 9 0
      Bindings/Contents/LUA/API/Polycode/ScreenShape.lua
  73. 52 0
      Bindings/Contents/LUA/API/Polycode/ScreenSound.lua
  74. 40 0
      Bindings/Contents/LUA/API/Polycode/ScreenSoundListener.lua
  75. 18 0
      Bindings/Contents/LUA/API/Polycode/Shader.lua
  76. 5 0
      Bindings/Contents/LUA/API/Polycode/ShaderBinding.lua
  77. 4 0
      Bindings/Contents/LUA/API/Polycode/Skeleton.lua
  78. 33 2
      Bindings/Contents/LUA/API/Polycode/Sound.lua
  79. 12 0
      Bindings/Contents/LUA/API/Polycode/SoundManager.lua
  80. 30 0
      Bindings/Contents/LUA/API/Polycode/String.lua
  81. 1 0
      Bindings/Contents/LUA/API/Polycode/Texture.lua
  82. 1 0
      Bindings/Contents/LUA/API/Polycode/Vector3.lua
  83. 39 1
      Bindings/Contents/LUA/API/Polycode/Vertex.lua
  84. 170 0
      Bindings/Contents/LUA/API/Polycode/Win32Core.lua
  85. 1 1
      Bindings/Contents/LUA/Include/PolycodeLUA.h
  86. 594 123
      Bindings/Contents/LUA/Include/PolycodeLUAWrappers.h
  87. 94 7
      Bindings/Contents/LUA/Source/PolycodeLUA.cpp
  88. 128 81
      Bindings/Scripts/create_lua_library/create_lua_library.py
  89. 40 0
      Core/Build/Mac OS X/PolyCore.xcodeproj/project.pbxproj
  90. 184 165
      Core/Build/Mac OS X/PolyCore.xcodeproj/project.xcworkspace/xcuserdata/ivansafrin.xcuserdatad/UserInterfaceState.xcuserstate
  91. 5 0
      Core/Contents/Include/PolyCamera.h
  92. 1 0
      Core/Contents/Include/PolyCocoaCore.h
  93. 2 0
      Core/Contents/Include/PolyGLRenderer.h
  94. 128 0
      Core/Contents/Include/PolyGLSLProgram.h
  95. 93 0
      Core/Contents/Include/PolyGLSLShader.h
  96. 84 0
      Core/Contents/Include/PolyGLSLShaderModule.h
  97. 14 5
      Core/Contents/Include/PolyMesh.h
  98. 3 1
      Core/Contents/Include/PolyParticle.h
  99. 155 27
      Core/Contents/Include/PolyParticleEmitter.h
  100. 19 2
      Core/Contents/Include/PolyRenderer.h

+ 2 - 0
.gitignore

@@ -25,6 +25,8 @@
 *.lib
 *.manifest
 *.exp
+*.zip
+*.swo
 
 Core/Build/Mac\ OS\ X/build
 IDE/Build/Mac\ OS\ X/build

BIN
Assets/Default asset pack/default.pak


+ 103 - 0
Assets/Default asset pack/default/DefaultParticleShader.frag

@@ -0,0 +1,103 @@
+float calculateAttenuation(in int i, in float dist)
+{
+    return(1.0 / (gl_LightSource[i].constantAttenuation +
+                  gl_LightSource[i].linearAttenuation * dist +
+                  gl_LightSource[i].quadraticAttenuation * dist * dist));
+}
+
+void pointLight(in int i, in vec3 N, in vec3 V, in float shininess,
+                inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    vec3 D = gl_LightSource[i].position.xyz - V;
+    vec3 L = normalize(D);
+
+    float dist = length(D);
+    float attenuation = calculateAttenuation(i, dist);
+
+    float nDotL = 1.0; //dot(N,L);
+
+    if (nDotL > 0.0)
+    {   
+        vec3 E = normalize(-V);
+        vec3 R = reflect(-L, N);
+       
+        float pf = pow(max(dot(R,E), 0.0), shininess);
+
+        diffuse  += gl_LightSource[i].diffuse  * attenuation * nDotL;
+        specular += gl_LightSource[i].specular * attenuation * pf;
+    }
+   
+    ambient  += gl_LightSource[i].ambient * attenuation;
+}
+
+void spotLight(in int i, in vec3 N, in vec3 V, in float shininess,
+               inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    vec3 D = gl_LightSource[i].position.xyz - V;
+    vec3 L = normalize(D);
+
+    float dist = length(D);
+    float attenuation = calculateAttenuation(i, dist);
+	
+    float nDotL = dot(N,L);	
+    if (nDotL > 0.0)
+    {   
+        float spotEffect = dot(normalize(gl_LightSource[i].spotDirection), -L);
+       
+        if (spotEffect > gl_LightSource[i].spotCosCutoff)
+        {
+            attenuation *=  pow(spotEffect, gl_LightSource[i].spotExponent);
+
+            vec3 E = normalize(-V);
+            vec3 R = reflect(-L, N);
+       
+            float pf = pow(max(dot(R,E), 0.0), shininess);
+
+            diffuse  += gl_LightSource[i].diffuse  * attenuation * nDotL;
+            specular += gl_LightSource[i].specular * attenuation * pf;
+        }
+    }
+   
+    ambient  += gl_LightSource[i].ambient * attenuation;
+}
+
+void calculateLighting(in int numLights, in vec3 N, in vec3 V, in float shininess,
+                       inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    // Just loop through each light, and if its enabled add
+    // its contributions to the color of the pixel.
+    for (int i = 0; i < numLights; i++)
+    {
+		if (gl_LightSource[i].spotCutoff == 180.0)
+                pointLight(i, N, V, shininess, ambient, diffuse, specular);
+            else
+                 spotLight(i, N, V, shininess, ambient, diffuse, specular);
+
+    }
+}
+
+uniform sampler2D diffuse;
+varying vec3 normal;
+varying vec3 vertex;
+varying vec4 vertexColor;
+
+void main()
+{
+    vec3 n = normalize(normal);
+   
+    vec4 ambient_c  = vec4(0.0);
+    vec4 diffuse_c  = vec4(0.0);
+    vec4 specular_c = vec4(0.0);
+
+    calculateLighting(6, n, vertex, gl_FrontMaterial.shininess, ambient_c, diffuse_c, specular_c);
+   
+	vec4 texColor = texture2D(diffuse, gl_TexCoord[0].st);
+    
+    vec4 color = gl_FrontLightModelProduct.sceneColor  +
+                 (ambient_c  * 1.0) +
+                 (diffuse_c  * 1.0) +
+                 (specular_c * 1.0);
+	color.a = 1.0;
+    color = clamp(color*texColor*vertexColor, 0.0, 1.0);
+    gl_FragColor = color;
+}

+ 11 - 0
Assets/Default asset pack/default/DefaultParticleShader.vert

@@ -0,0 +1,11 @@
+varying vec3 normal;
+varying vec3 vertex;
+varying vec4 vertexColor;
+void main()
+{
+    gl_TexCoord[0] = gl_MultiTexCoord0;		
+    normal = normalize(gl_NormalMatrix * gl_Normal);   
+    vertex = vec3(gl_ModelViewMatrix * gl_Vertex);     
+    vertexColor = gl_Color;
+    gl_Position = ftransform();
+}

+ 15 - 18
Assets/Default asset pack/default/DefaultShader.frag

@@ -76,32 +76,29 @@ void calculateLighting(in int numLights, in vec3 N, in vec3 V, in float shinines
 
     }
 }
+
+uniform sampler2D diffuse;
 varying vec3 normal;
 varying vec3 vertex;
 varying vec4 vertexColor;
+
 void main()
 {
-    // Normalize the normal. A varying variable CANNOT
-    // be modified by a fragment shader. So a new variable
-    // needs to be created.
     vec3 n = normalize(normal);
    
-    vec4 ambient  = vec4(0.0);
-    vec4 diffuse  = vec4(0.0);
-    vec4 specular = vec4(0.0);
-
-    // In this case the built in uniform gl_MaxLights is used
-    // to denote the number of lights. A better option may be passing
-    // in the number of lights as a uniform or replacing the current
-    // value with a smaller value.
-    calculateLighting(1, n, vertex, gl_FrontMaterial.shininess,
-                      ambient, diffuse, specular);
+    vec4 ambient_c  = vec4(0.0);
+    vec4 diffuse_c  = vec4(0.0);
+    vec4 specular_c = vec4(0.0);
+
+    calculateLighting(6, n, vertex, gl_FrontMaterial.shininess, ambient_c, diffuse_c, specular_c);
    
+	vec4 texColor = texture2D(diffuse, gl_TexCoord[0].st);
+    
     vec4 color = gl_FrontLightModelProduct.sceneColor  +
-                 (ambient  * 1.0) +
-                 (diffuse  * 1.0) +
-                 (specular * 0.0);
-    color = clamp(color*vertexColor, 0.0, 1.0);
-    color.a = vertexColor.a;
+                 (ambient_c  * 1.0) +
+                 (diffuse_c  * 1.0) +
+                 (specular_c * 1.0);
+	color.a = 1.0;				 
+    color = clamp(color*texColor*vertexColor, 0.0, 1.0);
     gl_FragColor = color;
 }

+ 2 - 1
Assets/Default asset pack/default/DefaultShader.vert

@@ -3,8 +3,9 @@ varying vec3 vertex;
 varying vec4 vertexColor;
 void main()
 {
+    gl_TexCoord[0] = gl_MultiTexCoord0;		
     normal = normalize(gl_NormalMatrix * gl_Normal);   
     vertex = vec3(gl_ModelViewMatrix * gl_Vertex);     
-   vertexColor = gl_Color;
+    vertexColor = gl_Color;
     gl_Position = ftransform();
 }

+ 101 - 0
Assets/Default asset pack/default/DefaultShaderNoTexture.frag

@@ -0,0 +1,101 @@
+float calculateAttenuation(in int i, in float dist)
+{
+    return(1.0 / (gl_LightSource[i].constantAttenuation +
+                  gl_LightSource[i].linearAttenuation * dist +
+                  gl_LightSource[i].quadraticAttenuation * dist * dist));
+}
+
+void pointLight(in int i, in vec3 N, in vec3 V, in float shininess,
+                inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    vec3 D = gl_LightSource[i].position.xyz - V;
+    vec3 L = normalize(D);
+
+    float dist = length(D);
+    float attenuation = calculateAttenuation(i, dist);
+
+    float nDotL = dot(N,L);
+
+    if (nDotL > 0.0)
+    {   
+        vec3 E = normalize(-V);
+        vec3 R = reflect(-L, N);
+       
+        float pf = pow(max(dot(R,E), 0.0), shininess);
+
+        diffuse  += gl_LightSource[i].diffuse  * attenuation * nDotL;
+        specular += gl_LightSource[i].specular * attenuation * pf;
+    }
+   
+    ambient  += gl_LightSource[i].ambient * attenuation;
+}
+
+void spotLight(in int i, in vec3 N, in vec3 V, in float shininess,
+               inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    vec3 D = gl_LightSource[i].position.xyz - V;
+    vec3 L = normalize(D);
+
+    float dist = length(D);
+    float attenuation = calculateAttenuation(i, dist);
+
+    float nDotL = dot(N,L);
+
+    if (nDotL > 0.0)
+    {   
+        float spotEffect = dot(normalize(gl_LightSource[i].spotDirection), -L);
+       
+        if (spotEffect > gl_LightSource[i].spotCosCutoff)
+        {
+            attenuation *=  pow(spotEffect, gl_LightSource[i].spotExponent);
+
+            vec3 E = normalize(-V);
+            vec3 R = reflect(-L, N);
+       
+            float pf = pow(max(dot(R,E), 0.0), shininess);
+
+            diffuse  += gl_LightSource[i].diffuse  * attenuation * nDotL;
+            specular += gl_LightSource[i].specular * attenuation * pf;
+        }
+    }
+   
+    ambient  += gl_LightSource[i].ambient * attenuation;
+}
+
+void calculateLighting(in int numLights, in vec3 N, in vec3 V, in float shininess,
+                       inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    // Just loop through each light, and if its enabled add
+    // its contributions to the color of the pixel.
+    for (int i = 0; i < numLights; i++)
+    {
+		if (gl_LightSource[i].spotCutoff == 180.0)
+                pointLight(i, N, V, shininess, ambient, diffuse, specular);
+            else
+                 spotLight(i, N, V, shininess, ambient, diffuse, specular);
+
+    }
+}
+
+varying vec3 normal;
+varying vec3 vertex;
+varying vec4 vertexColor;
+
+void main()
+{
+    vec3 n = normalize(normal);
+   
+    vec4 ambient_c  = vec4(0.0);
+    vec4 diffuse_c  = vec4(0.0);
+    vec4 specular_c = vec4(0.0);
+
+    calculateLighting(6, n, vertex, gl_FrontMaterial.shininess, ambient_c, diffuse_c, specular_c);
+    
+    vec4 color = gl_FrontLightModelProduct.sceneColor  +
+                 (ambient_c  * 1.0) +
+                 (diffuse_c  * 1.0) +
+                 (specular_c * 1.0);
+    color = clamp(color*vertexColor, 0.0, 1.0);
+    color.a = vertexColor.a;
+    gl_FragColor = color;
+}

+ 11 - 0
Assets/Default asset pack/default/DefaultShaderNoTexture.vert

@@ -0,0 +1,11 @@
+varying vec3 normal;
+varying vec3 vertex;
+varying vec4 vertexColor;
+void main()
+{
+    gl_TexCoord[0] = gl_MultiTexCoord0;		
+    normal = normalize(gl_NormalMatrix * gl_Normal);   
+    vertex = vec3(gl_ModelViewMatrix * gl_Vertex);     
+   vertexColor = gl_Color;
+    gl_Position = gl_ProjectionMatrix * vec4(vertex, 1.0);
+}

+ 131 - 0
Assets/Default asset pack/default/DefaultShaderShadows.frag

@@ -0,0 +1,131 @@
+uniform sampler2D diffuse;
+uniform sampler2D shadowMap0;
+uniform sampler2D shadowMap1;
+varying vec3 normal;
+varying vec3 vertex;
+varying vec4 vertexColor;
+varying vec4 ShadowCoord0;
+varying vec4 ShadowCoord1;
+uniform mat4 shadowMatrix0;
+uniform mat4 shadowMatrix1;
+
+
+
+
+float calculateAttenuation(in int i, in float dist)
+{
+    return(1.0 / (gl_LightSource[i].constantAttenuation +
+                  gl_LightSource[i].linearAttenuation * dist +
+                  gl_LightSource[i].quadraticAttenuation * dist * dist));
+}
+
+void pointLight(in int i, in vec3 N, in vec3 V, in float shininess,
+                inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    vec3 D = gl_LightSource[i].position.xyz - V;
+    vec3 L = normalize(D);
+
+    float dist = length(D);
+    float attenuation = calculateAttenuation(i, dist);
+
+    float nDotL = dot(N,L);
+
+    if (nDotL > 0.0)
+    {   
+        vec3 E = normalize(-V);
+        vec3 R = reflect(-L, N);
+       
+        float pf = pow(max(dot(R,E), 0.0), shininess);
+
+        diffuse  += gl_LightSource[i].diffuse  * attenuation * nDotL;
+        specular += gl_LightSource[i].specular * attenuation * pf;
+    }
+   
+    ambient  += gl_LightSource[i].ambient * attenuation;
+}
+
+void spotLight(in int i, in vec3 N, in vec3 V, in float shininess,
+               inout vec4 ambient, inout vec4 diffuse, inout vec4 specular, sampler2D shadowMap, vec4 ShadowCoord)
+{
+	
+	vec4 shadowCoordinateWdivide = ShadowCoord / ShadowCoord.w;
+	shadowCoordinateWdivide.z -= 0.000000005;
+	float distanceFromLight = texture2D(shadowMap,shadowCoordinateWdivide.st).z;
+	float shadow = 1.0;
+	if (ShadowCoord.w > 0.0)
+		shadow = distanceFromLight < shadowCoordinateWdivide.z ? 0.0 : 1.0 ;
+	
+    vec3 D = gl_LightSource[i].position.xyz - V;
+    vec3 L = normalize(D);
+
+    float dist = length(D);
+    float attenuation = calculateAttenuation(i, dist);
+
+    float nDotL = dot(N,L);
+
+    if (nDotL > 0.0)
+    {   
+        float spotEffect = dot(normalize(gl_LightSource[i].spotDirection), -L);
+       
+        if (spotEffect > gl_LightSource[i].spotCosCutoff)
+        {
+            attenuation *=  pow(spotEffect, gl_LightSource[i].spotExponent);
+
+            vec3 E = normalize(-V);
+            vec3 R = reflect(-L, N);
+       
+            float pf = pow(max(dot(R,E), 0.0), shininess);
+
+            diffuse  += gl_LightSource[i].diffuse  * attenuation * nDotL * shadow;
+            specular += gl_LightSource[i].specular * attenuation * pf * shadow;
+        }
+    }
+   
+    ambient  += gl_LightSource[i].ambient * attenuation;
+}
+
+void calculateLighting(in int numLights, in vec3 N, in vec3 V, in float shininess,
+                       inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+	int spot = 0;
+    // Just loop through each light, and if its enabled add
+    // its contributions to the color of the pixel.
+    for (int i = 0; i < numLights; i++)
+    {
+		if (gl_LightSource[i].spotCutoff == 180.0)
+                pointLight(i, N, V, shininess, ambient, diffuse, specular);
+            else {
+            	if(spot == 0) {
+                 spotLight(i, N, V, shininess, ambient, diffuse, specular, shadowMap0, ShadowCoord0);            		
+                 spot = 1;
+            	} else {
+                 spotLight(i, N, V, shininess, ambient, diffuse, specular, shadowMap1, ShadowCoord1);
+            	}
+            }
+
+    }
+}
+
+
+
+void main()
+{
+  vec3 n = normalize(normal);
+   
+    vec4 ambient_c  = vec4(0.0);
+    vec4 diffuse_c  = vec4(0.0);
+    vec4 specular_c = vec4(0.0);
+
+    calculateLighting(6, n, vertex, gl_FrontMaterial.shininess, ambient_c, diffuse_c, specular_c);
+   
+	vec4 texColor = texture2D(diffuse, gl_TexCoord[0].st);
+    
+    vec4 color = gl_FrontLightModelProduct.sceneColor  +
+                 (ambient_c  * 1.0) +
+                 (diffuse_c  * 1.0) +
+                 (specular_c * 1.0);
+	color.a = 1.0;				 
+    color = clamp(color*texColor*vertexColor, 0.0, 1.0);
+    gl_FragColor = color;
+
+}

+ 22 - 0
Assets/Default asset pack/default/DefaultShaderShadows.vert

@@ -0,0 +1,22 @@
+varying vec3 normal;
+varying vec3 vertex;
+varying vec4 vertexColor;
+varying vec4 ShadowCoord0;
+varying vec4 ShadowCoord1;
+uniform mat4 shadowMatrix0;
+uniform mat4 shadowMatrix1;
+
+void main()
+{
+    gl_TexCoord[0] = gl_MultiTexCoord0;		
+    normal = normalize(gl_NormalMatrix * gl_Normal);   
+    vec4 v = gl_ModelViewMatrix * gl_Vertex;
+    vertex = vec3(v);     
+    
+	ShadowCoord0 = shadowMatrix0 * gl_Vertex;	
+	ShadowCoord1 = shadowMatrix1 * gl_Vertex;	
+		    
+    
+    vertexColor = gl_Color;
+    gl_Position = ftransform();
+}

+ 9 - 0
Assets/Default asset pack/default/DefaultShaderVertex.frag

@@ -0,0 +1,9 @@
+uniform sampler2D diffuse;
+varying vec4 vertexColor;
+
+void main()
+{
+	vec4 texColor = texture2D(diffuse, gl_TexCoord[0].st);	
+    vec4 color = texColor*vertexColor;
+    gl_FragColor = color;
+}

+ 101 - 0
Assets/Default asset pack/default/DefaultShaderVertex.vert

@@ -0,0 +1,101 @@
+float calculateAttenuation(in int i, in float dist)
+{
+    return(1.0 / (gl_LightSource[i].constantAttenuation +
+                  gl_LightSource[i].linearAttenuation * dist +
+                  gl_LightSource[i].quadraticAttenuation * dist * dist));
+}
+
+void pointLight(in int i, in vec3 N, in vec3 V, in float shininess,
+                inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    vec3 D = gl_LightSource[i].position.xyz - V;
+    vec3 L = normalize(D);
+
+    float dist = length(D);
+    float attenuation = calculateAttenuation(i, dist);
+
+    float nDotL = dot(N,L);
+
+    if (nDotL > 0.0)
+    {   
+        vec3 E = normalize(-V);
+        vec3 R = reflect(-L, N);
+       
+        float pf = pow(max(dot(R,E), 0.0), shininess);
+
+        diffuse  += gl_LightSource[i].diffuse  * attenuation * nDotL;
+        specular += gl_LightSource[i].specular * attenuation * pf;
+    }
+   
+    ambient  += gl_LightSource[i].ambient * attenuation;
+}
+
+void spotLight(in int i, in vec3 N, in vec3 V, in float shininess,
+               inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    vec3 D = gl_LightSource[i].position.xyz - V;
+    vec3 L = normalize(D);
+
+    float dist = length(D);
+    float attenuation = calculateAttenuation(i, dist);
+
+    float nDotL = dot(N,L);
+
+    if (nDotL > 0.0)
+    {   
+        float spotEffect = dot(normalize(gl_LightSource[i].spotDirection), -L);
+       
+        if (spotEffect > gl_LightSource[i].spotCosCutoff)
+        {
+            attenuation *=  pow(spotEffect, gl_LightSource[i].spotExponent);
+
+            vec3 E = normalize(-V);
+            vec3 R = reflect(-L, N);
+       
+            float pf = pow(max(dot(R,E), 0.0), shininess);
+
+            diffuse  += gl_LightSource[i].diffuse  * attenuation * nDotL;
+            specular += gl_LightSource[i].specular * attenuation * pf;
+        }
+    }
+   
+    ambient  += gl_LightSource[i].ambient * attenuation;
+}
+
+void calculateLighting(in int numLights, in vec3 N, in vec3 V, in float shininess,
+                       inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    // Just loop through each light, and if its enabled add
+    // its contributions to the color of the pixel.
+    for (int i = 0; i < numLights; i++)
+    {
+		if (gl_LightSource[i].spotCutoff == 180.0)
+                pointLight(i, N, V, shininess, ambient, diffuse, specular);
+            else
+                 spotLight(i, N, V, shininess, ambient, diffuse, specular);
+
+    }
+}
+
+varying vec4 vertexColor;
+void main()
+{
+
+    gl_TexCoord[0] = gl_MultiTexCoord0;		
+    vec3 normal = normalize(gl_NormalMatrix * gl_Normal);   
+    vec3 vertex = vec3(gl_ModelViewMatrix * gl_Vertex);     
+    gl_Position = ftransform();    
+   
+    vec4 ambient_c  = vec4(0.0);
+    vec4 diffuse_c  = vec4(0.0);
+    vec4 specular_c = vec4(0.0);
+    
+    calculateLighting(6, normal, vertex, gl_FrontMaterial.shininess, ambient_c, diffuse_c, specular_c);   
+    vec4 color = gl_FrontLightModelProduct.sceneColor  +
+                 (ambient_c  * 1.0) +
+                 (diffuse_c  * 1.0) +
+                 (specular_c * 1.0);
+	color.a = 1.0;				 
+    color = clamp(color*gl_Color, 0.0, 1.0);
+   vertexColor = color;    
+}

+ 8 - 0
Assets/Default asset pack/default/DefaultShaderVertexNoTexture.frag

@@ -0,0 +1,8 @@
+
+varying vec4 vertexColor;
+
+void main()
+{
+    vec4 color = vertexColor;
+    gl_FragColor = color;
+}

+ 100 - 0
Assets/Default asset pack/default/DefaultShaderVertexNoTexture.vert

@@ -0,0 +1,100 @@
+float calculateAttenuation(in int i, in float dist)
+{
+    return(1.0 / (gl_LightSource[i].constantAttenuation +
+                  gl_LightSource[i].linearAttenuation * dist +
+                  gl_LightSource[i].quadraticAttenuation * dist * dist));
+}
+
+void pointLight(in int i, in vec3 N, in vec3 V, in float shininess,
+                inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    vec3 D = gl_LightSource[i].position.xyz - V;
+    vec3 L = normalize(D);
+
+    float dist = length(D);
+    float attenuation = calculateAttenuation(i, dist);
+
+    float nDotL = dot(N,L);
+
+    if (nDotL > 0.0)
+    {   
+        vec3 E = normalize(-V);
+        vec3 R = reflect(-L, N);
+       
+        float pf = pow(max(dot(R,E), 0.0), shininess);
+
+        diffuse  += gl_LightSource[i].diffuse  * attenuation * nDotL;
+        specular += gl_LightSource[i].specular * attenuation * pf;
+    }
+   
+    ambient  += gl_LightSource[i].ambient * attenuation;
+}
+
+void spotLight(in int i, in vec3 N, in vec3 V, in float shininess,
+               inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    vec3 D = gl_LightSource[i].position.xyz - V;
+    vec3 L = normalize(D);
+
+    float dist = length(D);
+    float attenuation = calculateAttenuation(i, dist);
+
+    float nDotL = dot(N,L);
+
+    if (nDotL > 0.0)
+    {   
+        float spotEffect = dot(normalize(gl_LightSource[i].spotDirection), -L);
+       
+        if (spotEffect > gl_LightSource[i].spotCosCutoff)
+        {
+            attenuation *=  pow(spotEffect, gl_LightSource[i].spotExponent);
+
+            vec3 E = normalize(-V);
+            vec3 R = reflect(-L, N);
+       
+            float pf = pow(max(dot(R,E), 0.0), shininess);
+
+            diffuse  += gl_LightSource[i].diffuse  * attenuation * nDotL;
+            specular += gl_LightSource[i].specular * attenuation * pf;
+        }
+    }
+   
+    ambient  += gl_LightSource[i].ambient * attenuation;
+}
+
+void calculateLighting(in int numLights, in vec3 N, in vec3 V, in float shininess,
+                       inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
+{
+    // Just loop through each light, and if its enabled add
+    // its contributions to the color of the pixel.
+    for (int i = 0; i < numLights; i++)
+    {
+		if (gl_LightSource[i].spotCutoff == 180.0)
+                pointLight(i, N, V, shininess, ambient, diffuse, specular);
+            else
+                 spotLight(i, N, V, shininess, ambient, diffuse, specular);
+
+    }
+}
+
+varying vec4 vertexColor;
+void main()
+{
+
+    gl_TexCoord[0] = gl_MultiTexCoord0;		
+    vec3 normal = normalize(gl_NormalMatrix * gl_Normal);   
+    vec3 vertex = vec3(gl_ModelViewMatrix * gl_Vertex);     
+    gl_Position = ftransform();    
+   
+    vec4 ambient_c  = vec4(0.0);
+    vec4 diffuse_c  = vec4(0.0);
+    vec4 specular_c = vec4(0.0);
+    
+    calculateLighting(6, normal, vertex, gl_FrontMaterial.shininess, ambient_c, diffuse_c, specular_c);   
+    vec4 color = gl_FrontLightModelProduct.sceneColor  +
+                 (ambient_c  * 1.0) +
+                 (diffuse_c  * 1.0) +
+                 (specular_c * 1.0);
+    color = clamp(color*gl_Color, 0.0, 1.0);
+   vertexColor = color;    
+}

+ 8 - 0
Assets/Default asset pack/default/ScreenShader.vert

@@ -0,0 +1,8 @@
+varying vec2 vTexCoord;
+void main(void)
+{
+	gl_TexCoord[0] = gl_MultiTexCoord0;		      
+//   vec2 Pos;
+//   Pos = sign(); 
+   gl_Position = vec4(gl_Vertex.xy, 0.0, 1.0);
+}

+ 9 - 0
Assets/Default asset pack/default/Unlit.frag

@@ -0,0 +1,9 @@
+
+uniform sampler2D diffuse;
+varying vec4 vertexColor;
+
+void main()
+{
+	vec4 texColor = texture2D(diffuse, gl_TexCoord[0].st);
+    gl_FragColor = texColor*vertexColor;
+}

+ 8 - 0
Assets/Default asset pack/default/Unlit.vert

@@ -0,0 +1,8 @@
+
+varying vec4 vertexColor;
+void main()
+{
+    gl_TexCoord[0] = gl_MultiTexCoord0;		
+    vertexColor = gl_Color;
+    gl_Position = ftransform();
+}

+ 69 - 9
Assets/Default asset pack/default/default.mat

@@ -1,21 +1,81 @@
 <?xml version="1.0" ?>
-<tau>
+<polycode>	
 	<shaders>		
-		<shader type="glsl" name="DefaultShader">		
+		<shader type="glsl" name="DefaultShader" numAreaLights="4" numSpotLights="2">		
 			<vp source="DefaultShader.vert">
-				<params>
-				</params>
+				<params>			
+				</params>				
 			</vp>
 			<fp source="DefaultShader.frag">
 				<params>			
-				</params>					
+				</params>				
 			</fp>
 		</shader>	
+		<shader type="glsl" name="DefaultShaderNoTexture" numAreaLights="4" numSpotLights="2">		
+			<vp source="DefaultShaderNoTexture.vert">
+				<params>			
+				</params>				
+			</vp>
+			<fp source="DefaultShaderNoTexture.frag">
+				<params>			
+				</params>				
+			</fp>
+		</shader>		
+		<shader type="glsl" name="DefaultShaderVertex" numAreaLights="4" numSpotLights="2">		
+			<vp source="DefaultShaderVertex.vert">
+				<params>			
+				</params>				
+			</vp>
+			<fp source="DefaultShaderVertex.frag">
+				<params>			
+				</params>				
+			</fp>
+		</shader>			
+		<shader type="glsl" name="DefaultShaderVertexNoTexture" numAreaLights="4" numSpotLights="2">		
+			<vp source="DefaultShaderVertexNoTexture.vert">
+				<params>			
+				</params>				
+			</vp>
+			<fp source="DefaultShaderVertexNoTexture.frag">
+				<params>			
+				</params>				
+			</fp>
+		</shader>			
+		<shader type="glsl" name="DefaultShaderShadows" numAreaLights="4" numSpotLights="2">		
+			<vp source="DefaultShaderShadows.vert">
+				<params>			
+				</params>				
+			</vp>
+			<fp source="DefaultShaderShadows.frag">
+				<params>			
+				</params>				
+			</fp>
+		</shader>	
+		<shader type="glsl" name="DefaultParticleShader" numAreaLights="4" numSpotLights="2">		
+			<vp source="DefaultParticleShader.vert">
+				<params>			
+				</params>				
+			</vp>
+			<fp source="DefaultParticleShader.frag">
+				<params>			
+				</params>				
+			</fp>
+		</shader>	
+		<shader type="glsl" name="Unlit" numAreaLights="0" numSpotLights="0">		
+			<vp source="Unlit.vert">
+				<params>			
+				</params>				
+			</vp>
+			<fp source="Unlit.frag">
+				<params>			
+				</params>				
+			</fp>
+		</shader>										
 	</shaders>
 	<materials>
-		<material name="default">
-			<shader name="DefaultShader">
+		<material name="Default">
+			<shader name="DefaultShaderNoTexture">
 			</shader>
-		</material>		
+		</material>			
 	</materials>
-</tau>
+</polycode>

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 11151 - 238
Bindings/Build/Mac OS X/Bindings.xcodeproj/project.xcworkspace/xcuserdata/ivansafrin.xcuserdatad/UserInterfaceState.xcuserstate


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

@@ -6,6 +6,7 @@ require "Polycode/Bone"
 require "Polycode/Camera"
 require "Polycode/Color"
 require "Polycode/Config"
+require "Polycode/PolycodeViewBase"
 require "Polycode/Core"
 require "Polycode/CoreInput"
 require "Polycode/CoreServices"
@@ -51,6 +52,8 @@ require "Polycode/SceneManager"
 require "Polycode/SceneMesh"
 require "Polycode/ScenePrimitive"
 require "Polycode/SceneRenderTexture"
+require "Polycode/SceneSound"
+require "Polycode/SceneSoundListener"
 require "Polycode/Screen"
 require "Polycode/ScreenCurve"
 require "Polycode/ScreenEntity"
@@ -61,6 +64,8 @@ require "Polycode/ScreenLine"
 require "Polycode/ScreenManager"
 require "Polycode/ScreenMesh"
 require "Polycode/ScreenShape"
+require "Polycode/ScreenSoundListener"
+require "Polycode/ScreenSound"
 require "Polycode/ScreenSprite"
 require "Polycode/Shader"
 require "Polycode/ShaderBinding"

+ 3 - 0
Bindings/Contents/LUA/API/Polycode/BezierCurve.lua

@@ -22,6 +22,7 @@ end
 
 function BezierCurve:getControlPoint(index)
 	local retVal = Polycore.BezierCurve_getControlPoint(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -63,6 +64,7 @@ end
 
 function BezierCurve:getPointAt(a)
 	local retVal = Polycore.BezierCurve_getPointAt(self.__ptr, a)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -74,6 +76,7 @@ end
 
 function BezierCurve:getPointBetween(a, bp1, bp2)
 	local retVal = Polycore.BezierCurve_getPointBetween(self.__ptr, a, bp1.__ptr, bp2.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 36 - 0
Bindings/Contents/LUA/API/Polycode/Bone.lua

@@ -7,6 +7,33 @@ class "Bone" (SceneEntity)
 function Bone:__index__(name)
 	if name == "parentBoneId" then
 		return Polycore.Bone_get_parentBoneId(self.__ptr)
+	elseif name == "boneMatrix" then
+		retVal = Polycore.Bone_get_boneMatrix(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "restMatrix" then
+		retVal = Polycore.Bone_get_restMatrix(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "baseMatrix" then
+		retVal = Polycore.Bone_get_baseMatrix(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Matrix4("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
 	end
 end
 
@@ -63,6 +90,7 @@ end
 
 function Bone:getParentBone()
 	local retVal =  Polycore.Bone_getParentBone(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -79,6 +107,7 @@ end
 
 function Bone:getChildBone(index)
 	local retVal = Polycore.Bone_getChildBone(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -90,6 +119,7 @@ end
 
 function Bone:getBoneMatrix()
 	local retVal =  Polycore.Bone_getBoneMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -105,6 +135,7 @@ end
 
 function Bone:getRestMatrix()
 	local retVal =  Polycore.Bone_getRestMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -116,6 +147,7 @@ end
 
 function Bone:getFullRestMatrix()
 	local retVal =  Polycore.Bone_getFullRestMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -127,6 +159,7 @@ end
 
 function Bone:getParentRestMatrix()
 	local retVal =  Polycore.Bone_getParentRestMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -138,6 +171,7 @@ end
 
 function Bone:getFinalMatrix()
 	local retVal =  Polycore.Bone_getFinalMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -157,6 +191,7 @@ end
 
 function Bone:getBaseMatrix()
 	local retVal =  Polycore.Bone_getBaseMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -168,6 +203,7 @@ end
 
 function Bone:getFullBaseMatrix()
 	local retVal =  Polycore.Bone_getFullBaseMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 105 - 0
Bindings/Contents/LUA/API/Polycode/BoneTrack.lua

@@ -2,8 +2,113 @@ class "BoneTrack"
 
 
 
+function BoneTrack:__index__(name)
+	if name == "LocXVec" then
+		retVal = Polycore.BoneTrack_get_LocXVec(self.__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
+	elseif name == "LocYVec" then
+		retVal = Polycore.BoneTrack_get_LocYVec(self.__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
+	elseif name == "LocZVec" then
+		retVal = Polycore.BoneTrack_get_LocZVec(self.__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
+	elseif name == "ScaleXVec" then
+		retVal = Polycore.BoneTrack_get_ScaleXVec(self.__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
+	elseif name == "ScaleYVec" then
+		retVal = Polycore.BoneTrack_get_ScaleYVec(self.__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
+	elseif name == "ScaleZVec" then
+		retVal = Polycore.BoneTrack_get_ScaleZVec(self.__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
+	elseif name == "boneQuat" then
+		retVal = Polycore.BoneTrack_get_boneQuat(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Quaternion("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "QuatWVec" then
+		retVal = Polycore.BoneTrack_get_QuatWVec(self.__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
+	elseif name == "QuatXVec" then
+		retVal = Polycore.BoneTrack_get_QuatXVec(self.__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
+	elseif name == "QuatYVec" then
+		retVal = Polycore.BoneTrack_get_QuatYVec(self.__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
+	elseif name == "QuatZVec" then
+		retVal = Polycore.BoneTrack_get_QuatZVec(self.__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
+end
 
 
+function BoneTrack:__set_callback(name,value)
+	return false
+end
 
 
 function BoneTrack:BoneTrack(...)

+ 4 - 0
Bindings/Contents/LUA/API/Polycode/Camera.lua

@@ -98,6 +98,10 @@ function Camera:setPostFilter(shaderName)
 	local retVal = Polycore.Camera_setPostFilter(self.__ptr, shaderName)
 end
 
+function Camera:removePostFilter()
+	local retVal =  Polycore.Camera_removePostFilter(self.__ptr)
+end
+
 
 
 function Camera:__delete()

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

@@ -30,6 +30,7 @@ end
 
 function Config:getEntry(configNamespace, key)
 	local retVal = Polycore.Config_getEntry(self.__ptr, configNamespace, key)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 7 - 0
Bindings/Contents/LUA/API/Polycode/Core.lua

@@ -36,6 +36,7 @@ end
 
 function Core:createMutex()
 	local retVal =  Polycore.Core_createMutex(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -51,6 +52,7 @@ end
 
 function Core:getClipboardString()
 	local retVal =  Polycore.Core_getClipboardString(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -62,6 +64,7 @@ end
 
 function Core:getServices()
 	local retVal =  Polycore.Core_getServices(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -92,6 +95,7 @@ end
 
 function Core:getInput()
 	local retVal =  Polycore.Core_getInput(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -134,6 +138,7 @@ end
 
 function Core:openFolderPicker()
 	local retVal =  Polycore.Core_openFolderPicker(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -166,6 +171,7 @@ end
 
 function Core:getTicks()
 	local retVal =  Polycore.Core_getTicks(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -186,6 +192,7 @@ end
 
 function Core:getUserPointer()
 	local retVal =  Polycore.Core_getUserPointer(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 3 - 0
Bindings/Contents/LUA/API/Polycode/CoreInput.lua

@@ -33,6 +33,7 @@ end
 
 function CoreInput:getMousePosition()
 	local retVal =  Polycore.CoreInput_getMousePosition(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -49,6 +50,7 @@ end
 
 function CoreInput:getMouseDelta()
 	local retVal =  Polycore.CoreInput_getMouseDelta(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -89,6 +91,7 @@ end
 
 function CoreInput:createEvent(event)
 	local retVal = Polycore.CoreInput_createEvent(event.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 17 - 0
Bindings/Contents/LUA/API/Polycode/CoreServices.lua

@@ -10,6 +10,7 @@ class "CoreServices" (EventDispatcher)
 
 function CoreServices:getInstance()
 	local retVal =  Polycore.CoreServices_getInstance()
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -19,8 +20,13 @@ function CoreServices:getInstance()
 	end
 end
 
+function CoreServices:setInstance(_instance)
+	local retVal = Polycore.CoreServices_setInstance(_instance.__ptr)
+end
+
 function CoreServices:getRenderMutex()
 	local retVal =  Polycore.CoreServices_getRenderMutex()
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -36,6 +42,7 @@ end
 
 function CoreServices:getRenderer()
 	local retVal =  Polycore.CoreServices_getRenderer(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -55,6 +62,7 @@ end
 
 function CoreServices:getCore()
 	local retVal =  Polycore.CoreServices_getCore(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -70,6 +78,7 @@ end
 
 function CoreServices:getMaterialManager()
 	local retVal =  Polycore.CoreServices_getMaterialManager(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -81,6 +90,7 @@ end
 
 function CoreServices:getScreenManager()
 	local retVal =  Polycore.CoreServices_getScreenManager(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -92,6 +102,7 @@ end
 
 function CoreServices:getSceneManager()
 	local retVal =  Polycore.CoreServices_getSceneManager(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -103,6 +114,7 @@ end
 
 function CoreServices:getTimerManager()
 	local retVal =  Polycore.CoreServices_getTimerManager(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -114,6 +126,7 @@ end
 
 function CoreServices:getTweenManager()
 	local retVal =  Polycore.CoreServices_getTweenManager(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -125,6 +138,7 @@ end
 
 function CoreServices:getResourceManager()
 	local retVal =  Polycore.CoreServices_getResourceManager(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -136,6 +150,7 @@ end
 
 function CoreServices:getSoundManager()
 	local retVal =  Polycore.CoreServices_getSoundManager(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -147,6 +162,7 @@ end
 
 function CoreServices:getFontManager()
 	local retVal =  Polycore.CoreServices_getFontManager(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -158,6 +174,7 @@ end
 
 function CoreServices:getConfig()
 	local retVal =  Polycore.CoreServices_getConfig(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -40,6 +40,7 @@ end
 
 function Data:getData()
 	local retVal =  Polycore.Data_getData(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 31 - 0
Bindings/Contents/LUA/API/Polycode/Entity.lua

@@ -15,6 +15,15 @@ function Entity:__index__(name)
 		return Polycore.Entity_get_backfaceCulled(self.__ptr)
 	elseif name == "renderWireframe" then
 		return Polycore.Entity_get_renderWireframe(self.__ptr)
+	elseif name == "color" then
+		retVal = Polycore.Entity_get_color(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Color("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
 	elseif name == "enabled" then
 		return Polycore.Entity_get_enabled(self.__ptr)
 	elseif name == "visible" then
@@ -29,6 +38,15 @@ function Entity:__index__(name)
 		return Polycore.Entity_get_colorAffectsChildren(self.__ptr)
 	elseif name == "depthOnly" then
 		return Polycore.Entity_get_depthOnly(self.__ptr)
+	elseif name == "bBox" then
+		retVal = Polycore.Entity_get_bBox(self.__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
 	elseif name == "ignoreParentMatrix" then
 		return Polycore.Entity_get_ignoreParentMatrix(self.__ptr)
 	elseif name == "isMask" then
@@ -132,6 +150,7 @@ end
 
 function Entity:getTransformMatrix()
 	local retVal =  Polycore.Entity_getTransformMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -143,6 +162,7 @@ end
 
 function Entity:getConcatenatedMatrix()
 	local retVal =  Polycore.Entity_getConcatenatedMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -154,6 +174,7 @@ end
 
 function Entity:getConcatenatedRollMatrix()
 	local retVal =  Polycore.Entity_getConcatenatedRollMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -173,6 +194,7 @@ end
 
 function Entity:getLookAtMatrix(loc, upVector)
 	local retVal = Polycore.Entity_getLookAtMatrix(self.__ptr, loc.__ptr, upVector.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -200,6 +222,7 @@ end
 
 function Entity:getParentEntity()
 	local retVal =  Polycore.Entity_getParentEntity(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -211,6 +234,7 @@ end
 
 function Entity:getPosition()
 	local retVal =  Polycore.Entity_getPosition(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -222,6 +246,7 @@ end
 
 function Entity:getCombinedPosition()
 	local retVal =  Polycore.Entity_getCombinedPosition(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -273,6 +298,7 @@ end
 
 function Entity:getCompoundScale()
 	local retVal =  Polycore.Entity_getCompoundScale(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -284,6 +310,7 @@ end
 
 function Entity:getScale()
 	local retVal =  Polycore.Entity_getScale(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -357,6 +384,7 @@ end
 
 function Entity:getRotationQuat()
 	local retVal =  Polycore.Entity_getRotationQuat(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -376,6 +404,7 @@ end
 
 function Entity:getCombinedColor()
 	local retVal =  Polycore.Entity_getCombinedColor(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -425,6 +454,7 @@ end
 
 function Entity:getChildCenter()
 	local retVal =  Polycore.Entity_getChildCenter(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -445,6 +475,7 @@ end
 
 function Entity:buildPositionMatrix()
 	local retVal =  Polycore.Entity_buildPositionMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -29,6 +29,7 @@ end
 
 function Event:getDispatcher()
 	local retVal =  Polycore.Event_getDispatcher(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -30,6 +30,7 @@ end
 
 function FixedShader:createBinding()
 	local retVal =  Polycore.FixedShader_createBinding(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -42,6 +42,7 @@ end
 
 function FixedShaderBinding:getDiffuseTexture()
 	local retVal =  Polycore.FixedShaderBinding_getDiffuseTexture(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -22,6 +22,7 @@ end
 
 function Font:getFace()
 	local retVal =  Polycore.Font_getFace(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -26,6 +26,7 @@ end
 
 function FontManager:getFontByName(fontName)
 	local retVal = Polycore.FontManager_getFontByName(self.__ptr, fontName)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 54 - 0
Bindings/Contents/LUA/API/Polycode/GLSLProgram.lua

@@ -0,0 +1,54 @@
+require "Polycode/Resource"
+
+class "GLSLProgram" (Resource)
+
+
+
+TYPE_VERT = 0
+TYPE_FRAG = 1
+function GLSLProgram:__index__(name)
+	if name == "type" then
+		return Polycore.GLSLProgram_get_type(self.__ptr)
+	end
+end
+
+
+function GLSLProgram:__set_callback(name,value)
+	if name == "type" then
+		Polycore.GLSLProgram_set_type(self.__ptr, value)
+		return true
+	end
+	return false
+end
+
+
+function GLSLProgram:GLSLProgram(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "Resource" 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 = Polycore.GLSLProgram(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function GLSLProgram:addParam(name, isAuto, autoID, paramType, defaultData)
+	local retVal = Polycore.GLSLProgram_addParam(self.__ptr, name, isAuto, autoID, paramType, defaultData.__ptr)
+end
+
+
+
+function GLSLProgram:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Polycore.delete_GLSLProgram(self.__ptr)
+end

+ 47 - 0
Bindings/Contents/LUA/API/Polycode/GLSLShader.lua

@@ -0,0 +1,47 @@
+require "Polycode/Shader"
+
+class "GLSLShader" (Shader)
+
+
+
+
+
+
+
+function GLSLShader:GLSLShader(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "Shader" 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 = Polycore.GLSLShader(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function GLSLShader:createBinding()
+	local retVal =  Polycore.GLSLShader_createBinding(self.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = ShaderBinding("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+
+
+function GLSLShader:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Polycore.delete_GLSLShader(self.__ptr)
+end

+ 52 - 0
Bindings/Contents/LUA/API/Polycode/GLSLShaderBinding.lua

@@ -0,0 +1,52 @@
+require "Polycode/ShaderBinding"
+
+class "GLSLShaderBinding" (ShaderBinding)
+
+
+
+
+
+
+
+function GLSLShaderBinding:GLSLShaderBinding(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "ShaderBinding" 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 = Polycore.GLSLShaderBinding(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function GLSLShaderBinding:addTexture(name, texture)
+	local retVal = Polycore.GLSLShaderBinding_addTexture(self.__ptr, name, texture.__ptr)
+end
+
+function GLSLShaderBinding:addCubemap(name, cubemap)
+	local retVal = Polycore.GLSLShaderBinding_addCubemap(self.__ptr, name, cubemap.__ptr)
+end
+
+function GLSLShaderBinding:clearTexture(name)
+	local retVal = Polycore.GLSLShaderBinding_clearTexture(self.__ptr, name)
+end
+
+function GLSLShaderBinding:addParam(type, name, value)
+	local retVal = Polycore.GLSLShaderBinding_addParam(self.__ptr, type, name, value)
+end
+
+
+
+function GLSLShaderBinding:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Polycore.delete_GLSLShaderBinding(self.__ptr)
+end

+ 73 - 0
Bindings/Contents/LUA/API/Polycode/GLSLShaderModule.lua

@@ -0,0 +1,73 @@
+class "GLSLShaderModule"
+
+
+
+
+
+
+
+function GLSLShaderModule:GLSLShaderModule(...)
+	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 = Polycore.GLSLShaderModule(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function GLSLShaderModule:acceptsExtension(extension)
+	local retVal = Polycore.GLSLShaderModule_acceptsExtension(self.__ptr, extension)
+	return retVal
+end
+
+function GLSLShaderModule:createProgramFromFile(extension, fullPath)
+	local retVal = Polycore.GLSLShaderModule_createProgramFromFile(self.__ptr, extension, fullPath)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = Resource("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function GLSLShaderModule:reloadPrograms()
+	local retVal =  Polycore.GLSLShaderModule_reloadPrograms(self.__ptr)
+end
+
+function GLSLShaderModule:getShaderType()
+	local retVal =  Polycore.GLSLShaderModule_getShaderType(self.__ptr)
+	return retVal
+end
+
+function GLSLShaderModule:createShader(node)
+	local retVal = Polycore.GLSLShaderModule_createShader(self.__ptr, node.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = Shader("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function GLSLShaderModule:applyShaderMaterial(r_enderer, material, localOptions, shaderIndex)
+	local retVal = Polycore.GLSLShaderModule_applyShaderMaterial(self.__ptr, r_enderer.__ptr, material.__ptr, localOptions.__ptr, shaderIndex)
+	return retVal
+end
+
+function GLSLShaderModule:clearShader()
+	local retVal =  Polycore.GLSLShaderModule_clearShader(self.__ptr)
+end
+
+
+
+function GLSLShaderModule:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Polycore.delete_GLSLShaderModule(self.__ptr)
+end

+ 2 - 0
Bindings/Contents/LUA/API/Polycode/Image.lua

@@ -46,6 +46,7 @@ end
 
 function Image:getPixel(x, y)
 	local retVal = Polycore.Image_getPixel(self.__ptr, x, y)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -143,6 +144,7 @@ end
 
 function Image:getPixels()
 	local retVal =  Polycore.Image_getPixels(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 29 - 0
Bindings/Contents/LUA/API/Polycode/InputEvent.lua

@@ -18,6 +18,33 @@ EVENT_KEYUP = 14
 function InputEvent:__index__(name)
 	if name == "mouseButton" then
 		return Polycore.InputEvent_get_mouseButton(self.__ptr)
+	elseif name == "mousePosition" then
+		retVal = Polycore.InputEvent_get_mousePosition(self.__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
+	elseif name == "key" then
+		retVal = Polycore.InputEvent_get_key(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = PolyKEY("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "charCode" then
+		retVal = Polycore.InputEvent_get_charCode(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = wchar_t("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
 	elseif name == "timestamp" then
 		return Polycore.InputEvent_get_timestamp(self.__ptr)
 	end
@@ -58,6 +85,7 @@ end
 
 function InputEvent:getMousePosition()
 	local retVal =  Polycore.InputEvent_getMousePosition(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -69,6 +97,7 @@ end
 
 function InputEvent:getKey()
 	local retVal =  Polycore.InputEvent_getKey(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -51,6 +51,7 @@ end
 
 function Label:getFont()
 	local retVal =  Polycore.Label_getFont(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 3 - 0
Bindings/Contents/LUA/API/Polycode/Material.lua

@@ -48,6 +48,7 @@ end
 
 function Material:getShaderRenderTarget(index)
 	local retVal = Polycore.Material_getShaderRenderTarget(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -64,6 +65,7 @@ end
 
 function Material:getShader(index)
 	local retVal = Polycore.Material_getShader(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -75,6 +77,7 @@ end
 
 function Material:getShaderBinding(index)
 	local retVal = Polycore.Material_getShaderBinding(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 10 - 0
Bindings/Contents/LUA/API/Polycode/MaterialManager.lua

@@ -26,6 +26,7 @@ end
 
 function MaterialManager:createFramebufferTexture(width, height, type)
 	local retVal = Polycore.MaterialManager_createFramebufferTexture(self.__ptr, width, height, type)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -37,6 +38,7 @@ end
 
 function MaterialManager:createTexture(width, height, imageData, clamp, type)
 	local retVal = Polycore.MaterialManager_createTexture(self.__ptr, width, height, imageData.__ptr, clamp, type)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -48,6 +50,7 @@ end
 
 function MaterialManager:createNewTexture(width, height, clamp, type)
 	local retVal = Polycore.MaterialManager_createNewTexture(self.__ptr, width, height, clamp, type)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -59,6 +62,7 @@ end
 
 function MaterialManager:createTextureFromImage(image, clamp)
 	local retVal = Polycore.MaterialManager_createTextureFromImage(self.__ptr, image.__ptr, clamp)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -70,6 +74,7 @@ end
 
 function MaterialManager:createTextureFromFile(fileName, clamp)
 	local retVal = Polycore.MaterialManager_createTextureFromFile(self.__ptr, fileName, clamp)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -101,6 +106,7 @@ end
 
 function MaterialManager:getTextureByResourcePath(resourcePath)
 	local retVal = Polycore.MaterialManager_getTextureByResourcePath(self.__ptr, resourcePath)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -112,6 +118,7 @@ end
 
 function MaterialManager:cubemapFromXMLNode(node)
 	local retVal = Polycore.MaterialManager_cubemapFromXMLNode(self.__ptr, node.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -127,6 +134,7 @@ end
 
 function MaterialManager:materialFromXMLNode(node)
 	local retVal = Polycore.MaterialManager_materialFromXMLNode(self.__ptr, node.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -138,6 +146,7 @@ end
 
 function MaterialManager:setShaderFromXMLNode(node)
 	local retVal = Polycore.MaterialManager_setShaderFromXMLNode(self.__ptr, node.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -149,6 +158,7 @@ end
 
 function MaterialManager:createShaderFromXMLNode(node)
 	local retVal = Polycore.MaterialManager_createShaderFromXMLNode(self.__ptr, node.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 4 - 0
Bindings/Contents/LUA/API/Polycode/Matrix4.lua

@@ -26,6 +26,7 @@ end
 
 function Matrix4:rotateVector(v2)
 	local retVal = Polycore.Matrix4_rotateVector(self.__ptr, v2.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -37,6 +38,7 @@ end
 
 function Matrix4:getPosition()
 	local retVal =  Polycore.Matrix4_getPosition(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -60,6 +62,7 @@ end
 
 function Matrix4:inverse()
 	local retVal =  Polycore.Matrix4_inverse(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -71,6 +74,7 @@ end
 
 function Matrix4:inverseAffine()
 	local retVal =  Polycore.Matrix4_inverseAffine(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 17 - 0
Bindings/Contents/LUA/API/Polycode/Mesh.lua

@@ -59,8 +59,14 @@ function Mesh:getPolygonCount()
 	return retVal
 end
 
+function Mesh:getVertexCount()
+	local retVal =  Polycore.Mesh_getVertexCount(self.__ptr)
+	return retVal
+end
+
 function Mesh:getPolygon(index)
 	local retVal = Polycore.Mesh_getPolygon(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -82,8 +88,17 @@ function Mesh:createSphere(radius, numRings, numSegments)
 	local retVal = Polycore.Mesh_createSphere(self.__ptr, radius, numRings, numSegments)
 end
 
+function Mesh:createCylinder(height, radius, numSegments)
+	local retVal = Polycore.Mesh_createCylinder(self.__ptr, height, radius, numSegments)
+end
+
+function Mesh:createCone(height, radius, numSegments)
+	local retVal = Polycore.Mesh_createCone(self.__ptr, height, radius, numSegments)
+end
+
 function Mesh:recenterMesh()
 	local retVal =  Polycore.Mesh_recenterMesh(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -103,6 +118,7 @@ end
 
 function Mesh:getVertexBuffer()
 	local retVal =  Polycore.Mesh_getVertexBuffer(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -132,6 +148,7 @@ end
 
 function Mesh:calculateBBox()
 	local retVal =  Polycore.Mesh_calculateBBox(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -8,6 +8,7 @@ class "OSBasics"
 
 function OSBasics:open(filename, opts)
 	local retVal = Polycore.OSBasics_open(filename, opts)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -70,6 +70,7 @@ end
 
 function ObjectEntry:addChild(name)
 	local retVal = Polycore.ObjectEntry_addChild(self.__ptr, name)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 30 - 3
Bindings/Contents/LUA/API/Polycode/Particle.lua

@@ -5,7 +5,34 @@ class "Particle"
 BILLBOARD_PARTICLE = 0
 MESH_PARTICLE = 1
 function Particle:__index__(name)
-	if name == "life" then
+	if name == "velVector" then
+		retVal = Polycore.Particle_get_velVector(self.__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
+	elseif name == "dirVector" then
+		retVal = Polycore.Particle_get_dirVector(self.__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
+	elseif name == "deviation" then
+		retVal = Polycore.Particle_get_deviation(self.__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
+	elseif name == "life" then
 		return Polycore.Particle_get_life(self.__ptr)
 	elseif name == "lifespan" then
 		return Polycore.Particle_get_lifespan(self.__ptr)
@@ -63,8 +90,8 @@ function Particle:Reset(continuious)
 	local retVal = Polycore.Particle_Reset(self.__ptr, continuious)
 end
 
-function Particle:createSceneParticle(particleType, texture, particleMesh)
-	local retVal = Polycore.Particle_createSceneParticle(self.__ptr, particleType, texture.__ptr, particleMesh.__ptr)
+function Particle:createSceneParticle(particleType, material, particleMesh)
+	local retVal = Polycore.Particle_createSceneParticle(self.__ptr, particleType, material.__ptr, particleMesh.__ptr)
 end
 
 function Particle:createScreenParticle(particleType, texture, particleMesh)

+ 98 - 26
Bindings/Contents/LUA/API/Polycode/ParticleEmitter.lua

@@ -4,16 +4,91 @@ class "ParticleEmitter"
 
 CONTINUOUS_EMITTER = 0
 TRIGGERED_EMITTER = 1
-CLOUD_EMITTER = 2
 function ParticleEmitter:__index__(name)
 	if name == "particleSpeedMod" then
 		return Polycore.ParticleEmitter_get_particleSpeedMod(self.__ptr)
 	elseif name == "brightnessDeviation" then
 		return Polycore.ParticleEmitter_get_brightnessDeviation(self.__ptr)
+	elseif name == "deviation" then
+		retVal = Polycore.ParticleEmitter_get_deviation(self.__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
+	elseif name == "dirVector" then
+		retVal = Polycore.ParticleEmitter_get_dirVector(self.__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
+	elseif name == "gravVector" then
+		retVal = Polycore.ParticleEmitter_get_gravVector(self.__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
 	elseif name == "lifespan" then
 		return Polycore.ParticleEmitter_get_lifespan(self.__ptr)
 	elseif name == "rotationFollowsPath" then
 		return Polycore.ParticleEmitter_get_rotationFollowsPath(self.__ptr)
+	elseif name == "scaleCurve" then
+		retVal = Polycore.ParticleEmitter_get_scaleCurve(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = BezierCurve("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "colorCurveR" then
+		retVal = Polycore.ParticleEmitter_get_colorCurveR(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = BezierCurve("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "colorCurveG" then
+		retVal = Polycore.ParticleEmitter_get_colorCurveG(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = BezierCurve("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "colorCurveB" then
+		retVal = Polycore.ParticleEmitter_get_colorCurveB(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = BezierCurve("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "colorCurveA" then
+		retVal = Polycore.ParticleEmitter_get_colorCurveA(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = BezierCurve("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "useColorCurves" then
+		return Polycore.ParticleEmitter_get_useColorCurves(self.__ptr)
+	elseif name == "useScaleCurves" then
+		return Polycore.ParticleEmitter_get_useScaleCurves(self.__ptr)
 	end
 end
 
@@ -31,11 +106,31 @@ function ParticleEmitter:__set_callback(name,value)
 	elseif name == "rotationFollowsPath" then
 		Polycore.ParticleEmitter_set_rotationFollowsPath(self.__ptr, value)
 		return true
+	elseif name == "useColorCurves" then
+		Polycore.ParticleEmitter_set_useColorCurves(self.__ptr, value)
+		return true
+	elseif name == "useScaleCurves" then
+		Polycore.ParticleEmitter_set_useScaleCurves(self.__ptr, value)
+		return true
 	end
 	return false
 end
 
 
+function ParticleEmitter:ParticleEmitter(...)
+	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 = Polycore.ParticleEmitter(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
 function ParticleEmitter:createParticles()
 	local retVal =  Polycore.ParticleEmitter_createParticles(self.__ptr)
 end
@@ -44,14 +139,6 @@ function ParticleEmitter:setRotationSpeed(speed)
 	local retVal = Polycore.ParticleEmitter_setRotationSpeed(self.__ptr, speed)
 end
 
-function ParticleEmitter:setStartingColor(c)
-	local retVal = Polycore.ParticleEmitter_setStartingColor(self.__ptr, c.__ptr)
-end
-
-function ParticleEmitter:setEndingColor(c)
-	local retVal = Polycore.ParticleEmitter_setEndingColor(self.__ptr, c.__ptr)
-end
-
 function ParticleEmitter:setParticleBlendingMode(mode)
 	local retVal = Polycore.ParticleEmitter_setParticleBlendingMode(self.__ptr, mode)
 end
@@ -86,23 +173,7 @@ function ParticleEmitter:emitterEnabled()
 end
 
 function ParticleEmitter:setEmitterRadius(rad)
-	local retVal = Polycore.ParticleEmitter_setEmitterRadius(self.__ptr, rad)
-end
-
-function ParticleEmitter:setStartingScaleModifier(mod)
-	local retVal = Polycore.ParticleEmitter_setStartingScaleModifier(self.__ptr, mod)
-end
-
-function ParticleEmitter:setEndingScaleModifier(mod)
-	local retVal = Polycore.ParticleEmitter_setEndingScaleModifier(self.__ptr, mod)
-end
-
-function ParticleEmitter:setEmitRotationVector(rotVector)
-	local retVal = Polycore.ParticleEmitter_setEmitRotationVector(self.__ptr, rotVector.__ptr)
-end
-
-function ParticleEmitter:setEmitRotationDeviance(rotVector)
-	local retVal = Polycore.ParticleEmitter_setEmitRotationDeviance(self.__ptr, rotVector.__ptr)
+	local retVal = Polycore.ParticleEmitter_setEmitterRadius(self.__ptr, rad.__ptr)
 end
 
 function ParticleEmitter:setAllAtOnce(val)
@@ -131,6 +202,7 @@ end
 
 function ParticleEmitter:getBaseMatrix()
 	local retVal =  Polycore.ParticleEmitter_getBaseMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 28 - 0
Bindings/Contents/LUA/API/Polycode/PolycodeViewBase.lua

@@ -0,0 +1,28 @@
+class "PolycodeViewBase"
+
+
+
+
+
+
+
+function PolycodeViewBase:PolycodeViewBase(...)
+	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 = Polycore.PolycodeViewBase(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+
+
+function PolycodeViewBase:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Polycore.delete_PolycodeViewBase(self.__ptr)
+end

+ 4 - 0
Bindings/Contents/LUA/API/Polycode/Polygon.lua

@@ -39,6 +39,7 @@ end
 
 function Polygon:getVertex(index)
 	local retVal = Polycore.Polygon_getVertex(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -50,6 +51,7 @@ end
 
 function Polygon:addVertex(x, y, z)
 	local retVal = Polycore.Polygon_addVertex(self.__ptr, x, y, z)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -69,6 +71,7 @@ end
 
 function Polygon:getFaceNormal()
 	local retVal =  Polycore.Polygon_getFaceNormal(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -80,6 +83,7 @@ end
 
 function Polygon:getBounds2D()
 	local retVal =  Polycore.Polygon_getBounds2D(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 7 - 0
Bindings/Contents/LUA/API/Polycode/Quaternion.lua

@@ -53,6 +53,7 @@ end
 
 function Quaternion:Slerp(fT, rkP, rkQ, shortestPath)
 	local retVal = Polycore.Quaternion_Slerp(fT, rkP.__ptr, rkQ.__ptr, shortestPath)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -69,6 +70,7 @@ end
 
 function Quaternion:Log()
 	local retVal =  Polycore.Quaternion_Log(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -80,6 +82,7 @@ end
 
 function Quaternion:Exp()
 	local retVal =  Polycore.Quaternion_Exp(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -109,6 +112,7 @@ end
 
 function Quaternion:Squad(fT, rkP, rkA, rkB, rkQ, shortestPath)
 	local retVal = Polycore.Quaternion_Squad(fT, rkP.__ptr, rkA.__ptr, rkB.__ptr, rkQ.__ptr, shortestPath)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -120,6 +124,7 @@ end
 
 function Quaternion:Inverse()
 	local retVal =  Polycore.Quaternion_Inverse(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -135,6 +140,7 @@ end
 
 function Quaternion:inverse()
 	local retVal =  Polycore.Quaternion_inverse(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -167,6 +173,7 @@ end
 
 function Quaternion:createMatrix()
 	local retVal =  Polycore.Quaternion_createMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -22,6 +22,7 @@ end
 
 function QuaternionCurve:interpolate(t, useShortestPath)
 	local retVal = Polycore.QuaternionCurve_interpolate(self.__ptr, t, useShortestPath)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 51 - 3
Bindings/Contents/LUA/API/Polycode/Renderer.lua

@@ -15,8 +15,35 @@ DEPTH_FUNCTION_LEQUAL = 1
 TEX_FILTERING_NEAREST = 0
 TEX_FILTERING_LINEAR = 1
 function Renderer:__index__(name)
-	if name == "exposureLevel" then
+	if name == "ambientColor" then
+		retVal = Polycore.Renderer_get_ambientColor(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Color("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "clearColor" then
+		retVal = Polycore.Renderer_get_clearColor(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Color("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "exposureLevel" then
 		return Polycore.Renderer_get_exposureLevel(self.__ptr)
+	elseif name == "cameraPosition" then
+		retVal = Polycore.Renderer_get_cameraPosition(self.__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
 end
 
@@ -44,6 +71,7 @@ end
 
 function Renderer:createCubemap(t0, t1, t2, t3, t4, t5)
 	local retVal = Polycore.Renderer_createCubemap(self.__ptr, t0.__ptr, t1.__ptr, t2.__ptr, t3.__ptr, t4.__ptr, t5.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -55,6 +83,7 @@ end
 
 function Renderer:createTexture(width, height, textureData, clamp, type)
 	local retVal = Polycore.Renderer_createTexture(self.__ptr, width, height, textureData.__ptr, clamp, type)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -70,6 +99,7 @@ end
 
 function Renderer:createFramebufferTexture(width, height)
 	local retVal = Polycore.Renderer_createFramebufferTexture(self.__ptr, width, height)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -165,6 +195,7 @@ end
 
 function Renderer:createRenderDataArrayForMesh(mesh, arrayType)
 	local retVal = Polycore.Renderer_createRenderDataArrayForMesh(self.__ptr, mesh.__ptr, arrayType)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -176,6 +207,7 @@ end
 
 function Renderer:createRenderDataArray(arrayType)
 	local retVal = Polycore.Renderer_createRenderDataArray(self.__ptr, arrayType)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -304,6 +336,7 @@ end
 
 function Renderer:getCameraMatrix()
 	local retVal =  Polycore.Renderer_getCameraMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -335,12 +368,16 @@ function Renderer:getYRes()
 	return retVal
 end
 
+function Renderer:cullFrontFaces(val)
+	local retVal = Polycore.Renderer_cullFrontFaces(self.__ptr, val)
+end
+
 function Renderer:clearLights()
 	local retVal =  Polycore.Renderer_clearLights(self.__ptr)
 end
 
-function Renderer:addLight(position, direction, type, color, distance, intensity, textureMatrix)
-	local retVal = Polycore.Renderer_addLight(self.__ptr, position.__ptr, direction.__ptr, type, color.__ptr, distance, intensity, textureMatrix.__ptr)
+function Renderer:addLight(position, direction, type, color, constantAttenuation, linearAttenuation, quadraticAttenuation, intensity, spotlightCutoff, spotlightExponent, shadowsEnabled, textureMatrix)
+	local retVal = Polycore.Renderer_addLight(self.__ptr, position.__ptr, direction.__ptr, type, color.__ptr, constantAttenuation, linearAttenuation, quadraticAttenuation, intensity, spotlightCutoff, spotlightExponent, shadowsEnabled, textureMatrix.__ptr)
 end
 
 function Renderer:setExposureLevel(level)
@@ -356,6 +393,10 @@ function Renderer:enableShaders(flag)
 	local retVal = Polycore.Renderer_enableShaders(self.__ptr, flag)
 end
 
+function Renderer:initOSSpecific()
+	local retVal =  Polycore.Renderer_initOSSpecific(self.__ptr)
+end
+
 function Renderer:addShaderModule(module)
 	local retVal = Polycore.Renderer_addShaderModule(self.__ptr, module.__ptr)
 end
@@ -367,6 +408,7 @@ end
 
 function Renderer:getProjectionMatrix()
 	local retVal =  Polycore.Renderer_getProjectionMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -378,6 +420,7 @@ end
 
 function Renderer:getModelviewMatrix()
 	local retVal =  Polycore.Renderer_getModelviewMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -393,6 +436,7 @@ end
 
 function Renderer:Unproject(x, y)
 	local retVal = Polycore.Renderer_Unproject(self.__ptr, x, y)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -402,6 +446,10 @@ function Renderer:Unproject(x, y)
 	end
 end
 
+function Renderer:sortLights()
+	local retVal =  Polycore.Renderer_sortLights(self.__ptr)
+end
+
 function Renderer:getNumAreaLights()
 	local retVal =  Polycore.Renderer_getNumAreaLights(self.__ptr)
 	return retVal

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

@@ -63,6 +63,7 @@ end
 
 function ResourceManager:getResource(resourceType, resourceName)
 	local retVal = Polycore.ResourceManager_getResource(self.__ptr, resourceType, resourceName)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 37 - 3
Bindings/Contents/LUA/API/Polycode/Scene.lua

@@ -10,8 +10,35 @@ ENTITY_CAMERA = 2
 ENTITY_ENTITY = 3
 ENTITY_COLLMESH = 4
 function Scene:__index__(name)
-	if name == "useClearColor" then
+	if name == "clearColor" then
+		retVal = Polycore.Scene_get_clearColor(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Color("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "useClearColor" then
 		return Polycore.Scene_get_useClearColor(self.__ptr)
+	elseif name == "ambientColor" then
+		retVal = Polycore.Scene_get_ambientColor(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Color("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "fogColor" then
+		retVal = Polycore.Scene_get_fogColor(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Color("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
 	elseif name == "enabled" then
 		return Polycore.Scene_get_enabled(self.__ptr)
 	end
@@ -60,6 +87,7 @@ end
 
 function Scene:getDefaultCamera()
 	local retVal =  Polycore.Scene_getDefaultCamera(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -110,6 +138,7 @@ end
 
 function Scene:getEntity(index)
 	local retVal = Polycore.Scene_getEntity(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -121,6 +150,7 @@ end
 
 function Scene:getEntityAtScreenPosition(x, y)
 	local retVal = Polycore.Scene_getEntityAtScreenPosition(self.__ptr, x, y)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -130,8 +160,8 @@ function Scene:getEntityAtScreenPosition(x, y)
 	end
 end
 
-function Scene:Render()
-	local retVal =  Polycore.Scene_Render(self.__ptr)
+function Scene:Render(targetCamera)
+	local retVal = Polycore.Scene_Render(self.__ptr, targetCamera.__ptr)
 end
 
 function Scene:RenderDepthOnly(targetCamera)
@@ -157,6 +187,7 @@ end
 
 function Scene:getNearestLight(pos)
 	local retVal = Polycore.Scene_getNearestLight(self.__ptr, pos.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -185,6 +216,7 @@ end
 
 function Scene:getStaticGeometry(index)
 	local retVal = Polycore.Scene_getStaticGeometry(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -205,6 +237,7 @@ end
 
 function Scene:getLight(index)
 	local retVal = Polycore.Scene_getLight(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -216,6 +249,7 @@ end
 
 function Scene:getCustomEntityByType(type)
 	local retVal = Polycore.Scene_getCustomEntityByType(self.__ptr, type)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -39,6 +39,7 @@ end
 
 function SceneLabel:getLabel()
 	local retVal =  Polycore.SceneLabel_getLabel(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 43 - 2
Bindings/Contents/LUA/API/Polycode/SceneLight.lua

@@ -6,8 +6,23 @@ class "SceneLight" (SceneEntity)
 
 AREA_LIGHT = 0
 SPOT_LIGHT = 1
+function SceneLight:__index__(name)
+	if name == "lightColor" then
+		retVal = Polycore.SceneLight_get_lightColor(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Color("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	end
+end
 
 
+function SceneLight:__set_callback(name,value)
+	return false
+end
 
 
 function SceneLight:SceneLight(...)
@@ -35,8 +50,18 @@ function SceneLight:getIntensity()
 	return retVal
 end
 
-function SceneLight:getDistance()
-	local retVal =  Polycore.SceneLight_getDistance(self.__ptr)
+function SceneLight:getConstantAttenuation()
+	local retVal =  Polycore.SceneLight_getConstantAttenuation(self.__ptr)
+	return retVal
+end
+
+function SceneLight:getLinearAttenuation()
+	local retVal =  Polycore.SceneLight_getLinearAttenuation(self.__ptr)
+	return retVal
+end
+
+function SceneLight:getQuadraticAttenuation()
+	local retVal =  Polycore.SceneLight_getQuadraticAttenuation(self.__ptr)
 	return retVal
 end
 
@@ -55,6 +80,7 @@ end
 
 function SceneLight:getLightViewMatrix()
 	local retVal =  Polycore.SceneLight_getLightViewMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -66,6 +92,7 @@ end
 
 function SceneLight:getZBufferTexture()
 	local retVal =  Polycore.SceneLight_getZBufferTexture(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -79,6 +106,20 @@ function SceneLight:setLightColor(r, g, b)
 	local retVal = Polycore.SceneLight_setLightColor(self.__ptr, r, g, b)
 end
 
+function SceneLight:setSpotlightProperties(spotlightCutoff, spotlightExponent)
+	local retVal = Polycore.SceneLight_setSpotlightProperties(self.__ptr, spotlightCutoff, spotlightExponent)
+end
+
+function SceneLight:getSpotlightCutoff()
+	local retVal =  Polycore.SceneLight_getSpotlightCutoff(self.__ptr)
+	return retVal
+end
+
+function SceneLight:getSpotlightExponent()
+	local retVal =  Polycore.SceneLight_getSpotlightExponent(self.__ptr)
+	return retVal
+end
+
 function SceneLight:enableShadows(val, resolution)
 	local retVal = Polycore.SceneLight_enableShadows(self.__ptr, val, resolution)
 end

+ 15 - 1
Bindings/Contents/LUA/API/Polycode/SceneMesh.lua

@@ -5,7 +5,16 @@ class "SceneMesh" (SceneEntity)
 
 
 function SceneMesh:__index__(name)
-	if name == "showVertexNormals" then
+	if name == "lightmapIndex" then
+		retVal = Polycore.SceneMesh_get_lightmapIndex(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = unsigned int("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "showVertexNormals" then
 		return Polycore.SceneMesh_get_showVertexNormals(self.__ptr)
 	end
 end
@@ -46,6 +55,7 @@ end
 
 function SceneMesh:getLocalShaderOptions()
 	local retVal =  Polycore.SceneMesh_getLocalShaderOptions(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -57,6 +67,7 @@ end
 
 function SceneMesh:getMesh()
 	local retVal =  Polycore.SceneMesh_getMesh(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -68,6 +79,7 @@ end
 
 function SceneMesh:getTexture()
 	local retVal =  Polycore.SceneMesh_getTexture(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -79,6 +91,7 @@ end
 
 function SceneMesh:getMaterial()
 	local retVal =  Polycore.SceneMesh_getMaterial(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -118,6 +131,7 @@ end
 
 function SceneMesh:getSkeleton()
 	local retVal =  Polycore.SceneMesh_getSkeleton(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 13 - 0
Bindings/Contents/LUA/API/Polycode/SceneParticleEmitter.lua

@@ -28,12 +28,25 @@ function SceneParticleEmitter:SceneParticleEmitter(...)
 	end
 end
 
+function SceneParticleEmitter:getEmitter()
+	local retVal =  Polycore.SceneParticleEmitter_getEmitter(self.__ptr)
+	if retVal == nil then return nil end
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = ParticleEmitter("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
 function SceneParticleEmitter:addParticleBody(particleBody)
 	local retVal = Polycore.SceneParticleEmitter_addParticleBody(self.__ptr, particleBody.__ptr)
 end
 
 function SceneParticleEmitter:getBaseMatrix()
 	local retVal =  Polycore.SceneParticleEmitter_getBaseMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 2 - 0
Bindings/Contents/LUA/API/Polycode/ScenePrimitive.lua

@@ -7,6 +7,8 @@ class "ScenePrimitive" (SceneMesh)
 TYPE_BOX = 0
 TYPE_PLANE = 1
 TYPE_SPHERE = 2
+TYPE_CYLINDER = 3
+TYPE_CONE = 4
 
 
 

+ 3 - 0
Bindings/Contents/LUA/API/Polycode/SceneRenderTexture.lua

@@ -26,6 +26,7 @@ end
 
 function SceneRenderTexture:getTargetTexture()
 	local retVal =  Polycore.SceneRenderTexture_getTargetTexture(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -37,6 +38,7 @@ end
 
 function SceneRenderTexture:getTargetScene()
 	local retVal =  Polycore.SceneRenderTexture_getTargetScene(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -48,6 +50,7 @@ end
 
 function SceneRenderTexture:getTargetCamera()
 	local retVal =  Polycore.SceneRenderTexture_getTargetCamera(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 52 - 0
Bindings/Contents/LUA/API/Polycode/SceneSound.lua

@@ -0,0 +1,52 @@
+require "Polycode/SceneEntity"
+
+class "SceneSound" (SceneEntity)
+
+
+
+
+
+
+
+function SceneSound:SceneSound(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "SceneEntity" 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 = Polycore.SceneSound(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function SceneSound:Update()
+	local retVal =  Polycore.SceneSound_Update(self.__ptr)
+end
+
+function SceneSound:getSound()
+	local retVal =  Polycore.SceneSound_getSound(self.__ptr)
+	if retVal == nil then return nil end
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = Sound("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+
+
+function SceneSound:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Polycore.delete_SceneSound(self.__ptr)
+end

+ 40 - 0
Bindings/Contents/LUA/API/Polycode/SceneSoundListener.lua

@@ -0,0 +1,40 @@
+require "Polycode/SceneEntity"
+
+class "SceneSoundListener" (SceneEntity)
+
+
+
+
+
+
+
+function SceneSoundListener:SceneSoundListener(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "SceneEntity" 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 = Polycore.SceneSoundListener(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function SceneSoundListener:Update()
+	local retVal =  Polycore.SceneSoundListener_Update(self.__ptr)
+end
+
+
+
+function SceneSoundListener:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Polycore.delete_SceneSoundListener(self.__ptr)
+end

+ 9 - 0
Bindings/Contents/LUA/API/Polycode/Screen.lua

@@ -42,6 +42,7 @@ end
 
 function Screen:addChild(newEntity)
 	local retVal = Polycore.Screen_addChild(self.__ptr, newEntity.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -53,6 +54,7 @@ end
 
 function Screen:removeChild(entityToRemove)
 	local retVal = Polycore.Screen_removeChild(self.__ptr, entityToRemove.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -68,6 +70,7 @@ end
 
 function Screen:getScreenOffset()
 	local retVal =  Polycore.Screen_getScreenOffset(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -87,6 +90,7 @@ end
 
 function Screen:getEntityAt(x, y)
 	local retVal = Polycore.Screen_getEntityAt(self.__ptr, x, y)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -112,6 +116,10 @@ function Screen:setScreenShader(shaderName)
 	local retVal = Polycore.Screen_setScreenShader(self.__ptr, shaderName)
 end
 
+function Screen:clearScreenShader()
+	local retVal =  Polycore.Screen_clearScreenShader(self.__ptr)
+end
+
 function Screen:getHighestZIndex()
 	local retVal =  Polycore.Screen_getHighestZIndex(self.__ptr)
 	return retVal
@@ -151,6 +159,7 @@ end
 
 function Screen:getRootEntity()
 	local retVal =  Polycore.Screen_getRootEntity(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 2 - 0
Bindings/Contents/LUA/API/Polycode/ScreenEntity.lua

@@ -139,6 +139,7 @@ end
 
 function ScreenEntity:buildPositionMatrix()
 	local retVal =  Polycore.ScreenEntity_buildPositionMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -212,6 +213,7 @@ end
 
 function ScreenEntity:getPosition2D()
 	local retVal =  Polycore.ScreenEntity_getPosition2D(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -43,6 +43,7 @@ end
 
 function ScreenLabel:getLabel()
 	local retVal =  Polycore.ScreenLabel_getLabel(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 3 - 3
Bindings/Contents/LUA/API/Polycode/ScreenLine.lua

@@ -1,6 +1,6 @@
-require "Polycode/ScreenEntity"
+require "Polycode/ScreenMesh"
 
-class "ScreenLine" (ScreenEntity)
+class "ScreenLine" (ScreenMesh)
 
 
 
@@ -10,7 +10,7 @@ class "ScreenLine" (ScreenEntity)
 
 function ScreenLine:ScreenLine(...)
 	if type(arg[1]) == "table" and count(arg) == 1 then
-		if ""..arg[1]:class() == "ScreenEntity" then
+		if ""..arg[1]:class() == "ScreenMesh" then
 			self.__ptr = arg[1].__ptr
 			return
 		end

+ 2 - 0
Bindings/Contents/LUA/API/Polycode/ScreenMesh.lua

@@ -34,6 +34,7 @@ end
 
 function ScreenMesh:getMesh()
 	local retVal =  Polycore.ScreenMesh_getMesh(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -45,6 +46,7 @@ end
 
 function ScreenMesh:getTexture()
 	local retVal =  Polycore.ScreenMesh_getTexture(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 13 - 0
Bindings/Contents/LUA/API/Polycode/ScreenParticleEmitter.lua

@@ -28,12 +28,25 @@ function ScreenParticleEmitter:ScreenParticleEmitter(...)
 	end
 end
 
+function ScreenParticleEmitter:getEmitter()
+	local retVal =  Polycore.ScreenParticleEmitter_getEmitter(self.__ptr)
+	if retVal == nil then return nil end
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = ParticleEmitter("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
 function ScreenParticleEmitter:addParticleBody(particleBody)
 	local retVal = Polycore.ScreenParticleEmitter_addParticleBody(self.__ptr, particleBody.__ptr)
 end
 
 function ScreenParticleEmitter:getBaseMatrix()
 	local retVal =  Polycore.ScreenParticleEmitter_getBaseMatrix(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 9 - 0
Bindings/Contents/LUA/API/Polycode/ScreenShape.lua

@@ -10,6 +10,15 @@ SHAPE_CUSTOM = 4
 function ScreenShape:__index__(name)
 	if name == "strokeEnabled" then
 		return Polycore.ScreenShape_get_strokeEnabled(self.__ptr)
+	elseif name == "strokeColor" then
+		retVal = Polycore.ScreenShape_get_strokeColor(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Color("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
 	elseif name == "lineSmooth" then
 		return Polycore.ScreenShape_get_lineSmooth(self.__ptr)
 	end

+ 52 - 0
Bindings/Contents/LUA/API/Polycode/ScreenSound.lua

@@ -0,0 +1,52 @@
+require "Polycode/ScreenEntity"
+
+class "ScreenSound" (ScreenEntity)
+
+
+
+
+
+
+
+function ScreenSound:ScreenSound(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "ScreenEntity" 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 = Polycore.ScreenSound(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function ScreenSound:Update()
+	local retVal =  Polycore.ScreenSound_Update(self.__ptr)
+end
+
+function ScreenSound:getSound()
+	local retVal =  Polycore.ScreenSound_getSound(self.__ptr)
+	if retVal == nil then return nil end
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = Sound("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+
+
+function ScreenSound:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Polycore.delete_ScreenSound(self.__ptr)
+end

+ 40 - 0
Bindings/Contents/LUA/API/Polycode/ScreenSoundListener.lua

@@ -0,0 +1,40 @@
+require "Polycode/ScreenEntity"
+
+class "ScreenSoundListener" (ScreenEntity)
+
+
+
+
+
+
+
+function ScreenSoundListener:ScreenSoundListener(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "ScreenEntity" 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 = Polycore.ScreenSoundListener(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function ScreenSoundListener:Update()
+	local retVal =  Polycore.ScreenSoundListener_Update(self.__ptr)
+end
+
+
+
+function ScreenSoundListener:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Polycore.delete_ScreenSoundListener(self.__ptr)
+end

+ 18 - 0
Bindings/Contents/LUA/API/Polycode/Shader.lua

@@ -6,8 +6,25 @@ class "Shader" (Resource)
 
 FIXED_SHADER = 0
 MODULE_SHADER = 1
+function Shader:__index__(name)
+	if name == "numSpotLights" then
+		return Polycore.Shader_get_numSpotLights(self.__ptr)
+	elseif name == "numAreaLights" then
+		return Polycore.Shader_get_numAreaLights(self.__ptr)
+	end
+end
 
 
+function Shader:__set_callback(name,value)
+	if name == "numSpotLights" then
+		Polycore.Shader_set_numSpotLights(self.__ptr, value)
+		return true
+	elseif name == "numAreaLights" then
+		Polycore.Shader_set_numAreaLights(self.__ptr, value)
+		return true
+	end
+	return false
+end
 
 
 function Shader:getType()
@@ -26,6 +43,7 @@ end
 
 function Shader:createBinding()
 	local retVal =  Polycore.Shader_createBinding(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 5 - 0
Bindings/Contents/LUA/API/Polycode/ShaderBinding.lua

@@ -43,6 +43,7 @@ end
 
 function ShaderBinding:getLocalParam(index)
 	local retVal = Polycore.ShaderBinding_getLocalParam(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -54,6 +55,7 @@ end
 
 function ShaderBinding:getLocalParamByName(name)
 	local retVal = Polycore.ShaderBinding_getLocalParamByName(self.__ptr, name)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -74,6 +76,7 @@ end
 
 function ShaderBinding:getRenderTargetBinding(index)
 	local retVal = Polycore.ShaderBinding_getRenderTargetBinding(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -90,6 +93,7 @@ end
 
 function ShaderBinding:getInTargetBinding(index)
 	local retVal = Polycore.ShaderBinding_getInTargetBinding(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -106,6 +110,7 @@ end
 
 function ShaderBinding:getOutTargetBinding(index)
 	local retVal = Polycore.ShaderBinding_getOutTargetBinding(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 4 - 0
Bindings/Contents/LUA/API/Polycode/Skeleton.lua

@@ -46,6 +46,7 @@ end
 
 function Skeleton:getAnimation(name)
 	local retVal = Polycore.Skeleton_getAnimation(self.__ptr, name)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -61,6 +62,7 @@ end
 
 function Skeleton:getBoneByName(name)
 	local retVal = Polycore.Skeleton_getBoneByName(self.__ptr, name)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -85,6 +87,7 @@ end
 
 function Skeleton:getBone(index)
 	local retVal = Polycore.Skeleton_getBone(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -96,6 +99,7 @@ end
 
 function Skeleton:getCurrentAnimation()
 	local retVal =  Polycore.Skeleton_getCurrentAnimation(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 33 - 2
Bindings/Contents/LUA/API/Polycode/Sound.lua

@@ -20,16 +20,45 @@ function Sound:Sound(...)
 	end
 end
 
-function Sound:Play(once)
-	local retVal = Polycore.Sound_Play(self.__ptr, once)
+function Sound:Play(loop)
+	local retVal = Polycore.Sound_Play(self.__ptr, loop)
 end
 
 function Sound:Stop()
 	local retVal =  Polycore.Sound_Stop(self.__ptr)
 end
 
+function Sound:setVolume(newVolume)
+	local retVal = Polycore.Sound_setVolume(self.__ptr, newVolume)
+end
+
+function Sound:setPitch(newPitch)
+	local retVal = Polycore.Sound_setPitch(self.__ptr, newPitch)
+end
+
+function Sound:setIsPositional(isPositional)
+	local retVal = Polycore.Sound_setIsPositional(self.__ptr, isPositional)
+end
+
+function Sound:setSoundPosition(position)
+	local retVal = Polycore.Sound_setSoundPosition(self.__ptr, position.__ptr)
+end
+
+function Sound:setSoundVelocity(velocity)
+	local retVal = Polycore.Sound_setSoundVelocity(self.__ptr, velocity.__ptr)
+end
+
+function Sound:setSoundDirection(direction)
+	local retVal = Polycore.Sound_setSoundDirection(self.__ptr, direction.__ptr)
+end
+
+function Sound:setPositionalProperties(referenceDistance, maxDistance)
+	local retVal = Polycore.Sound_setPositionalProperties(self.__ptr, referenceDistance, maxDistance)
+end
+
 function Sound:loadWAV(fileName)
 	local retVal = Polycore.Sound_loadWAV(self.__ptr, fileName)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -41,6 +70,7 @@ end
 
 function Sound:loadOGG(fileName)
 	local retVal = Polycore.Sound_loadOGG(self.__ptr, fileName)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -52,6 +82,7 @@ end
 
 function Sound:GenSource(buffer)
 	local retVal = Polycore.Sound_GenSource(self.__ptr, buffer.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 12 - 0
Bindings/Contents/LUA/API/Polycode/SoundManager.lua

@@ -20,10 +20,22 @@ function SoundManager:SoundManager(...)
 	end
 end
 
+function SoundManager:setListenerPosition(position)
+	local retVal = Polycore.SoundManager_setListenerPosition(self.__ptr, position.__ptr)
+end
+
+function SoundManager:setListenerOrientation(orientation)
+	local retVal = Polycore.SoundManager_setListenerOrientation(self.__ptr, orientation.__ptr)
+end
+
 function SoundManager:initAL()
 	local retVal =  Polycore.SoundManager_initAL(self.__ptr)
 end
 
+function SoundManager:setGlobalVolume(globalVolume)
+	local retVal = Polycore.SoundManager_setGlobalVolume(self.__ptr, globalVolume)
+end
+
 
 
 function SoundManager:__delete()

+ 30 - 0
Bindings/Contents/LUA/API/Polycode/String.lua

@@ -3,8 +3,32 @@ class "String"
 
 
 ENCODING_UTF8 = 0
+function String:__index__(name)
+	if name == "contents" then
+		retVal = Polycore.String_get_contents(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = wstring("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "s_contents" then
+		retVal = Polycore.String_get_s_contents(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = string("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	end
+end
 
 
+function String:__set_callback(name,value)
+	return false
+end
 
 
 function String:String(...)
@@ -33,6 +57,7 @@ end
 
 function String:getSTLString()
 	local retVal =  Polycore.String_getSTLString(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -44,6 +69,7 @@ end
 
 function String:getSTLWString()
 	local retVal =  Polycore.String_getSTLWString(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -95,6 +121,7 @@ end
 
 function String:c_str()
 	local retVal =  Polycore.String_c_str(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -106,6 +133,7 @@ end
 
 function String:wc_str()
 	local retVal =  Polycore.String_wc_str(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -117,6 +145,7 @@ end
 
 function String:data()
 	local retVal =  Polycore.String_data(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -128,6 +157,7 @@ end
 
 function String:getDataWithEncoding(encoding)
 	local retVal = Polycore.String_getDataWithEncoding(self.__ptr, encoding)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -67,6 +67,7 @@ end
 
 function Texture:getTextureData()
 	local retVal =  Polycore.Texture_getTextureData(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

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

@@ -63,6 +63,7 @@ end
 
 function Vector3:crossProduct(vec2)
 	local retVal = Polycore.Vector3_crossProduct(self.__ptr, vec2.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 39 - 1
Bindings/Contents/LUA/API/Polycode/Vertex.lua

@@ -5,7 +5,43 @@ class "Vertex" (Vector3)
 
 
 function Vertex:__index__(name)
-	if name == "useVertexColor" then
+	if name == "restNormal" then
+		retVal = Polycore.Vertex_get_restNormal(self.__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
+	elseif name == "restPosition" then
+		retVal = Polycore.Vertex_get_restPosition(self.__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
+	elseif name == "normal" then
+		retVal = Polycore.Vertex_get_normal(self.__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
+	elseif name == "vertexColor" then
+		retVal = Polycore.Vertex_get_vertexColor(self.__ptr)
+		if Polycore.__ptr_lookup[retVal] ~= nil then
+			return Polycore.__ptr_lookup[retVal]
+		else
+			Polycore.__ptr_lookup[retVal] = Color("__skip_ptr__")
+			Polycore.__ptr_lookup[retVal].__ptr = retVal
+			return Polycore.__ptr_lookup[retVal]
+		end
+	elseif name == "useVertexColor" then
 		return Polycore.Vertex_get_useVertexColor(self.__ptr)
 	end
 end
@@ -51,6 +87,7 @@ end
 
 function Vertex:getBoneAssignment(index)
 	local retVal = Polycore.Vertex_getBoneAssignment(self.__ptr, index)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else
@@ -66,6 +103,7 @@ end
 
 function Vertex:getTexCoord()
 	local retVal =  Polycore.Vertex_getTexCoord(self.__ptr)
+	if retVal == nil then return nil end
 	if Polycore.__ptr_lookup[retVal] ~= nil then
 		return Polycore.__ptr_lookup[retVal]
 	else

+ 170 - 0
Bindings/Contents/LUA/API/Polycode/Win32Core.lua

@@ -0,0 +1,170 @@
+require "Polycode/Core"
+
+class "Win32Core" (Core)
+
+
+
+
+
+
+
+function Win32Core:Win32Core(...)
+	if type(arg[1]) == "table" and count(arg) == 1 then
+		if ""..arg[1]:class() == "Core" 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 = Polycore.Win32Core(unpack(arg))
+		Polycore.__ptr_lookup[self.__ptr] = self
+	end
+end
+
+function Win32Core:enableMouse(newval)
+	local retVal = Polycore.Win32Core_enableMouse(self.__ptr, newval)
+end
+
+function Win32Core:getTicks()
+	local retVal =  Polycore.Win32Core_getTicks(self.__ptr)
+	return retVal
+end
+
+function Win32Core:Update()
+	local retVal =  Polycore.Win32Core_Update(self.__ptr)
+	return retVal
+end
+
+function Win32Core:handleKeyDown(lParam, wParam)
+	local retVal = Polycore.Win32Core_handleKeyDown(self.__ptr, lParam.__ptr, wParam.__ptr)
+end
+
+function Win32Core:handleKeyUp(lParam, wParam)
+	local retVal = Polycore.Win32Core_handleKeyUp(self.__ptr, lParam.__ptr, wParam.__ptr)
+end
+
+function Win32Core:handleMouseMove(lParam, wParam)
+	local retVal = Polycore.Win32Core_handleMouseMove(self.__ptr, lParam.__ptr, wParam.__ptr)
+end
+
+function Win32Core:handleMouseWheel(lParam, wParam)
+	local retVal = Polycore.Win32Core_handleMouseWheel(self.__ptr, lParam.__ptr, wParam.__ptr)
+end
+
+function Win32Core:handleMouseDown(mouseCode, lParam, wParam)
+	local retVal = Polycore.Win32Core_handleMouseDown(self.__ptr, mouseCode, lParam.__ptr, wParam.__ptr)
+end
+
+function Win32Core:handleMouseUp(mouseCode, lParam, wParam)
+	local retVal = Polycore.Win32Core_handleMouseUp(self.__ptr, mouseCode, lParam.__ptr, wParam.__ptr)
+end
+
+function Win32Core:setVideoMode(xRes, yRes, fullScreen, aaLevel)
+	local retVal = Polycore.Win32Core_setVideoMode(self.__ptr, xRes, yRes, fullScreen, aaLevel)
+end
+
+function Win32Core:initContext(usePixelFormat, pixelFormat)
+	local retVal = Polycore.Win32Core_initContext(self.__ptr, usePixelFormat, pixelFormat)
+end
+
+function Win32Core:destroyContext()
+	local retVal =  Polycore.Win32Core_destroyContext(self.__ptr)
+end
+
+function Win32Core:createThread(target)
+	local retVal = Polycore.Win32Core_createThread(self.__ptr, target.__ptr)
+end
+
+function Win32Core:mapKey(lParam, wParam)
+	local retVal = Polycore.Win32Core_mapKey(self.__ptr, lParam.__ptr, wParam.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = PolyKEY("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function Win32Core:lockMutex(mutex)
+	local retVal = Polycore.Win32Core_lockMutex(self.__ptr, mutex.__ptr)
+end
+
+function Win32Core:unlockMutex(mutex)
+	local retVal = Polycore.Win32Core_unlockMutex(self.__ptr, mutex.__ptr)
+end
+
+function Win32Core:createMutex()
+	local retVal =  Polycore.Win32Core_createMutex(self.__ptr)
+	if Polycore.__ptr_lookup[retVal] ~= nil then
+		return Polycore.__ptr_lookup[retVal]
+	else
+		Polycore.__ptr_lookup[retVal] = CoreMutex("__skip_ptr__")
+		Polycore.__ptr_lookup[retVal].__ptr = retVal
+		return Polycore.__ptr_lookup[retVal]
+	end
+end
+
+function Win32Core:checkEvents()
+	local retVal =  Polycore.Win32Core_checkEvents(self.__ptr)
+end
+
+function Win32Core:initKeymap()
+	local retVal =  Polycore.Win32Core_initKeymap(self.__ptr)
+end
+
+function Win32Core:platformSleep(msecs)
+	local retVal = Polycore.Win32Core_platformSleep(self.__ptr, msecs)
+end
+
+function Win32Core:setCursor(cursorType)
+	local retVal = Polycore.Win32Core_setCursor(self.__ptr, cursorType)
+end
+
+function Win32Core:copyStringToClipboard(str)
+	local retVal = Polycore.Win32Core_copyStringToClipboard(self.__ptr, str)
+end
+
+function Win32Core:getClipboardString()
+	local retVal =  Polycore.Win32Core_getClipboardString(self.__ptr)
+	return retVal
+end
+
+function Win32Core:createFolder(folderPath)
+	local retVal = Polycore.Win32Core_createFolder(self.__ptr, folderPath)
+end
+
+function Win32Core:copyDiskItem(itemPath, destItemPath)
+	local retVal = Polycore.Win32Core_copyDiskItem(self.__ptr, itemPath, destItemPath)
+end
+
+function Win32Core:moveDiskItem(itemPath, destItemPath)
+	local retVal = Polycore.Win32Core_moveDiskItem(self.__ptr, itemPath, destItemPath)
+end
+
+function Win32Core:openFolderPicker()
+	local retVal =  Polycore.Win32Core_openFolderPicker(self.__ptr)
+	return retVal
+end
+
+function Win32Core:removeDiskItem(itemPath)
+	local retVal = Polycore.Win32Core_removeDiskItem(self.__ptr, itemPath)
+end
+
+function Win32Core:resizeTo(xRes, yRes)
+	local retVal = Polycore.Win32Core_resizeTo(self.__ptr, xRes, yRes)
+end
+
+
+
+function Win32Core:__delete()
+	Polycore.__ptr_lookup[self.__ptr] = nil
+	Polycore.delete_Win32Core(self.__ptr)
+end

+ 1 - 1
Bindings/Contents/LUA/Include/PolycodeLUA.h

@@ -6,5 +6,5 @@ extern "C" {
 #include "lua.h"
 #include "lualib.h"
 #include "lauxlib.h"
-int luaopen_Polycode(lua_State *L);
+int _PolyExport luaopen_Polycode(lua_State *L);
 }

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 594 - 123
Bindings/Contents/LUA/Include/PolycodeLUAWrappers.h


+ 94 - 7
Bindings/Contents/LUA/Source/PolycodeLUA.cpp

@@ -45,6 +45,9 @@ int luaopen_Polycode(lua_State *L) {
 		{"BezierCurve_rebuildBuffers", Polycore_BezierCurve_rebuildBuffers},
 		{"delete_BezierCurve", Polycore_delete_BezierCurve},
 		{"Bone_get_parentBoneId", Polycore_Bone_get_parentBoneId},
+		{"Bone_get_boneMatrix", Polycore_Bone_get_boneMatrix},
+		{"Bone_get_restMatrix", Polycore_Bone_get_restMatrix},
+		{"Bone_get_baseMatrix", Polycore_Bone_get_baseMatrix},
 		{"Bone_set_parentBoneId", Polycore_Bone_set_parentBoneId},
 		{"Bone", Polycore_Bone},
 		{"Bone_enableBoneLabel", Polycore_Bone_enableBoneLabel},
@@ -83,6 +86,7 @@ int luaopen_Polycode(lua_State *L) {
 		{"Camera_getExposureLevel", Polycore_Camera_getExposureLevel},
 		{"Camera_createPostFilter", Polycore_Camera_createPostFilter},
 		{"Camera_setPostFilter", Polycore_Camera_setPostFilter},
+		{"Camera_removePostFilter", Polycore_Camera_removePostFilter},
 		{"delete_Camera", Polycore_delete_Camera},
 		{"Color_get_r", Polycore_Color_get_r},
 		{"Color_get_g", Polycore_Color_get_g},
@@ -112,6 +116,8 @@ int luaopen_Polycode(lua_State *L) {
 		{"Config_getNumericValue", Polycore_Config_getNumericValue},
 		{"Config_getStringValue", Polycore_Config_getStringValue},
 		{"delete_Config", Polycore_delete_Config},
+		{"PolycodeViewBase", Polycore_PolycodeViewBase},
+		{"delete_PolycodeViewBase", Polycore_delete_PolycodeViewBase},
 		{"Core_Update", Polycore_Core_Update},
 		{"Core_enableMouse", Polycore_Core_enableMouse},
 		{"Core_setCursor", Polycore_Core_setCursor},
@@ -192,6 +198,7 @@ int luaopen_Polycode(lua_State *L) {
 		{"Entity_get_alphaTest", Polycore_Entity_get_alphaTest},
 		{"Entity_get_backfaceCulled", Polycore_Entity_get_backfaceCulled},
 		{"Entity_get_renderWireframe", Polycore_Entity_get_renderWireframe},
+		{"Entity_get_color", Polycore_Entity_get_color},
 		{"Entity_get_enabled", Polycore_Entity_get_enabled},
 		{"Entity_get_visible", Polycore_Entity_get_visible},
 		{"Entity_get_depthWrite", Polycore_Entity_get_depthWrite},
@@ -199,6 +206,7 @@ int luaopen_Polycode(lua_State *L) {
 		{"Entity_get_blendingMode", Polycore_Entity_get_blendingMode},
 		{"Entity_get_colorAffectsChildren", Polycore_Entity_get_colorAffectsChildren},
 		{"Entity_get_depthOnly", Polycore_Entity_get_depthOnly},
+		{"Entity_get_bBox", Polycore_Entity_get_bBox},
 		{"Entity_get_ignoreParentMatrix", Polycore_Entity_get_ignoreParentMatrix},
 		{"Entity_get_isMask", Polycore_Entity_get_isMask},
 		{"Entity_set_custEntityType", Polycore_Entity_set_custEntityType},
@@ -348,6 +356,9 @@ int luaopen_Polycode(lua_State *L) {
 		{"Image_getPixels", Polycore_Image_getPixels},
 		{"delete_Image", Polycore_delete_Image},
 		{"InputEvent_get_mouseButton", Polycore_InputEvent_get_mouseButton},
+		{"InputEvent_get_mousePosition", Polycore_InputEvent_get_mousePosition},
+		{"InputEvent_get_key", Polycore_InputEvent_get_key},
+		{"InputEvent_get_charCode", Polycore_InputEvent_get_charCode},
 		{"InputEvent_get_timestamp", Polycore_InputEvent_get_timestamp},
 		{"InputEvent_set_mouseButton", Polycore_InputEvent_set_mouseButton},
 		{"InputEvent_set_timestamp", Polycore_InputEvent_set_timestamp},
@@ -416,6 +427,7 @@ int luaopen_Polycode(lua_State *L) {
 		{"Mesh_saveToFile", Polycore_Mesh_saveToFile},
 		{"Mesh_loadFromFile", Polycore_Mesh_loadFromFile},
 		{"Mesh_getPolygonCount", Polycore_Mesh_getPolygonCount},
+		{"Mesh_getVertexCount", Polycore_Mesh_getVertexCount},
 		{"Mesh_getPolygon", Polycore_Mesh_getPolygon},
 		{"Mesh_createPlane", Polycore_Mesh_createPlane},
 		{"Mesh_createBox", Polycore_Mesh_createBox},
@@ -460,6 +472,9 @@ int luaopen_Polycode(lua_State *L) {
 		{"ObjectEntry", Polycore_ObjectEntry},
 		{"ObjectEntry_addChild", Polycore_ObjectEntry_addChild},
 		{"delete_ObjectEntry", Polycore_delete_ObjectEntry},
+		{"Particle_get_velVector", Polycore_Particle_get_velVector},
+		{"Particle_get_dirVector", Polycore_Particle_get_dirVector},
+		{"Particle_get_deviation", Polycore_Particle_get_deviation},
 		{"Particle_get_life", Polycore_Particle_get_life},
 		{"Particle_get_lifespan", Polycore_Particle_get_lifespan},
 		{"Particle_get_brightnessDeviation", Polycore_Particle_get_brightnessDeviation},
@@ -478,27 +493,40 @@ int luaopen_Polycode(lua_State *L) {
 		{"Particle_createScreenParticle", Polycore_Particle_createScreenParticle},
 		{"delete_Particle", Polycore_delete_Particle},
 		{"ScreenParticleEmitter", Polycore_ScreenParticleEmitter},
+		{"ScreenParticleEmitter_getEmitter", Polycore_ScreenParticleEmitter_getEmitter},
 		{"ScreenParticleEmitter_addParticleBody", Polycore_ScreenParticleEmitter_addParticleBody},
 		{"ScreenParticleEmitter_getBaseMatrix", Polycore_ScreenParticleEmitter_getBaseMatrix},
 		{"ScreenParticleEmitter_Update", Polycore_ScreenParticleEmitter_Update},
 		{"delete_ScreenParticleEmitter", Polycore_delete_ScreenParticleEmitter},
 		{"SceneParticleEmitter", Polycore_SceneParticleEmitter},
+		{"SceneParticleEmitter_getEmitter", Polycore_SceneParticleEmitter_getEmitter},
 		{"SceneParticleEmitter_addParticleBody", Polycore_SceneParticleEmitter_addParticleBody},
 		{"SceneParticleEmitter_getBaseMatrix", Polycore_SceneParticleEmitter_getBaseMatrix},
 		{"SceneParticleEmitter_Update", Polycore_SceneParticleEmitter_Update},
 		{"delete_SceneParticleEmitter", Polycore_delete_SceneParticleEmitter},
 		{"ParticleEmitter_get_particleSpeedMod", Polycore_ParticleEmitter_get_particleSpeedMod},
 		{"ParticleEmitter_get_brightnessDeviation", Polycore_ParticleEmitter_get_brightnessDeviation},
+		{"ParticleEmitter_get_deviation", Polycore_ParticleEmitter_get_deviation},
+		{"ParticleEmitter_get_dirVector", Polycore_ParticleEmitter_get_dirVector},
+		{"ParticleEmitter_get_gravVector", Polycore_ParticleEmitter_get_gravVector},
 		{"ParticleEmitter_get_lifespan", Polycore_ParticleEmitter_get_lifespan},
 		{"ParticleEmitter_get_rotationFollowsPath", Polycore_ParticleEmitter_get_rotationFollowsPath},
+		{"ParticleEmitter_get_scaleCurve", Polycore_ParticleEmitter_get_scaleCurve},
+		{"ParticleEmitter_get_colorCurveR", Polycore_ParticleEmitter_get_colorCurveR},
+		{"ParticleEmitter_get_colorCurveG", Polycore_ParticleEmitter_get_colorCurveG},
+		{"ParticleEmitter_get_colorCurveB", Polycore_ParticleEmitter_get_colorCurveB},
+		{"ParticleEmitter_get_colorCurveA", Polycore_ParticleEmitter_get_colorCurveA},
+		{"ParticleEmitter_get_useColorCurves", Polycore_ParticleEmitter_get_useColorCurves},
+		{"ParticleEmitter_get_useScaleCurves", Polycore_ParticleEmitter_get_useScaleCurves},
 		{"ParticleEmitter_set_particleSpeedMod", Polycore_ParticleEmitter_set_particleSpeedMod},
 		{"ParticleEmitter_set_brightnessDeviation", Polycore_ParticleEmitter_set_brightnessDeviation},
 		{"ParticleEmitter_set_lifespan", Polycore_ParticleEmitter_set_lifespan},
 		{"ParticleEmitter_set_rotationFollowsPath", Polycore_ParticleEmitter_set_rotationFollowsPath},
+		{"ParticleEmitter_set_useColorCurves", Polycore_ParticleEmitter_set_useColorCurves},
+		{"ParticleEmitter_set_useScaleCurves", Polycore_ParticleEmitter_set_useScaleCurves},
+		{"ParticleEmitter", Polycore_ParticleEmitter},
 		{"ParticleEmitter_createParticles", Polycore_ParticleEmitter_createParticles},
 		{"ParticleEmitter_setRotationSpeed", Polycore_ParticleEmitter_setRotationSpeed},
-		{"ParticleEmitter_setStartingColor", Polycore_ParticleEmitter_setStartingColor},
-		{"ParticleEmitter_setEndingColor", Polycore_ParticleEmitter_setEndingColor},
 		{"ParticleEmitter_setParticleBlendingMode", Polycore_ParticleEmitter_setParticleBlendingMode},
 		{"ParticleEmitter_setDepthWrite", Polycore_ParticleEmitter_setDepthWrite},
 		{"ParticleEmitter_setDepthTest", Polycore_ParticleEmitter_setDepthTest},
@@ -508,10 +536,6 @@ int luaopen_Polycode(lua_State *L) {
 		{"ParticleEmitter_enableEmitter", Polycore_ParticleEmitter_enableEmitter},
 		{"ParticleEmitter_emitterEnabled", Polycore_ParticleEmitter_emitterEnabled},
 		{"ParticleEmitter_setEmitterRadius", Polycore_ParticleEmitter_setEmitterRadius},
-		{"ParticleEmitter_setStartingScaleModifier", Polycore_ParticleEmitter_setStartingScaleModifier},
-		{"ParticleEmitter_setEndingScaleModifier", Polycore_ParticleEmitter_setEndingScaleModifier},
-		{"ParticleEmitter_setEmitRotationVector", Polycore_ParticleEmitter_setEmitRotationVector},
-		{"ParticleEmitter_setEmitRotationDeviance", Polycore_ParticleEmitter_setEmitRotationDeviance},
 		{"ParticleEmitter_setAllAtOnce", Polycore_ParticleEmitter_setAllAtOnce},
 		{"ParticleEmitter_Trigger", Polycore_ParticleEmitter_Trigger},
 		{"ParticleEmitter_resetParticle", Polycore_ParticleEmitter_resetParticle},
@@ -582,7 +606,10 @@ int luaopen_Polycode(lua_State *L) {
 		{"Rectangle", Polycore_Rectangle},
 		{"Rectangle_setRect", Polycore_Rectangle_setRect},
 		{"delete_Rectangle", Polycore_delete_Rectangle},
+		{"Renderer_get_ambientColor", Polycore_Renderer_get_ambientColor},
+		{"Renderer_get_clearColor", Polycore_Renderer_get_clearColor},
 		{"Renderer_get_exposureLevel", Polycore_Renderer_get_exposureLevel},
+		{"Renderer_get_cameraPosition", Polycore_Renderer_get_cameraPosition},
 		{"Renderer_set_exposureLevel", Polycore_Renderer_set_exposureLevel},
 		{"Renderer_Resize", Polycore_Renderer_Resize},
 		{"Renderer_BeginRender", Polycore_Renderer_BeginRender},
@@ -649,17 +676,20 @@ int luaopen_Polycode(lua_State *L) {
 		{"Renderer_drawScreenQuad", Polycore_Renderer_drawScreenQuad},
 		{"Renderer_getXRes", Polycore_Renderer_getXRes},
 		{"Renderer_getYRes", Polycore_Renderer_getYRes},
+		{"Renderer_cullFrontFaces", Polycore_Renderer_cullFrontFaces},
 		{"Renderer_clearLights", Polycore_Renderer_clearLights},
 		{"Renderer_addLight", Polycore_Renderer_addLight},
 		{"Renderer_setExposureLevel", Polycore_Renderer_setExposureLevel},
 		{"Renderer_rayTriangleIntersect", Polycore_Renderer_rayTriangleIntersect},
 		{"Renderer_enableShaders", Polycore_Renderer_enableShaders},
+		{"Renderer_initOSSpecific", Polycore_Renderer_initOSSpecific},
 		{"Renderer_addShaderModule", Polycore_Renderer_addShaderModule},
 		{"Renderer_test2DCoordinate", Polycore_Renderer_test2DCoordinate},
 		{"Renderer_getProjectionMatrix", Polycore_Renderer_getProjectionMatrix},
 		{"Renderer_getModelviewMatrix", Polycore_Renderer_getModelviewMatrix},
 		{"Renderer_addShadowMap", Polycore_Renderer_addShadowMap},
 		{"Renderer_Unproject", Polycore_Renderer_Unproject},
+		{"Renderer_sortLights", Polycore_Renderer_sortLights},
 		{"Renderer_getNumAreaLights", Polycore_Renderer_getNumAreaLights},
 		{"Renderer_getNumSpotLights", Polycore_Renderer_getNumSpotLights},
 		{"Renderer_getNumLights", Polycore_Renderer_getNumLights},
@@ -685,7 +715,10 @@ int luaopen_Polycode(lua_State *L) {
 		{"ResourceManager_getResource", Polycore_ResourceManager_getResource},
 		{"ResourceManager_addShaderModule", Polycore_ResourceManager_addShaderModule},
 		{"delete_ResourceManager", Polycore_delete_ResourceManager},
+		{"Scene_get_clearColor", Polycore_Scene_get_clearColor},
 		{"Scene_get_useClearColor", Polycore_Scene_get_useClearColor},
+		{"Scene_get_ambientColor", Polycore_Scene_get_ambientColor},
+		{"Scene_get_fogColor", Polycore_Scene_get_fogColor},
 		{"Scene_get_enabled", Polycore_Scene_get_enabled},
 		{"Scene_set_useClearColor", Polycore_Scene_set_useClearColor},
 		{"Scene_set_enabled", Polycore_Scene_set_enabled},
@@ -730,15 +763,21 @@ int luaopen_Polycode(lua_State *L) {
 		{"SceneLabel_getLabel", Polycore_SceneLabel_getLabel},
 		{"SceneLabel_Render", Polycore_SceneLabel_Render},
 		{"delete_SceneLabel", Polycore_delete_SceneLabel},
+		{"SceneLight_get_lightColor", Polycore_SceneLight_get_lightColor},
 		{"SceneLight", Polycore_SceneLight},
 		{"SceneLight_getIntensity", Polycore_SceneLight_getIntensity},
-		{"SceneLight_getDistance", Polycore_SceneLight_getDistance},
+		{"SceneLight_getConstantAttenuation", Polycore_SceneLight_getConstantAttenuation},
+		{"SceneLight_getLinearAttenuation", Polycore_SceneLight_getLinearAttenuation},
+		{"SceneLight_getQuadraticAttenuation", Polycore_SceneLight_getQuadraticAttenuation},
 		{"SceneLight_getType", Polycore_SceneLight_getType},
 		{"SceneLight_renderDepthMap", Polycore_SceneLight_renderDepthMap},
 		{"SceneLight_Render", Polycore_SceneLight_Render},
 		{"SceneLight_getLightViewMatrix", Polycore_SceneLight_getLightViewMatrix},
 		{"SceneLight_getZBufferTexture", Polycore_SceneLight_getZBufferTexture},
 		{"SceneLight_setLightColor", Polycore_SceneLight_setLightColor},
+		{"SceneLight_setSpotlightProperties", Polycore_SceneLight_setSpotlightProperties},
+		{"SceneLight_getSpotlightCutoff", Polycore_SceneLight_getSpotlightCutoff},
+		{"SceneLight_getSpotlightExponent", Polycore_SceneLight_getSpotlightExponent},
 		{"SceneLight_enableShadows", Polycore_SceneLight_enableShadows},
 		{"SceneLight_setShadowMapFOV", Polycore_SceneLight_setShadowMapFOV},
 		{"SceneLight_areShadowsEnabled", Polycore_SceneLight_areShadowsEnabled},
@@ -754,6 +793,7 @@ int luaopen_Polycode(lua_State *L) {
 		{"SceneManager_removeScene", Polycore_SceneManager_removeScene},
 		{"SceneManager_registerRenderTexture", Polycore_SceneManager_registerRenderTexture},
 		{"delete_SceneManager", Polycore_delete_SceneManager},
+		{"SceneMesh_get_lightmapIndex", Polycore_SceneMesh_get_lightmapIndex},
 		{"SceneMesh_get_showVertexNormals", Polycore_SceneMesh_get_showVertexNormals},
 		{"SceneMesh_set_showVertexNormals", Polycore_SceneMesh_set_showVertexNormals},
 		{"SceneMesh", Polycore_SceneMesh},
@@ -781,6 +821,13 @@ int luaopen_Polycode(lua_State *L) {
 		{"SceneRenderTexture_getTargetScene", Polycore_SceneRenderTexture_getTargetScene},
 		{"SceneRenderTexture_getTargetCamera", Polycore_SceneRenderTexture_getTargetCamera},
 		{"delete_SceneRenderTexture", Polycore_delete_SceneRenderTexture},
+		{"SceneSound", Polycore_SceneSound},
+		{"SceneSound_Update", Polycore_SceneSound_Update},
+		{"SceneSound_getSound", Polycore_SceneSound_getSound},
+		{"delete_SceneSound", Polycore_delete_SceneSound},
+		{"SceneSoundListener", Polycore_SceneSoundListener},
+		{"SceneSoundListener_Update", Polycore_SceneSoundListener_Update},
+		{"delete_SceneSoundListener", Polycore_delete_SceneSoundListener},
 		{"Screen_get_enabled", Polycore_Screen_get_enabled},
 		{"Screen_set_enabled", Polycore_Screen_set_enabled},
 		{"Screen", Polycore_Screen},
@@ -795,6 +842,7 @@ int luaopen_Polycode(lua_State *L) {
 		{"Screen_setRenderer", Polycore_Screen_setRenderer},
 		{"Screen_setNormalizedCoordinates", Polycore_Screen_setNormalizedCoordinates},
 		{"Screen_setScreenShader", Polycore_Screen_setScreenShader},
+		{"Screen_clearScreenShader", Polycore_Screen_clearScreenShader},
 		{"Screen_getHighestZIndex", Polycore_Screen_getHighestZIndex},
 		{"Screen_sortChildren", Polycore_Screen_sortChildren},
 		{"Screen_cmpZindex", Polycore_Screen_cmpZindex},
@@ -885,6 +933,7 @@ int luaopen_Polycode(lua_State *L) {
 		{"ScreenMesh_setTexture", Polycore_ScreenMesh_setTexture},
 		{"delete_ScreenMesh", Polycore_delete_ScreenMesh},
 		{"ScreenShape_get_strokeEnabled", Polycore_ScreenShape_get_strokeEnabled},
+		{"ScreenShape_get_strokeColor", Polycore_ScreenShape_get_strokeColor},
 		{"ScreenShape_get_lineSmooth", Polycore_ScreenShape_get_lineSmooth},
 		{"ScreenShape_set_strokeEnabled", Polycore_ScreenShape_set_strokeEnabled},
 		{"ScreenShape_set_lineSmooth", Polycore_ScreenShape_set_lineSmooth},
@@ -897,11 +946,22 @@ int luaopen_Polycode(lua_State *L) {
 		{"ScreenShape_setShapeSize", Polycore_ScreenShape_setShapeSize},
 		{"ScreenShape_addShapePoint", Polycore_ScreenShape_addShapePoint},
 		{"delete_ScreenShape", Polycore_delete_ScreenShape},
+		{"ScreenSoundListener", Polycore_ScreenSoundListener},
+		{"ScreenSoundListener_Update", Polycore_ScreenSoundListener_Update},
+		{"delete_ScreenSoundListener", Polycore_delete_ScreenSoundListener},
+		{"ScreenSound", Polycore_ScreenSound},
+		{"ScreenSound_Update", Polycore_ScreenSound_Update},
+		{"ScreenSound_getSound", Polycore_ScreenSound_getSound},
+		{"delete_ScreenSound", Polycore_delete_ScreenSound},
 		{"ScreenSprite", Polycore_ScreenSprite},
 		{"ScreenSprite_addAnimation", Polycore_ScreenSprite_addAnimation},
 		{"ScreenSprite_playAnimation", Polycore_ScreenSprite_playAnimation},
 		{"ScreenSprite_Update", Polycore_ScreenSprite_Update},
 		{"delete_ScreenSprite", Polycore_delete_ScreenSprite},
+		{"Shader_get_numSpotLights", Polycore_Shader_get_numSpotLights},
+		{"Shader_get_numAreaLights", Polycore_Shader_get_numAreaLights},
+		{"Shader_set_numSpotLights", Polycore_Shader_set_numSpotLights},
+		{"Shader_set_numAreaLights", Polycore_Shader_set_numAreaLights},
 		{"Shader_getType", Polycore_Shader_getType},
 		{"Shader_setName", Polycore_Shader_setName},
 		{"Shader_getName", Polycore_Shader_getName},
@@ -931,6 +991,17 @@ int luaopen_Polycode(lua_State *L) {
 		{"SkeletonAnimation_Update", Polycore_SkeletonAnimation_Update},
 		{"SkeletonAnimation_setSpeed", Polycore_SkeletonAnimation_setSpeed},
 		{"delete_SkeletonAnimation", Polycore_delete_SkeletonAnimation},
+		{"BoneTrack_get_LocXVec", Polycore_BoneTrack_get_LocXVec},
+		{"BoneTrack_get_LocYVec", Polycore_BoneTrack_get_LocYVec},
+		{"BoneTrack_get_LocZVec", Polycore_BoneTrack_get_LocZVec},
+		{"BoneTrack_get_ScaleXVec", Polycore_BoneTrack_get_ScaleXVec},
+		{"BoneTrack_get_ScaleYVec", Polycore_BoneTrack_get_ScaleYVec},
+		{"BoneTrack_get_ScaleZVec", Polycore_BoneTrack_get_ScaleZVec},
+		{"BoneTrack_get_boneQuat", Polycore_BoneTrack_get_boneQuat},
+		{"BoneTrack_get_QuatWVec", Polycore_BoneTrack_get_QuatWVec},
+		{"BoneTrack_get_QuatXVec", Polycore_BoneTrack_get_QuatXVec},
+		{"BoneTrack_get_QuatYVec", Polycore_BoneTrack_get_QuatYVec},
+		{"BoneTrack_get_QuatZVec", Polycore_BoneTrack_get_QuatZVec},
 		{"BoneTrack", Polycore_BoneTrack},
 		{"BoneTrack_Play", Polycore_BoneTrack_Play},
 		{"BoneTrack_Stop", Polycore_BoneTrack_Stop},
@@ -954,6 +1025,13 @@ int luaopen_Polycode(lua_State *L) {
 		{"Sound", Polycore_Sound},
 		{"Sound_Play", Polycore_Sound_Play},
 		{"Sound_Stop", Polycore_Sound_Stop},
+		{"Sound_setVolume", Polycore_Sound_setVolume},
+		{"Sound_setPitch", Polycore_Sound_setPitch},
+		{"Sound_setIsPositional", Polycore_Sound_setIsPositional},
+		{"Sound_setSoundPosition", Polycore_Sound_setSoundPosition},
+		{"Sound_setSoundVelocity", Polycore_Sound_setSoundVelocity},
+		{"Sound_setSoundDirection", Polycore_Sound_setSoundDirection},
+		{"Sound_setPositionalProperties", Polycore_Sound_setPositionalProperties},
 		{"Sound_loadWAV", Polycore_Sound_loadWAV},
 		{"Sound_loadOGG", Polycore_Sound_loadOGG},
 		{"Sound_GenSource", Polycore_Sound_GenSource},
@@ -962,8 +1040,13 @@ int luaopen_Polycode(lua_State *L) {
 		{"Sound_soundCheck", Polycore_Sound_soundCheck},
 		{"delete_Sound", Polycore_delete_Sound},
 		{"SoundManager", Polycore_SoundManager},
+		{"SoundManager_setListenerPosition", Polycore_SoundManager_setListenerPosition},
+		{"SoundManager_setListenerOrientation", Polycore_SoundManager_setListenerOrientation},
 		{"SoundManager_initAL", Polycore_SoundManager_initAL},
+		{"SoundManager_setGlobalVolume", Polycore_SoundManager_setGlobalVolume},
 		{"delete_SoundManager", Polycore_delete_SoundManager},
+		{"String_get_contents", Polycore_String_get_contents},
+		{"String_get_s_contents", Polycore_String_get_s_contents},
 		{"String", Polycore_String},
 		{"String_size", Polycore_String_size},
 		{"String_length", Polycore_String_length},
@@ -1053,6 +1136,10 @@ int luaopen_Polycode(lua_State *L) {
 		{"Vector3_crossProduct", Polycore_Vector3_crossProduct},
 		{"Vector3_Normalize", Polycore_Vector3_Normalize},
 		{"delete_Vector3", Polycore_delete_Vector3},
+		{"Vertex_get_restNormal", Polycore_Vertex_get_restNormal},
+		{"Vertex_get_restPosition", Polycore_Vertex_get_restPosition},
+		{"Vertex_get_normal", Polycore_Vertex_get_normal},
+		{"Vertex_get_vertexColor", Polycore_Vertex_get_vertexColor},
 		{"Vertex_get_useVertexColor", Polycore_Vertex_get_useVertexColor},
 		{"Vertex_set_useVertexColor", Polycore_Vertex_set_useVertexColor},
 		{"Vertex", Polycore_Vertex},

+ 128 - 81
Bindings/Scripts/create_lua_library/create_lua_library.py

@@ -13,8 +13,9 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 	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"
+	if prefix != "Polycode":
+		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"
@@ -45,7 +46,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 	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"]
+		ignore = ["PolyGLSLProgram", "PolyGLSLShader", "PolyGLSLShaderModule", "PolyWinCore", "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
@@ -55,7 +56,10 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 				cppHeader = CppHeaderParser.CppHeader(contents, "string")
 				ignore_classes = ["PolycodeShaderModule", "Object", "Threaded", "OpenGLCubemap"]
 				for ckey in cppHeader.classes:
+					print ">> Parsing class %s" % ckey
 					c = cppHeader.classes[ckey]
+		#			if ckey == "ParticleEmitter":
+		#				print c
 					lout = ""
 					inherits = False
 					if len(c["inherits"]) > 0:
@@ -75,20 +79,29 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 					if ckey == "OSFileEntry":
 						print c["methods"]["public"]
 					parsed_methods = []
-					ignore_methods = ["readByte32", "readByte16", "getCustomEntitiesByType", "Core","ParticleEmitter", "Renderer", "Shader", "Texture", "handleEvent", "secondaryHandler"]
+					ignore_methods = ["readByte32", "readByte16", "getCustomEntitiesByType", "Core", "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"])
+							if "defaltValue" in pp:
+								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":
+							#there are some bugs in the class parser that cause it to return junk
+							if pp["type"].find("*") == -1 and pp["type"].find("vector") == -1 and pp["name"] != "16" and pp["name"] != "setScale" and pp["name"] != "setPosition" and pp["name"] != "BUFFER_CACHE_PRECISION":
 								pps.append(pp)
+							#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
+			
+					# hack to fix the lack of multiple inheritance
+					#if ckey == "ScreenParticleEmitter" or ckey == "SceneParticleEmitter":
+					#		pps.append({"name": "emitter", "type": "ParticleEmitter"})
+	
 					if len(pps) > 0:
 						lout += "function %s:__index__(name)\n" % ckey
 						for pp in pps:
@@ -96,29 +109,47 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 								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"
+
+							if pp["type"] == "Number" or  pp["type"] == "String" or pp["type"] == "int" or pp["type"] == "bool":
+								lout += "\t\treturn %s.%s_get_%s(self.__ptr)\n" % (libName, ckey, pp["name"])
+							elif (ckey == "ScreenParticleEmitter" or ckey == "SceneParticleEmitter") and pp["name"] == "emitter":
+								lout += "\t\tlocal ret = %s(\"__skip_ptr__\")\n" % (pp["type"])
+								lout += "\t\tret.__ptr = self.__ptr\n"
+								lout += "\t\treturn ret\n"
+							else:
+								lout += "\t\tretVal = %s.%s_get_%s(self.__ptr)\n" % (libName, ckey, pp["name"])
+								lout += "\t\tif Polycore.__ptr_lookup[retVal] ~= nil then\n"
+								lout += "\t\t\treturn Polycore.__ptr_lookup[retVal]\n"
+								lout += "\t\telse\n"
+								lout += "\t\t\tPolycore.__ptr_lookup[retVal] = %s(\"__skip_ptr__\")\n" % (pp["type"])
+								lout += "\t\t\tPolycore.__ptr_lookup[retVal].__ptr = retVal\n"
+								lout += "\t\t\treturn Polycore.__ptr_lookup[retVal]\n"
+								lout += "\t\tend\n"
+
+							if not ((ckey == "ScreenParticleEmitter" or ckey == "SceneParticleEmitter") and pp["name"] == "emitter"):
+								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").replace("Rectangle", "Polycode::Rectangle"), ckey.replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
+	
+								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"
+	
+								if pp["type"] == "Number" or  pp["type"] == "String" or pp["type"] == "int" or pp["type"] == "bool":
+									out += "\t%s(L, inst->%s%s);\n" % (outfunc, pp["name"], retFunc)
+								else:
+									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"
@@ -129,36 +160,37 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 					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"
+							if pp["type"] == "Number" or  pp["type"] == "String" or pp["type"] == "int" or pp["type"] == "bool":
+								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").replace("Rectangle", "Polycode::Rectangle"), ckey.replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
+	
+								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
+						if pidx != 0:
+							lout += "\tend\n"
 						lout += "\treturn false\n"
 						lout += "end\n"
 						
@@ -183,7 +215,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 	
 								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"))
+									out += "\t%s *inst = (%s*)lua_topointer(L, 1);\n" % (ckey.replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"), ckey.replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
 								idx = 2
 							paramlist = []
 							lparamlist = []
@@ -198,11 +230,11 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 									luatype = "LUA_TLIGHTUSERDATA"
 									checkfunc = "lua_islightuserdata"
 									if param["type"].find("*") > -1:
-										luafunc = "(%s)lua_topointer" % (param["type"].replace("Polygon", "Polycode::Polygon"))
+										luafunc = "(%s)lua_topointer" % (param["type"].replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
 									elif param["type"].find("&") > -1:
-										luafunc = "*(%s*)lua_topointer" % (param["type"].replace("const", "").replace("&", "").replace("Polygon", "Polycode::Polygon"))
+										luafunc = "*(%s*)lua_topointer" % (param["type"].replace("const", "").replace("&", "").replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
 									else:
-										luafunc = "*(%s*)lua_topointer" % (param["type"])
+										luafunc = "*(%s*)lua_topointer" % (param["type"].replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
 									lend = ".__ptr"
 									if param["type"] == "int" or param["type"] == "unsigned int":
 										luafunc = "lua_tointeger"
@@ -225,19 +257,26 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 										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"
+									param["type"] = param["type"].replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle")
+	
+									if "defaltValue" in param:
+										if checkfunc != "lua_islightuserdata" or (checkfunc == "lua_islightuserdata" and param["defaltValue"] == "NULL"):
+											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 += "\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)
 									else:
 										out += "\tluaL_checktype(L, %d, %s);\n" % (idx, luatype);
 										if param["type"] == "String":
@@ -255,7 +294,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 									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 += "\t%s *inst = new %s(%s);\n" % (ckey.replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"), ckey.replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"), ", ".join(paramlist))
 								out += "\tlua_pushlightuserdata(L, (void*)inst);\n"
 								out += "\treturn 1;\n"
 							else:
@@ -287,13 +326,20 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 										basicType = True
 	
 									if pm["rtnType"].find("*") > -1:
-										out += "\t%s(L, (void*)%s%s);\n" % (outfunc, call, retFunc)
+										out += "\tvoid *ptrRetVal = (void*)%s%s;\n" % (call, retFunc)
+										out += "\tif(ptrRetVal == NULL) {\n"
+										out += "\t\tlua_pushnil(L);\n"
+										out += "\t} else {\n"
+										out += "\t\t%s(L, ptrRetVal);\n" % (outfunc)
+										out += "\t}\n"
 									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"
+										if className == "Rectangle":
+											className = "Polycode::Rectangle"
 										out += "\t%s *retInst = new %s();\n" % (className, className)
 										out += "\t*retInst = %s;\n" % (call)
 										out += "\t%s(L, retInst);\n" % (outfunc)
@@ -342,6 +388,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 										lout += "\treturn retVal\n"
 									else:
 										className = pm["rtnType"].replace("const", "").replace("&", "").replace("inline", "").replace("virtual", "").replace("static", "").replace("*","").replace(" ", "")
+										lout += "\tif retVal == nil then return nil end\n"
 										lout += "\tif Polycore.__ptr_lookup[retVal] ~= nil then\n"
 										lout += "\t\treturn Polycore.__ptr_lookup[retVal]\n"
 										lout += "\telse\n"
@@ -357,11 +404,11 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 					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 += "\t%s *inst = (%s*)lua_topointer(L, 1);\n" % (ckey.replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"), ckey.replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
 					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"
@@ -400,7 +447,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 	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 += "int _PolyExport luaopen_%s(lua_State *L);\n" % (prefix)
 	shout += "}\n"
 	
 	fout = open("%s/%sLUA.h" % (includePath, prefix), "w")

+ 40 - 0
Core/Build/Mac OS X/PolyCore.xcodeproj/project.pbxproj

@@ -11,8 +11,18 @@
 		6D8656AB12AF5FD5008A486E /* PolyString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D8656AA12AF5FD5008A486E /* PolyString.cpp */; };
 		6D865AC212B07363008A486E /* PolyData.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D865AC112B07363008A486E /* PolyData.h */; };
 		6D865AC412B0736C008A486E /* PolyData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D865AC312B0736C008A486E /* PolyData.cpp */; };
+		6DB5B5B91394A9F0008C00CA /* PolySceneSound.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DB5B5B71394A9EF008C00CA /* PolySceneSound.h */; };
+		6DB5B5BA1394A9F0008C00CA /* PolyScreenSound.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DB5B5B81394A9EF008C00CA /* PolyScreenSound.h */; };
+		6DB5B5BE1394AA11008C00CA /* PolySceneSound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6DB5B5BC1394AA0C008C00CA /* PolySceneSound.cpp */; };
+		6DB5B5BF1394AA11008C00CA /* PolyScreenSound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6DB5B5BD1394AA0F008C00CA /* PolyScreenSound.cpp */; };
 		6DD40E2B136C68B700D602D3 /* PolycodeView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DD40E2A136C68B700D602D3 /* PolycodeView.h */; };
 		6DD40E2D136C68C400D602D3 /* PolycodeView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6DD40E2C136C68C400D602D3 /* PolycodeView.mm */; };
+		6DE45C54138EF8CB000BDFBA /* PolyGLSLProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6DE45C51138EF8CA000BDFBA /* PolyGLSLProgram.cpp */; };
+		6DE45C55138EF8CB000BDFBA /* PolyGLSLShader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6DE45C52138EF8CB000BDFBA /* PolyGLSLShader.cpp */; };
+		6DE45C56138EF8CB000BDFBA /* PolyGLSLShaderModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6DE45C53138EF8CB000BDFBA /* PolyGLSLShaderModule.cpp */; };
+		6DE45C5A138EF933000BDFBA /* PolyGLSLProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DE45C57138EF933000BDFBA /* PolyGLSLProgram.h */; };
+		6DE45C5B138EF933000BDFBA /* PolyGLSLShader.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DE45C58138EF933000BDFBA /* PolyGLSLShader.h */; };
+		6DE45C5C138EF933000BDFBA /* PolyGLSLShaderModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DE45C59138EF933000BDFBA /* PolyGLSLShaderModule.h */; };
 		6DFB016F12A73BC200C43A7D /* PolyModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DFB016E12A73BC200C43A7D /* PolyModule.h */; };
 		6DFB017112A73BCF00C43A7D /* PolyModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6DFB017012A73BCF00C43A7D /* PolyModule.cpp */; };
 		6DFBF3BD12A3184E00C43A7D /* OSBasics.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DFBF30D12A3184E00C43A7D /* OSBasics.h */; };
@@ -185,8 +195,18 @@
 		6D8656AA12AF5FD5008A486E /* PolyString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolyString.cpp; sourceTree = "<group>"; };
 		6D865AC112B07363008A486E /* PolyData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolyData.h; sourceTree = "<group>"; };
 		6D865AC312B0736C008A486E /* PolyData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolyData.cpp; sourceTree = "<group>"; };
+		6DB5B5B71394A9EF008C00CA /* PolySceneSound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolySceneSound.h; sourceTree = "<group>"; };
+		6DB5B5B81394A9EF008C00CA /* PolyScreenSound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolyScreenSound.h; sourceTree = "<group>"; };
+		6DB5B5BC1394AA0C008C00CA /* PolySceneSound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolySceneSound.cpp; sourceTree = "<group>"; };
+		6DB5B5BD1394AA0F008C00CA /* PolyScreenSound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolyScreenSound.cpp; sourceTree = "<group>"; };
 		6DD40E2A136C68B700D602D3 /* PolycodeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolycodeView.h; sourceTree = "<group>"; };
 		6DD40E2C136C68C400D602D3 /* PolycodeView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = PolycodeView.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
+		6DE45C51138EF8CA000BDFBA /* PolyGLSLProgram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolyGLSLProgram.cpp; sourceTree = "<group>"; };
+		6DE45C52138EF8CB000BDFBA /* PolyGLSLShader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolyGLSLShader.cpp; sourceTree = "<group>"; };
+		6DE45C53138EF8CB000BDFBA /* PolyGLSLShaderModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolyGLSLShaderModule.cpp; sourceTree = "<group>"; };
+		6DE45C57138EF933000BDFBA /* PolyGLSLProgram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolyGLSLProgram.h; sourceTree = "<group>"; };
+		6DE45C58138EF933000BDFBA /* PolyGLSLShader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolyGLSLShader.h; sourceTree = "<group>"; };
+		6DE45C59138EF933000BDFBA /* PolyGLSLShaderModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolyGLSLShaderModule.h; sourceTree = "<group>"; };
 		6DFB016E12A73BC200C43A7D /* PolyModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolyModule.h; sourceTree = "<group>"; };
 		6DFB017012A73BCF00C43A7D /* PolyModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolyModule.cpp; sourceTree = "<group>"; };
 		6DFBF30D12A3184E00C43A7D /* OSBasics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSBasics.h; sourceTree = "<group>"; };
@@ -408,6 +428,11 @@
 		6DFBF30B12A3184E00C43A7D /* Include */ = {
 			isa = PBXGroup;
 			children = (
+				6DB5B5B71394A9EF008C00CA /* PolySceneSound.h */,
+				6DB5B5B81394A9EF008C00CA /* PolyScreenSound.h */,
+				6DE45C57138EF933000BDFBA /* PolyGLSLProgram.h */,
+				6DE45C58138EF933000BDFBA /* PolyGLSLShader.h */,
+				6DE45C59138EF933000BDFBA /* PolyGLSLShaderModule.h */,
 				6DD40E2A136C68B700D602D3 /* PolycodeView.h */,
 				6DFE5FC412D450C30005B100 /* PolyObject.h */,
 				6D865AC112B07363008A486E /* PolyData.h */,
@@ -504,6 +529,11 @@
 		6DFBF36612A3184E00C43A7D /* Source */ = {
 			isa = PBXGroup;
 			children = (
+				6DB5B5BC1394AA0C008C00CA /* PolySceneSound.cpp */,
+				6DB5B5BD1394AA0F008C00CA /* PolyScreenSound.cpp */,
+				6DE45C51138EF8CA000BDFBA /* PolyGLSLProgram.cpp */,
+				6DE45C52138EF8CB000BDFBA /* PolyGLSLShader.cpp */,
+				6DE45C53138EF8CB000BDFBA /* PolyGLSLShaderModule.cpp */,
 				6DD40E2C136C68C400D602D3 /* PolycodeView.mm */,
 				6DFE5FC712D450CB0005B100 /* PolyObject.cpp */,
 				6D865AC312B0736C008A486E /* PolyData.cpp */,
@@ -696,6 +726,11 @@
 				6D865AC212B07363008A486E /* PolyData.h in Headers */,
 				6DFE5FC512D450C30005B100 /* PolyObject.h in Headers */,
 				6DD40E2B136C68B700D602D3 /* PolycodeView.h in Headers */,
+				6DE45C5A138EF933000BDFBA /* PolyGLSLProgram.h in Headers */,
+				6DE45C5B138EF933000BDFBA /* PolyGLSLShader.h in Headers */,
+				6DE45C5C138EF933000BDFBA /* PolyGLSLShaderModule.h in Headers */,
+				6DB5B5B91394A9F0008C00CA /* PolySceneSound.h in Headers */,
+				6DB5B5BA1394A9F0008C00CA /* PolyScreenSound.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -830,6 +865,11 @@
 				6D865AC412B0736C008A486E /* PolyData.cpp in Sources */,
 				6DFE5FC812D450CB0005B100 /* PolyObject.cpp in Sources */,
 				6DD40E2D136C68C400D602D3 /* PolycodeView.mm in Sources */,
+				6DE45C54138EF8CB000BDFBA /* PolyGLSLProgram.cpp in Sources */,
+				6DE45C55138EF8CB000BDFBA /* PolyGLSLShader.cpp in Sources */,
+				6DE45C56138EF8CB000BDFBA /* PolyGLSLShaderModule.cpp in Sources */,
+				6DB5B5BE1394AA11008C00CA /* PolySceneSound.cpp in Sources */,
+				6DB5B5BF1394AA11008C00CA /* PolyScreenSound.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 184 - 165
Core/Build/Mac OS X/PolyCore.xcodeproj/project.xcworkspace/xcuserdata/ivansafrin.xcuserdatad/UserInterfaceState.xcuserstate


+ 5 - 0
Core/Contents/Include/PolyCamera.h

@@ -106,6 +106,11 @@ namespace Polycode {
 			*/												
 			void setPostFilter(String shaderName);
 			
+			/**
+			* Removes the currently assigned post filter.
+			*/
+			void removePostFilter();
+			
 		private:
 		
 			Number exposureLevel;

+ 1 - 0
Core/Contents/Include/PolyCocoaCore.h

@@ -33,6 +33,7 @@
 #include <mach/mach_time.h>
 #include <unistd.h>
 
+#include "PolyGLSLShaderModule.h"
 #import <Cocoa/Cocoa.h>
 
 using std::vector;

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

@@ -134,6 +134,8 @@ namespace Polycode {
 		void bindFrameBufferTexture(Texture *texture);
 		void unbindFramebuffers();
 		
+		void cullFrontFaces(bool val);
+				
 		void pushRenderDataArray(RenderDataArray *array);
 		RenderDataArray *createRenderDataArrayForMesh(Mesh *mesh, int arrayType);
 		RenderDataArray *createRenderDataArray(int arrayType);

+ 128 - 0
Core/Contents/Include/PolyGLSLProgram.h

@@ -0,0 +1,128 @@
+/*
+Copyright (C) 2011 by Ivan Safrin
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#pragma once
+
+#include "Polycode.h"
+
+#include "PolyGlobals.h"
+
+#include "PolyLogger.h"
+#include "PolyResource.h"
+#include "PolyVector3.h"
+#include <vector>
+
+
+#if defined(__APPLE__) && defined(__MACH__)
+#include <OpenGL/gl.h>
+#include <OpenGL/glext.h>
+#include <OpenGL/glu.h>	
+#else
+#include <GL/gl.h>	
+#include <GL/glu.h>	
+#include <GL/glext.h>
+#endif
+
+
+
+using std::vector;
+
+namespace Polycode {
+
+class _PolyExport GLSLProgramParam {
+	public:
+	
+	String name;
+	bool isAuto;
+	int autoID;
+	void *defaultData;
+	int paramType;
+	
+	static void *createParamData(int *retType, String type, String value);
+	
+	static const int POLY_MODELVIEWPROJ_MATRIX = 0;
+	static const int POLY_MODELVIEW_MATRIX = 2;
+	static const int POLY_MODELVIEW_INVERSE_MATRIX = 3;
+	static const int POLY_EXPOSURE_LEVEL = 7;
+	static const int POLY_CLEARCOLOR = 10;
+	static const int POLY_AMBIENTCOLOR = 11;	
+	
+	static const int POLY_AREA_LIGHT_POSITION_0 = 12;
+	static const int POLY_AREA_LIGHT_COLOR_0 = 13;	
+	static const int POLY_AREA_LIGHT_POSITION_1 = 14;
+	static const int POLY_AREA_LIGHT_COLOR_1 = 15;	
+	static const int POLY_AREA_LIGHT_POSITION_2 = 16;
+	static const int POLY_AREA_LIGHT_COLOR_2 = 17;	
+	static const int POLY_AREA_LIGHT_POSITION_3 = 18;
+	static const int POLY_AREA_LIGHT_COLOR_3 = 19;	
+	static const int POLY_AREA_LIGHT_POSITION_4 = 20;
+	static const int POLY_AREA_LIGHT_COLOR_4 = 21;	
+	static const int POLY_AREA_LIGHT_POSITION_5 = 22;
+	static const int POLY_AREA_LIGHT_COLOR_5 = 23;	
+	static const int POLY_AREA_LIGHT_POSITION_6 = 24;
+	static const int POLY_AREA_LIGHT_COLOR_6 = 25;	
+	static const int POLY_AREA_LIGHT_POSITION_7 = 26;
+	static const int POLY_AREA_LIGHT_COLOR_7 = 27;	
+
+	static const int POLY_SPOT_LIGHT_POSITION_0 = 30;
+	static const int POLY_SPOT_LIGHT_COLOR_0 = 31;
+	static const int POLY_SPOT_LIGHT_DIRECTION_0 = 32;
+	static const int POLY_SPOT_LIGHT_POSITION_1 = 33;
+	static const int POLY_SPOT_LIGHT_COLOR_1 = 34;
+	static const int POLY_SPOT_LIGHT_DIRECTION_1 = 35;
+	static const int POLY_SPOT_LIGHT_POSITION_2 = 36;
+	static const int POLY_SPOT_LIGHT_COLOR_2 = 37;
+	static const int POLY_SPOT_LIGHT_DIRECTION_2 = 38;
+	static const int POLY_SPOT_LIGHT_POSITION_3 = 39;
+	static const int POLY_SPOT_LIGHT_COLOR_3 = 40;
+	static const int POLY_SPOT_LIGHT_DIRECTION_3 = 41;
+	
+	static const int POLY_SPOT_LIGHT_TEXTUREMATRIX_0 = 42;	
+	static const int POLY_SPOT_LIGHT_TEXTUREMATRIX_1 = 43;
+	static const int POLY_SPOT_LIGHT_TEXTUREMATRIX_2 = 44;
+	static const int POLY_SPOT_LIGHT_TEXTUREMATRIX_3 = 45;
+	
+	static const int PARAM_UNKNOWN = 0;	
+	static const int PARAM_Number = 1;
+	static const int PARAM_Number3 = 2;
+	static const int PARAM_Number4 = 3;
+	
+	};
+
+	class _PolyExport GLSLProgram : public Resource {
+		public:
+			GLSLProgram(int type);
+			~GLSLProgram();
+			
+			void addParam(String name, bool isAuto, int autoID, int paramType, void *defaultData);
+		
+			unsigned int program;
+//			GLSLparameter modelViewProjection;
+	
+			static const int TYPE_VERT = 0;
+			static const int TYPE_FRAG = 1;		
+			
+			int type;
+			
+			vector<GLSLProgramParam> params;
+	};
+}

+ 93 - 0
Core/Contents/Include/PolyGLSLShader.h

@@ -0,0 +1,93 @@
+/*
+Copyright (C) 2011 by Ivan Safrin
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#pragma once
+
+#include "PolyGlobals.h"
+
+#include "PolyLogger.h"
+#include "PolyShader.h"
+#include "PolyGLSLProgram.h"
+#include "PolyTexture.h"
+#include "PolyCubemap.h"
+#include <vector>
+
+#if defined(__APPLE__) && defined(__MACH__)
+#include <OpenGL/gl.h>
+#include <OpenGL/glext.h>
+#include <OpenGL/glu.h>	
+#else
+#include <GL/gl.h>	
+#include <GL/glu.h>	
+#include <GL/glext.h>
+#ifdef _WINDOWS
+#include <GL/wglext.h>
+#endif
+#endif
+
+
+using std::vector;
+
+namespace Polycode {
+
+	typedef struct {
+		Texture *texture;
+		String name;
+	} GLSLTextureBinding;
+
+	typedef struct {
+		Cubemap *cubemap;
+		String name;
+	} GLSLCubemapBinding;
+	
+	
+	class _PolyExport GLSLShader : public Shader {
+		public:
+			GLSLShader(GLSLProgram *vp, GLSLProgram *fp);
+			virtual ~GLSLShader();
+
+			ShaderBinding *createBinding();
+			
+			unsigned int shader_id;		
+			GLSLProgram *vp;
+			GLSLProgram *fp;			
+			
+		protected:
+			
+	};
+	
+	class _PolyExport GLSLShaderBinding : public ShaderBinding {
+		public:
+			GLSLShaderBinding(GLSLShader *shader);
+			virtual ~GLSLShaderBinding();
+			
+			void addTexture(String name, Texture *texture); 
+			void addCubemap(String name, Cubemap *cubemap);				
+			void clearTexture(String name);			
+			void addParam(String type, String name, String value);
+			
+			vector<GLSLTextureBinding> textures;
+			vector<GLSLCubemapBinding> cubemaps;		
+		
+			GLSLShader *glslShader;
+	};
+}

+ 84 - 0
Core/Contents/Include/PolyGLSLShaderModule.h

@@ -0,0 +1,84 @@
+/*
+Copyright (C) 2011 by Ivan Safrin
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#pragma once
+
+#include "Polycode.h"
+#include "PolyGLSLProgram.h"
+#include "PolyGLSLShader.h"
+#include "PolyMaterial.h"
+#include "PolyGLTexture.h"
+#include <string>
+#include <vector>
+
+#if defined(__APPLE__) && defined(__MACH__)
+#include <OpenGL/gl.h>
+#include <OpenGL/glext.h>
+#include <OpenGL/glu.h>	
+#else
+#include <GL/gl.h>	
+#include <GL/glu.h>	
+#include <GL/glext.h>
+#endif
+
+
+using std::vector;
+using std::string;
+
+namespace Polycode {
+	
+	class _PolyExport GLSLShaderModule : public PolycodeShaderModule {
+		public:
+			GLSLShaderModule();
+			virtual ~GLSLShaderModule();
+		
+			bool acceptsExtension(String extension);
+			Resource* createProgramFromFile(String extension, String fullPath);	
+			void reloadPrograms();
+			String getShaderType();
+			Shader *createShader(TiXmlNode *node);
+			bool applyShaderMaterial(Renderer *renderer, Material *material, ShaderBinding *localOptions, unsigned int shaderIndex);	
+			void clearShader();
+		
+	protected:
+
+		void addParamToProgram(GLSLProgram *program,TiXmlNode *node);		
+		void recreateGLSLProgram(GLSLProgram *prog, String fileName, int type);
+		GLSLProgram *createGLSLProgram(String fileName, int type);		
+		void updateGLSLParam(Renderer *renderer, GLSLProgramParam &param, ShaderBinding *materialOptions, ShaderBinding *localOptions);		
+			
+		void setGLSLAreaLightPositionParameter(Renderer *renderer, GLSLProgramParam &param, int lightIndex);
+		void setGLSLAreaLightColorParameter(Renderer *renderer, GLSLProgramParam &param, int lightIndex);	
+		
+		void setGLSLSpotLightPositionParameter(Renderer *renderer, GLSLProgramParam &param, int lightIndex);
+		void setGLSLSpotLightDirectionParameter(Renderer *renderer, GLSLProgramParam &param, int lightIndex);
+		void setGLSLSpotLightColorParameter(Renderer *renderer, GLSLProgramParam &param, int lightIndex);	
+		void setGLSLSpotLightTextureMatrixParameter(Renderer *renderer, GLSLProgramParam &param, int lightIndex);		
+		
+//		GLSLcontext GLSLContext;
+//		GLSLprofile vertexProfile;
+//		GLSLprofile fragmentProfile;
+		
+		vector<GLSLProgram*> programs;
+	};
+	
+}

+ 14 - 5
Core/Contents/Include/PolyMesh.h

@@ -105,17 +105,20 @@ namespace Polycode {
 	*/
 	class _PolyExport Mesh {
 		public:
-			/**
-			* Construct from a mesh loaded from a file.
-			* @param fileName Path to mesh file.
-			*/
-			Mesh(String fileName);
+		
 			
 			/**
 			* Construct with an empty mesh of specified type.
 			* @param meshType Type of mesh. Possible values are: Mesh::QUAD_MESH, Mesh::TRI_MESH, Mesh::TRIFAN_MESH, Mesh::TRISTRIP_MESH, Mesh::LINE_MESH, Mesh::POINT_MESH.
 			*/			
 			Mesh(int meshType);
+					
+			/**
+			* Construct from a mesh loaded from a file.
+			* @param fileName Path to mesh file.
+			*/
+			Mesh(String fileName);
+
 			~Mesh();
 			
 			/**
@@ -145,6 +148,12 @@ namespace Polycode {
 			*/						
 			unsigned int getPolygonCount();
 			
+			/**
+			* Returns the total vertex count in the mesh.
+			* @return Number of vertices in the mesh.
+			*/
+			unsigned int getVertexCount();
+			
 			/**
 			* Returns a polygon at specified index.
 			* @param index Index of polygon.

+ 3 - 1
Core/Contents/Include/PolyParticle.h

@@ -37,7 +37,7 @@ namespace Polycode {
 			~Particle();
 			void Reset(bool continuious);
 			
-			void createSceneParticle(int particleType, Texture *texture, Mesh *particleMesh);
+			void createSceneParticle(int particleType, Material *material, Mesh *particleMesh);
 			void createScreenParticle(int particleType, Texture *texture, Mesh *particleMesh);
 		
 			Entity *particleBody;						
@@ -52,6 +52,8 @@ namespace Polycode {
 			Number perlinPosY;
 			Number perlinPosZ;
 			
+			static Mesh* billboardMesh;
+			
 			static const int BILLBOARD_PARTICLE = 0;
 			static const int MESH_PARTICLE = 1;
 	};

+ 155 - 27
Core/Contents/Include/PolyParticleEmitter.h

@@ -33,6 +33,10 @@ THE SOFTWARE.
 using std::vector;
 
 namespace Polycode {
+
+	/** 
+	* Particle emitter base.
+	*/
 	class _PolyExport ParticleEmitter {
 		public:
 			ParticleEmitter(String imageFile, Mesh *particleMesh, int particleType, int emitterType, Number lifespan, unsigned int numParticles, Vector3 direction, Vector3 gravity, Vector3 deviation);
@@ -40,58 +44,160 @@ namespace Polycode {
 		
 			void createParticles();
 			
+			/**
+			* Sets the speed at which particles rotate
+			* @param speed New rotation speed.
+			*/ 
 			void setRotationSpeed(Number speed);
-			void setStartingColor(Color c);
-			void setEndingColor(Color c);
+			
+			/**
+			* Sets the blending mode used for the particles. See documentation for the Entity for information on blending modes.
+			* @param mode New blending mode.
+			*/ 			
 			void setParticleBlendingMode(int mode);
+			
+			/**
+			* Turns depth write on and off for particles.
+			*/ 						
 			void setDepthWrite(bool val);
+			
+			/**
+			* Turns depth test on and off for particles.
+			*/ 									
 			void setDepthTest(bool val);		
+			
+			/**
+			* Turns alpha testing on and off for particles.
+			*/ 												
 			void setAlphaTest(bool val);
-		
+
+			/**
+			* Enables perlin noise movement for particles.
+			*/ 														
 			void enablePerlin(bool val);
+			
+			/**
+			* Enables perlin noise movement size.
+			*/ 														
+			void setPerlinModSize(Number size);
+
+			/**
+			* Enables or disables billboard mode for particles.
+			*/ 																	
 			void setBillboardMode(bool mode);
+			
+			/**
+			* Enables or disables the emitter
+			*/ 																				
 			void enableEmitter(bool val);
-			bool emitterEnabled();
 			
-			void setEmitterRadius(Number rad);
-			void setStartingScaleModifier(Number mod);
-			void setEndingScaleModifier(Number mod);
-			void setEmitRotationVector(Vector3 rotVector);
-			void setEmitRotationDeviance(Vector3 rotVector);
+			/**
+			* Returns true if the emitter is enabled, false otherwise.
+			*/ 																							
+			bool emitterEnabled();
+
+			/**
+			* Sets the emitter radius on all 3 axises.
+			*/ 																										
+			void setEmitterRadius(Vector3 rad);
+
+			/**
+			* If set to true, will release all particles at once.
+			*/ 																													
 			void setAllAtOnce(bool val);
 			
+			/**
+			* If emitter mode is TRIGGERED_EMITTER, calling this method will trigger particle emission.
+			*/ 																													
 			void Trigger();
+			
 			void resetParticle(Particle *particle);
 			
-			void setPerlinModSize(Number size);
+			/**
+			* Changes the particle count in the emitter.
+			*/ 																													
 			void setParticleCount(int count);
 		
-			virtual void addParticleBody(Entity *particleBody) = 0;
-			virtual Matrix4 getBaseMatrix() = 0;
+			virtual void addParticleBody(Entity *particleBody) {}
+			virtual Matrix4 getBaseMatrix() {Matrix4 m; return m;}
 		
+			/**
+			* Particle movement speed multiplier
+			*/ 																																								
 			Number particleSpeedMod;
+			
+			/**
+			* Particle brightness deviation
+			*/ 																																										
 			Number brightnessDeviation;
 			
 			void updateEmitter();
 
+			/**
+			* Continuous emitter setting.
+			*/ 																													
 			static const int CONTINUOUS_EMITTER = 0;
+
+			/**
+			* Triggered emitter setting.
+			*/ 																																
 			static const int TRIGGERED_EMITTER = 1;
-			static const int CLOUD_EMITTER = 2;
 			
+			/**
+			* Particle direction deviation
+			*/ 																																							
 			Vector3 deviation;
+			/**
+			* Particle direction and emission strength vector
+			*/ 																																								
 			Vector3 dirVector;
+			
+			/**
+			* Particle gravity strength vector
+			*/ 																																								
 			Vector3 gravVector;			
 
+			/**
+			* Lifespan of particles.
+			*/ 																																						
 			Number lifespan;
 		
+			/**
+			* If set to true, particles' rotation will follow their movement.
+			*/ 																																		
 			bool rotationFollowsPath;
-		
+
+			/**
+			* Bezier curve that controls the scale of the particles.
+			*/ 																																				
 			BezierCurve scaleCurve;
-		
+
+			/**
+			* Bezier curve that controls the red component of particles' color.
+			*/ 																																						
 			BezierCurve colorCurveR;
+			/**
+			* Bezier curve that controls the green component of particles' color.
+			*/ 																																								
 			BezierCurve colorCurveG;
+			/**
+			* Bezier curve that controls the blue component of particles' color.
+			*/ 																																								
 			BezierCurve colorCurveB;
+			/**
+			* Bezier curve that controls the alpha component of particles' color.
+			*/ 																																								
 			BezierCurve colorCurveA;
+			
+			/**
+			* If set to true, will use the color curves to control particle color. False by default.
+			*/
+			bool useColorCurves;
+			
+			/**
+			* If set to true, will use the scale curve to control particle scale. False by default.
+			*/			
+			bool useScaleCurves;
 		
 		protected:
 		
@@ -108,17 +214,10 @@ namespace Polycode {
 		
 			bool isEmitterEnabled;
 		
-			Vector3 emitRotationVector;
-			Vector3 emitRotationDeviance;
-			Number emitterRadius;
+			Vector3 emitterRadius;
 			Number perlinModSize;
 			Perlin *motionPerlin;
 			bool perlinEnabled;
-			Number startingScaleMod;
-			Number endingScaleMod;
-			
-			Color startingColor;
-			Color endingColor;
 			
 			Number rotationSpeed;
 			Number numParticles;
@@ -128,11 +227,33 @@ namespace Polycode {
 			Timer *timer;
 	};
 
+	/**
+	* 3D particle emitter.
+	*/
 	class _PolyExport SceneParticleEmitter : public SceneEntity, public ParticleEmitter {
 	public:
-		SceneParticleEmitter(String imageFile, Mesh *particleMesh, SceneMesh *emitter, Scene *particleParentScene, int particleType, int emitterType, Number lifespan, unsigned int numParticles, Vector3 direction, Vector3 gravity, Vector3 deviation);
+		/**
+		* Constructor.
+		* @param materialName Name of the material to use for particles.
+		* @param particleParentScene Scene to create particles in.
+		* @param particleType Type of particles to create. Can be Particle::BILLBOARD_PARTICLE or Particle::MESH_PARTICLE
+		* @param emitterType Type of emitter to create. Can be ParticleEmitter::CONTINUOUS_EMITTER or ParticleEmitter::TRIGGERED_EMITTER
+		* @param lifespan Lifetime of particles in seconds.
+		* @param numParticles Total number of particles to create.
+		* @param direction Direction of the emitter, length of this vector controls emitter strength
+		* @param gravity Gravity direction and strength
+		* @param deviation Emitter deviation on each axis
+		* @param particleMesh If particle type is Particle::MESH_PARTICLE, this must be set to the mesh to use for each particle
+		* @param emitter If this is specified, particles will be emitted from this meshe's vertices.
+		*/
+		SceneParticleEmitter(String materialName, Scene *particleParentScene, int particleType, int emitterType, Number lifespan, unsigned int numParticles, Vector3 direction, Vector3 gravity, Vector3 deviation, Mesh *particleMesh = NULL, SceneMesh *emitter = NULL);
 		~SceneParticleEmitter();		
 		
+		/**
+		* Returns the emitter (helper method for LUA).
+		*/ 
+		ParticleEmitter *getEmitter() { return this; }
+		
 		void addParticleBody(Entity *particleBody);
 		Matrix4 getBaseMatrix();
 		void Update();
@@ -141,13 +262,20 @@ namespace Polycode {
 		SceneMesh *emitterMesh;		
 		Scene *particleParentScene;
 	};	
-	
-	
+		
+	/**
+	* 3D particle emitter.
+	*/
 	class _PolyExport ScreenParticleEmitter : public ScreenEntity, public ParticleEmitter {
 	public:
-		ScreenParticleEmitter(String imageFile, Mesh *particleMesh, ScreenMesh *emitter, Screen *particleParentScreen, int particleType, int emitterType, Number lifespan, unsigned int numParticles, Vector3 direction, Vector3 gravity, Vector3 deviation);
+		ScreenParticleEmitter(String imageFile, Screen *particleParentScreen, int particleType, int emitterType, Number lifespan, unsigned int numParticles, Vector3 direction, Vector3 gravity, Vector3 deviation, Mesh *particleMesh = NULL, ScreenMesh *emitter = NULL);
 		~ScreenParticleEmitter();		
 		
+		/**
+		* Returns the emitter (helper method for LUA).
+		*/ 		
+		ParticleEmitter *getEmitter() { return this; }		
+		
 		void addParticleBody(Entity *particleBody);
 		Matrix4 getBaseMatrix();
 		void Update();

+ 19 - 2
Core/Contents/Include/PolyRenderer.h

@@ -43,12 +43,24 @@ namespace Polycode {
 			Vector3 position;
 			Vector3 color;
 			Vector3 dir;
-			Number distance;
+			Number constantAttenuation;
+			Number linearAttenuation;
+			Number quadraticAttenuation;			
 			Number intensity;
+			Number spotlightCutoff;
+			Number spotlightExponent;			
 			int type;
+			bool shadowsEnabled;
 			Matrix4 textureMatrix;
 	};
 
+	class _PolyExport LightSorter {
+		public:
+			Vector3 basePosition;
+			Matrix4 cameraMatrix;
+			bool operator() (LightInfo i,LightInfo j) { return ((cameraMatrix*i.position).distance(basePosition)<(cameraMatrix*j.position).distance(basePosition));}
+	};
+
 	/**
 	* Main renderer. The renderer should only be accessed from the CoreServices singleton. Renderer operations should only be called from within Render methods of entities so that they can be properly managed.
 	*/
@@ -158,8 +170,10 @@ namespace Polycode {
 		int getXRes();
 		int getYRes();
 		
+		virtual void cullFrontFaces(bool val) = 0;
+		
 		void clearLights();
-		void addLight(Vector3 position, Vector3 direction, int type, Color color, Number distance, Number intensity, Matrix4 *textureMatrix);
+		void addLight(Vector3 position, Vector3 direction, int type, Color color, Number constantAttenuation, Number linearAttenuation, Number quadraticAttenuation, Number intensity, Number spotlightCutoff, Number spotlightExponent, bool shadowsEnabled, Matrix4 *textureMatrix);
 		
 		void setExposureLevel(Number level);
 		
@@ -203,6 +217,8 @@ namespace Polycode {
 		Number exposureLevel;		
 		Vector3 cameraPosition;
 		
+		void sortLights();
+		
 		int getNumAreaLights() { return numAreaLights; }
 		int getNumSpotLights() { return numSpotLights; }
 		int getNumLights() { return numLights; }
@@ -212,6 +228,7 @@ namespace Polycode {
 		
 	protected:
 	
+		bool cullingFrontFaces;
 				
 		Texture *currentTexture;
 		Material *currentMaterial;

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно