soc-2008-mxcurioni: merged changes to revision 15705
[blender.git] / source / gameengine / Ketsji / KX_PythonInit.cpp
index 1b6d55f68e9dbcc09f7b313e3c8bdcadf0a0a854..61ed8b6a8e4a8567e8e92e03dedba20c75bc514a 100644 (file)
@@ -1,15 +1,12 @@
 /**
  * $Id$
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
  * Initialize Python thingies.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "GL/glew.h"
+
+#include <stdlib.h>
 
 #ifdef WIN32
 #pragma warning (disable : 4786)
 #endif //WIN32
 
 #include "KX_PythonInit.h"
+//python physics binding
+#include "KX_PyConstraintBinding.h"
+
+#include "KX_KetsjiEngine.h"
 
 #include "SCA_IInputDevice.h"
 #include "SCA_PropertySensor.h"
 #include "SCA_RandomActuator.h"
 #include "KX_ConstraintActuator.h"
 #include "KX_IpoActuator.h"
+#include "KX_SoundActuator.h"
+#include "BL_ActionActuator.h"
 #include "RAS_IRasterizer.h"
 #include "RAS_ICanvas.h"
 #include "MT_Vector3.h"
 #include "KX_Scene.h"
 #include "SND_DeviceManager.h"
 
+#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h"
+#include "BL_Shader.h"
+
 #include "KX_PyMath.h"
 
+#include "PHY_IPhysicsEnvironment.h"
 // FIXME: Enable for access to blender python modules.  This is disabled because
 // python has dependencies on a lot of other modules and is a pain to link.
 //#define USE_BLENDER_PYTHON
 //#include "BPY_extern.h"
 #endif 
 
+#include "BKE_utildefines.h"
+#include "BKE_global.h"
+#include "BLI_blenlib.h"
+
 static void setSandbox(TPythonSecurityLevel level);
 
 
@@ -71,6 +82,12 @@ static RAS_ICanvas* gp_Canvas = NULL;
 static KX_Scene*       gp_KetsjiScene = NULL;
 static RAS_IRasterizer* gp_Rasterizer = NULL;
 
+void   KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)
+{
+       if (gp_Rasterizer)
+               gp_Rasterizer->DrawDebugLine(from,to,color);
+}
+
 /* Macro for building the keyboard translation */
 //#define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, PyInt_FromLong(SCA_IInputDevice::KX_##name))
 #define KX_MACRO_addToDict(dict, name) PyDict_SetItemString(dict, #name, PyInt_FromLong(name))
@@ -86,54 +103,58 @@ static RAS_IRasterizer* gp_Rasterizer = NULL;
 static PyObject* ErrorObject;
 STR_String gPyGetRandomFloat_doc="getRandomFloat returns a random floating point value in the range [0..1)";
 
-static PyObject* gPyGetRandomFloat(PyObject* self,
-                                                                                PyObject* args, 
-                                                                                PyObject* kwds)
+static PyObject* gPyGetRandomFloat(PyObject*)
 {
        return PyFloat_FromDouble(MT_random());
 }
 
-
-
-
-
-void GlobalConvertPythonVectorArg(PyObject* args, MT_Vector3 &pos)
-{
-       PyObject* pylist;
-       PyArg_ParseTuple(args,"O",&pylist);
-
-       pos = MT_Vector3FromPyList(pylist);
-}
-
-void GlobalConvertPythonVectorArg(PyObject* args, MT_Vector4 &vec)
-{
-       PyObject* pylist;
-       PyArg_ParseTuple(args,"O",&pylist);
-
-       vec = MT_Vector4FromPyList(pylist);
-}
-
-
-static PyObject* gPySetGravity(PyObject* self,
+static PyObject* gPySetGravity(PyObject*,
                                                                                 PyObject* args, 
-                                                                                PyObject* kwds)
+                                                                                PyObject*)
 {
        MT_Vector3 vec = MT_Vector3(0., 0., 0.);
-       GlobalConvertPythonVectorArg(args, vec);
+       if (PyVecArgTo(args, vec))
+       {
+               if (gp_KetsjiScene)
+                       gp_KetsjiScene->SetGravity(vec);
+               
+               Py_Return;
+       }
+       
+       return NULL;
+}
 
