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
diff options
context:
space:
mode:
authorJacques Guignot <guignot@wanadoo.fr>2003-10-26 19:54:33 +0300
committerJacques Guignot <guignot@wanadoo.fr>2003-10-26 19:54:33 +0300
commitcfa48583ae1dd32a8d1575447c659c9786b0f406 (patch)
tree9f649ae933256365f4c2da42ce0ee3634a9edbb1 /source/blender
parent6b1b9c1890633fb45c7e1f826d2fb2cb491f68aa (diff)
added a new function : getCurve(string) allowing access to an ipo curve from its name.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/python/api2_2x/Ipo.c104
-rw-r--r--source/blender/python/api2_2x/Ipo.h3
2 files changed, 91 insertions, 16 deletions
diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c
index 1c506199324..f243cfb9b23 100644
--- a/source/blender/python/api2_2x/Ipo.c
+++ b/source/blender/python/api2_2x/Ipo.c
@@ -53,7 +53,7 @@ static PyObject *M_Ipo_New(PyObject *self, PyObject *args)
if (!strcmp(code,"Material"))idcode = ID_MA;
if (idcode == -1)
return (EXPP_ReturnPyObjError (PyExc_TypeError,"Bad code"));
-
+ printf("%d %d %d \n", ID_OB, ID_CA, ID_WO);
blipo = add_ipo(name,idcode);
if (blipo)
@@ -264,27 +264,89 @@ static PyObject *Ipo_getNcurves(C_Ipo *self)
}
+int num_from_type(char*type,int ipotype)
+{
+ int i = 0,typenumber = -1,tabsize;
+ if (ipotype == ID_OB)
+ {
+ 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"};
+ tabsize = 24;
+ for(i = 0;i<tabsize;i++)
+ if(!strcmp(nametab[i],type))
+ typenumber=i+1;
+
+ }
+ if (ipotype == ID_CA)
+ {
+ char*nametab[3] = {"Lens","ClSta","ClEnd"};
+ tabsize = 3;
+ for(i = 0;i<tabsize;i++)
+ if(!strcmp(nametab[i],type))
+ typenumber=i+1;
+ }
+ if (ipotype == ID_WO)
+ {
+ char*nametab[29] = {"HorR","HorG","HorB","ZenR","ZenG","ZenB","Expos","Misi","MisDi","MisSta","MisHi","StaR","StaG","StaB","StarDi","StarSi","OfsX","OfsY","OfsZ","SizeX","SizeY","SizeZ","TexR","TexG","TexB","DefVar","Col","Nor","Var"};
+ tabsize = 29;
+ for(i = 0;i<tabsize;i++)
+ if(!strcmp(nametab[i],type))
+ typenumber=i+1;
+ }
+ if (ipotype == ID_MA)
+ {
+ char*nametab[32] = {"R","G","B","SpecR","SpecG","SpecB","MirR","MirG","MirB","Ref","Alpha","Emit","Amb","Spec","Hard","SpTra","Ang","Mode","HaSize","OfsX","OfsY","OfsZ","SizeX","SizeY","SizeZ","TexR","TexG","TexB","DefVar","Col","Nor","Var"};
+ tabsize = 32;
+ for(i = 0;i<tabsize;i++)
+ if(!strcmp(nametab[i],type))
+ typenumber=i+1;
+ }
+
+ return typenumber;
+}
+
+char* type_from_num(int num,int ipotype)
+{
+
+ if (ipotype == ID_CA)
+ {
+ char * nametab[3] = {"Lens","ClSta","ClEnd"};
+ return nametab[num-1];
+ }
+ if (ipotype == ID_OB)
+ {
+ 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"};
+ return nametab[num-1];
+ }
+ if (ipotype == ID_WO)
+ {
+ char*nametab[29] = {"HorR","HorG","HorB","ZenR","ZenG","ZenB","Expos","Misi","MisDi","MisSta","MisHi","StaR","StaG","StaB","StarDi","StarSi","OfsX","OfsY","OfsZ","SizeX","SizeY","SizeZ","TexR","TexG","TexB","DefVar","Col","Nor","Var"};
+ return nametab[num-1];
+ }
+ if (ipotype == ID_MA)
+ {
+ char*nametab[32] = {"R","G","B","SpecR","SpecG","SpecB","MirR","MirG","MirB","Ref","Alpha","Emit","Amb","Spec","Hard","SpTra","Ang","Mode","HaSize","OfsX","OfsY","OfsZ","SizeX","SizeY","SizeZ","TexR","TexG","TexB","DefVar","Col","Nor","Var"};
+ return nametab[num-1];
+ }
+ return 0;
+}
+
static PyObject *Ipo_addCurve(C_Ipo *self, PyObject *args)
{
void *MEM_callocN(unsigned int len, char *str);
IpoCurve *ptr;
- int i = 0,typenumber = -1;
+ int typenumber = -1;
char*type = 0;
- static char *name="mmm";
- 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"};
+ static char *name="mmm";
if (!PyArg_ParseTuple(args, "s",&type))
return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument"));
- for(i = 0;i<24;i++)
- if(!strcmp(nametab[i],type))
- typenumber=i+1;
-
+ typenumber = num_from_type(type,self->ipo->blocktype);
if (typenumber == -1)
return (EXPP_ReturnPyObjError (PyExc_TypeError, "unknown type"));
ptr = (IpoCurve*)MEM_callocN(sizeof(IpoCurve),name);
- ptr->blocktype = 16975;
+ ptr->blocktype = ID_OB;
ptr->totvert = 0;
ptr->adrcode = typenumber;
ptr->ipo = 2;
@@ -295,6 +357,21 @@ static PyObject *Ipo_addCurve(C_Ipo *self, PyObject *args)
return IpoCurve_CreatePyObject (ptr);
}
+static PyObject *Ipo_getCurve(C_Ipo *self, PyObject *args)
+{
+ int num = 0 , i = 0;
+ char*str;
+ IpoCurve *icu = 0;
+ if (!PyArg_ParseTuple(args, "s",&str))
+ return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument"));
+ puts(str);
+ for (icu=self->ipo->curve.first; icu; icu=icu->next){
+ if (!strcmp(type_from_num(icu->adrcode, icu->blocktype),str))return IpoCurve_CreatePyObject(icu);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
static PyObject *Ipo_getCurves(C_Ipo *self)
{
@@ -523,7 +600,7 @@ static int IpoSetAttr (C_Ipo *self, char *name, PyObject *value)
/*****************************************************************************/
static PyObject *IpoRepr (C_Ipo *self)
{
- return PyString_FromFormat("[Ipo \"%s\"]", self->ipo->id.name+2);
+ return PyString_FromFormat("[Ipo \"%s\" %d]", self->ipo->id.name+2,self->ipo->blocktype);
}
/* Three Python Ipo_Type helper functions needed by the Object module: */
@@ -536,15 +613,10 @@ static PyObject *IpoRepr (C_Ipo *self)
PyObject *Ipo_CreatePyObject (Ipo *ipo)
{
C_Ipo *pyipo;
-
pyipo = (C_Ipo *)PyObject_NEW (C_Ipo, &Ipo_Type);
-
if (!pyipo)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create C_Ipo object");
-
+ return EXPP_ReturnPyObjError (PyExc_MemoryError,"couldn't create C_Ipo object");
pyipo->ipo = ipo;
-
return (PyObject *)pyipo;
}
diff --git a/source/blender/python/api2_2x/Ipo.h b/source/blender/python/api2_2x/Ipo.h
index 28e45e84ffb..c71a38dca85 100644
--- a/source/blender/python/api2_2x/Ipo.h
+++ b/source/blender/python/api2_2x/Ipo.h
@@ -93,6 +93,7 @@ static PyObject *Ipo_setBlocktype(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getRctf(C_Ipo *self);
static PyObject *Ipo_setRctf(C_Ipo *self, PyObject *args);
+static PyObject *Ipo_getCurve(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getCurves(C_Ipo *self);
static PyObject *Ipo_addCurve(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getNcurves(C_Ipo *self);
@@ -143,6 +144,8 @@ static PyMethodDef C_Ipo_methods[] = {
"() - Return curval"},
{"getCurves", (PyCFunction)Ipo_getCurves, METH_NOARGS,
"() - Return curval"},
+ {"getCurve", (PyCFunction)Ipo_getCurve, METH_VARARGS,
+ "() - Return curval"},
{0}
};