Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/Ketsji/KX_PythonInit.cpp
| Context not available. | |||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| static PyObject *gPyGetBackgroundColor(PyObject *) | |||||
| { | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.getBackgroundColor(), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| PyObject *retVal= PyList_New(3); | |||||
| PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(wi->getBackColorRed())); | |||||
| PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(wi->getBackColorGreen())); | |||||
| PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(wi->getBackColorBlue())); | |||||
| return retVal; | |||||
| } | |||||
| static PyObject *gPySetMistColor(PyObject *, PyObject *value) | |||||
| { | |||||
| MT_Vector3 vec; | |||||
| if (!PyVecTo(value, vec)) | |||||
| return NULL; | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.setMistColor(color), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| wi->setMistColor((float)vec[0], (float)vec[1], (float)vec[2]); | |||||
| Py_RETURN_NONE; | |||||
| } | |||||
| static PyObject *gPyGetMistColor(PyObject *) | |||||
| { | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.getMistColor(), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| PyObject *retVal= PyList_New(3); | |||||
| PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(wi->getMistColorRed())); | |||||
| PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(wi->getMistColorRed())); | |||||
| PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(wi->getMistColorRed())); | |||||
| return retVal; | |||||
| } | |||||
| static PyObject *gPyEnableMist(PyObject *, PyObject *args) | |||||
| { | |||||
| int enable; | |||||
| if (!PyArg_ParseTuple(args,"i:enableMist",&enable)) | |||||
| return NULL; | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.enableMist(enable), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| wi->setMistEnable(enable); | |||||
| Py_RETURN_NONE; | |||||
| } | |||||
| static PyObject *gPyMistEnabled(PyObject *) | |||||
| { | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.mistEnabled(), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| return PyBool_FromLong(wi->hasMist()); | |||||
| } | |||||
| static PyObject *gPySetMistType(PyObject *, PyObject *args) | |||||
| { | |||||
| short type; | |||||
| if (!PyArg_ParseTuple(args,"i:setMistType",&type)) | |||||
| return NULL; | |||||
| if (type < 0 || type > 2) { | |||||
| PyErr_SetString(PyExc_ValueError, "Rasterizer.setMistType(int): Mist type is not known"); | |||||
| return NULL; | |||||
| } | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.setMistType(int), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| wi->setMistType(type); | |||||
| Py_RETURN_NONE; | |||||
| } | |||||
| static PyObject *gPyGetMistType(PyObject *) | |||||
| { | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.setMistType(), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| return PyLong_FromLong(wi->getMistType()); | |||||
| } | |||||
| static PyObject *gPySetMistStart(PyObject *, PyObject *args) | |||||
| { | |||||
| float miststart; | |||||
| if (!PyArg_ParseTuple(args,"f:setMistStart",&miststart)) | |||||
| return NULL; | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.setMistStart(float), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| wi->setMistStart(miststart); | |||||
| Py_RETURN_NONE; | |||||
| } | |||||
| static PyObject *gPyGetMistStart(PyObject *) | |||||
| { | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.getMistStart(), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| return PyFloat_FromDouble(wi->getMistStart()); | |||||
| } | |||||
| static PyObject *gPySetMistDistance(PyObject *, PyObject *args) | |||||
| { | |||||
| float mistdist; | |||||
| if (!PyArg_ParseTuple(args,"f:setMistDistance",&mistdist)) | |||||
| return NULL; | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.setMistDistance(float), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| wi->setMistDistance(mistdist); | |||||
| Py_RETURN_NONE; | |||||
| } | |||||
| static PyObject *gPyGetMistDist(PyObject *) | |||||
| { | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.getMistDistance(), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| return PyFloat_FromDouble(wi->getMistDistance()); | |||||
| } | |||||
| static PyObject *gPySetMistIntensity(PyObject *, PyObject *args) | |||||
| { | |||||
| float intensity; | |||||
| if (!PyArg_ParseTuple(args,"f:setMistIntensity",&intensity)) | |||||
| return NULL; | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.setMistIntensity(float), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| wi->setMistIntensity(intensity); | |||||
| Py_RETURN_NONE; | |||||
| } | |||||
| static PyObject *gPyGetMistIntensity(PyObject *) | |||||
| { | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.getMistIntensity(), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| return PyFloat_FromDouble(wi->getMistIntensity()); | |||||
| } | |||||
| static PyObject *gPySetAmbientColor(PyObject *, PyObject *value) | static PyObject *gPySetAmbientColor(PyObject *, PyObject *value) | ||||
| { | { | ||||
| MT_Vector3 vec; | MT_Vector3 vec; | ||||
| Context not available. | |||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| static PyObject *gPyGetAmbientColor(PyObject *) | |||||
| { | |||||
| if (!gp_Rasterizer) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getAmbientColor(), Rasterizer not available"); | |||||
| return NULL; | |||||
| } | |||||
| KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); | |||||
| if (!wi->hasWorld()) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "bge.render.getAmbientColor(color), World not available"); | |||||
| return NULL; | |||||
| } | |||||
| PyObject *retVal= PyList_New(3); | |||||
| PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(wi->getAmbientColorRed())); | |||||
| PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(wi->getAmbientColorGreen())); | |||||
| PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(wi->getAmbientColorBlue())); | |||||
| return retVal; | |||||
| } | |||||
| static PyObject *gPyMakeScreenshot(PyObject *, PyObject *args) | static PyObject *gPyMakeScreenshot(PyObject *, PyObject *args) | ||||
| { | { | ||||
| char* filename; | char* filename; | ||||
| Context not available. | |||||
| {"setMousePosition",(PyCFunction) gPySetMousePosition, | {"setMousePosition",(PyCFunction) gPySetMousePosition, | ||||
| METH_VARARGS, "setMousePosition(int x,int y)"}, | METH_VARARGS, "setMousePosition(int x,int y)"}, | ||||
| {"setBackgroundColor",(PyCFunction)gPySetBackgroundColor,METH_O,"set Background Color (rgb)"}, | {"setBackgroundColor",(PyCFunction)gPySetBackgroundColor,METH_O,"set Background Color (rgb)"}, | ||||
| {"getBackgroundColor", (PyCFunction) gPyGetBackgroundColor, METH_NOARGS, "get the background color"}, | |||||
| {"setAmbientColor",(PyCFunction)gPySetAmbientColor,METH_O,"set Ambient Color (rgb)"}, | {"setAmbientColor",(PyCFunction)gPySetAmbientColor,METH_O,"set Ambient Color (rgb)"}, | ||||
| {"getAmbientColor", (PyCFunction) gPyGetAmbientColor, METH_NOARGS, "get the ambient color"}, | |||||
| {"enableMist",(PyCFunction)gPyEnableMist,METH_VARARGS,"enable or disable mist"}, | |||||
| {"mistEnabled",(PyCFunction)gPyMistEnabled,METH_NOARGS,"get the state of the mist"}, | |||||
| {"setMistColor",(PyCFunction)gPySetMistColor,METH_O,"set Mist Color (rgb)"}, | |||||
| {"getMistColor", (PyCFunction) gPyGetMistColor, METH_NOARGS, "get the mist color"}, | |||||
| {"setMistType",(PyCFunction)gPySetMistType,METH_VARARGS,"set mist type (short type)"}, | |||||
| {"getMistType", (PyCFunction) gPyGetMistType, METH_NOARGS, "get the mist type"}, | |||||
| {"setMistStart",(PyCFunction)gPySetMistStart,METH_VARARGS,"set Mist Start"}, | |||||
| {"getMistStart", (PyCFunction) gPyGetMistStart, METH_NOARGS, "get the mist start"}, | |||||
| {"setMistDistance",(PyCFunction)gPySetMistDistance,METH_VARARGS,"set Mist Distance"}, | |||||
| {"getMistDist", (PyCFunction) gPyGetMistDist, METH_NOARGS, "get the mist distance"}, | |||||
| {"setMistIntensity",(PyCFunction)gPySetMistIntensity,METH_VARARGS,"set mist intensity (float intensity)"}, | |||||
| {"getMistIntensity", (PyCFunction) gPyGetMistIntensity, METH_NOARGS, "get the mist intensity"}, | |||||
| {"enableMotionBlur",(PyCFunction)gPyEnableMotionBlur,METH_VARARGS,"enable motion blur"}, | {"enableMotionBlur",(PyCFunction)gPyEnableMotionBlur,METH_VARARGS,"enable motion blur"}, | ||||
| {"disableMotionBlur",(PyCFunction)gPyDisableMotionBlur,METH_NOARGS,"disable motion blur"}, | {"disableMotionBlur",(PyCFunction)gPyDisableMotionBlur,METH_NOARGS,"disable motion blur"}, | ||||
| Context not available. | |||||
| KX_MACRO_addTypesToDict(d, VSYNC_ON, VSYNC_ON); | KX_MACRO_addTypesToDict(d, VSYNC_ON, VSYNC_ON); | ||||
| KX_MACRO_addTypesToDict(d, VSYNC_ADAPTIVE, VSYNC_ADAPTIVE); | KX_MACRO_addTypesToDict(d, VSYNC_ADAPTIVE, VSYNC_ADAPTIVE); | ||||
| /* KX_WorldInfo mist types */ | |||||
| KX_MACRO_addTypesToDict(d, KX_MIST_QUADRATIC, KX_WorldInfo::KX_MIST_QUADRATIC); | |||||
| KX_MACRO_addTypesToDict(d, KX_MIST_LINEAR, KX_WorldInfo::KX_MIST_LINEAR); | |||||
| KX_MACRO_addTypesToDict(d, KX_MIST_INV_QUADRATIC, KX_WorldInfo::KX_MIST_INV_QUADRATIC); | |||||
| // XXXX Add constants here | // XXXX Add constants here | ||||
| // Check for errors | // Check for errors | ||||
| Context not available. | |||||