Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / source / gameengine / Ketsji / KX_TrackToActuator.cpp
index e6c2f86..b5b7e9d 100644 (file)
@@ -453,6 +453,14 @@ PyTypeObject KX_TrackToActuator::Type = {
 };
 
 PyMethodDef KX_TrackToActuator::Methods[] = {
+       // ---> deprecated
+       {"setTime", (PyCFunction) KX_TrackToActuator::sPySetTime, METH_VARARGS, (const char *)SetTime_doc},
+       {"getTime", (PyCFunction) KX_TrackToActuator::sPyGetTime, METH_NOARGS, (const char *)GetTime_doc},
+       {"setUse3D", (PyCFunction) KX_TrackToActuator::sPySetUse3D, METH_VARARGS, (const char *)SetUse3D_doc},
+       {"getUse3D", (PyCFunction) KX_TrackToActuator::sPyGetUse3D, METH_NOARGS, (const char *)GetUse3D_doc},
+       {"setObject", (PyCFunction) KX_TrackToActuator::sPySetObject, METH_O, (const char *)SetObject_doc},
+       {"getObject", (PyCFunction) KX_TrackToActuator::sPyGetObject, METH_VARARGS, (const char *)GetObject_doc},
+       
        {NULL,NULL} //Sentinel
 };
 
@@ -492,4 +500,123 @@ int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUT
        return PY_SET_ATTR_SUCCESS;
 }
 
+
+/* 1. setObject */
+const char KX_TrackToActuator::SetObject_doc[] = 
+"setObject(object)\n"
+"\t- object: KX_GameObject, string or None\n"
+"\tSet the object to track with the parent of this actuator.\n";
+PyObject* KX_TrackToActuator::PySetObject(PyObject* value)
+{
+       KX_GameObject *gameobj;
+       
+       ShowDeprecationWarning("setObject()", "the object property");
+       
+       if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.setObject(value): KX_TrackToActuator"))
+               return NULL; // ConvertPythonToGameObject sets the error
+       
+       if (m_object != NULL)
+               m_object->UnregisterActuator(this);     
+
+       m_object = (SCA_IObject*)gameobj;
+       if (m_object)
+               m_object->RegisterActuator(this);
+       
+       Py_RETURN_NONE;
+}
+
+
+
+/* 2. getObject */
+const char KX_TrackToActuator::GetObject_doc[] = 
+"getObject(name_only = 1)\n"
+"name_only - optional arg, when true will return the KX_GameObject rather then its name\n"
+"\tReturns the object to track with the parent of this actuator\n";
+PyObject* KX_TrackToActuator::PyGetObject(PyObject* args)
+{
+       int ret_name_only = 1;
+       
+       ShowDeprecationWarning("getObject()", "the object property");
+       
+       if (!PyArg_ParseTuple(args, "|i:getObject", &ret_name_only))
+               return NULL;
+       
+       if (!m_object)
+               Py_RETURN_NONE;
+       
+       if (ret_name_only)
+               return PyUnicode_FromString(m_object->GetName());
+       else
+               return m_object->GetProxy();
+}
+
+
+
+/* 3. setTime */
+const char KX_TrackToActuator::SetTime_doc[] = 
+"setTime(time)\n"
+"\t- time: integer\n"
+"\tSet the time in frames with which to delay the tracking motion.\n";
+PyObject* KX_TrackToActuator::PySetTime(PyObject* args)
+{
+       ShowDeprecationWarning("setTime()", "the timer property");
+       int timeArg;
+       
+       if (!PyArg_ParseTuple(args, "i:setTime", &timeArg))
+       {
+               return NULL;
+       }
+       
+       m_time= timeArg;
+       
+       Py_RETURN_NONE;
+}
+
+
+
+/* 4.getTime */
+const char KX_TrackToActuator::GetTime_doc[] = 
+"getTime()\n"
+"\t- time: integer\n"
+"\tReturn the time in frames with which the tracking motion is delayed.\n";
+PyObject* KX_TrackToActuator::PyGetTime()
+{
+       ShowDeprecationWarning("getTime()", "the timer property");
+       return PyLong_FromSsize_t(m_time);
+}
+
+
+
+/* 5. getUse3D */
+const char KX_TrackToActuator::GetUse3D_doc[] = 
+"getUse3D()\n"
+"\tReturns 1 if the motion is allowed to extend in the z-direction.\n";
+PyObject* KX_TrackToActuator::PyGetUse3D()
+{
+       ShowDeprecationWarning("setTime()", "the use3D property");
+       return PyLong_FromSsize_t(!(m_allow3D == 0));
+}
+
+
+
+/* 6. setUse3D */
+const char KX_TrackToActuator::SetUse3D_doc[] = 
+"setUse3D(value)\n"
+"\t- value: 0 or 1\n"
+"\tSet to 1 to allow the tracking motion to extend in the z-direction,\n"
+"\tset to 0 to lock the tracking motion to the x-y plane.\n";
+PyObject* KX_TrackToActuator::PySetUse3D(PyObject* args)
+{
+       ShowDeprecationWarning("setTime()", "the use3D property");
+       int boolArg;
+       
+       if (!PyArg_ParseTuple(args, "i:setUse3D", &boolArg)) {
+               return NULL;
+       }
+       
+       m_allow3D = !(boolArg == 0);
+       
+       Py_RETURN_NONE;
+}
+
 /* eof */