Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMichel Selten <michel@mselten.demon.nl>2004-04-02 22:38:38 +0400
committerMichel Selten <michel@mselten.demon.nl>2004-04-02 22:38:38 +0400
commit7cc4d7525d401048068e34376d6095edc1341f79 (patch)
tree6813ed0404c5745371039565ba3c31b218689ce8 /source
parent8e5fd5bba355be855f851415f6a93d0e8f0d87d5 (diff)
Python API fixes. Provided by Anders Nilsson (breakin)
* Typo fixed in IpoCurve_getInterpolation. 'Bonstant' was used, while 'Constant' is what we want. * IpoCurve.getName now also returns curve names for action-IPOs. * Update to the Object module: Added obj.getTimeOffset() and obj.setTimeOffset() methods Anders Nilsson has promissed me to provide some updated Python API docs :)
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/Ipocurve.c65
-rw-r--r--source/blender/python/api2_2x/Object.c33
2 files changed, 77 insertions, 21 deletions
diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c
index d5af53dfc00..78cd12f299c 100644
--- a/source/blender/python/api2_2x/Ipocurve.c
+++ b/source/blender/python/api2_2x/Ipocurve.c
@@ -224,7 +224,7 @@ IpoCurve_getInterpolation (C_IpoCurve * self)
if (icu->ipo == IPO_BEZ)
str = "Bezier";
if (icu->ipo == IPO_CONST)
- str = "Bonstant";
+ str = "Constant";
if (icu->ipo == IPO_LIN)
str = "Linear";
@@ -290,7 +290,7 @@ IpoCurve_addBezier (C_IpoCurve * self, PyObject * args)
PyObject *popo = 0;
if (!PyArg_ParseTuple (args, "O", &popo))
return (EXPP_ReturnPyObjError
- (PyExc_TypeError, "expected tuple argument"));
+ (PyExc_TypeError, "expected tuple argument"));
x = PyFloat_AsDouble (PyTuple_GetItem (popo, 0));
y = PyFloat_AsDouble (PyTuple_GetItem (popo, 1));
@@ -341,28 +341,51 @@ IpoCurve_Recalc (C_IpoCurve * self)
static PyObject *
IpoCurve_getName (C_IpoCurve * self)
{
- char *nametab[24] =
- { "LocX", "LocY", "LocZ", "dLocX", "dLocY", "dLocZ", "RotX", "RotY",
- "RotZ", "dRotX", "dRotY", "dRotZ", "SizeX", "SizeY", "SizeZ", "dSizeX",
- "dSizeY",
- "dSizeZ", "Layer", "Time", "ColR", "ColG", "ColB", "ColA"
- };
-
- if (self->ipocurve->blocktype != ID_OB)
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "This function doesn't support this ipocurve type yet");
-
- // printf("IpoCurve_getName %d\n",self->ipocurve->vartype);
- if (self->ipocurve->adrcode <= 0)
- return PyString_FromString ("Index too small");
- if (self->ipocurve->adrcode >= 25)
- return PyString_FromString ("Index too big");
-
- return PyString_FromString (nametab[self->ipocurve->adrcode - 1]);
+ const int objectType=self->ipocurve->blocktype;
+ const int trackType=self->ipocurve->adrcode;
+
+ const char * ob_nametab[24] = {"LocX","LocY","LocZ","dLocX","dLocY","dLocZ",
+ "RotX","RotY","RotZ","dRotX","dRotY","dRotZ","SizeX","SizeY","SizeZ",
+ "dSizeX","dSizeY","dSizeZ","Layer","Time","ColR","ColG","ColB","ColA"};
+
+ const char * ac_nametab[5] = {"QuatW", "QuatX", "QuatY", "QuatZ","TotIpo"};
+
+ switch (objectType) {
+ case ID_OB: {
+ if (self->ipocurve->adrcode <= 0 ) {
+ return PyString_FromString("Index too small");
+ } else if (self->ipocurve->adrcode >= 25 ) {
+ return PyString_FromString("Index too big");
+ } else {
+ return PyString_FromString(ob_nametab[trackType-1]);
+ }
+ }
+ break;
+
+ case ID_AC: {
+ switch (trackType) {
+ case 1: case 2: case 3: case 13: case 14: case 15:
+ return PyString_FromString(ob_nametab[trackType-1]);
+ break;
+
+ case 25: case 26: case 27: case 28:
+ return PyString_FromString(ac_nametab[trackType-25]);
+ break;
+ case 10:
+ return PyString_FromString(ac_nametab[4]);
+ break;
+ default:
+ return PyString_FromString("Index out of range");
+ }
+ }
+ break;
+ default:
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "This function doesn't support this ipocurve type yet");
+ }
}
-
static void
IpoCurveDeAlloc (C_IpoCurve * self)
{
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index 3bc293dffb2..1674413afa7 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -102,6 +102,7 @@ static PyObject *Object_getMatrix (BPy_Object *self);
static PyObject *Object_getName (BPy_Object *self);
static PyObject *Object_getParent (BPy_Object *self);
static PyObject *Object_getSize (BPy_Object *self, PyObject *args);
+static PyObject *Object_getTimeOffset (BPy_Object *self);
static PyObject *Object_getTracked (BPy_Object *self);
static PyObject *Object_getType (BPy_Object *self);
static PyObject *Object_getBoundBox (BPy_Object *self);
@@ -119,6 +120,7 @@ static PyObject *Object_setLocation (BPy_Object *self, PyObject *args);
static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args);
static PyObject *Object_setName (BPy_Object *self, PyObject *args);
static PyObject *Object_setSize (BPy_Object *self, PyObject *args);
+static PyObject *Object_setTimeOffset (BPy_Object *self, PyObject *args);
static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args);
/*****************************************************************************/
@@ -159,6 +161,8 @@ hierarchy (faster)"},
"Returns the object's parent object"},
{"getSize", (PyCFunction)Object_getSize, METH_VARARGS,
"Returns the object's size (x, y, z)"},
+ {"getTimeOffset", (PyCFunction)Object_getTimeOffset, METH_NOARGS,
+ "Returns the object's time offset"},
{"getTracked", (PyCFunction)Object_getTracked, METH_NOARGS,
"Returns the object's tracked object"},
{"getType", (PyCFunction)Object_getType, METH_NOARGS,
@@ -208,6 +212,8 @@ objects."},
{"setSize", (PyCFunction)Object_setSize, METH_VARARGS,
"Set the object's size. The first argument must be a vector\n\
triple."},
+ {"setTimeOffset", (PyCFunction)Object_setTimeOffset, METH_VARARGS,
+ "Set the object's time offset."},
{"shareFrom", (PyCFunction)Object_shareFrom, METH_VARARGS,
"Link data of self with object specified in the argument. This\n\
works only if self and the object specified are of the same type."},
@@ -843,6 +849,17 @@ static PyObject *Object_getSize (BPy_Object *self, PyObject *args)
"couldn't get Object.size attributes"));
}
+static PyObject *Object_getTimeOffset (BPy_Object *self)
+{
+ PyObject *attr = Py_BuildValue ("f", self->object->sf);
+
+ if (attr) return (attr);
+
+ return (PythonReturnErrorObject (PyExc_RuntimeError,
+ "couldn't get Object.sf attributes"));
+}
+
+
static PyObject *Object_getTracked (BPy_Object *self)
{
PyObject *attr;
@@ -1390,6 +1407,22 @@ static PyObject *Object_setSize (BPy_Object *self, PyObject *args)
return (Py_None);
}
+static PyObject *Object_setTimeOffset (BPy_Object *self, PyObject *args)
+{
+ float newTimeOffset;
+
+ if (!PyArg_ParseTuple (args, "f", &newTimeOffset))
+ {
+ return (PythonReturnErrorObject (PyExc_AttributeError,
+ "expected a float as argument"));
+ }
+
+ self->object->sf=newTimeOffset;
+
+ Py_INCREF (Py_None);
+ return (Py_None);
+}
+
static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args)
{
BPy_Object * object;