diff options
author | Ton Roosendaal <ton@blender.org> | 2004-07-27 01:44:55 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2004-07-27 01:44:55 +0400 |
commit | 73f1da749b5e721005dec2dec27134074f7e7679 (patch) | |
tree | 1e7e44c3ff5ab4b45ec49f9a6eeb6c293000aa72 /source/blender | |
parent | 0437f23008e7b3932e4febff26abb81182811c86 (diff) |
Nathan's huge ipo patch.
- now more than 31 channels possible for ipos
- added lotsa new channels all over
- Texture block has ipo now too
- recoded getname_ei functions
(Will ask nathan to give release log info when he's back!)
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_texture.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/ipo.c | 144 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 43 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 1 | ||||
-rw-r--r-- | source/blender/include/BSE_editipo.h | 27 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_ipo_types.h | 44 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Ipo.c | 978 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Ipocurve.c | 64 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Lamp.c | 78 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Lamp.h | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Texture.c | 119 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Ipo.py | 61 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Lamp.py | 20 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Texture.py | 19 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/World.py | 10 | ||||
-rw-r--r-- | source/blender/python/api2_2x/modules.h | 6 |
16 files changed, 1463 insertions, 154 deletions
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index dc1856a4803..23c31564a66 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -59,6 +59,7 @@ struct MTex *add_mtex(void); struct Tex *copy_texture(struct Tex *tex); void make_local_texture(struct Tex *tex); void autotexname(struct Tex *tex); +struct Tex *give_current_texture(struct Object *ob, int act); #endif diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 581877cf42e..1f4ecf133d3 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -115,6 +115,20 @@ int ma_ar[MA_TOTIPO]= { MA_MAP1+MAP_DVAR, MA_MAP1+MAP_COLF, MA_MAP1+MAP_NORF, MA_MAP1+MAP_VARF, MA_MAP1+MAP_DISP }; +int te_ar[TE_TOTIPO] ={ + + TE_NSIZE, TE_NDEPTH, TE_NTYPE, TE_TURB, + + TE_VNW1, TE_VNW2, TE_VNW3, TE_VNW4, + TE_VNMEXP, TE_VN_COLT, TE_VN_DISTM, + + TE_ISCA, TE_DISTA, + + TE_MG_TYP, TE_MGH, TE_MG_LAC, TE_MG_OCT, TE_MG_OFF, TE_MG_GAIN, + + TE_N_BAS1, TE_N_BAS2 +}; + int seq_ar[SEQ_TOTIPO]= { SEQ_FAC1 }; @@ -860,6 +874,58 @@ float read_ipo_poin(void *poin, int type) return val; } +void *give_tex_poin(Tex *tex, int adrcode, int *type ) +{ + void *poin=0; + + switch(adrcode) { + case TE_NSIZE: + poin= &(tex->noisesize); break; + case TE_TURB: + poin= &(tex->turbul); break; + case TE_NDEPTH: + poin= &(tex->noisedepth); *type= IPO_SHORT; break; + case TE_NTYPE: + poin= &(tex->noisetype); *type= IPO_SHORT; break; + case TE_VNW1: + poin= &(tex->vn_w1); break; + case TE_VNW2: + poin= &(tex->vn_w2); break; + case TE_VNW3: + poin= &(tex->vn_w3); break; + case TE_VNW4: + poin= &(tex->vn_w4); break; + case TE_VNMEXP: + poin= &(tex->vn_mexp); break; + case TE_ISCA: + poin= &(tex->ns_outscale); break; + case TE_DISTA: + poin= &(tex->dist_amount); break; + case TE_VN_COLT: + poin= &(tex->vn_coltype); *type= IPO_SHORT; break; + case TE_VN_DISTM: + poin= &(tex->vn_distm); *type= IPO_SHORT; break; + case TE_MG_TYP: + poin= &(tex->stype); *type= IPO_SHORT; break; + case TE_MGH: + poin= &(tex->mg_H); break; + case TE_MG_LAC: + poin= &(tex->mg_lacunarity); break; + case TE_MG_OCT: + poin= &(tex->mg_octaves); break; + case TE_MG_OFF: + poin= &(tex->mg_offset); break; + case TE_MG_GAIN: + poin= &(tex->mg_gain); break; + case TE_N_BAS1: + poin= &(tex->noisebasis); *type= IPO_SHORT; break; + case TE_N_BAS2: + poin= &(tex->noisebasis2); *type= IPO_SHORT; break; + } + + return poin; +} + void *give_mtex_poin(MTex *mtex, int adrcode ) { void *poin=0; @@ -917,6 +983,7 @@ void *get_ipo_poin(ID *id, IpoCurve *icu, int *type) Object *ob; Material *ma; MTex *mtex; + Tex *tex; Lamp *la; Sequence *seq; World *wo; @@ -1107,6 +1174,11 @@ void *get_ipo_poin(ID *id, IpoCurve *icu, int *type) } } } + else if( GS(id->name)==ID_TE) { + tex= (Tex *)id; + + if(tex) poin= give_tex_poin(tex, icu->adrcode, type); + } else if( GS(id->name)==ID_SEQ) { seq= (Sequence *)id; @@ -1334,6 +1406,63 @@ void set_icu_vars(IpoCurve *icu) } } } + else if(icu->blocktype==ID_TE) { + switch(icu->adrcode & (MA_MAP1-1)) { + case TE_NSIZE: + icu->ymin= 0.0001; + icu->ymax= 2.0; break; + case TE_NDEPTH: + icu->vartype= IPO_SHORT; + icu->ipo= IPO_CONST; + icu->ymax= 6.0; break; + case TE_NTYPE: + icu->vartype= IPO_SHORT; + icu->ipo= IPO_CONST; + icu->ymax= 1.0; break; + case TE_TURB: + icu->ymax= 200.0; break; + case TE_VNW1: + case TE_VNW2: + case TE_VNW3: + case TE_VNW4: + icu->ymax= 2.0; + icu->ymin= -2.0; break; + case TE_VNMEXP: + icu->ymax= 10.0; + icu->ymin= 0.01; break; + case TE_VN_DISTM: + icu->vartype= IPO_SHORT; + icu->ipo= IPO_CONST; + icu->ymax= 6.0; break; + case TE_VN_COLT: + icu->vartype= IPO_SHORT; + icu->ipo= IPO_CONST; + icu->ymax= 3.0; break; + case TE_ISCA: + icu->ymax= 10.0; + icu->ymin= 0.01; break; + case TE_DISTA: + icu->ymax= 10.0; break; + case TE_MG_TYP: + icu->vartype= IPO_SHORT; + icu->ipo= IPO_CONST; + icu->ymax= 4.0; break; + case TE_MGH: + icu->ymin= 0.0001; + icu->ymax= 2.0; break; + case TE_MG_LAC: + case TE_MG_OFF: + case TE_MG_GAIN: + icu->ymax= 6.0; break; + case TE_MG_OCT: + icu->ymax= 8.0; break; + case TE_N_BAS1: + case TE_N_BAS2: + icu->vartype= IPO_SHORT; + icu->ipo= IPO_CONST; + icu->ymax= 8.0; break; + } + } else if(icu->blocktype==ID_SEQ) { icu->ymax= 1.0; @@ -1489,6 +1618,7 @@ void do_ipo_nocalc(Ipo *ipo) { Object *ob; Material *ma; + Tex *tex; World *wo; Lamp *la; Camera *ca; @@ -1514,6 +1644,13 @@ void do_ipo_nocalc(Ipo *ipo) ma= ma->id.next; } break; + case ID_TE: + tex= G.main->tex.first; + while(tex) { + if(tex->ipo==ipo) execute_ipo((ID *)tex, ipo); + tex=tex->id.next; + } + break; case ID_WO: wo= G.main->world.first; while(wo) { @@ -1643,6 +1780,7 @@ void do_all_ipos() { Base *base; Material *ma; + Tex *tex; World *wo; Ipo *ipo; Lamp *la; @@ -1684,6 +1822,12 @@ void do_all_ipos() } } + tex= G.main->tex.first; + while(tex) { + if(tex->ipo) execute_ipo((ID *)tex, tex->ipo); + tex= tex->id.next; + } + ma= G.main->mat.first; while(ma) { if(ma->ipo) execute_ipo((ID *)ma, ma->ipo); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 2507ca5c2b8..95168c4c016 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -76,6 +76,7 @@ #include "BKE_library.h" #include "BKE_image.h" +#include "BKE_material.h" #include "BKE_texture.h" #include "BKE_key.h" #include "BKE_ipo.h" @@ -600,5 +601,43 @@ void autotexname(Tex *tex) /* ------------------------------------------------------------------------- */ - -/* eof */ +Tex *give_current_texture(Object *ob, int act) +{ + Material ***matarar, *ma; + Lamp *la = 0; + MTex *mtex = 0; + Tex *tex = 0; + + if(ob==0) return 0; + if(ob->totcol==0) return 0; + + if(ob->type==OB_LAMP) { + la=(Lamp *)ob->data; + if(la) { + mtex= la->mtex[(int)(la->texact)]; + if(mtex) tex= mtex->tex; + } + else tex= 0; + } else { + if(act>ob->totcol) act= ob->totcol; + else if(act==0) act= 1; + + if( BTST(ob->colbits, act-1) ) { /* in object */ + ma= ob->mat[act-1]; + } + else { /* in data */ + matarar= give_matarar(ob); + + if(matarar && *matarar) ma= (*matarar)[act-1]; + else ma= 0; + + } + if(ma) { + mtex= ma->mtex[(int)(ma->texact)]; + if(mtex) tex= mtex->tex; + } + else tex= 0; + } + + return tex; +} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 9740ee738ca..d100e35f42f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4473,6 +4473,7 @@ static void expand_key(FileData *fd, Main *mainvar, Key *key) static void expand_texture(FileData *fd, Main *mainvar, Tex *tex) { expand_doit(fd, mainvar, tex->ima); + expand_doit(fd, mainvar, tex->ipo); } static void expand_material(FileData *fd, Main *mainvar, Material *ma) diff --git a/source/blender/include/BSE_editipo.h b/source/blender/include/BSE_editipo.h index a3f82a83b06..d42a176b35e 100644 --- a/source/blender/include/BSE_editipo.h +++ b/source/blender/include/BSE_editipo.h @@ -43,20 +43,22 @@ struct ListBase; struct Object; struct IpoKey; struct TransOb; +struct Tex; void remake_object_ipos(struct Object *ob); -void getname_ac_ei(int nr, char *str); -void getname_co_ei(int nr, char *str); -void getname_ob_ei(int nr, char *str, int colipo); -void getname_tex_ei(int nr, char *str); -void getname_mat_ei(int nr, char *str); -void getname_world_ei(int nr, char *str); -void getname_seq_ei(int nr, char *str); -void getname_cu_ei(int nr, char *str); -void getname_key_ei(int nr, char *str); -void getname_la_ei(int nr, char *str); -void getname_cam_ei(int nr, char *str); -void getname_snd_ei(int nr, char *str); +char *getname_ac_ei(int nr); +char *getname_co_ei(int nr); +char *getname_ob_ei(int nr, int colipo); +char *getname_mtex_ei(int nr); +char *getname_tex_ei(int nr); +char *getname_mat_ei(int nr); +char *getname_world_ei(int nr); +char *getname_seq_ei(int nr); +char *getname_cu_ei(int nr); +char *getname_key_ei(int nr); +char *getname_la_ei(int nr); +char *getname_cam_ei(int nr); +char *getname_snd_ei(int nr); struct IpoCurve *find_ipocurve(struct Ipo *ipo, int adrcode); void boundbox_ipocurve(struct IpoCurve *icu); void boundbox_ipo(struct Ipo *ipo, struct rctf *bb); @@ -71,6 +73,7 @@ void make_key_editipo(struct SpaceIpo *si); int texchannel_to_adrcode(int channel); void make_mat_editipo(struct SpaceIpo *si); void make_world_editipo(struct SpaceIpo *si); +void make_texture_editipo(struct SpaceIpo *si); void make_lamp_editipo(struct SpaceIpo *si); void make_camera_editipo(struct SpaceIpo *si); int make_action_editipo(struct Ipo *ipo, struct EditIpo **si); diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h index b18cacedb63..84f6f79ca53 100644 --- a/source/blender/makesdna/DNA_ipo_types.h +++ b/source/blender/makesdna/DNA_ipo_types.h @@ -69,6 +69,7 @@ typedef short IPO_Channel; /* ******************** */ #define OB_TOTIPO 29 +#define OB_TOTNAM 29 #define OB_LOC_X 1 #define OB_LOC_Y 2 @@ -115,6 +116,7 @@ typedef short IPO_Channel; /* ******************** */ #define MA_TOTIPO 40 +#define MA_TOTNAM 26 #define MA_COL_R 1 #define MA_COL_G 2 @@ -152,6 +154,8 @@ typedef short IPO_Channel; #define MA_MAP7 0x800 #define MA_MAP8 0x1000 +#define TEX_TOTNAM 14 + #define MAP_OFS_X 1 #define MAP_OFS_Y 2 #define MAP_OFS_Z 3 @@ -170,19 +174,53 @@ typedef short IPO_Channel; /* ******************** */ +#define TE_TOTIPO 21 +#define TE_TOTNAM 21 + +#define TE_NSIZE 1 +#define TE_NDEPTH 2 +#define TE_NTYPE 3 +#define TE_TURB 4 + +#define TE_VNW1 5 +#define TE_VNW2 6 +#define TE_VNW3 7 +#define TE_VNW4 8 +#define TE_VNMEXP 9 +#define TE_VN_DISTM 10 +#define TE_VN_COLT 11 + +#define TE_ISCA 12 +#define TE_DISTA 13 + +#define TE_MG_TYP 14 +#define TE_MGH 15 +#define TE_MG_LAC 16 +#define TE_MG_OCT 17 +#define TE_MG_OFF 18 +#define TE_MG_GAIN 19 + +#define TE_N_BAS1 20 +#define TE_N_BAS2 21 + +/* ******************** */ + #define SEQ_TOTIPO 1 +#define SEQ_TOTNAM 1 #define SEQ_FAC1 1 /* ******************** */ #define CU_TOTIPO 1 +#define CU_TOTNAM 1 #define CU_SPEED 1 /* ******************** */ #define KEY_TOTIPO 32 +#define KEY_TOTNAM 32 #define KEY_SPEED 0 #define KEY_NR 1 @@ -190,6 +228,7 @@ typedef short IPO_Channel; /* ******************** */ #define WO_TOTIPO 29 +#define WO_TOTNAM 16 #define WO_HOR_R 1 #define WO_HOR_G 2 @@ -214,6 +253,7 @@ typedef short IPO_Channel; /* ******************** */ #define LA_TOTIPO 23 +#define LA_TOTNAM 10 #define LA_ENERGY 1 #define LA_COL_R 2 @@ -229,6 +269,7 @@ typedef short IPO_Channel; /* ******************** */ #define CAM_TOTIPO 3 +#define CAM_TOTNAM 3 #define CAM_LENS 1 #define CAM_STA 2 @@ -238,6 +279,7 @@ typedef short IPO_Channel; /* ******************** */ #define SND_TOTIPO 4 +#define SND_TOTNAM 4 #define SND_VOLUME 1 #define SND_PITCH 2 @@ -247,6 +289,7 @@ typedef short IPO_Channel; /* ******************** */ #define AC_TOTIPO 10 /* __NLA */ +#define AC_TOTNAM 10 #define AC_LOC_X 1 #define AC_LOC_Y 2 @@ -263,6 +306,7 @@ typedef short IPO_Channel; /* ******************** */ #define CO_TOTIPO 1 /* Constraint Ipos */ +#define CO_TOTNAM 1 #define CO_ENFORCE 1 /* diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c index 9033219e764..68224ca4695 100644 --- a/source/blender/python/api2_2x/Ipo.c +++ b/source/blender/python/api2_2x/Ipo.c @@ -24,7 +24,7 @@ * * This is a new part of Blender. * - * Contributor(s): Jacques Guignot + * Contributor(s): Jacques Guignot, Nathan Letwory * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ @@ -35,6 +35,7 @@ #include <BKE_global.h> #include <BKE_object.h> #include <BKE_library.h> +#include <BSE_editipo.h> #include <BLI_blenlib.h> #include "constant.h" @@ -43,11 +44,7 @@ /* forward declarations */ -void GetIpoCurveName (IpoCurve * icu, char *s); -void getname_mat_ei (int nr, char *str); -void getname_world_ei (int nr, char *str); -void getname_cam_ei (int nr, char *str); -void getname_ob_ei (int nr, char *str); +char *GetIpoCurveName (IpoCurve * icu); /*****************************************************************************/ /* Python API function prototypes for the Ipo module. */ @@ -206,6 +203,18 @@ M_Ipo_New (PyObject * self, PyObject * args) idcode = ID_WO; if (!strcmp (code, "Material")) idcode = ID_MA; + if (!strcmp (code, "Texture")) + idcode = ID_TE; + if (!strcmp (code, "Lamp")) + idcode = ID_LA; +/* if (!strcmp (code, "Constraint")) + idcode = IPO_CO; + if (!strcmp (code, "Sequence")) + idcode = ID_SEQ;*/ + if (!strcmp (code, "Curve")) + idcode = ID_CU; + if (!strcmp (code, "Key")) + idcode = ID_KE; if (idcode == -1) return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad code")); @@ -444,172 +453,959 @@ Ipo_getNcurves (BPy_Ipo * self) return (PyInt_FromLong (i)); } +int Ipo_laIcuName(char * s, int * param) +{ + int ok = 0; + if (!strcmp (s, "Energy")) + { + *param = LA_ENERGY; + ok = 1; + } + if (!strcmp (s, "R")) + { + *param = LA_COL_R; + ok = 1; + } + if (!strcmp (s, "G")) + { + *param = LA_COL_G; + ok = 1; + } + if (!strcmp (s, "B")) + { + *param = LA_COL_B; + ok = 1; + } + if (!strcmp (s, "Dist")) + { + *param = LA_DIST; + ok = 1; + } + if (!strcmp (s, "SpoSi")) + { + *param = LA_SPOTSI; + ok = 1; + } + if (!strcmp (s, "SpoBl")) + { + *param = LA_SPOTBL; + ok = 1; + } + if (!strcmp (s, "Quad1")) + { + *param = LA_QUAD1; + ok = 1; + } + if (!strcmp (s, "Quad2")) + { + *param = LA_QUAD2; + ok = 1; + } + if (!strcmp (s, "HaInt")) + { + *param = LA_HALOINT; + ok = 1; + } + return ok; +} -static PyObject * -Ipo_addCurve (BPy_Ipo * self, PyObject * args) +int Ipo_woIcuName(char * s, int * param) { - IpoCurve *get_ipocurve (ID * from, short type, int adrcode, Ipo * useipo); - void allspace (unsigned short event, short val); - void allqueue (unsigned short event, short val); - int param = 0, ok = 0; - char *s = 0; - IpoCurve *icu; - Link *link; - struct Object *object = NULL; + int ok = 0; + if (!strcmp (s, "HorR")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "HorG")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "HorB")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "ZenR")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "ZenG")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "ZenB")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "Expos")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "Misi")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "MisDi")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "MisHi")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "StarR")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "StarB")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "StarG")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "ClSta")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "StarDi")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "StarSi")) + { + *param = CAM_END; + ok = 1; + } + return ok; +} - if (!PyArg_ParseTuple (args, "s", &s)) - return (EXPP_ReturnPyObjError - (PyExc_TypeError, "expected string argument")); +int Ipo_maIcuName(char * s, int * param) +{ + int ok = 0; + if (!strcmp (s, "R")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "G")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "B")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "SpecR")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "SpecG")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "SpecB")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "MirR")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "MirG")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "MirB")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "Ref")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "Alpha")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "Emit")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "Amb")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "Spec")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "Hard")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "SpTra")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "Ior")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "Mode")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "HaSize")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "Translu")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "RayMir")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "FresMir")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "FresMirI")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "FresTra")) + { + *param = CAM_END; + ok = 1; + } + if (!strcmp (s, "FresTraI")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "TraGlow")) + { + *param = CAM_STA; + ok = 1; + } + return ok; +} - /* insertkey demande un pointeur sur l'objet pour lequel on veut ajouter - une courbe IPO */ - link = G.main->object.first; - while (link) +int Ipo_keIcuName(char *s, int * param) +{ + char key[10]; + int ok = 0; + int nr = 0; + if (!strcmp (s, "Speed")) { - object = (Object *) link; - if (object->ipo == self->ipo) - break; - link = link->next; + *param = KEY_SPEED; + ok = 1; + } + for(nr = 1; nr<32; nr++) { + sprintf(key, "Key %d", nr); + if (!strcmp (s, key)) { + *param = nr; + ok = 1; + break; + } + } + + return ok; +} + +int Ipo_seqIcuName(char *s, int * param) +{ + int ok = 0; + if (!strcmp (s, "Fac")) + { + *param = SEQ_FAC1; + ok = 1; + } + + return ok; +} + +int Ipo_cuIcuName(char *s, int * param) +{ + int ok = 0; + if (!strcmp (s, "Speed")) + { + *param = CU_SPEED; + ok = 1; + } + + return ok; +} + +int Ipo_coIcuName(char *s, int * param) +{ + int ok = 0; + if (!strcmp (s, "Inf")) + { + *param = CO_ENFORCE; + ok = 1; + } + + return ok; +} + +int Ipo_acIcuName(char *s, int * param) +{ + int ok = 0; + if (!strcmp (s, "LocX")) + { + *param = AC_LOC_X; + ok = 1; + } + if (!strcmp (s, "LocY")) + { + *param = AC_LOC_Y; + ok = 1; + } + if (!strcmp (s, "LocZ")) + { + *param = AC_LOC_Z; + ok = 1; + } + if (!strcmp (s, "SizeX")) + { + *param = AC_SIZE_X; + ok = 1; + } + if (!strcmp (s, "SizeY")) + { + *param = AC_SIZE_Y; + ok = 1; + } + if (!strcmp (s, "SizeZ")) + { + *param = AC_SIZE_Z; + ok = 1; + } + if (!strcmp (s, "QuatX")) + { + *param = AC_QUAT_X; + ok = 1; + } + if (!strcmp (s, "QuatY")) + { + *param = AC_QUAT_Y; + ok = 1; + } + if (!strcmp (s, "QuatZ")) + { + *param = AC_QUAT_Z; + ok = 1; } - /* todo : what kind of object.... - #define GS(a) (*((short *)(a))) - printf("object %p\n",object); - printf("type %d\n",GS(object->id.name)); - */ + if (!strcmp (s, "QuatW")) + { + *param = AC_QUAT_W; + ok = 1; + } + return ok; +} +int Ipo_caIcuName(char * s, int * param) +{ + int ok = 0; + if (!strcmp (s, "Lens")) + { + *param = CAM_LENS; + ok = 1; + } + if (!strcmp (s, "ClSta")) + { + *param = CAM_STA; + ok = 1; + } + if (!strcmp (s, "ClEnd")) + { + *param = CAM_END; + ok = 1; + } + return ok; +} + +int Ipo_texIcuName(char * s, int * param) +{ + int ok = 0; + if (!strcmp (s, "NSize")) + { + *param = TE_NSIZE; + ok = 1; + } + if (!strcmp (s, "NDepth")) + { + *param = TE_NDEPTH; + ok = 1; + } + if (!strcmp (s, "NType")) + { + *param = TE_NTYPE; + ok = 1; + } + if (!strcmp (s, "Turb")) + { + *param = TE_TURB; + ok = 1; + } + if (!strcmp (s, "Vnw1")) + { + *param = TE_VNW1; + ok = 1; + } + if (!strcmp (s, "Vnw2")) + { + *param = TE_VNW2; + ok = 1; + } + if (!strcmp (s, "Vnw3")) + { + *param = TE_VNW3; + ok = 1; + } + if (!strcmp (s, "Vnw4")) + { + *param = TE_VNW4; + ok = 1; + } + if (!strcmp (s, "MinkMExp")) + { + *param = TE_VNMEXP; + ok = 1; + } + if (!strcmp (s, "DistM")) + { + *param = TE_VN_DISTM; + ok = 1; + } + if (!strcmp (s, "ColT")) + { + *param = TE_VN_COLT; + ok = 1; + } + if (!strcmp (s, "iScale")) + { + *param = TE_ISCA; + ok = 1; + } + if (!strcmp (s, "DistA")) + { + *param = TE_DISTA; + ok = 1; + } + if (!strcmp (s, "MgType")) + { + *param = TE_MG_TYP; + ok = 1; + } + if (!strcmp (s, "MgH")) + { + *param = TE_MGH; + ok = 1; + } + if (!strcmp (s, "Lacu")) + { + *param = TE_MG_LAC; + ok = 1; + } + if (!strcmp (s, "Oct")) + { + *param = TE_MG_OCT; + ok = 1; + } + if (!strcmp (s, "MgOff")) + { + *param = TE_MG_OFF; + ok = 1; + } + if (!strcmp (s, "MgGain")) + { + *param = TE_MG_GAIN; + ok = 1; + } + if (!strcmp (s, "NBase1")) + { + *param = TE_N_BAS1; + ok = 1; + } + if (!strcmp (s, "NBase2")) + { + *param = TE_N_BAS2; + ok = 1; + } + + return ok; +} + +int Ipo_obIcuName(char * s, int * param) +{ + int ok = 0; if (!strcmp (s, "LocX")) { - param = OB_LOC_X; + *param = OB_LOC_X; ok = 1; } if (!strcmp (s, "LocY")) { - param = OB_LOC_Y; + *param = OB_LOC_Y; ok = 1; } if (!strcmp (s, "LocZ")) { - param = OB_LOC_Z; + *param = OB_LOC_Z; ok = 1; } if (!strcmp (s, "RotX")) { - param = OB_ROT_X; + *param = OB_ROT_X; ok = 1; } if (!strcmp (s, "RotY")) { - param = OB_ROT_Y; + *param = OB_ROT_Y; ok = 1; } if (!strcmp (s, "RotZ")) { - param = OB_ROT_Z; + *param = OB_ROT_Z; ok = 1; } if (!strcmp (s, "SizeX")) { - param = OB_SIZE_X; + *param = OB_SIZE_X; ok = 1; } if (!strcmp (s, "SizeY")) { - param = OB_SIZE_Y; + *param = OB_SIZE_Y; ok = 1; } if (!strcmp (s, "SizeZ")) { - param = OB_SIZE_Z; + *param = OB_SIZE_Z; ok = 1; } if (!strcmp (s, "dLocX")) { - param = OB_DLOC_X; + *param = OB_DLOC_X; ok = 1; } if (!strcmp (s, "dLocY")) { - param = OB_DLOC_Y; + *param = OB_DLOC_Y; ok = 1; } if (!strcmp (s, "dLocZ")) { - param = OB_DLOC_Z; + *param = OB_DLOC_Z; ok = 1; } if (!strcmp (s, "dRotX")) { - param = OB_DROT_X; + *param = OB_DROT_X; ok = 1; } if (!strcmp (s, "dRotY")) { - param = OB_DROT_Y; + *param = OB_DROT_Y; ok = 1; } if (!strcmp (s, "dRotZ")) { - param = OB_DROT_Z; + *param = OB_DROT_Z; ok = 1; } if (!strcmp (s, "dSizeX")) { - param = OB_DSIZE_X; + *param = OB_DSIZE_X; ok = 1; } if (!strcmp (s, "dSizeY")) { - param = OB_DSIZE_Y; + *param = OB_DSIZE_Y; ok = 1; } if (!strcmp (s, "dSizeZ")) { - param = OB_DSIZE_Z; + *param = OB_DSIZE_Z; ok = 1; } if (!strcmp (s, "Layer")) { - param = OB_LAY; + *param = OB_LAY; ok = 1; } if (!strcmp (s, "Time")) { - param = OB_TIME; + *param = OB_TIME; ok = 1; } if (!strcmp (s, "ColR")) { - param = OB_COL_R; + *param = OB_COL_R; ok = 1; } if (!strcmp (s, "ColG")) { - param = OB_COL_G; + *param = OB_COL_G; ok = 1; } if (!strcmp (s, "ColB")) { - param = OB_COL_B; + *param = OB_COL_B; ok = 1; } if (!strcmp (s, "ColA")) { - param = OB_COL_A; + *param = OB_COL_A; + ok = 1; + } + if (!strcmp (s, "FStreng")) + { + *param = OB_PD_FSTR; + ok = 1; + } + if (!strcmp (s, "FFall")) + { + *param = OB_PD_FFALL; + ok = 1; + } + if (!strcmp (s, "Damping")) + { + *param = OB_PD_SDAMP; ok = 1; } - if (!ok) - return (EXPP_ReturnPyObjError (PyExc_ValueError, "Not a valid param.")); + if (!strcmp (s, "RDamp")) + { + *param = OB_PD_RDAMP; + ok = 1; + } + if (!strcmp (s, "Perm")) + { + *param = OB_PD_PERM; + ok = 1; + } + + return ok; +} + +struct Lamp * Ipo_getIdLa(Ipo * ipo) +{ + Link * link = G.main->lamp.first; + struct Lamp *la = 0; + while(link) + { + la = (struct Lamp *)link; + if(la->ipo == ipo) return la; + link = link->next; + } + return 0; +} - /* add a new curve to the ipo. we pass in self->ipo so a new one does - not get created */ - icu = get_ipocurve (&(object->id), ID_OB, param, self->ipo ); +struct Camera * Ipo_getIdCam(Ipo * ipo) +{ + Link * link = G.main->camera.first; + struct Camera *cam = 0; + while(link) + { + cam = (struct Camera *)link; + if(cam->ipo == ipo) return cam; + link = link->next; + } + return 0; +} +struct Tex * Ipo_getIdTex(Ipo * ipo) +{ + Link * link = G.main->tex.first; + struct Tex *tex = 0; + while(link) + { + tex = (struct Tex *)link; + if(tex->ipo == ipo) return tex; + link = link->next; + } + return 0; +} + +struct Material * Ipo_getIdMat(Ipo * ipo) +{ + Link * link = G.main->mat.first; + struct Material *mat = 0; + while(link) + { + mat = (struct Material *)link; + if(mat->ipo == ipo) return mat; + link = link->next; + } + return 0; +} + +struct World * Ipo_getIdWorld(Ipo * ipo) +{ + Link * link = G.main->world.first; + struct World *wo = 0; + while(link) + { + wo = (struct World *)link; + if(wo->ipo == ipo) return wo; + link = link->next; + } + return 0; +} + +/* code unfinished, is c&p! */ +/*struct Object * Ipo_getIdCo(Ipo * ipo) +{ + Link * link = G.main->action.first; + struct bAction *ac = 0; + while(link) + { + ac = (struct bAction *)link; + if(ac->ipo == ipo) return ac; + link = link->next; + } + return 0; +} +struct bAction * Ipo_getIdAc(Ipo * ipo) +{ + Link * link = G.main->action.first; + struct bAction *ac = 0; + while(link) + { + ac = (struct bAction *)link; + if(ac->ipo == ipo) return ac; + link = link->next; + } + return 0; +}*/ + +struct Key * Ipo_getIdKe(Ipo * ipo) +{ + Link * link = G.main->key.first; + struct Key *ke = 0; + while(link) + { + ke = (struct Key *)link; + if(ke->ipo == ipo) return ke; + link = link->next; + } + return 0; +} + +struct Curve * Ipo_getIdCu(Ipo * ipo) +{ + Link * link = G.main->curve.first; + struct Curve *cu = 0; + while(link) + { + cu = (struct Curve *)link; + if(cu->ipo == ipo) return cu; + link = link->next; + } + return 0; +} + +/*struct Sequence * Ipo_getIdSeq(Ipo * ipo) +{ + struct Editing *ed = 0; + struct Sequence *seq = 0; + + ed = G.scene->ed; + if(ed==0) return 0; + seq= ed->seqbasep->first; + + while(seq) + { + if(seq->ipo == ipo) return seq; + seq = seq->next; + } + return 0; +}*/ + +struct Object * Ipo_getIdObj(Ipo * ipo) +{ + Link * link = G.main->object.first; + struct Object *ob = 0; + while(link) + { + ob = (struct Object *)link; + if(ob->ipo == ipo) return ob; + link = link->next; + } + return 0; +} + +static PyObject * +Ipo_addCurve (BPy_Ipo * self, PyObject * args) +{ + IpoCurve *get_ipocurve (ID * from, short type, int adrcode, Ipo * useipo); + void allspace (unsigned short event, short val); + void allqueue (unsigned short event, short val); + int param = 0, ok = 0, ipofound = 0; + char *s = 0; + ID id; + struct Lamp * la = 0; + struct Camera * ca = 0; + struct Object * ob = 0; + struct Tex * tex = 0; + struct World * wo = 0; + struct Material * mat = 0; + struct Key * ke = 0; + /*struct bAction * ac = 0;*/ + struct Curve * cu = 0; + /*struct Sequence * seq = 0;*/ + Ipo *ipo = 0; + IpoCurve *icu = 0; + Link *link; + + if (!PyArg_ParseTuple (args, "s", &s)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected string argument")); + + + link = G.main->ipo.first; + + while(link) + { + ipo = (Ipo *)link; + if(ipo == self->ipo) { + ipofound = 1; + break; + } + link = link->next; + } + + if(ipo && ipofound) { + switch(ipo->blocktype) { + case ID_OB: + ok = Ipo_obIcuName(s, ¶m); + if(ok) { + ob = Ipo_getIdObj(ipo); + if(ob) icu = get_ipocurve (&(ob->id), ipo->blocktype, param, self->ipo ); + } + break; + case ID_CA: + ok = Ipo_caIcuName(s, ¶m); + if(ok) { + ca = Ipo_getIdCam(ipo); + if(ca) icu = get_ipocurve (&(ca->id), ipo->blocktype, param, self->ipo ); + } + break; + case ID_LA: + ok = Ipo_laIcuName(s, ¶m); + if(ok) { + la = Ipo_getIdLa(ipo); + if(la) icu = get_ipocurve (&(la->id), ipo->blocktype, param, self->ipo ); + } + break; + case ID_TE: + ok = Ipo_texIcuName(s, ¶m); + if(ok) { + tex = Ipo_getIdTex(ipo); + if(tex) icu = get_ipocurve (&(tex->id), ipo->blocktype, param, self->ipo ); + } + break; + case ID_WO: + ok = Ipo_woIcuName(s, ¶m); + if(ok) { + wo = Ipo_getIdWorld(ipo); + if(wo) icu = get_ipocurve (&(wo->id), ipo->blocktype, param, self->ipo ); + } + break; + case ID_MA: + ok = Ipo_maIcuName(s, ¶m); + if(ok) { + mat = Ipo_getIdMat(ipo); + if(mat) icu = get_ipocurve (&(mat->id), ipo->blocktype, param, self->ipo ); + } + break; + /*case ID_AC: + ok = Ipo_acIcuName(s, ¶m); + if(ok) { + ac = Ipo_getIdAc(ipo); + if(ac) icu = get_ipocurve (&(ac->id), ipo->blocktype, param, self->ipo ); + } + break; + case IPO_CO: + ok = Ipo_coIcuName(s, ¶m); + if(ok) { + co = Ipo_getIdCo(ipo); + if(co) icu = get_ipocurve (&(ac->id), ipo->blocktype, param, self->ipo ); + } + break;*/ + case ID_CU: + ok = Ipo_cuIcuName(s, ¶m); + if(ok) { + cu = Ipo_getIdCu(ipo); + if(cu) icu = get_ipocurve (&(cu->id), ipo->blocktype, param, self->ipo ); + } + break; + case ID_KE: + ok = Ipo_keIcuName(s, ¶m); + if(ok) { + ke = Ipo_getIdKe(ipo); + if(ke) icu = get_ipocurve (&(ke->id), ipo->blocktype, param, self->ipo ); + } + break; + /*case ID_SEQ: + ok = Ipo_seqIcuName(s, ¶m); + if(ok) { + seq = Ipo_getIdSeq(ipo); + if(seq) icu = get_ipocurve (&(seq->id), ipo->blocktype, param, self->ipo ); + } + break;*/ + } + } + + if (icu==0) return (EXPP_ReturnPyObjError (PyExc_ValueError, "Not a valid param.")); #define REMAKEIPO 1 -#define REDRAWIPO 0x4023 +#define REDRAWIPO 0x4023 allspace (REMAKEIPO, 0); allqueue (REDRAWIPO, 0); @@ -621,15 +1417,14 @@ Ipo_addCurve (BPy_Ipo * self, PyObject * args) static PyObject * Ipo_getCurve (BPy_Ipo * self, PyObject * args) { - char *str; + char *str, *str1; IpoCurve *icu = 0; if (!PyArg_ParseTuple (args, "s", &str)) return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument")); for (icu = self->ipo->curve.first; icu; icu = icu->next) { - char str1[80]; - GetIpoCurveName (icu, str1); + str1 = GetIpoCurveName (icu); if (!strcmp (str1, str)) return IpoCurve_CreatePyObject (icu); } @@ -638,36 +1433,58 @@ Ipo_getCurve (BPy_Ipo * self, PyObject * args) return Py_None; } - -void -GetIpoCurveName (IpoCurve * icu, char *s) +char * +GetIpoCurveName(IpoCurve * icu) { switch (icu->blocktype) { case ID_MA: { - getname_mat_ei (icu->adrcode, s); - break; + return getname_mat_ei (icu->adrcode); } case ID_WO: { - getname_world_ei (icu->adrcode, s); - break; + return getname_world_ei (icu->adrcode); } case ID_CA: { - getname_cam_ei (icu->adrcode, s); - break; + return getname_cam_ei (icu->adrcode); } case ID_OB: { - getname_ob_ei (icu->adrcode, s); - break; + return getname_ob_ei (icu->adrcode, 1); /* solve: what if EffX/Y/Z are wanted? */ + } + case ID_TE: + { + return getname_tex_ei (icu->adrcode); + } + case ID_LA: + { + return getname_la_ei(icu->adrcode); + } + case ID_AC: + { + return getname_ac_ei(icu->adrcode); + } + case ID_CU: + { + return getname_cu_ei(icu->adrcode); + } + case ID_KE: + { + return getname_key_ei(icu->adrcode); + } + case ID_SEQ: + { + return getname_seq_ei(icu->adrcode); + } + case IPO_CO: + { + return getname_co_ei(icu->adrcode); } } } - static PyObject * Ipo_getCurves (BPy_Ipo * self) { @@ -859,7 +1676,7 @@ Ipo_getCurvecurval (BPy_Ipo * self, PyObject * args) { int numcurve = 0, i; IpoCurve *icu; - char *stringname = 0; + char *stringname = 0, *str1 = 0; icu = self->ipo->curve.first; if (!icu) @@ -886,8 +1703,9 @@ Ipo_getCurvecurval (BPy_Ipo * self, PyObject * args) (PyExc_TypeError, "expected int or string argument")); while (icu) { - char str1[10]; - GetIpoCurveName (icu, str1); + /*char str1[10]; + GetIpoCurveName (icu, str1);*/ + str1 = GetIpoCurveName(icu); if (!strcmp (str1, stringname)) break; icu = icu->next; diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c index 2fb99f08cfd..ead122e3f55 100644 --- a/source/blender/python/api2_2x/Ipocurve.c +++ b/source/blender/python/api2_2x/Ipocurve.c @@ -24,7 +24,7 @@ * * This is a new part of Blender. * - * Contributor(s): Jacques Guignot + * Contributor(s): Jacques Guignot, Nathan Letwory * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ @@ -37,6 +37,7 @@ #include <BKE_library.h> #include <BKE_ipo.h> #include <BLI_blenlib.h> +#include <BSE_editipo.h> #include "constant.h" #include "gen_utils.h" @@ -349,46 +350,35 @@ IpoCurve_Recalc (C_IpoCurve * self) static PyObject * IpoCurve_getName (C_IpoCurve * self) { - 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"}; - - 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; - default: - return PyString_FromString("Index out of range"); - } - } - break; - + switch (self->ipocurve->blocktype) { + case ID_OB: + return PyString_FromString(getname_ob_ei(self->ipocurve->adrcode, 1)); /* solve: what if EffX/Y/Z are wanted? */ + case ID_TE: + return PyString_FromString(getname_tex_ei(self->ipocurve->adrcode)); + case ID_LA: + return PyString_FromString(getname_la_ei(self->ipocurve->adrcode)); + case ID_MA: + return PyString_FromString(getname_mat_ei(self->ipocurve->adrcode)); + case ID_CA: + return PyString_FromString(getname_cam_ei(self->ipocurve->adrcode)); + case ID_WO: + return PyString_FromString(getname_world_ei(self->ipocurve->adrcode)); + case ID_AC: + return PyString_FromString(getname_ac_ei(self->ipocurve->adrcode)); + case ID_CU: + return PyString_FromString(getname_cu_ei(self->ipocurve->adrcode)); + case ID_KE: + return PyString_FromString(getname_key_ei(self->ipocurve->adrcode)); + case ID_SEQ: + return PyString_FromString(getname_seq_ei(self->ipocurve->adrcode)); + case IPO_CO: + return PyString_FromString(getname_co_ei(self->ipocurve->adrcode)); default: return EXPP_ReturnPyObjError (PyExc_TypeError, "This function doesn't support this ipocurve type yet"); } + + return PyString_FromString(""); } static void diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c index 74f2718a5fa..1fd5164626b 100644 --- a/source/blender/python/api2_2x/Lamp.c +++ b/source/blender/python/api2_2x/Lamp.c @@ -24,7 +24,7 @@ * * This is a new part of Blender. * - * Contributor(s): Willian P. Germano + * Contributor(s): Willian P. Germano, Nathan Letwory * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ @@ -167,6 +167,9 @@ static PyObject *Lamp_getHaloInt(BPy_Lamp *self); static PyObject *Lamp_getQuad1(BPy_Lamp *self); static PyObject *Lamp_getQuad2(BPy_Lamp *self); static PyObject *Lamp_getCol(BPy_Lamp *self); +static PyObject *Lamp_getIpo(BPy_Lamp *self); +static PyObject *Lamp_clearIpo(BPy_Lamp *self); +static PyObject *Lamp_setIpo(BPy_Lamp *self, PyObject *args); static PyObject *Lamp_setName(BPy_Lamp *self, PyObject *args); static PyObject *Lamp_setType(BPy_Lamp *self, PyObject *args); static PyObject *Lamp_setIntType(BPy_Lamp *self, PyObject *args); @@ -1370,3 +1373,76 @@ static PyObject *Lamp_repr (BPy_Lamp *self) { return PyString_FromFormat("[Lamp \"%s\"]", self->lamp->id.name+2); } + +static PyObject * +Lamp_getIpo (BPy_Lamp * self) +{ + struct Ipo *ipo = self->lamp->ipo; + + if (!ipo) + { + Py_INCREF (Py_None); + return Py_None; + } + + return Ipo_CreatePyObject (ipo); +} + +extern PyTypeObject Ipo_Type; + +static PyObject * +Lamp_setIpo (BPy_Lamp * self, PyObject * args) +{ + PyObject *pyipo = 0; + Ipo *ipo = NULL; + Ipo *oldipo; + + if (!PyArg_ParseTuple (args, "O!", &Ipo_Type, &pyipo)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected Ipo as argument"); + + ipo = Ipo_FromPyObject (pyipo); + + if (!ipo) + return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!"); + + if (ipo->blocktype != ID_TE) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "this ipo is not a lamp data ipo"); + + oldipo = self->lamp->ipo; + if (oldipo) + { + ID *id = &oldipo->id; + if (id->us > 0) + id->us--; + } + + ((ID *) & ipo->id)->us++; + + self->lamp->ipo = ipo; + + Py_INCREF (Py_None); + return Py_None; +} + +static PyObject * +Lamp_clearIpo (BPy_Lamp * self) +{ + Lamp *lamp = self->lamp; + Ipo *ipo = (Ipo *) lamp->ipo; + + if (ipo) + { + ID *id = &ipo->id; + if (id->us > 0) + id->us--; + lamp->ipo = NULL; + + Py_INCREF (Py_True); + return Py_True; + } + + Py_INCREF (Py_False); /* no ipo found */ + return Py_False; +} diff --git a/source/blender/python/api2_2x/Lamp.h b/source/blender/python/api2_2x/Lamp.h index 1ba8a8a5d35..08bbbfef67e 100644 --- a/source/blender/python/api2_2x/Lamp.h +++ b/source/blender/python/api2_2x/Lamp.h @@ -24,7 +24,7 @@ * * This is a new part of Blender. * - * Contributor(s): Willian P. Germano + * Contributor(s): Willian P. Germano, Nathan Letwory * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c index 6c6dda84ed9..c4cb10354f4 100644 --- a/source/blender/python/api2_2x/Texture.c +++ b/source/blender/python/api2_2x/Texture.c @@ -24,7 +24,7 @@ * * This is a new part of Blender. * - * Contributor(s): Alex Mole + * Contributor(s): Alex Mole, Nathan Letwory * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ @@ -59,9 +59,12 @@ #define EXPP_TEX_TYPE_IMAGE TEX_IMAGE #define EXPP_TEX_TYPE_PLUGIN TEX_PLUGIN #define EXPP_TEX_TYPE_ENVMAP TEX_ENVMAP +#define EXPP_TEX_TYPE_MUSGRAVE TEX_MUSGRAVE +#define EXPP_TEX_TYPE_VORONOI TEX_VORONOI +#define EXPP_TEX_TYPE_DISTNOISE TEX_DISTNOISE #define EXPP_TEX_TYPE_MIN EXPP_TEX_TYPE_NONE -#define EXPP_TEX_TYPE_MAX EXPP_TEX_TYPE_ENVMAP +#define EXPP_TEX_TYPE_MAX EXPP_TEX_TYPE_DISTNOISE /* i can't find these defined anywhere- they're just taken from looking at */ /* the button creation code in source/blender/src/buttons_shading.c */ @@ -90,6 +93,12 @@ #define EXPP_TEX_STYPE_ENV_STATIC 0 #define EXPP_TEX_STYPE_ENV_ANIM 1 #define EXPP_TEX_STYPE_ENV_LOAD 2 +/* musgrave stype */ +#define EXPP_TEX_STYPE_MUS_MFRACTAL 0 +#define EXPP_TEX_STYPE_MUS_RIDGEDMF 1 +#define EXPP_TEX_STYPE_MUS_HYBRIDMF 2 +#define EXPP_TEX_STYPE_MUS_FBM 3 +#define EXPP_TEX_STYPE_MUS_HTERRAIN 4 #define EXPP_TEX_FLAG_COLORBAND TEX_COLORBAND #define EXPP_TEX_FLAG_FLIPBLEND TEX_FLIPBLEND @@ -150,6 +159,9 @@ static const EXPP_map_pair tex_type_map[] = { { "Image", EXPP_TEX_TYPE_IMAGE }, { "Plugin", EXPP_TEX_TYPE_PLUGIN }, { "EnvMap", EXPP_TEX_TYPE_ENVMAP }, + { "Musgrave", EXPP_TEX_TYPE_MUSGRAVE }, + { "Voronoi", EXPP_TEX_TYPE_VORONOI }, + { "DistortedNoise", EXPP_TEX_TYPE_DISTNOISE }, { NULL, 0 } }; @@ -234,6 +246,16 @@ static const EXPP_map_pair tex_stype_envmap_map[] = { { NULL , 0 } }; +static const EXPP_map_pair tex_stype_musg_map[] = { + { "Default", 0}, + { "MultiFractal", EXPP_TEX_STYPE_MUS_MFRACTAL }, + { "HeteroTerrain", EXPP_TEX_STYPE_MUS_HTERRAIN }, + { "RidgedMultiFractal", EXPP_TEX_STYPE_MUS_RIDGEDMF }, + { "HybridMultiFractal", EXPP_TEX_STYPE_MUS_HYBRIDMF }, + { "fBM", EXPP_TEX_STYPE_MUS_FBM }, + { NULL , 0 } +}; + static const EXPP_map_pair *tex_stype_map[] = { tex_stype_default_map, /* none */ tex_stype_clouds_map, @@ -245,7 +267,8 @@ static const EXPP_map_pair *tex_stype_map[] = { tex_stype_default_map, /* noise */ tex_stype_default_map, /* image */ tex_stype_default_map, /* plugin */ - tex_stype_envmap_map + tex_stype_envmap_map, + tex_stype_musg_map /* musgrave */ }; @@ -298,6 +321,9 @@ GETFUNC (getImage); GETFUNC (getName); GETFUNC (getType); GETFUNC (getSType); +GETFUNC (getIpo); +GETFUNC (clearIpo); +SETFUNC (setIpo); SETFUNC (setAnimFrames); SETFUNC (setAnimLength); SETFUNC (setAnimMontage); @@ -342,6 +368,12 @@ static PyMethodDef BPy_Texture_methods[] = { "() - Return Texture stype as string"}, {"getType", (PyCFunction)Texture_getType, METH_NOARGS, "() - Return Texture type as string"}, + {"getIpo", (PyCFunction)Texture_getIpo, METH_NOARGS, + "() - Return Texture Ipo"}, + {"setIpo", (PyCFunction)Texture_setIpo, METH_VARARGS, + "(Blender Ipo) - Set Texture Ipo"}, + {"clearIpo", (PyCFunction) Texture_clearIpo, METH_NOARGS, + "() - Unlink Ipo from this Texture."}, {"setExtend", (PyCFunction)Texture_setExtend, METH_VARARGS, "(s) - Set Texture extend mode"}, {"setFlags", (PyCFunction)Texture_setFlags, METH_VARARGS, @@ -508,6 +540,9 @@ static PyObject *M_Texture_TypesDict (void) EXPP_ADDCONST (IMAGE); EXPP_ADDCONST (PLUGIN); EXPP_ADDCONST (ENVMAP); + EXPP_ADDCONST (MUSGRAVE); + EXPP_ADDCONST (VORONOI); + EXPP_ADDCONST (DISTNOISE); } return Types; } @@ -547,6 +582,11 @@ static PyObject *M_Texture_STypesDict (void) EXPP_ADDCONST(ENV_STATIC); EXPP_ADDCONST(ENV_ANIM); EXPP_ADDCONST(ENV_LOAD); + EXPP_ADDCONST(MUS_MFRACTAL); + EXPP_ADDCONST(MUS_RIDGEDMF); + EXPP_ADDCONST(MUS_HYBRIDMF); + EXPP_ADDCONST(MUS_FBM); + EXPP_ADDCONST(MUS_HTERRAIN); } return STypes; } @@ -1511,3 +1551,76 @@ static PyObject *Texture_repr (BPy_Texture *self) return PyString_FromFormat("[Texture \"%s\"]", self->texture->id.name+2); } +static PyObject * +Texture_getIpo (BPy_Texture * self) +{ + struct Ipo *ipo = self->texture->ipo; + + if (!ipo) + { + Py_INCREF (Py_None); + return Py_None; + } + + return Ipo_CreatePyObject (ipo); +} + +extern PyTypeObject Ipo_Type; + +static PyObject * +Texture_setIpo (BPy_Texture * self, PyObject * args) +{ + PyObject *pyipo = 0; + Ipo *ipo = NULL; + Ipo *oldipo; + + if (!PyArg_ParseTuple (args, "O!", &Ipo_Type, &pyipo)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected Ipo as argument"); + + ipo = Ipo_FromPyObject (pyipo); + + if (!ipo) + return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!"); + + if (ipo->blocktype != ID_TE) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "this ipo is not a texture data ipo"); + + oldipo = self->texture->ipo; + if (oldipo) + { + ID *id = &oldipo->id; + if (id->us > 0) + id->us--; + } + + ((ID *) & ipo->id)->us++; + + self->texture->ipo = ipo; + + Py_INCREF (Py_None); + return Py_None; +} + +static PyObject * +Texture_clearIpo (BPy_Texture * self) +{ + Tex *tex = self->texture; + Ipo *ipo = (Ipo *) tex->ipo; + + if (ipo) + { + ID *id = &ipo->id; + if (id->us > 0) + id->us--; + tex->ipo = NULL; + + Py_INCREF (Py_True); + return Py_True; + } + + Py_INCREF (Py_False); /* no ipo found */ + return Py_False; +} + diff --git a/source/blender/python/api2_2x/doc/Ipo.py b/source/blender/python/api2_2x/doc/Ipo.py index a594ca0aa4e..eca647e5c3b 100644 --- a/source/blender/python/api2_2x/doc/Ipo.py +++ b/source/blender/python/api2_2x/doc/Ipo.py @@ -26,7 +26,8 @@ def New (type, name): @type type: string @type name: string @param type: The Ipo's blocktype. Depends on the object the ipo will be - linked to. Currently supported types are Object, Camera, World, Material. + linked to. Currently supported types are Object, Camera, World, + Material, Texture, Lamp, Curve, Key. @param name: The name for this Ipo. @rtype: Blender Ipo @return: The created Ipo. @@ -71,14 +72,26 @@ class Ipo: 'curvename' are: 1. Camera Ipo: Lens, ClSta, ClEnd. 2. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref, - Alpha, Emit, Amb, Spec, Hard, SpTra, Ang, Mode, HaSize, OfsX, OfsY, + Alpha, Emit, Amb, Spec, Hard, SpTra, Ang, Mode, HaSize, Translu, + RayMir, FresMir, FresMirI, FresTra, FresTraI, TraGlow, OfsX, OfsY, OfsZ, SizeX, SizeY, SizeZ, TexR, TexG, TexB, DefVar, Col, Nor, Var; 3. Object Ipo: LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ, dRotX, dRotY, dRotZ, SizeX, SizeY, SizeZ, dSizeX, dSizeY, dSizeZ, - Layer, Time, ColR, ColG, ColB, ColA; - 4. World Ipo: HorR, HorG, HorB, ZenR, ZenG, ZenB, Expos, Misi, MisDi, + Layer, Time, ColR, ColG, ColB, ColA, FStreng, FFOff, Damping, + RDamp, Perm; + 4. Lamp Ipo: Energ, R, G, B, Dist, SpoSi, SpoBl, Quad1, Quad2, HaIntl; + 5. World Ipo: 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; + 6. Texture Ipo: NSize, NDepth, NType, Turb, Vnw1, Vnw2, Vnw3, Vnw4, + MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct, + MgOff, MgGan, NBase1, NBase2; + 7. Curve Ipo: Speed; + 8. Key Ipo: Speed, 'Key 1' - 'Key 31'; + 9. Action Ipo: LocX, LocY, LocZ, SizeX, SizeY, SizeZ, + QuatX, QuatY, QuatZ, QuatW; + 10.Sequence Ipo: Fac; + 11.Constraint Ipo: Inf. @type curvename : string @rtype: IpoCurve object @return: the corresponding IpoCurve, or None. @@ -89,7 +102,21 @@ class Ipo: Add a new curve to the IPO object. The possible values for 'curvename' are: 1. Object Ipo: LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ, dRotX, dRotY, dRotZ, SizeX, SizeY, SizeZ, dSizeX, dSizeY, dSizeZ, - Layer, Time, ColR, ColG, ColB, ColA. + Layer, Time, ColR, ColG, ColB, ColA, FStreng, FFOff, Damping, RDamp, + Perm; + 2. Camera Ipo: Lens, ClSta, ClEnd; + 3. Lamp Ipo: Energ, R, G, B, Dist, SpoSi, SpoBl, Quad1, Quad2, HaIntl + 4. Texture Ipo: NSize, NDepth, NType, Turb, Vnw1, Vnw2, Vnw3, Vnw4, + MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct, + MgOff, MgGan, NBase1, NBase2; + 5. World Ipo: 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; + 6. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref, + Alpha, Emit, Amb, Spec, Hard, SpTra, Ior, Mode, HaSize, Translu, + RayMir, FresMir, FresMirI, FresTra, FresTraI, TraGlow; + 7. Curve Ipo: Speed; + 8. Key Ipo: Speed, 'Key 1' - 'Key 31' @type curvename : string @rtype: IpoCurve object @return: the corresponding IpoCurve, or None. @@ -265,10 +292,28 @@ class IpoCurve: def getName(): """ Returns the name of the ipo curve. This name can be: - 1. LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ, + 1. Camera Ipo: Lens, ClSta, ClEnd. + 2. Material Ipo: R, G, B, SpecR, SpecG, SpecB, MirR, MirG, MirB, Ref, + Alpha, Emit, Amb, Spec, Hard, SpTra, Ang, Mode, HaSize, Translu, + RayMir, FresMir, FresMirI, FresTra, FresTraI, TraGlow, OfsX, OfsY, + OfsZ, SizeX, SizeY, SizeZ, TexR, TexG, TexB, DefVar, Col, Nor, Var; + 3. Object Ipo: LocX, LocY, LocZ, dLocX, dLocY, dLocZ, RotX, RotY, RotZ, dRotX, dRotY, dRotZ, SizeX, SizeY, SizeZ, dSizeX, dSizeY, dSizeZ, - Layer, Time, ColR, ColG, ColB, ColA, QuatX, QuatY, QuatZ or QuatW. - @warn: currently this only works with object and action IPO's.. + Layer, Time, ColR, ColG, ColB, ColA, FStreng, FFOff, Damping, + RDamp, Perm; + 4. Lamp Ipo: Energ, R, G, B, Dist, SpoSi, SpoBl, Quad1, Quad2, HaIntl; + 5. World Ipo: 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; + 6. Texture Ipo: NSize, NDepth, NType, Turb, Vnw1, Vnw2, Vnw3, Vnw4, + MinkMExp, DistM, ColT, iScale, DistA, MgType, MgH, Lacu, Oct, + MgOff, MgGan, NBase1, NBase2; + 7. Curve Ipo: Speed; + 8. Key Ipo: Speed, 'Key 1' - 'Key 31'; + 9. Action Ipo: LocX, LocY, LocZ, SizeX, SizeY, SizeZ, + QuatX, QuatY, QuatZ, QuatW; + 10.Sequence Ipo: Fac; + 11.Constraint Ipo: Inf. @rtype: string @return: the name of the ipo curve. """ diff --git a/source/blender/python/api2_2x/doc/Lamp.py b/source/blender/python/api2_2x/doc/Lamp.py index a120605117d..f67957278fc 100644 --- a/source/blender/python/api2_2x/doc/Lamp.py +++ b/source/blender/python/api2_2x/doc/Lamp.py @@ -348,3 +348,23 @@ class Lamp: @type event: string @param event: "FrameChanged" or "Redraw". """ + + def getIpo(): + """ + Get the Ipo associated with this Lamp object, if any. + @rtype: Ipo + @return: the wrapped ipo or None. + """ + + def setIpo(ipo): + """ + Link an ipo to this Lamp object. + @type ipo: Blender Ipo + @param ipo: a "lamp data" ipo. + """ + + def clearIpo(): + """ + Unlink the ipo from this Lamp object. + @return: True if there was an ipo linked or False otherwise. + """ diff --git a/source/blender/python/api2_2x/doc/Texture.py b/source/blender/python/api2_2x/doc/Texture.py index cc5ef586c96..369523a3bcd 100644 --- a/source/blender/python/api2_2x/doc/Texture.py +++ b/source/blender/python/api2_2x/doc/Texture.py @@ -302,3 +302,22 @@ class MTex: @cvar mapto: "Map to" field of texture. OR'd values of L{MapTo} """ + def getIpo(): + """ + Get the Ipo associated with this texture object, if any. + @rtype: Ipo + @return: the wrapped ipo or None. + """ + + def setIpo(ipo): + """ + Link an ipo to this texture object. + @type ipo: Blender Ipo + @param ipo: a "texture data" ipo. + """ + + def clearIpo(): + """ + Unlink the ipo from this texture object. + @return: True if there was an ipo linked or False otherwise. + """ diff --git a/source/blender/python/api2_2x/doc/World.py b/source/blender/python/api2_2x/doc/World.py index 2a500ca8c48..55b3cf2dc8c 100644 --- a/source/blender/python/api2_2x/doc/World.py +++ b/source/blender/python/api2_2x/doc/World.py @@ -71,7 +71,7 @@ class World: ================ This object gives access to generic data from all worlds in Blender. Its attributes depend upon its type. - + @cvar name: the name of the world. @cvar skytype: type of the sky. Bit 0 : Blend; Bit 1 : Real; Bit 2 : paper. @cvar mode: @@ -145,7 +145,6 @@ class World: @return: the skytype of the world object. """ - def setSkytype(skytype): """ Sets the skytype of a world object. @@ -164,7 +163,6 @@ class World: @return: the mode of the world object. """ - def setMode(mode): """ Sets the mode of a world object. @@ -183,7 +181,6 @@ class World: @return: the mistype of the world object. """ - def setMistype(mistype): """ Sets the mist type of a world object. @@ -202,7 +199,6 @@ class World: @return: the horizon color of the world object. """ - def setHor(hor): """ Sets the horizon color of a world object. @@ -220,7 +216,6 @@ class World: @return: the zenith color of the world object. """ - def setZen(zen): """ Sets the zenith color of a world object. @@ -238,7 +233,6 @@ class World: @return: the ambient color of the world object. """ - def setAmb(amb): """ Sets the ambient color of a world object. @@ -263,7 +257,6 @@ class World: @return: the star parameters """ - def setStar(star): """ Sets the star parameters of a world object. @@ -286,7 +279,6 @@ class World: @return: the mist parameters """ - def setMist(mist): """ Sets the mist parameters of a world object. diff --git a/source/blender/python/api2_2x/modules.h b/source/blender/python/api2_2x/modules.h index 89360e1cf0d..77c47f3525e 100644 --- a/source/blender/python/api2_2x/modules.h +++ b/source/blender/python/api2_2x/modules.h @@ -24,7 +24,7 @@ * * This is a new part of Blender. * - * Contributor(s): Michel Selten, Willian P. Germano + * Contributor(s): Michel Selten, Willian P. Germano, Nathan Letwory * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ @@ -46,9 +46,13 @@ #include <DNA_effect_types.h> #include <DNA_meta_types.h> #include <DNA_image_types.h> +#include <DNA_texture_types.h> #include <DNA_text_types.h> #include <DNA_world_types.h> +#include <DNA_key_types.h> +#include <DNA_sequence_types.h> #include <DNA_action_types.h> +#include <DNA_constraint_types.h> /*****************************************************************************/ /* Global variables */ |