-       if (gp_KetsjiScene)
-               gp_KetsjiScene->SetGravity(vec);
+static char gPyExpandPath_doc[] =
+"(path) - Converts a blender internal path into a proper file system path.\n\
+path - the string path to convert.\n\n\
+Use / as directory separator in path\n\
+You can use '//' at the start of the string to define a relative path;\n\
+Blender replaces that string by the directory of the startup .blend or runtime\n\
+file to make a full path name (doesn't change during the game, even if you load\n\
+other .blend).\n\
+The function also converts the directory separator to the local file system format.";
+
+static PyObject* gPyExpandPath(PyObject*,
+                                                               PyObject* args, 
+                                                               PyObject*)
+{
+       char expanded[FILE_MAXDIR + FILE_MAXFILE];
+       char* filename;
        
-       Py_Return;
+       if (PyArg_ParseTuple(args,"s",&filename))
+       {
+               BLI_strncpy(expanded, filename, FILE_MAXDIR + FILE_MAXFILE);
+               BLI_convertstringcode(expanded, G.sce);
+               return PyString_FromString(expanded);
+       }
+       return NULL;
 }
 
 
 static bool usedsp = false;
 
 // this gets a pointer to an array filled with floats
-static PyObject* gPyGetSpectrum(PyObject* self,
-                                                               PyObject* args, 
-                                                               PyObject* kwds)
+static PyObject* gPyGetSpectrum(PyObject*)
 {
        SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
 
@@ -160,9 +181,9 @@ static PyObject* gPyGetSpectrum(PyObject* self,
 
 
 
-static PyObject* gPyStartDSP(PyObject* self,
+static PyObject* gPyStartDSP(PyObject*,
                                                PyObject* args, 
-                                               PyObject* kwds)
+                                               PyObject*)
 {
        SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
 
@@ -180,9 +201,9 @@ static PyObject* gPyStartDSP(PyObject* self,
 
 
 
-static PyObject* gPyStopDSP(PyObject* self,
+static PyObject* gPyStopDSP(PyObject*,
                                           PyObject* args, 
-                                          PyObject* kwds)
+                                          PyObject*)
 {
        SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
 
@@ -198,40 +219,169 @@ static PyObject* gPyStopDSP(PyObject* self,
        return NULL;
 }
 
+static PyObject* gPySetLogicTicRate(PyObject*,
+                                       PyObject* args,
+                                       PyObject*)
+{
+       float ticrate;
+       if (PyArg_ParseTuple(args, "f", &ticrate))
+       {
+               KX_KetsjiEngine::SetTicRate(ticrate);
+               Py_Return;
+       }
+       
+       return NULL;
+}
+
+static PyObject* gPyGetLogicTicRate(PyObject*)
+{
+       return PyFloat_FromDouble(KX_KetsjiEngine::GetTicRate());
+}
+
+static PyObject* gPySetPhysicsTicRate(PyObject*,
+                                       PyObject* args,
+                                       PyObject*)
+{
+       float ticrate;
+       if (PyArg_ParseTuple(args, "f", &ticrate))
+       {
+
+               PHY_GetActiveEnvironment()->setFixedTimeStep(true,ticrate);
+               Py_Return;
+       }
+       
+       return NULL;
+}
+
+static PyObject* gPySetPhysicsDebug(PyObject*,
+                                       PyObject* args,
+                                       PyObject*)
+{
+       int debugMode;
+       if (PyArg_ParseTuple(args, "i", &debugMode))
+       {
+               PHY_GetActiveEnvironment()->setDebugMode(debugMode);
+               Py_Return;
+       }
+       
+       return NULL;
+}
+
+
+
+static PyObject* gPyGetPhysicsTicRate(PyObject*)
+{
+       return PyFloat_FromDouble(PHY_GetActiveEnvironment()->getFixedTimeStep());
+}
 
 static STR_String gPyGetCurrentScene_doc =  
 "getCurrentScene()\n"
 "Gets a reference to the current scene.\n";
-static PyObject* gPyGetCurrentScene(PyObject* self,
-                                          PyObject* args, 
-                                          PyObject* kwds)
+static PyObject* gPyGetCurrentScene(PyObject* self)
 {
        Py_INCREF(gp_KetsjiScene);
        return (PyObject*) gp_KetsjiScene;
 }
-                                          
+
+static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
+{
+#define pprint(x) std::cout << x << std::endl;
+       bool count=0;
+       bool support=0;
+       pprint("Supported Extensions...");
+       pprint(" GL_ARB_shader_objects supported?       "<< (GLEW_ARB_shader_objects?"yes.":"no."));
+       count = 1;
+
+       support= GLEW_ARB_vertex_shader;
+       pprint(" GL_ARB_vertex_shader supported?        "<< (support?"yes.":"no."));
+       count = 1;
+       if(support){
+               pprint(" ----------Details----------");
+               int max=0;
+               glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, (GLint*)&max);
+               pprint("  Max uniform components." << max);
+
+               glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, (GLint*)&max);
+               pprint("  Max varying floats." << max);
+
+               glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max);
+               pprint("  Max vertex texture units." << max);
+       
+               glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, (GLint*)&max);
+               pprint("  Max combined texture units." << max);
+               pprint("");
+       }
+
+       support=GLEW_ARB_fragment_shader;
+       pprint(" GL_ARB_fragment_shader supported?      "<< (support?"yes.":"no."));
+       count = 1;
+       if(support){
+               pprint(" ----------Details----------");
+               int max=0;
+               glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, (GLint*)&max);
+               pprint("  Max uniform components." << max);
+               pprint("");
+       }
+
+       support = GLEW_ARB_texture_cube_map;
+       pprint(" GL_ARB_texture_cube_map supported?     "<< (support?"yes.":"no."));
+       count = 1;
+       if(support){
+               pprint(" ----------Details----------");
+               int size=0;
+               glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, (GLint*)&size);
+               pprint("  Max cubemap size." << size);
+               pprint("");
+       }
+
+       support = GLEW_ARB_multitexture;
+       count = 1;
+       pprint(" GL_ARB_multitexture supported?         "<< (support?"yes.":"no."));
+       if(support){
+               pprint(" ----------Details----------");
+               int units=0;
+               glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&units);
+               pprint("  Max texture units available.  " << units);
+               pprint("");
+       }
+
+       pprint(" GL_ARB_texture_env_combine supported?  "<< (GLEW_ARB_texture_env_combine?"yes.":"no."));
+       count = 1;
+
+       if(!count)
+               pprint("No extenstions are used in this build");
+
+       Py_INCREF(Py_None);
+       return Py_None;
+}
 
 
 static struct PyMethodDef game_methods[] = {
+       {"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, gPyExpandPath_doc},
        {"getCurrentController",
        (PyCFunction) SCA_PythonController::sPyGetCurrentController,
-       METH_VARARGS, SCA_PythonController::sPyGetCurrentController__doc__},
+       METH_NOARGS, SCA_PythonController::sPyGetCurrentController__doc__},
        {"getCurrentScene", (PyCFunction) gPyGetCurrentScene,
-       METH_VARARGS, gPyGetCurrentScene_doc.Ptr()},
+       METH_NOARGS, gPyGetCurrentScene_doc.Ptr()},
        {"addActiveActuator",(PyCFunction) SCA_PythonController::sPyAddActiveActuator,
        METH_VARARGS, SCA_PythonController::sPyAddActiveActuator__doc__},
        {"getRandomFloat",(PyCFunction) gPyGetRandomFloat,
-       METH_VARARGS,gPyGetRandomFloat_doc.Ptr()},
+       METH_NOARGS,gPyGetRandomFloat_doc.Ptr()},
        {"setGravity",(PyCFunction) gPySetGravity, METH_VARARGS,"set Gravitation"},
