forked from bartvdbraak/blender
BGE API cleanup: AddObject, DeleteObject and Scene actuator added.
This commit is contained in:
parent
e392eb4d9c
commit
059c2a10c4
@ -38,7 +38,7 @@
|
|||||||
#include "SCA_IScene.h"
|
#include "SCA_IScene.h"
|
||||||
#include "KX_GameObject.h"
|
#include "KX_GameObject.h"
|
||||||
#include "KX_IPhysicsController.h"
|
#include "KX_IPhysicsController.h"
|
||||||
|
#include "blendef.h"
|
||||||
#include "PyObjectPlus.h"
|
#include "PyObjectPlus.h"
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -53,9 +53,9 @@ KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj,
|
|||||||
SCA_IObject *original,
|
SCA_IObject *original,
|
||||||
int time,
|
int time,
|
||||||
SCA_IScene* scene,
|
SCA_IScene* scene,
|
||||||
const MT_Vector3& linvel,
|
const float *linvel,
|
||||||
bool linv_local,
|
bool linv_local,
|
||||||
const MT_Vector3& angvel,
|
const float *angvel,
|
||||||
bool angv_local,
|
bool angv_local,
|
||||||
PyTypeObject* T)
|
PyTypeObject* T)
|
||||||
:
|
:
|
||||||
@ -63,12 +63,16 @@ KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj,
|
|||||||
m_OriginalObject(original),
|
m_OriginalObject(original),
|
||||||
m_scene(scene),
|
m_scene(scene),
|
||||||
|
|
||||||
m_linear_velocity(linvel),
|
|
||||||
m_localLinvFlag(linv_local),
|
m_localLinvFlag(linv_local),
|
||||||
|
|
||||||
m_angular_velocity(angvel),
|
|
||||||
m_localAngvFlag(angv_local)
|
m_localAngvFlag(angv_local)
|
||||||
{
|
{
|
||||||
|
m_linear_velocity[0] = linvel[0];
|
||||||
|
m_linear_velocity[1] = linvel[1];
|
||||||
|
m_linear_velocity[2] = linvel[2];
|
||||||
|
m_angular_velocity[0] = angvel[0];
|
||||||
|
m_angular_velocity[1] = angvel[1];
|
||||||
|
m_angular_velocity[2] = angvel[2];
|
||||||
|
|
||||||
if (m_OriginalObject)
|
if (m_OriginalObject)
|
||||||
m_OriginalObject->RegisterActuator(this);
|
m_OriginalObject->RegisterActuator(this);
|
||||||
|
|
||||||
@ -188,6 +192,7 @@ PyParentObject KX_SCA_AddObjectActuator::Parents[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
PyMethodDef KX_SCA_AddObjectActuator::Methods[] = {
|
PyMethodDef KX_SCA_AddObjectActuator::Methods[] = {
|
||||||
|
// ---> deprecated
|
||||||
{"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_O, (PY_METHODCHAR)SetTime_doc},
|
{"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_O, (PY_METHODCHAR)SetTime_doc},
|
||||||
{"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_NOARGS, (PY_METHODCHAR)GetTime_doc},
|
{"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_NOARGS, (PY_METHODCHAR)GetTime_doc},
|
||||||
{"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_NOARGS, (PY_METHODCHAR)GetLinearVelocity_doc},
|
{"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_NOARGS, (PY_METHODCHAR)GetLinearVelocity_doc},
|
||||||
@ -196,8 +201,6 @@ PyMethodDef KX_SCA_AddObjectActuator::Methods[] = {
|
|||||||
{"setAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetAngularVelocity, METH_VARARGS, (PY_METHODCHAR)SetAngularVelocity_doc},
|
{"setAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetAngularVelocity, METH_VARARGS, (PY_METHODCHAR)SetAngularVelocity_doc},
|
||||||
{"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_NOARGS,"getLastCreatedObject() : get the object handle to the last created object\n"},
|
{"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_NOARGS,"getLastCreatedObject() : get the object handle to the last created object\n"},
|
||||||
{"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_NOARGS,"instantAddObject() : immediately add object without delay\n"},
|
{"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_NOARGS,"instantAddObject() : immediately add object without delay\n"},
|
||||||
|
|
||||||
// ---> deprecated
|
|
||||||
{"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc},
|
{"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc},
|
||||||
{"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc},
|
{"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc},
|
||||||
|
|
||||||
@ -205,41 +208,65 @@ PyMethodDef KX_SCA_AddObjectActuator::Methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
PyAttributeDef KX_SCA_AddObjectActuator::Attributes[] = {
|
PyAttributeDef KX_SCA_AddObjectActuator::Attributes[] = {
|
||||||
|
KX_PYATTRIBUTE_RW_FUNCTION("object",KX_SCA_AddObjectActuator,pyattr_get_object,pyattr_set_object),
|
||||||
|
KX_PYATTRIBUTE_RO_FUNCTION("objectLastCreated",KX_SCA_AddObjectActuator,pyattr_get_objectLastCreated),
|
||||||
|
KX_PYATTRIBUTE_INT_RW("time",0,2000,true,KX_SCA_AddObjectActuator,m_timeProp),
|
||||||
|
KX_PYATTRIBUTE_FLOAT_ARRAY_RW("linearVelocity",-MAXFLOAT,MAXFLOAT,KX_SCA_AddObjectActuator,m_linear_velocity,3),
|
||||||
|
KX_PYATTRIBUTE_FLOAT_ARRAY_RW("angularVelocity",-MAXFLOAT,MAXFLOAT,KX_SCA_AddObjectActuator,m_angular_velocity,3),
|
||||||
{ NULL } //Sentinel
|
{ NULL } //Sentinel
|
||||||
};
|
};
|
||||||
|
|
||||||
PyObject* KX_SCA_AddObjectActuator::_getattr(const char *attr)
|
PyObject* KX_SCA_AddObjectActuator::pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
|
||||||
{
|
{
|
||||||
if (!strcmp(attr, "object")) {
|
KX_SCA_AddObjectActuator* actuator = static_cast<KX_SCA_AddObjectActuator*>(self);
|
||||||
if (!m_OriginalObject) Py_RETURN_NONE;
|
if (!actuator->m_OriginalObject)
|
||||||
else return m_OriginalObject->AddRef();
|
Py_RETURN_NONE;
|
||||||
} else if (!strcmp(attr, "objectLastCreated")) {
|
else
|
||||||
if (!m_OriginalObject) Py_RETURN_NONE;
|
return actuator->m_OriginalObject->AddRef();
|
||||||
else return m_lastCreatedObject->AddRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
_getattr_up(SCA_IActuator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int KX_SCA_AddObjectActuator::_setattr(const char *attr, PyObject* value) {
|
int KX_SCA_AddObjectActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||||
|
{
|
||||||
|
KX_SCA_AddObjectActuator* actuator = static_cast<KX_SCA_AddObjectActuator*>(self);
|
||||||
|
KX_GameObject *gameobj;
|
||||||
|
|
||||||
if (!strcmp(attr, "object")) {
|
if (!ConvertPythonToGameObject(value, &gameobj, true))
|
||||||
KX_GameObject *gameobj;
|
return 1; // ConvertPythonToGameObject sets the error
|
||||||
|
|
||||||
if (!ConvertPythonToGameObject(value, &gameobj, true))
|
if (actuator->m_OriginalObject != NULL)
|
||||||
return 1; // ConvertPythonToGameObject sets the error
|
actuator->m_OriginalObject->UnregisterActuator(actuator);
|
||||||
|
|
||||||
if (m_OriginalObject != NULL)
|
actuator->m_OriginalObject = (SCA_IObject*)gameobj;
|
||||||
m_OriginalObject->UnregisterActuator(this);
|
|
||||||
|
|
||||||
m_OriginalObject = (SCA_IObject*)gameobj;
|
if (actuator->m_OriginalObject)
|
||||||
|
actuator->m_OriginalObject->RegisterActuator(actuator);
|
||||||
|
|
||||||
if (m_OriginalObject)
|
return 0;
|
||||||
m_OriginalObject->RegisterActuator(this);
|
}
|
||||||
|
|
||||||
return 0;
|
PyObject* KX_SCA_AddObjectActuator::pyattr_get_objectLastCreated(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
|
||||||
}
|
{
|
||||||
|
KX_SCA_AddObjectActuator* actuator = static_cast<KX_SCA_AddObjectActuator*>(self);
|
||||||
|
if (!actuator->m_lastCreatedObject)
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
else
|
||||||
|
return actuator->m_lastCreatedObject->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PyObject* KX_SCA_AddObjectActuator::_getattr(const char *attr)
|
||||||
|
{
|
||||||
|
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||||
|
if (object != NULL)
|
||||||
|
return object;
|
||||||
|
_getattr_up(SCA_IActuator);
|
||||||
|
}
|
||||||
|
|
||||||
|
int KX_SCA_AddObjectActuator::_setattr(const char *attr, PyObject* value)
|
||||||
|
{
|
||||||
|
int ret = _setattr_self(Attributes, this, attr, value);
|
||||||
|
if (ret >= 0)
|
||||||
|
return ret;
|
||||||
return SCA_IActuator::_setattr(attr, value);
|
return SCA_IActuator::_setattr(attr, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,6 +307,7 @@ const char KX_SCA_AddObjectActuator::SetTime_doc[] =
|
|||||||
|
|
||||||
PyObject* KX_SCA_AddObjectActuator::PySetTime(PyObject* self, PyObject* value)
|
PyObject* KX_SCA_AddObjectActuator::PySetTime(PyObject* self, PyObject* value)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("setTime()", "the time property");
|
||||||
int deltatime = PyInt_AsLong(value);
|
int deltatime = PyInt_AsLong(value);
|
||||||
if (deltatime==-1 && PyErr_Occurred()) {
|
if (deltatime==-1 && PyErr_Occurred()) {
|
||||||
PyErr_SetString(PyExc_TypeError, "expected an int");
|
PyErr_SetString(PyExc_TypeError, "expected an int");
|
||||||
@ -296,12 +324,13 @@ PyObject* KX_SCA_AddObjectActuator::PySetTime(PyObject* self, PyObject* value)
|
|||||||
|
|
||||||
/* 3. getTime */
|
/* 3. getTime */
|
||||||
const char KX_SCA_AddObjectActuator::GetTime_doc[] =
|
const char KX_SCA_AddObjectActuator::GetTime_doc[] =
|
||||||
"GetTime()\n"
|
"getTime()\n"
|
||||||
"\tReturns the lifetime of the object that will be added.\n";
|
"\tReturns the lifetime of the object that will be added.\n";
|
||||||
|
|
||||||
|
|
||||||
PyObject* KX_SCA_AddObjectActuator::PyGetTime(PyObject* self)
|
PyObject* KX_SCA_AddObjectActuator::PyGetTime(PyObject* self)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("getTime()", "the time property");
|
||||||
return PyInt_FromLong(m_timeProp);
|
return PyInt_FromLong(m_timeProp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,6 +368,7 @@ const char KX_SCA_AddObjectActuator::GetLinearVelocity_doc[] =
|
|||||||
|
|
||||||
PyObject* KX_SCA_AddObjectActuator::PyGetLinearVelocity(PyObject* self)
|
PyObject* KX_SCA_AddObjectActuator::PyGetLinearVelocity(PyObject* self)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("getLinearVelocity()", "the linearVelocity property");
|
||||||
PyObject *retVal = PyList_New(3);
|
PyObject *retVal = PyList_New(3);
|
||||||
|
|
||||||
PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0]));
|
PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0]));
|
||||||
@ -361,12 +391,15 @@ const char KX_SCA_AddObjectActuator::SetLinearVelocity_doc[] =
|
|||||||
|
|
||||||
PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self, PyObject* args)
|
PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self, PyObject* args)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("setLinearVelocity()", "the linearVelocity property");
|
||||||
|
|
||||||
float vecArg[3];
|
float vecArg[3];
|
||||||
if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2]))
|
if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2]))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
m_linear_velocity.setValue(vecArg);
|
m_linear_velocity[0] = vecArg[0];
|
||||||
|
m_linear_velocity[1] = vecArg[1];
|
||||||
|
m_linear_velocity[2] = vecArg[2];
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,6 +411,7 @@ const char KX_SCA_AddObjectActuator::GetAngularVelocity_doc[] =
|
|||||||
|
|
||||||
PyObject* KX_SCA_AddObjectActuator::PyGetAngularVelocity(PyObject* self)
|
PyObject* KX_SCA_AddObjectActuator::PyGetAngularVelocity(PyObject* self)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("getAngularVelocity()", "the angularVelocity property");
|
||||||
PyObject *retVal = PyList_New(3);
|
PyObject *retVal = PyList_New(3);
|
||||||
|
|
||||||
PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0]));
|
PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0]));
|
||||||
@ -400,12 +434,15 @@ const char KX_SCA_AddObjectActuator::SetAngularVelocity_doc[] =
|
|||||||
|
|
||||||
PyObject* KX_SCA_AddObjectActuator::PySetAngularVelocity(PyObject* self, PyObject* args)
|
PyObject* KX_SCA_AddObjectActuator::PySetAngularVelocity(PyObject* self, PyObject* args)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("setAngularVelocity()", "the angularVelocity property");
|
||||||
|
|
||||||
float vecArg[3];
|
float vecArg[3];
|
||||||
if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2]))
|
if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2]))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
m_angular_velocity.setValue(vecArg);
|
m_angular_velocity[0] = vecArg[0];
|
||||||
|
m_angular_velocity[1] = vecArg[1];
|
||||||
|
m_angular_velocity[2] = vecArg[2];
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +454,7 @@ void KX_SCA_AddObjectActuator::InstantAddObject()
|
|||||||
// Now it needs to be added to the current scene.
|
// Now it needs to be added to the current scene.
|
||||||
SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp );
|
SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp );
|
||||||
KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica);
|
KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica);
|
||||||
game_obj->setLinearVelocity(m_linear_velocity,m_localLinvFlag);
|
game_obj->setLinearVelocity(m_linear_velocity ,m_localLinvFlag);
|
||||||
game_obj->setAngularVelocity(m_angular_velocity,m_localAngvFlag);
|
game_obj->setAngularVelocity(m_angular_velocity,m_localAngvFlag);
|
||||||
game_obj->ResolveCombinedVelocities(m_linear_velocity, m_angular_velocity, m_localLinvFlag, m_localAngvFlag);
|
game_obj->ResolveCombinedVelocities(m_linear_velocity, m_angular_velocity, m_localLinvFlag, m_localAngvFlag);
|
||||||
|
|
||||||
@ -453,6 +490,7 @@ const char KX_SCA_AddObjectActuator::GetLastCreatedObject_doc[] =
|
|||||||
|
|
||||||
PyObject* KX_SCA_AddObjectActuator::PyGetLastCreatedObject(PyObject* self)
|
PyObject* KX_SCA_AddObjectActuator::PyGetLastCreatedObject(PyObject* self)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("getLastCreatedObject()", "the objectLastCreated property");
|
||||||
SCA_IObject* result = this->GetLastCreatedObject();
|
SCA_IObject* result = this->GetLastCreatedObject();
|
||||||
|
|
||||||
// if result->GetSGNode() is NULL
|
// if result->GetSGNode() is NULL
|
||||||
|
@ -59,12 +59,12 @@ class KX_SCA_AddObjectActuator : public SCA_IActuator
|
|||||||
SCA_IScene* m_scene;
|
SCA_IScene* m_scene;
|
||||||
|
|
||||||
/// Linear velocity upon creation of the object.
|
/// Linear velocity upon creation of the object.
|
||||||
MT_Vector3 m_linear_velocity;
|
float m_linear_velocity[3];
|
||||||
/// Apply the velocity locally
|
/// Apply the velocity locally
|
||||||
bool m_localLinvFlag;
|
bool m_localLinvFlag;
|
||||||
|
|
||||||
/// Angular velocity upon creation of the object.
|
/// Angular velocity upon creation of the object.
|
||||||
MT_Vector3 m_angular_velocity;
|
float m_angular_velocity[3];
|
||||||
/// Apply the velocity locally
|
/// Apply the velocity locally
|
||||||
bool m_localAngvFlag;
|
bool m_localAngvFlag;
|
||||||
|
|
||||||
@ -85,9 +85,9 @@ public:
|
|||||||
SCA_IObject *original,
|
SCA_IObject *original,
|
||||||
int time,
|
int time,
|
||||||
SCA_IScene* scene,
|
SCA_IScene* scene,
|
||||||
const MT_Vector3& linvel,
|
const float *linvel,
|
||||||
bool linv_local,
|
bool linv_local,
|
||||||
const MT_Vector3& angvel,
|
const float *angvel,
|
||||||
bool angv_local,
|
bool angv_local,
|
||||||
PyTypeObject* T=&Type
|
PyTypeObject* T=&Type
|
||||||
);
|
);
|
||||||
@ -140,6 +140,9 @@ public:
|
|||||||
/* 10. instantAddObject*/
|
/* 10. instantAddObject*/
|
||||||
KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,InstantAddObject);
|
KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,InstantAddObject);
|
||||||
|
|
||||||
|
static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
|
||||||
|
static int pyattr_set_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||||
|
static PyObject* pyattr_get_objectLastCreated(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
|
||||||
|
|
||||||
}; /* end of class KX_SCA_AddObjectActuator : public KX_EditObjectActuator */
|
}; /* end of class KX_SCA_AddObjectActuator : public KX_EditObjectActuator */
|
||||||
|
|
||||||
|
@ -259,24 +259,83 @@ PyParentObject KX_SceneActuator::Parents[] =
|
|||||||
|
|
||||||
PyMethodDef KX_SceneActuator::Methods[] =
|
PyMethodDef KX_SceneActuator::Methods[] =
|
||||||
{
|
{
|
||||||
|
//Deprecated functions ------>
|
||||||
{"setUseRestart", (PyCFunction) KX_SceneActuator::sPySetUseRestart, METH_VARARGS, (PY_METHODCHAR)SetUseRestart_doc},
|
{"setUseRestart", (PyCFunction) KX_SceneActuator::sPySetUseRestart, METH_VARARGS, (PY_METHODCHAR)SetUseRestart_doc},
|
||||||
{"setScene", (PyCFunction) KX_SceneActuator::sPySetScene, METH_VARARGS, (PY_METHODCHAR)SetScene_doc},
|
{"setScene", (PyCFunction) KX_SceneActuator::sPySetScene, METH_VARARGS, (PY_METHODCHAR)SetScene_doc},
|
||||||
{"setCamera", (PyCFunction) KX_SceneActuator::sPySetCamera, METH_VARARGS, (PY_METHODCHAR)SetCamera_doc},
|
{"setCamera", (PyCFunction) KX_SceneActuator::sPySetCamera, METH_VARARGS, (PY_METHODCHAR)SetCamera_doc},
|
||||||
{"getUseRestart", (PyCFunction) KX_SceneActuator::sPyGetUseRestart, METH_VARARGS, (PY_METHODCHAR)GetUseRestart_doc},
|
{"getUseRestart", (PyCFunction) KX_SceneActuator::sPyGetUseRestart, METH_VARARGS, (PY_METHODCHAR)GetUseRestart_doc},
|
||||||
{"getScene", (PyCFunction) KX_SceneActuator::sPyGetScene, METH_VARARGS, (PY_METHODCHAR)GetScene_doc},
|
{"getScene", (PyCFunction) KX_SceneActuator::sPyGetScene, METH_VARARGS, (PY_METHODCHAR)GetScene_doc},
|
||||||
{"getCamera", (PyCFunction) KX_SceneActuator::sPyGetCamera, METH_VARARGS, (PY_METHODCHAR)GetCamera_doc},
|
{"getCamera", (PyCFunction) KX_SceneActuator::sPyGetCamera, METH_VARARGS, (PY_METHODCHAR)GetCamera_doc},
|
||||||
|
//<----- Deprecated
|
||||||
{NULL,NULL} //Sentinel
|
{NULL,NULL} //Sentinel
|
||||||
};
|
};
|
||||||
|
|
||||||
PyAttributeDef KX_SceneActuator::Attributes[] = {
|
PyAttributeDef KX_SceneActuator::Attributes[] = {
|
||||||
|
KX_PYATTRIBUTE_STRING_RW("scene",0,32,true,KX_SceneActuator,m_nextSceneName),
|
||||||
|
KX_PYATTRIBUTE_RW_FUNCTION("camera",KX_SceneActuator,pyattr_get_camera,pyattr_set_camera),
|
||||||
{ NULL } //Sentinel
|
{ NULL } //Sentinel
|
||||||
};
|
};
|
||||||
|
|
||||||
PyObject* KX_SceneActuator::_getattr(const char *attr)
|
PyObject* KX_SceneActuator::_getattr(const char *attr)
|
||||||
{
|
{
|
||||||
|
PyObject* object = _getattr_self(Attributes, this, attr);
|
||||||
|
if (object != NULL)
|
||||||
|
return object;
|
||||||
_getattr_up(SCA_IActuator);
|
_getattr_up(SCA_IActuator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int KX_SceneActuator::_setattr(const char *attr, PyObject *value)
|
||||||
|
{
|
||||||
|
int ret = _setattr_self(Attributes, this, attr, value);
|
||||||
|
if (ret >= 0)
|
||||||
|
return ret;
|
||||||
|
return SCA_IActuator::_setattr(attr, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject* KX_SceneActuator::pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
|
||||||
|
{
|
||||||
|
KX_SceneActuator* actuator = static_cast<KX_SceneActuator*>(self);
|
||||||
|
if (!actuator->m_camera)
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
actuator->m_camera->AddRef();
|
||||||
|
return actuator->m_camera;
|
||||||
|
}
|
||||||
|
|
||||||
|
int KX_SceneActuator::pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||||
|
{
|
||||||
|
KX_SceneActuator* actuator = static_cast<KX_SceneActuator*>(self);
|
||||||
|
KX_Camera *camOb;
|
||||||
|
|
||||||
|
if (PyObject_TypeCheck(value, &KX_Camera::Type))
|
||||||
|
{
|
||||||
|
camOb = static_cast<KX_Camera*>(value);
|
||||||
|
if (actuator->m_camera)
|
||||||
|
actuator->m_camera->UnregisterActuator(actuator);
|
||||||
|
actuator->m_camera = camOb;
|
||||||
|
if (actuator->m_camera)
|
||||||
|
actuator->m_camera->RegisterActuator(actuator);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PyString_Check(value))
|
||||||
|
{
|
||||||
|
char *camName = PyString_AsString(value);
|
||||||
|
|
||||||
|
camOb = actuator->FindCamera(camName);
|
||||||
|
if (camOb)
|
||||||
|
{
|
||||||
|
if (actuator->m_camera)
|
||||||
|
actuator->m_camera->UnregisterActuator(actuator);
|
||||||
|
actuator->m_camera = camOb;
|
||||||
|
actuator->m_camera->RegisterActuator(actuator);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
PyErr_SetString(PyExc_TypeError, "not a valid camera name");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
PyErr_SetString(PyExc_TypeError, "expected a string or a camera object reference");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 2. setUseRestart--------------------------------------------------------- */
|
/* 2. setUseRestart--------------------------------------------------------- */
|
||||||
@ -288,6 +347,7 @@ PyObject* KX_SceneActuator::PySetUseRestart(PyObject* self,
|
|||||||
PyObject* args,
|
PyObject* args,
|
||||||
PyObject* kwds)
|
PyObject* kwds)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("setUseRestart()", "(no replacement)");
|
||||||
int boolArg;
|
int boolArg;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "i", &boolArg))
|
if (!PyArg_ParseTuple(args, "i", &boolArg))
|
||||||
@ -310,6 +370,7 @@ PyObject* KX_SceneActuator::PyGetUseRestart(PyObject* self,
|
|||||||
PyObject* args,
|
PyObject* args,
|
||||||
PyObject* kwds)
|
PyObject* kwds)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("getUseRestart()", "(no replacement)");
|
||||||
return PyInt_FromLong(!(m_restart == 0));
|
return PyInt_FromLong(!(m_restart == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,6 +385,7 @@ PyObject* KX_SceneActuator::PySetScene(PyObject* self,
|
|||||||
PyObject* args,
|
PyObject* args,
|
||||||
PyObject* kwds)
|
PyObject* kwds)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("setScene()", "the scene property");
|
||||||
/* one argument: a scene, ignore the rest */
|
/* one argument: a scene, ignore the rest */
|
||||||
char *scene_name;
|
char *scene_name;
|
||||||
|
|
||||||
@ -348,6 +410,7 @@ PyObject* KX_SceneActuator::PyGetScene(PyObject* self,
|
|||||||
PyObject* args,
|
PyObject* args,
|
||||||
PyObject* kwds)
|
PyObject* kwds)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("getScene()", "the scene property");
|
||||||
return PyString_FromString(m_nextSceneName);
|
return PyString_FromString(m_nextSceneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,6 +425,7 @@ PyObject* KX_SceneActuator::PySetCamera(PyObject* self,
|
|||||||
PyObject* args,
|
PyObject* args,
|
||||||
PyObject* kwds)
|
PyObject* kwds)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("setCamera()", "the camera property");
|
||||||
PyObject *cam;
|
PyObject *cam;
|
||||||
if (PyArg_ParseTuple(args, "O!", &KX_Camera::Type, &cam))
|
if (PyArg_ParseTuple(args, "O!", &KX_Camera::Type, &cam))
|
||||||
{
|
{
|
||||||
@ -403,6 +467,7 @@ PyObject* KX_SceneActuator::PyGetCamera(PyObject* self,
|
|||||||
PyObject* args,
|
PyObject* args,
|
||||||
PyObject* kwds)
|
PyObject* kwds)
|
||||||
{
|
{
|
||||||
|
ShowDeprecationWarning("getCamera()", "the camera property");
|
||||||
return PyString_FromString(m_camera->GetName());
|
return PyString_FromString(m_camera->GetName());
|
||||||
}
|
}
|
||||||
/* eof */
|
/* eof */
|
||||||
|
@ -93,6 +93,7 @@ class KX_SceneActuator : public SCA_IActuator
|
|||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
virtual PyObject* _getattr(const char *attr);
|
virtual PyObject* _getattr(const char *attr);
|
||||||
|
virtual int _setattr(const char *attr, PyObject *value);
|
||||||
|
|
||||||
/* 1. set */
|
/* 1. set */
|
||||||
/* Removed */
|
/* Removed */
|
||||||
@ -110,6 +111,9 @@ class KX_SceneActuator : public SCA_IActuator
|
|||||||
/* 7. getCamera: */
|
/* 7. getCamera: */
|
||||||
KX_PYMETHOD_DOC(KX_SceneActuator,GetCamera);
|
KX_PYMETHOD_DOC(KX_SceneActuator,GetCamera);
|
||||||
|
|
||||||
|
static PyObject* pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
|
||||||
|
static int pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||||
|
|
||||||
}; /* end of class KXSceneActuator */
|
}; /* end of class KXSceneActuator */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,6 +9,12 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
|
|||||||
@type object: KX_GameObject or None
|
@type object: KX_GameObject or None
|
||||||
@ivar objectLastCreated: the last added object from this actuator (read only).
|
@ivar objectLastCreated: the last added object from this actuator (read only).
|
||||||
@type objectLastCreated: KX_GameObject or None
|
@type objectLastCreated: KX_GameObject or None
|
||||||
|
@ivar time: the lifetime of added objects, in frames.
|
||||||
|
@type time: integer
|
||||||
|
@ivar linearVelocity: the initial linear velocity of added objects.
|
||||||
|
@type linearVelocity: list [vx, vy, vz]
|
||||||
|
@ivar angularVelocity: the initial angular velocity of added objects.
|
||||||
|
@type angularVelocity: list [vx, vy, vz]
|
||||||
|
|
||||||
@warning: An Add Object actuator will be ignored if at game start, the linked object doesn't exist
|
@warning: An Add Object actuator will be ignored if at game start, the linked object doesn't exist
|
||||||
(or is empty) or the linked object is in an active layer.
|
(or is empty) or the linked object is in an active layer.
|
||||||
@ -19,6 +25,7 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
|
|||||||
"""
|
"""
|
||||||
def setObject(object):
|
def setObject(object):
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the object property
|
||||||
Sets the game object to add.
|
Sets the game object to add.
|
||||||
|
|
||||||
A copy of the object will be added to the scene when the actuator is activated.
|
A copy of the object will be added to the scene when the actuator is activated.
|
||||||
@ -31,6 +38,7 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
|
|||||||
"""
|
"""
|
||||||
def getObject(name_only = 0):
|
def getObject(name_only = 0):
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the object property
|
||||||
Returns the name of the game object to be added.
|
Returns the name of the game object to be added.
|
||||||
|
|
||||||
Returns None if no game object has been assigned to be added.
|
Returns None if no game object has been assigned to be added.
|
||||||
@ -40,6 +48,7 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
|
|||||||
"""
|
"""
|
||||||
def setTime(time):
|
def setTime(time):
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the time property
|
||||||
Sets the lifetime of added objects, in frames.
|
Sets the lifetime of added objects, in frames.
|
||||||
|
|
||||||
If time == 0, the object will last forever.
|
If time == 0, the object will last forever.
|
||||||
@ -49,12 +58,14 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
|
|||||||
"""
|
"""
|
||||||
def getTime():
|
def getTime():
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the time property
|
||||||
Returns the lifetime of the added object, in frames.
|
Returns the lifetime of the added object, in frames.
|
||||||
|
|
||||||
@rtype: integer
|
@rtype: integer
|
||||||
"""
|
"""
|
||||||
def setLinearVelocity(vx, vy, vz):
|
def setLinearVelocity(vx, vy, vz):
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the linearVelocity property
|
||||||
Sets the initial linear velocity of added objects.
|
Sets the initial linear velocity of added objects.
|
||||||
|
|
||||||
@type vx: float
|
@type vx: float
|
||||||
@ -66,12 +77,14 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
|
|||||||
"""
|
"""
|
||||||
def getLinearVelocity():
|
def getLinearVelocity():
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the linearVelocity property
|
||||||
Returns the initial linear velocity of added objects.
|
Returns the initial linear velocity of added objects.
|
||||||
|
|
||||||
@rtype: list [vx, vy, vz]
|
@rtype: list [vx, vy, vz]
|
||||||
"""
|
"""
|
||||||
def setAngularVelocity(vx, vy, vz):
|
def setAngularVelocity(vx, vy, vz):
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the angularVelocity property
|
||||||
Sets the initial angular velocity of added objects.
|
Sets the initial angular velocity of added objects.
|
||||||
|
|
||||||
@type vx: float
|
@type vx: float
|
||||||
@ -83,12 +96,14 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
|
|||||||
"""
|
"""
|
||||||
def getAngularVelocity():
|
def getAngularVelocity():
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the angularVelocity property
|
||||||
Returns the initial angular velocity of added objects.
|
Returns the initial angular velocity of added objects.
|
||||||
|
|
||||||
@rtype: list [vx, vy, vz]
|
@rtype: list [vx, vy, vz]
|
||||||
"""
|
"""
|
||||||
def getLastCreatedObject():
|
def getLastCreatedObject():
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the objectLastCreated property
|
||||||
Returns the last object created by this actuator.
|
Returns the last object created by this actuator.
|
||||||
|
|
||||||
@rtype: L{KX_GameObject}
|
@rtype: L{KX_GameObject}
|
||||||
|
@ -12,21 +12,32 @@ class KX_SceneActuator(SCA_IActuator):
|
|||||||
This will generate a warning in the console:
|
This will generate a warning in the console:
|
||||||
|
|
||||||
C{ERROR: GameObject I{OBName} has a SceneActuator I{ActuatorName} (SetScene) without scene}
|
C{ERROR: GameObject I{OBName} has a SceneActuator I{ActuatorName} (SetScene) without scene}
|
||||||
|
|
||||||
|
Properties:
|
||||||
|
|
||||||
|
@ivar scene: the name of the scene to change to/overlay/underlay/remove/suspend/resume
|
||||||
|
@type scene: string.
|
||||||
|
@ivar camera: the camera to change to.
|
||||||
|
When setting the attribute, you can use either a L{KX_Camera} or the name of the camera.
|
||||||
|
@type camera: L{KX_Camera} on read, string or L{KX_Camera} on write
|
||||||
"""
|
"""
|
||||||
def setUseRestart(flag):
|
def setUseRestart(flag):
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED
|
||||||
Set flag to True to restart the scene.
|
Set flag to True to restart the scene.
|
||||||
|
|
||||||
@type flag: boolean
|
@type flag: boolean
|
||||||
"""
|
"""
|
||||||
def setScene(scene):
|
def setScene(scene):
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the scene property instead
|
||||||
Sets the name of the scene to change to/overlay/underlay/remove/suspend/resume.
|
Sets the name of the scene to change to/overlay/underlay/remove/suspend/resume.
|
||||||
|
|
||||||
@type scene: string
|
@type scene: string
|
||||||
"""
|
"""
|
||||||
def setCamera(camera):
|
def setCamera(camera):
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the camera property instead
|
||||||
Sets the camera to change to.
|
Sets the camera to change to.
|
||||||
|
|
||||||
Camera can be either a L{KX_Camera} or the name of the camera.
|
Camera can be either a L{KX_Camera} or the name of the camera.
|
||||||
@ -35,12 +46,14 @@ class KX_SceneActuator(SCA_IActuator):
|
|||||||
"""
|
"""
|
||||||
def getUseRestart():
|
def getUseRestart():
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED
|
||||||
Returns True if the scene will be restarted.
|
Returns True if the scene will be restarted.
|
||||||
|
|
||||||
@rtype: boolean
|
@rtype: boolean
|
||||||
"""
|
"""
|
||||||
def getScene():
|
def getScene():
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the scene property instead
|
||||||
Returns the name of the scene to change to/overlay/underlay/remove/suspend/resume.
|
Returns the name of the scene to change to/overlay/underlay/remove/suspend/resume.
|
||||||
|
|
||||||
Returns an empty string ("") if no scene has been set.
|
Returns an empty string ("") if no scene has been set.
|
||||||
@ -49,6 +62,7 @@ class KX_SceneActuator(SCA_IActuator):
|
|||||||
"""
|
"""
|
||||||
def getCamera():
|
def getCamera():
|
||||||
"""
|
"""
|
||||||
|
DEPRECATED: use the camera property instead
|
||||||
Returns the name of the camera to change to.
|
Returns the name of the camera to change to.
|
||||||
|
|
||||||
@rtype: string
|
@rtype: string
|
||||||
|
Loading…
Reference in New Issue
Block a user