LEFT | RIGHT |
1 /* | 1 /* |
2 * $Id$ | 2 * $Id$ |
3 * | 3 * |
4 * ***** BEGIN GPL LICENSE BLOCK ***** | 4 * ***** BEGIN GPL LICENSE BLOCK ***** |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or | 6 * This program is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU General Public License | 7 * modify it under the terms of the GNU General Public License |
8 * as published by the Free Software Foundation; either version 2 | 8 * as published by the Free Software Foundation; either version 2 |
9 * of the License, or (at your option) any later version. | 9 * of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 #include "RAS_2DFilterManager.h" | 106 #include "RAS_2DFilterManager.h" |
107 #include "MT_Vector3.h" | 107 #include "MT_Vector3.h" |
108 #include "MT_Point3.h" | 108 #include "MT_Point3.h" |
109 #include "ListValue.h" | 109 #include "ListValue.h" |
110 #include "InputParser.h" | 110 #include "InputParser.h" |
111 #include "KX_Scene.h" | 111 #include "KX_Scene.h" |
112 | 112 |
113 #include "NG_NetworkScene.h" //Needed for sendMessage() | 113 #include "NG_NetworkScene.h" //Needed for sendMessage() |
114 | 114 |
115 #include "BL_Shader.h" | 115 #include "BL_Shader.h" |
| 116 #include "BL_Action.h" |
116 | 117 |
117 #include "KX_PyMath.h" | 118 #include "KX_PyMath.h" |
118 | 119 |
119 #include "PyObjectPlus.h" | 120 #include "PyObjectPlus.h" |
120 | 121 |
121 #include "KX_PythonInitTypes.h"· | 122 #include "KX_PythonInitTypes.h"· |
122 | 123 |
123 /* we only need this to get a list of libraries from the main struct */ | 124 /* we only need this to get a list of libraries from the main struct */ |
124 #include "DNA_ID.h" | 125 #include "DNA_ID.h" |
125 #include "DNA_scene_types.h" | 126 #include "DNA_scene_types.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 gp_KetsjiScene->GetNetworkScene()->SendMessage(to, from, subject, body); | 382 gp_KetsjiScene->GetNetworkScene()->SendMessage(to, from, subject, body); |
382 | 383 |
383 Py_RETURN_NONE; | 384 Py_RETURN_NONE; |
384 } | 385 } |
385 | 386 |
386 // this gets a pointer to an array filled with floats | 387 // this gets a pointer to an array filled with floats |
387 static PyObject* gPyGetSpectrum(PyObject*) | 388 static PyObject* gPyGetSpectrum(PyObject*) |
388 { | 389 { |
389 PyObject* resultlist = PyList_New(512); | 390 PyObject* resultlist = PyList_New(512); |
390 | 391 |
391 for (int index = 0; index < 512; index++) | 392 » for (int index = 0; index < 512; index++) |
392 { | 393 » { |
393 PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(0.0)); | 394 » » PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(0.0)); |
394 } | 395 » } |
395 | 396 |
396 return resultlist; | 397 return resultlist; |
397 } | 398 } |
398 | 399 |
399 static PyObject* gPySetLogicTicRate(PyObject*, PyObject* args) | 400 static PyObject* gPySetLogicTicRate(PyObject*, PyObject* args) |
400 { | 401 { |
401 float ticrate; | 402 float ticrate; |
402 if (!PyArg_ParseTuple(args, "f:setLogicTicRate", &ticrate)) | 403 if (!PyArg_ParseTuple(args, "f:setLogicTicRate", &ticrate)) |
403 return NULL; | 404 return NULL; |
404 ········ | 405 ········ |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 static PyObject* gPyGetAverageFrameRate(PyObject*) | 486 static PyObject* gPyGetAverageFrameRate(PyObject*) |
486 { | 487 { |
487 return PyFloat_FromDouble(KX_KetsjiEngine::GetAverageFrameRate()); | 488 return PyFloat_FromDouble(KX_KetsjiEngine::GetAverageFrameRate()); |
488 } | 489 } |
489 | 490 |
490 static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) | 491 static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) |
491 { | 492 { |
492 char cpath[sizeof(gp_GamePythonPath)]; | 493 char cpath[sizeof(gp_GamePythonPath)]; |
493 char *searchpath = NULL; | 494 char *searchpath = NULL; |
494 PyObject* list, *value; | 495 PyObject* list, *value; |
495 »······· | 496 |
496 DIR *dp; | 497 » DIR *dp; |
497 struct dirent *dirp; | 498 » struct dirent *dirp; |
498 » | 499 |
499 if (!PyArg_ParseTuple(args, "|s:getBlendFileList", &searchpath)) | 500 if (!PyArg_ParseTuple(args, "|s:getBlendFileList", &searchpath)) |
500 return NULL; | 501 return NULL; |
501 » | 502 |
502 list = PyList_New(0); | 503 list = PyList_New(0); |
503 ········ | 504 ········ |
504 if (searchpath) { | 505 if (searchpath) { |
505 BLI_strncpy(cpath, searchpath, FILE_MAXDIR + FILE_MAXFILE); | 506 BLI_strncpy(cpath, searchpath, FILE_MAXDIR + FILE_MAXFILE); |
506 BLI_path_abs(cpath, gp_GamePythonPath); | 507 BLI_path_abs(cpath, gp_GamePythonPath); |
507 } else { | 508 } else { |
508 /* Get the dir only */ | 509 /* Get the dir only */ |
509 BLI_split_dirfile(gp_GamePythonPath, cpath, NULL); | 510 BLI_split_dirfile(gp_GamePythonPath, cpath, NULL); |
510 } | 511 } |
511 »······· | 512 |
512 if((dp = opendir(cpath)) == NULL) { | 513 » if((dp = opendir(cpath)) == NULL) { |
513 /* todo, show the errno, this shouldnt happen anyway if the blen
dfile is readable */ | 514 /* todo, show the errno, this shouldnt happen anyway if the blen
dfile is readable */ |
514 fprintf(stderr, "Could not read directoty (%s) failed, code %d (
%s)\n", cpath, errno, strerror(errno)); | 515 fprintf(stderr, "Could not read directoty (%s) failed, code %d (
%s)\n", cpath, errno, strerror(errno)); |
515 return list; | 516 return list; |
516 } | 517 » } |
517 »······· | 518 »······· |
518 while ((dirp = readdir(dp)) != NULL) { | 519 » while ((dirp = readdir(dp)) != NULL) { |
519 if (BLI_testextensie(dirp->d_name, ".blend")) { | 520 if (BLI_testextensie(dirp->d_name, ".blend")) { |
520 value= PyUnicode_DecodeFSDefault(dirp->d_name); | 521 value= PyUnicode_DecodeFSDefault(dirp->d_name); |
521 PyList_Append(list, value); | 522 PyList_Append(list, value); |
522 Py_DECREF(value); | 523 Py_DECREF(value); |
523 } | 524 } |
524 } | 525 » } |
525 »······· | 526 »······· |
526 closedir(dp); | 527 » closedir(dp); |
527 return list; | 528 » return list; |
528 } | 529 } |
529 | 530 |
530 static char gPyAddScene_doc[] =· | 531 static char gPyAddScene_doc[] =· |
531 "addScene(name, [overlay])\n\ | 532 "addScene(name, [overlay])\n\ |
532 adds a scene to the game engine\n\ | 533 adds a scene to the game engine\n\ |
533 name = Name of the scene\n\ | 534 name = Name of the scene\n\ |
534 overlay = Overlay or underlay"; | 535 overlay = Overlay or underlay"; |
535 static PyObject* gPyAddScene(PyObject*, PyObject* args) | 536 static PyObject* gPyAddScene(PyObject*, PyObject* args) |
536 { | 537 { |
537 char* name; | 538 char* name; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 } | 732 } |
732 ········ | 733 ········ |
733 Main *maggie= (Main *)MEM_callocN( sizeof(Main), "BgeMain"); | 734 Main *maggie= (Main *)MEM_callocN( sizeof(Main), "BgeMain"); |
734 kx_scene->GetSceneConverter()->GetMainDynamic().push_back(maggie); | 735 kx_scene->GetSceneConverter()->GetMainDynamic().push_back(maggie); |
735 strncpy(maggie->name, path, sizeof(maggie->name)-1); | 736 strncpy(maggie->name, path, sizeof(maggie->name)-1); |
736 ········ | 737 ········ |
737 /* Copy the object into main */ | 738 /* Copy the object into main */ |
738 if(idcode==ID_ME) { | 739 if(idcode==ID_ME) { |
739 PyObject *ret= PyList_New(0); | 740 PyObject *ret= PyList_New(0); |
740 PyObject *item; | 741 PyObject *item; |
741 » » for(int i= 0; i < PyList_GET_SIZE(names); i++) { | 742 » » for(Py_ssize_t i= 0; i < PyList_GET_SIZE(names); i++) { |
742 name= _PyUnicode_AsString(PyList_GET_ITEM(names, i)); | 743 name= _PyUnicode_AsString(PyList_GET_ITEM(names, i)); |
743 if(name) { | 744 if(name) { |
744 RAS_MeshObject *meshobj= kx_scene->GetSceneConve
rter()->ConvertMeshSpecial(kx_scene, maggie, name); | 745 RAS_MeshObject *meshobj= kx_scene->GetSceneConve
rter()->ConvertMeshSpecial(kx_scene, maggie, name); |
745 if(meshobj) { | 746 if(meshobj) { |
746 KX_MeshProxy* meshproxy = new KX_MeshPro
xy(meshobj); | 747 KX_MeshProxy* meshproxy = new KX_MeshPro
xy(meshobj); |
747 item= meshproxy->NewProxy(true); | 748 item= meshproxy->NewProxy(true); |
748 PyList_Append(ret, item); | 749 PyList_Append(ret, item); |
749 Py_DECREF(item); | 750 Py_DECREF(item); |
750 } | 751 } |
751 } | 752 } |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 if(gm->matmode == GAME_MAT_GLSL) | 1217 if(gm->matmode == GAME_MAT_GLSL) |
1217 flag = KX_BLENDER_GLSL_MATERIAL; | 1218 flag = KX_BLENDER_GLSL_MATERIAL; |
1218 else if(gm->matmode == GAME_MAT_MULTITEX) | 1219 else if(gm->matmode == GAME_MAT_MULTITEX) |
1219 flag = KX_BLENDER_MULTITEX_MATERIAL; | 1220 flag = KX_BLENDER_MULTITEX_MATERIAL; |
1220 else | 1221 else |
1221 flag = KX_TEXFACE_MATERIAL; | 1222 flag = KX_TEXFACE_MATERIAL; |
1222 ········ | 1223 ········ |
1223 return PyLong_FromSsize_t(flag); | 1224 return PyLong_FromSsize_t(flag); |
1224 } | 1225 } |
1225 | 1226 |
| 1227 static PyObject* gPySetAnisotropicFiltering(PyObject*, PyObject* args) |
| 1228 { |
| 1229 short level; |
| 1230 |
| 1231 if (!PyArg_ParseTuple(args, "h:setAnisotropicFiltering", &level)) |
| 1232 return NULL; |
| 1233 |
| 1234 if (level != 1 && level != 2 && level != 4 && level != 8 && level != 16)
{ |
| 1235 PyErr_SetString(PyExc_ValueError, "Rasterizer.setAnisotropicFilt
ering(level): Expected value of 1, 2, 4, 8, or 16 for value"); |
| 1236 return NULL; |
| 1237 } |
| 1238 |
| 1239 gp_Rasterizer->SetAnisotropicFiltering(level); |
| 1240 |
| 1241 Py_RETURN_NONE; |
| 1242 } |
| 1243 |
| 1244 static PyObject* gPyGetAnisotropicFiltering(PyObject*, PyObject* args) |
| 1245 { |
| 1246 return PyLong_FromLong(gp_Rasterizer->GetAnisotropicFiltering()); |
| 1247 } |
| 1248 |
1226 static PyObject* gPyDrawLine(PyObject*, PyObject* args) | 1249 static PyObject* gPyDrawLine(PyObject*, PyObject* args) |
1227 { | 1250 { |
1228 PyObject* ob_from; | 1251 PyObject* ob_from; |
1229 PyObject* ob_to; | 1252 PyObject* ob_to; |
1230 PyObject* ob_color; | 1253 PyObject* ob_color; |
1231 | 1254 |
1232 if (!gp_Rasterizer) { | 1255 if (!gp_Rasterizer) { |
1233 PyErr_SetString(PyExc_RuntimeError, "Rasterizer.drawLine(obFrom,
obTo, color): Rasterizer not available"); | 1256 PyErr_SetString(PyExc_RuntimeError, "Rasterizer.drawLine(obFrom,
obTo, color): Rasterizer not available"); |
1234 return NULL; | 1257 return NULL; |
1235 } | 1258 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 {"setFocalLength", (PyCFunction) gPySetFocalLength, METH_VARARGS, "set the foc
al length for stereo mode"}, | 1303 {"setFocalLength", (PyCFunction) gPySetFocalLength, METH_VARARGS, "set the foc
al length for stereo mode"}, |
1281 {"getFocalLength", (PyCFunction) gPyGetFocalLength, METH_VARARGS, "get the foc
al length for stereo mode"}, | 1304 {"getFocalLength", (PyCFunction) gPyGetFocalLength, METH_VARARGS, "get the foc
al length for stereo mode"}, |
1282 {"setMaterialMode",(PyCFunction) gPySetMaterialType, | 1305 {"setMaterialMode",(PyCFunction) gPySetMaterialType, |
1283 METH_VARARGS, "set the material mode to use for OpenGL rendering"}, | 1306 METH_VARARGS, "set the material mode to use for OpenGL rendering"}, |
1284 {"getMaterialMode",(PyCFunction) gPyGetMaterialType, | 1307 {"getMaterialMode",(PyCFunction) gPyGetMaterialType, |
1285 METH_NOARGS, "get the material mode being used for OpenGL rendering"}, | 1308 METH_NOARGS, "get the material mode being used for OpenGL rendering"}, |
1286 {"setGLSLMaterialSetting",(PyCFunction) gPySetGLSLMaterialSetting, | 1309 {"setGLSLMaterialSetting",(PyCFunction) gPySetGLSLMaterialSetting, |
1287 METH_VARARGS, "set the state of a GLSL material setting"}, | 1310 METH_VARARGS, "set the state of a GLSL material setting"}, |
1288 {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting, | 1311 {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting, |
1289 METH_VARARGS, "get the state of a GLSL material setting"}, | 1312 METH_VARARGS, "get the state of a GLSL material setting"}, |
| 1313 {"setAnisotropicFiltering", (PyCFunction) gPySetAnisotropicFiltering, |
| 1314 METH_VARARGS, "set the anisotropic filtering level (must be one of 1, 2, 4, 8,
16)"}, |
| 1315 {"getAnisotropicFiltering", (PyCFunction) gPyGetAnisotropicFiltering, |
| 1316 METH_VARARGS, "get the anisotropic filtering level"}, |
1290 {"drawLine", (PyCFunction) gPyDrawLine, | 1317 {"drawLine", (PyCFunction) gPyDrawLine, |
1291 METH_VARARGS, "draw a line on the screen"}, | 1318 METH_VARARGS, "draw a line on the screen"}, |
1292 { NULL, (PyCFunction) NULL, 0, NULL } | 1319 { NULL, (PyCFunction) NULL, 0, NULL } |
1293 }; | 1320 }; |
1294 | 1321 |
1295 // Initialization function for the module (*must* be called initGameLogic) | 1322 // Initialization function for the module (*must* be called initGameLogic) |
1296 | 1323 |
1297 static char GameLogic_module_documentation[] = | 1324 static char GameLogic_module_documentation[] = |
1298 "This is the Python API for the game engine of bge.logic" | 1325 "This is the Python API for the game engine of bge.logic" |
1299 ; | 1326 ; |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 | 1664 |
1638 /* BL_Armature Channel rotation_mode */ | 1665 /* BL_Armature Channel rotation_mode */ |
1639 KX_MACRO_addTypesToDict(d, ROT_MODE_QUAT, ROT_MODE_QUAT); | 1666 KX_MACRO_addTypesToDict(d, ROT_MODE_QUAT, ROT_MODE_QUAT); |
1640 KX_MACRO_addTypesToDict(d, ROT_MODE_XYZ, ROT_MODE_XYZ); | 1667 KX_MACRO_addTypesToDict(d, ROT_MODE_XYZ, ROT_MODE_XYZ); |
1641 KX_MACRO_addTypesToDict(d, ROT_MODE_XZY, ROT_MODE_XZY); | 1668 KX_MACRO_addTypesToDict(d, ROT_MODE_XZY, ROT_MODE_XZY); |
1642 KX_MACRO_addTypesToDict(d, ROT_MODE_YXZ, ROT_MODE_YXZ); | 1669 KX_MACRO_addTypesToDict(d, ROT_MODE_YXZ, ROT_MODE_YXZ); |
1643 KX_MACRO_addTypesToDict(d, ROT_MODE_YZX, ROT_MODE_YZX); | 1670 KX_MACRO_addTypesToDict(d, ROT_MODE_YZX, ROT_MODE_YZX); |
1644 KX_MACRO_addTypesToDict(d, ROT_MODE_ZXY, ROT_MODE_ZXY); | 1671 KX_MACRO_addTypesToDict(d, ROT_MODE_ZXY, ROT_MODE_ZXY); |
1645 KX_MACRO_addTypesToDict(d, ROT_MODE_ZYX, ROT_MODE_ZYX); | 1672 KX_MACRO_addTypesToDict(d, ROT_MODE_ZYX, ROT_MODE_ZYX); |
1646 | 1673 |
| 1674 /* BL_Action play modes */ |
| 1675 KX_MACRO_addTypesToDict(d, KX_ACTION_MODE_PLAY, BL_Action::ACT_MODE_PLAY
); |
| 1676 KX_MACRO_addTypesToDict(d, KX_ACTION_MODE_LOOP, BL_Action::ACT_MODE_LOOP
); |
| 1677 KX_MACRO_addTypesToDict(d, KX_ACTION_MODE_PING_PONG, BL_Action::ACT_MODE
_PING_PONG); |
| 1678 |
1647 // Check for errors | 1679 // Check for errors |
1648 if (PyErr_Occurred()) | 1680 if (PyErr_Occurred()) |
1649 { | 1681 » { |
1650 Py_FatalError("can't initialize module bge.logic"); | 1682 Py_FatalError("can't initialize module bge.logic"); |
1651 } | 1683 » } |
1652 | 1684 |
1653 return m; | 1685 return m; |
1654 } | 1686 } |
1655 | 1687 |
1656 /* Explanation of· | 1688 /* Explanation of· |
1657 *· | 1689 *· |
1658 * - backupPySysObjects() : stores sys.path in gp_OrigPythonSysPat
h | 1690 * - backupPySysObjects() : stores sys.path in gp_OrigPythonSysPat
h |
1659 * - initPySysObjects(main) : initializes the blendfile and library paths | 1691 * - initPySysObjects(main) : initializes the blendfile and library paths |
1660 * - restorePySysObjects() : restores sys.path from gp_OrigPythonSy
sPath | 1692 * - restorePySysObjects() : restores sys.path from gp_OrigPythonSy
sPath |
1661 *· | 1693 *· |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1728 ········ | 1760 ········ |
1729 while(lib) { | 1761 while(lib) { |
1730 /* lib->name wont work in some cases (on win32), | 1762 /* lib->name wont work in some cases (on win32), |
1731 * even when expanding with gp_GamePythonPath, using lib->filena
me is less trouble */ | 1763 * even when expanding with gp_GamePythonPath, using lib->filena
me is less trouble */ |
1732 initPySysObjects__append(sys_path, lib->filepath); | 1764 initPySysObjects__append(sys_path, lib->filepath); |
1733 lib= (Library *)lib->id.next; | 1765 lib= (Library *)lib->id.next; |
1734 } | 1766 } |
1735 ········ | 1767 ········ |
1736 initPySysObjects__append(sys_path, gp_GamePythonPath); | 1768 initPySysObjects__append(sys_path, gp_GamePythonPath); |
1737 ········ | 1769 ········ |
1738 //» fprintf(stderr, "\nNew Path: %d ", PyList_Size(sys_path)); | 1770 //» fprintf(stderr, "\nNew Path: %d ", PyList_GET_SIZE(sys_path)); |
1739 // PyObject_Print(sys_path, stderr, 0); | 1771 // PyObject_Print(sys_path, stderr, 0); |
1740 } | 1772 } |
1741 | 1773 |
1742 static void restorePySysObjects(void) | 1774 static void restorePySysObjects(void) |
1743 { | 1775 { |
1744 if (gp_OrigPythonSysPath==NULL) | 1776 if (gp_OrigPythonSysPath==NULL) |
1745 return; | 1777 return; |
1746 ········ | 1778 ········ |
1747 PyObject *sys_path= PySys_GetObject("path"); /* should never fail */ | 1779 PyObject *sys_path= PySys_GetObject("path"); /* should never fail */ |
1748 PyObject *sys_mods= PySys_GetObject("modules"); /* should never fail */ | 1780 PyObject *sys_mods= PySys_GetObject("modules"); /* should never fail */ |
1749 | 1781 |
1750 /* paths */ | 1782 /* paths */ |
1751 PyList_SetSlice(sys_path, 0, INT_MAX, gp_OrigPythonSysPath); | 1783 PyList_SetSlice(sys_path, 0, INT_MAX, gp_OrigPythonSysPath); |
1752 Py_DECREF(gp_OrigPythonSysPath); | 1784 Py_DECREF(gp_OrigPythonSysPath); |
1753 gp_OrigPythonSysPath= NULL; | 1785 gp_OrigPythonSysPath= NULL; |
1754 ········ | 1786 ········ |
1755 /* modules */ | 1787 /* modules */ |
1756 PyDict_Clear(sys_mods); | 1788 PyDict_Clear(sys_mods); |
1757 PyDict_Update(sys_mods, gp_OrigPythonSysModules); | 1789 PyDict_Update(sys_mods, gp_OrigPythonSysModules); |
1758 Py_DECREF(gp_OrigPythonSysModules); | 1790 Py_DECREF(gp_OrigPythonSysModules); |
1759 gp_OrigPythonSysModules= NULL;·· | 1791 gp_OrigPythonSysModules= NULL;·· |
1760 ········ | 1792 ········ |
1761 ········ | 1793 ········ |
1762 //» fprintf(stderr, "\nRestore Path: %d ", PyList_Size(sys_path)); | 1794 //» fprintf(stderr, "\nRestore Path: %d ", PyList_GET_SIZE(sys_path)); |
1763 // PyObject_Print(sys_path, stderr, 0); | 1795 // PyObject_Print(sys_path, stderr, 0); |
1764 } | 1796 } |
1765 | 1797 |
1766 // Copied from bpy_interface.c | 1798 // Copied from bpy_interface.c |
1767 static struct _inittab bge_internal_modules[]= { | 1799 static struct _inittab bge_internal_modules[]= { |
1768 {(char *)"mathutils", PyInit_mathutils}, | 1800 {(char *)"mathutils", PyInit_mathutils}, |
1769 {(char *)"bgl", BPyInit_bgl}, | 1801 {(char *)"bgl", BPyInit_bgl}, |
1770 {(char *)"blf", BPyInit_blf}, | 1802 {(char *)"blf", BPyInit_blf}, |
1771 {(char *)"aud", AUD_initPython}, | 1803 {(char *)"aud", AUD_initPython}, |
1772 {NULL, NULL} | 1804 {NULL, NULL} |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 0, /* m_clear */ | 1963 0, /* m_clear */ |
1932 0, /* m_free */ | 1964 0, /* m_free */ |
1933 }; | 1965 }; |
1934 | 1966 |
1935 PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) | 1967 PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) |
1936 { | 1968 { |
1937 gp_Canvas = canvas; | 1969 gp_Canvas = canvas; |
1938 gp_Rasterizer = rasty; | 1970 gp_Rasterizer = rasty; |
1939 | 1971 |
1940 | 1972 |
1941 PyObject* m; | 1973 » PyObject* m; |
1942 PyObject* d; | 1974 » PyObject* d; |
1943 PyObject* item; | 1975 » PyObject* item; |
1944 | 1976 |
1945 /* Use existing module where possible | 1977 /* Use existing module where possible |
1946 » * be careful not to init any runtime vars after this */ | 1978 * be careful not to init any runtime vars after this */ |
1947 m = PyImport_ImportModule( "Rasterizer" ); | 1979 m = PyImport_ImportModule( "Rasterizer" ); |
1948 if(m) { | 1980 if(m) { |
1949 Py_DECREF(m); | 1981 Py_DECREF(m); |
1950 return m; | 1982 return m; |
1951 } | 1983 } |
1952 else { | 1984 else { |
1953 PyErr_Clear(); | 1985 PyErr_Clear(); |
1954 » | 1986 |
1955 // Create the module and add the functions | 1987 // Create the module and add the functions |
1956 m = PyModule_Create(&Rasterizer_module_def); | 1988 m = PyModule_Create(&Rasterizer_module_def); |
1957 PyDict_SetItemString(PySys_GetObject("modules"), Rasterizer_modu
le_def.m_name, m); | 1989 PyDict_SetItemString(PySys_GetObject("modules"), Rasterizer_modu
le_def.m_name, m); |
1958 } | 1990 } |
1959 | 1991 |
1960 // Add some symbolic constants to the module | 1992 » // Add some symbolic constants to the module |
1961 d = PyModule_GetDict(m); | 1993 » d = PyModule_GetDict(m); |
1962 ErrorObject = PyUnicode_FromString("Rasterizer.error"); | 1994 » ErrorObject = PyUnicode_FromString("Rasterizer.error"); |
1963 PyDict_SetItemString(d, "error", ErrorObject); | 1995 » PyDict_SetItemString(d, "error", ErrorObject); |
1964 Py_DECREF(ErrorObject); | 1996 » Py_DECREF(ErrorObject); |
1965 | 1997 |
1966 /* needed for get/setMaterialType */ | 1998 » /* needed for get/setMaterialType */ |
1967 KX_MACRO_addTypesToDict(d, KX_TEXFACE_MATERIAL, KX_TEXFACE_MATERIAL); | 1999 » KX_MACRO_addTypesToDict(d, KX_TEXFACE_MATERIAL, KX_TEXFACE_MATERIAL); |
1968 KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_M
ATERIAL); | 2000 » KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULT
ITEX_MATERIAL); |
1969 KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL)
; | 2001 » KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MAT
ERIAL); |
1970 | 2002 |
1971 // XXXX Add constants here | 2003 » // XXXX Add constants here |
1972 | 2004 |
1973 // Check for errors | 2005 » // Check for errors |
1974 if (PyErr_Occurred()) | 2006 » if (PyErr_Occurred()) |
1975 { | 2007 » { |
1976 Py_FatalError("can't initialize module Rasterizer"); | 2008 » » Py_FatalError("can't initialize module Rasterizer"); |
1977 } | 2009 » } |
1978 | 2010 |
1979 return d; | 2011 » return d; |
1980 } | 2012 } |
1981 | 2013 |
1982 | 2014 |
1983 | 2015 |
1984 /* ------------------------------------------------------------------------- */ | 2016 /* ------------------------------------------------------------------------- */ |
1985 /* GameKeys: symbolic constants for key mapping */ | 2017 /* GameKeys: symbolic constants for key mapping */ |
1986 /* ------------------------------------------------------------------------- */ | 2018 /* ------------------------------------------------------------------------- */ |
1987 | 2019 |
1988 static char GameKeys_module_documentation[] = | 2020 static char GameKeys_module_documentation[] = |
1989 "This modules provides defines for key-codes" | 2021 "This modules provides defines for key-codes" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2208 KX_MACRO_addTypesToDict(d, LEFTMOUSE, SCA_IInputDevice::KX_LEFTMOUSE); | 2240 KX_MACRO_addTypesToDict(d, LEFTMOUSE, SCA_IInputDevice::KX_LEFTMOUSE); |
2209 KX_MACRO_addTypesToDict(d, MIDDLEMOUSE, SCA_IInputDevice::KX_MIDDLEMOUSE
); | 2241 KX_MACRO_addTypesToDict(d, MIDDLEMOUSE, SCA_IInputDevice::KX_MIDDLEMOUSE
); |
2210 KX_MACRO_addTypesToDict(d, RIGHTMOUSE, SCA_IInputDevice::KX_RIGHTMOUSE); | 2242 KX_MACRO_addTypesToDict(d, RIGHTMOUSE, SCA_IInputDevice::KX_RIGHTMOUSE); |
2211 KX_MACRO_addTypesToDict(d, WHEELUPMOUSE, SCA_IInputDevice::KX_WHEELUPMOU
SE); | 2243 KX_MACRO_addTypesToDict(d, WHEELUPMOUSE, SCA_IInputDevice::KX_WHEELUPMOU
SE); |
2212 KX_MACRO_addTypesToDict(d, WHEELDOWNMOUSE, SCA_IInputDevice::KX_WHEELDOW
NMOUSE); | 2244 KX_MACRO_addTypesToDict(d, WHEELDOWNMOUSE, SCA_IInputDevice::KX_WHEELDOW
NMOUSE); |
2213 KX_MACRO_addTypesToDict(d, MOUSEX, SCA_IInputDevice::KX_MOUSEX); | 2245 KX_MACRO_addTypesToDict(d, MOUSEX, SCA_IInputDevice::KX_MOUSEX); |
2214 KX_MACRO_addTypesToDict(d, MOUSEY, SCA_IInputDevice::KX_MOUSEY); | 2246 KX_MACRO_addTypesToDict(d, MOUSEY, SCA_IInputDevice::KX_MOUSEY); |
2215 | 2247 |
2216 // Check for errors | 2248 // Check for errors |
2217 if (PyErr_Occurred()) | 2249 if (PyErr_Occurred()) |
2218 { | 2250 » { |
2219 Py_FatalError("can't initialize module GameKeys"); | 2251 Py_FatalError("can't initialize module GameKeys"); |
2220 } | 2252 » } |
2221 | 2253 |
2222 return d; | 2254 return d; |
2223 } | 2255 } |
2224 | 2256 |
2225 // utility function for loading and saving the globalDict | 2257 // utility function for loading and saving the globalDict |
2226 int saveGamePythonConfig( char **marshal_buffer) | 2258 int saveGamePythonConfig( char **marshal_buffer) |
2227 { | 2259 { |
2228 int marshal_length = 0; | 2260 int marshal_length = 0; |
2229 PyObject* gameLogic = PyImport_ImportModule("GameLogic"); | 2261 PyObject* gameLogic = PyImport_ImportModule("GameLogic"); |
2230 if (gameLogic) { | 2262 if (gameLogic) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2317 | 2349 |
2318 // we need this so while blender is open (not blenderplayer) | 2350 // we need this so while blender is open (not blenderplayer) |
2319 // loading new blendfiles will reset this on starting the | 2351 // loading new blendfiles will reset this on starting the |
2320 // engine but loading blend files within the BGE wont overwrite gp_GamePythonPat
hOrig | 2352 // engine but loading blend files within the BGE wont overwrite gp_GamePythonPat
hOrig |
2321 void resetGamePythonPath() | 2353 void resetGamePythonPath() |
2322 { | 2354 { |
2323 gp_GamePythonPathOrig[0] = '\0'; | 2355 gp_GamePythonPathOrig[0] = '\0'; |
2324 } | 2356 } |
2325 | 2357 |
2326 #endif // WITH_PYTHON | 2358 #endif // WITH_PYTHON |
LEFT | RIGHT |