-       {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_VARARGS,"get audio spectrum"},
+       {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_NOARGS,"get audio spectrum"},
        {"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS,"stop using the audio dsp (for performance reasons)"},
+       {"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_NOARGS, "Gets the logic tic rate"},
+       {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, "Sets the logic tic rate"},
+       {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, "Gets the physics tic rate"},
+       {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, "Sets the physics tic rate"},
+       {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, "Prints GL Extension Info"},
        {NULL, (PyCFunction) NULL, 0, NULL }
 };
 
 
-static PyObject* gPyGetWindowHeight(PyObject* self
+static PyObject* gPyGetWindowHeight(PyObject*, 
                                                                                 PyObject* args, 
-                                                                                PyObject* kwds)
+                                                                                PyObject*)
 {
        int height = (gp_Canvas ? gp_Canvas->GetHeight() : 0);
 
@@ -241,9 +391,9 @@ static PyObject* gPyGetWindowHeight(PyObject* self,
 
 
 
-static PyObject* gPyGetWindowWidth(PyObject* self
+static PyObject* gPyGetWindowWidth(PyObject*, 
                                                                                 PyObject* args, 
-                                                                                PyObject* kwds)
+                                                                                PyObject*)
 {
                
 
@@ -258,9 +408,9 @@ static PyObject* gPyGetWindowWidth(PyObject* self,
 // temporarility visibility thing, will be moved to rasterizer/renderer later
 bool gUseVisibilityTemp = false;
 
-static PyObject* gPyEnableVisibility(PyObject* self
+static PyObject* gPyEnableVisibility(PyObject*, 
                                                                                 PyObject* args, 
-                                                                                PyObject* kwds)
+                                                                                PyObject*)
 {
        int visible;
        if (PyArg_ParseTuple(args,"i",&visible))
@@ -269,16 +419,16 @@ static PyObject* gPyEnableVisibility(PyObject* self,
        }
        else
        {
-         Py_Return;         
+               return NULL;
        }
    Py_Return;
 }
 
 
 
-static PyObject* gPyShowMouse(PyObject* self
+static PyObject* gPyShowMouse(PyObject*, 
                                                                                 PyObject* args, 
-                                                                                PyObject* kwds)
+                                                                                PyObject*)
 {
        int visible;
        if (PyArg_ParseTuple(args,"i",&visible))
@@ -293,15 +443,18 @@ static PyObject* gPyShowMouse(PyObject* self,
                                gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
                }
        }
+       else {
+               return NULL;
+       }
        
    Py_Return;
 }
 
 
 
-static PyObject* gPySetMousePosition(PyObject* self
+static PyObject* gPySetMousePosition(PyObject*, 
                                                                                 PyObject* args, 
-                                                                                PyObject* kwds)
+                                                                                PyObject*)
 {
        int x,y;
        if (PyArg_ParseTuple(args,"ii",&x,&y))
@@ -309,49 +462,102 @@ static PyObject* gPySetMousePosition(PyObject* self,
            if (gp_Canvas)
                        gp_Canvas->SetMousePosition(x,y);
        }
+       else {
+               return NULL;
+       }
        
    Py_Return;
 }
 
+static PyObject* gPySetEyeSeparation(PyObject*,
+                                               PyObject* args,
+                                               PyObject*)
+{
+       float sep;
+       if (PyArg_ParseTuple(args, "f", &sep))
+       {
+               if (gp_Rasterizer)
+                       gp_Rasterizer->SetEyeSeparation(sep);
+                       
+               Py_Return;
+       }
+       
+       return NULL;
+}
+
+static PyObject* gPyGetEyeSeparation(PyObject*, PyObject*, PyObject*)
+{
+       if (gp_Rasterizer)
+               return PyFloat_FromDouble(gp_Rasterizer->GetEyeSeparation());
+       
+       return NULL;
+}
+
+static PyObject* gPySetFocalLength(PyObject*,
+                                       PyObject* args,
+                                       PyObject*)
+{
+       float focus;
+       if (PyArg_ParseTuple(args, "f", &focus))
+       {
+               if (gp_Rasterizer)
+                       gp_Rasterizer->SetFocalLength(focus);
+               Py_Return;
+       }
+       
+       return NULL;
+}
 
+static PyObject* gPyGetFocalLength(PyObject*, PyObject*, PyObject*)
+{
+       if (gp_Rasterizer)
+               return PyFloat_FromDouble(gp_Rasterizer->GetFocalLength());
+       return NULL;
+}
 
-static PyObject* gPySetBackgroundColor(PyObject* self
+static PyObject* gPySetBackgroundColor(PyObject*, 
                                                                                 PyObject* args, 
-                                                                                PyObject* kwds)
+                                                                                PyObject*)
 {
        
        MT_Vector4 vec = MT_Vector4(0., 0., 0.3, 0.);
-       GlobalConvertPythonVectorArg(args, vec);
-
-       if (gp_Canvas)
+       if (PyVecArgTo(args, vec))
        {
-               gp_Rasterizer->SetBackColor(vec[0], vec[1], vec[2], vec[3]);
+               if (gp_Canvas)
+               {
+                       gp_Rasterizer->SetBackColor(vec[0], vec[1], vec[2], vec[3]);
+               }
+               Py_Return;
        }
-   Py_Return;
+       
+       return NULL;
 }
 
 
 
-static PyObject* gPySetMistColor(PyObject* self
+static PyObject* gPySetMistColor(PyObject*, 
                                                                                 PyObject* args, 
-                                                                                PyObject* kwds)
+                                                                                PyObject*)
 {
        
        MT_Vector3 vec = MT_Vector3(0., 0., 0.);
-       GlobalConvertPythonVectorArg(args, vec);
-
-       if (gp_Rasterizer)
+       if (PyVecArgTo(args, vec))
        {
-               gp_Rasterizer->SetFogColor(vec[0], vec[1], vec[2]);
+               if (gp_Rasterizer)
+               {
+                       gp_Rasterizer->SetFogColor(vec[0], vec[1], vec[2]);
+               }
+               Py_Return;
        }
-   Py_Return;
+       
+       return NULL;
 }
 
 
 
-static PyObject* gPySetMistStart(PyObject* self
+static PyObject* gPySetMistStart(PyObject*, 
                                                                                 PyObject* args, 
-                                                                                PyObject* kwds)
+                                                                                PyObject*)
 {
 
        float miststart;
@@ -362,14 +568,17 @@ static PyObject* gPySetMistStart(PyObject* self,
                        gp_Rasterizer->SetFogStart(miststart);
                }
        }
+       else {
+               return NULL;
+       }
    Py_Return;
 }
 
 
 
-static PyObject* gPySetMistEnd(PyObject* self
+static PyObject* gPySetMistEnd(PyObject*, 
                                                                                 PyObject* args, 
-                                                                                PyObject* kwds)
+                                                                                PyObject*)
 {
 
        float mistend;
@@ -380,14 +589,37 @@ static PyObject* gPySetMistEnd(PyObject* self,
                        gp_Rasterizer->SetFogEnd(mistend);
                }
        }
+       else {
+               return NULL;
+       }
    Py_Return;
 }
 
 
+static PyObject* gPySetAmbientColor(PyObject*, 
+                                                                                PyObject* args, 
+                                                                                PyObject*)
+{
+       
+       MT_Vector3 vec = MT_Vector3(0., 0., 0.);
+       if (PyVecArgTo(args, vec))
+       {
+               if (gp_Rasterizer)
+               {
+                       gp_Rasterizer->SetAmbientColor(vec[0], vec[1], vec[2]);
+               }
+               Py_Return;
+       }
+       
+       return NULL;
+}
+
+
+
 
-static PyObject* gPyMakeScreenshot(PyObject* self,
+static PyObject* gPyMakeScreenshot(PyObject*,
                                                                        PyObject* args,
-                                                                       PyObject* kwds)
+                                                                       PyObject*)
 {
        char* filename;
        if (PyArg_ParseTuple(args,"s",&filename))
@@ -397,10 +629,40 @@ static PyObject* gPyMakeScreenshot(PyObject* self,
                        gp_Canvas->MakeScreenShot(filename);
                }
        }
+       else {
+               return NULL;
+       }
        Py_Return;
 }
 
+static PyObject* gPyEnableMotionBlur(PyObject*,
+                                                                       PyObject* args,
+                                                                       PyObject*)
+{
+       float motionblurvalue;
+       if (PyArg_ParseTuple(args,"f",&motionblurvalue))
+       {
+               if(gp_Rasterizer)
+               {
+                       gp_Rasterizer->EnableMotionBlur(motionblurvalue);
+               }
+       }
+       else {
+               return NULL;
+       }
+       Py_Return;
+}
 
+static PyObject* gPyDisableMotionBlur(PyObject*,
+                                                                       PyObject* args,
+                                                                       PyObject*)
+{
+       if(gp_Rasterizer)
+       {
+               gp_Rasterizer->DisableMotionBlur();
+       }
+       Py_Return;
+}
 
 STR_String     gPyGetWindowHeight__doc__="getWindowHeight doc";
 STR_String     gPyGetWindowWidth__doc__="getWindowWidth doc";
@@ -423,10 +685,18 @@ static struct PyMethodDef rasterizer_methods[] = {
    {"setMousePosition",(PyCFunction) gPySetMousePosition,
    METH_VARARGS, gPySetMousePosition__doc__.Ptr()},
   {"setBackgroundColor",(PyCFunction)gPySetBackgroundColor,METH_VARARGS,"set Background Color (rgb)"},
-  {"setMistColor",(PyCFunction)gPySetMistColor,METH_VARARGS,"set Mist Color (rgb)"},
+       {"setAmbientColor",(PyCFunction)gPySetAmbientColor,METH_VARARGS,"set Ambient Color (rgb)"},
+ {"setMistColor",(PyCFunction)gPySetMistColor,METH_VARARGS,"set Mist Color (rgb)"},
   {"setMistStart",(PyCFunction)gPySetMistStart,METH_VARARGS,"set Mist Start(rgb)"},
   {"setMistEnd",(PyCFunction)gPySetMistEnd,METH_VARARGS,"set Mist End(rgb)"},
+  {"enableMotionBlur",(PyCFunction)gPyEnableMotionBlur,METH_VARARGS,"enable motion blur"},
+  {"disableMotionBlur",(PyCFunction)gPyDisableMotionBlur,METH_VARARGS,"disable motion blur"},
+
   
+  {"setEyeSeparation", (PyCFunction) gPySetEyeSeparation, METH_VARARGS, "set the eye separation for stereo mode"},
+  {"getEyeSeparation", (PyCFunction) gPyGetEyeSeparation, METH_VARARGS, "get the eye separation for stereo mode"},
+  {"setFocalLength", (PyCFunction) gPySetFocalLength, METH_VARARGS, "set the focal length for stereo mode"},
+  {"getFocalLength", (PyCFunction) gPyGetFocalLength, METH_VARARGS, "get the focal length for stereo mode"},
   { NULL, (PyCFunction) NULL, 0, NULL }
 };
 
@@ -506,17 +776,61 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook
        KX_MACRO_addTypesToDict(d, KX_RANDOMACT_FLOAT_NORMAL,    SCA_RandomActuator::KX_RANDOMACT_FLOAT_NORMAL);
        KX_MACRO_addTypesToDict(d, KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL, SCA_RandomActuator::KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL);
 
+       /* 6. Sound actuator                                                      */
+       KX_MACRO_addTypesToDict(d, KX_SOUNDACT_PLAYSTOP,              KX_SoundActuator::KX_SOUNDACT_PLAYSTOP);
+       KX_MACRO_addTypesToDict(d, KX_SOUNDACT_PLAYEND,               KX_SoundActuator::KX_SOUNDACT_PLAYEND);
+       KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPSTOP,              KX_SoundActuator::KX_SOUNDACT_LOOPSTOP);
+       KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPEND,               KX_SoundActuator::KX_SOUNDACT_LOOPEND);
+       KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPBIDIRECTIONAL,     KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL);
+       KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP,     KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP);
+
+       /* 7. Action actuator                                                                                                      */
+       KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PLAY,     BL_ActionActuator::KX_ACT_ACTION_PLAY);
+       KX_MACRO_addTypesToDict(d, KX_ACTIONACT_FLIPPER,     BL_ActionActuator::KX_ACT_ACTION_FLIPPER);
+       KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPSTOP,     BL_ActionActuator::KX_ACT_ACTION_LOOPSTOP);
+       KX_MACRO_addTypesToDict(d, KX_ACTIONACT_LOOPEND,     BL_ActionActuator::KX_ACT_ACTION_LOOPEND);
+       KX_MACRO_addTypesToDict(d, KX_ACTIONACT_PROPERTY,     BL_ActionActuator::KX_ACT_ACTION_PROPERTY);
+       
+       /*8. GL_BlendFunc */
+       KX_MACRO_addTypesToDict(d, BL_ZERO, GL_ZERO);
+       KX_MACRO_addTypesToDict(d, BL_ONE, GL_ONE);
+       KX_MACRO_addTypesToDict(d, BL_SRC_COLOR, GL_SRC_COLOR);
+       KX_MACRO_addTypesToDict(d, BL_ONE_MINUS_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
+       KX_MACRO_addTypesToDict(d, BL_DST_COLOR, GL_DST_COLOR);
+       KX_MACRO_addTypesToDict(d, BL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_DST_COLOR);
+       KX_MACRO_addTypesToDict(d, BL_SRC_ALPHA, GL_SRC_ALPHA);
+       KX_MACRO_addTypesToDict(d, BL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       KX_MACRO_addTypesToDict(d, BL_DST_ALPHA, GL_DST_ALPHA);
+       KX_MACRO_addTypesToDict(d, BL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
+       KX_MACRO_addTypesToDict(d, BL_SRC_ALPHA_SATURATE, GL_SRC_ALPHA_SATURATE);
+
+
+       /* 9. UniformTypes */
+       KX_MACRO_addTypesToDict(d, SHD_TANGENT, BL_Shader::SHD_TANGENT);
+       KX_MACRO_addTypesToDict(d, MODELVIEWMATRIX, BL_Shader::MODELVIEWMATRIX);
+       KX_MACRO_addTypesToDict(d, MODELVIEWMATRIX_TRANSPOSE, BL_Shader::MODELVIEWMATRIX_TRANSPOSE);
+       KX_MACRO_addTypesToDict(d, MODELVIEWMATRIX_INVERSE, BL_Shader::MODELVIEWMATRIX_INVERSE);
+       KX_MACRO_addTypesToDict(d, MODELVIEWMATRIX_INVERSETRANSPOSE, BL_Shader::MODELVIEWMATRIX_INVERSETRANSPOSE);
+       KX_MACRO_addTypesToDict(d, MODELMATRIX, BL_Shader::MODELMATRIX);
+       KX_MACRO_addTypesToDict(d, MODELMATRIX_TRANSPOSE, BL_Shader::MODELMATRIX_TRANSPOSE);
+       KX_MACRO_addTypesToDict(d, MODELMATRIX_INVERSE, BL_Shader::MODELMATRIX_INVERSE);
+       KX_MACRO_addTypesToDict(d, MODELMATRIX_INVERSETRANSPOSE, BL_Shader::MODELMATRIX_INVERSETRANSPOSE);
+       KX_MACRO_addTypesToDict(d, VIEWMATRIX, BL_Shader::VIEWMATRIX);
+       KX_MACRO_addTypesToDict(d, VIEWMATRIX_TRANSPOSE, BL_Shader::VIEWMATRIX_TRANSPOSE);
+       KX_MACRO_addTypesToDict(d, VIEWMATRIX_INVERSE, BL_Shader::VIEWMATRIX_INVERSE);
+       KX_MACRO_addTypesToDict(d, VIEWMATRIX_INVERSETRANSPOSE, BL_Shader::VIEWMATRIX_INVERSETRANSPOSE);
+       KX_MACRO_addTypesToDict(d, CAM_POS, BL_Shader::CAM_POS);
+       KX_MACRO_addTypesToDict(d, CONSTANT_TIMER, BL_Shader::CONSTANT_TIMER);
+
        // Check for errors
        if (PyErr_Occurred())
     {
                Py_FatalError("can't initialize module GameLogic");
     }
 
-       return d;
+       return m;
 }
 
-
-
 // Python Sandbox code
 // override builtin functions import() and open()
 
@@ -552,7 +866,7 @@ PyObject *KXpy_import(PyObject *self, PyObject *args)
 
        /* quick hack for GamePython modules 
                TODO: register builtin modules properly by ExtendInittab */
-       if (!strcmp(name, "GameLogic") || !strcmp(name, "GameKeys") ||
+       if (!strcmp(name, "GameLogic") || !strcmp(name, "GameKeys") || !strcmp(name, "PhysicsConstraints") ||
                !strcmp(name, "Rasterizer")) {
                return PyImport_ImportModuleEx(name, globals, locals, fromlist);
        }
@@ -850,3 +1164,8 @@ void PHY_SetActiveScene(class KX_Scene* scene)
 {
        gp_KetsjiScene = scene;
 }
+
+class KX_Scene* PHY_GetActiveScene()
+{
+       return gp_KetsjiScene;
+}