Having variables controlled with Ipos is very easy. This short tutorial will show you where and what to edit by adding the translucency Ipo.
<typolist>
source/blender/makesdna/DNA_ipo_types.h
source/blender/blenkernel/ipo.c
source/blender/src/editipo.c
source/blender/src/editipo_lib.c
</typolist>
I'm going to add said Ipo, which will control the <ccode>translucency</ccode> variable in the <ccode>Material</ccode> struct.
I first open DNA_ipo_types.h and add a define for the Ipo:
<ccode>#define MA_TRANSLU 20</ccode> right after <ccode>#define MA_HASIZE 19</ccode>. When adding a new Ipo define, make sure you increase the *_TOTIPO for the Ipotype too. I thus increase the define for MA_TOTIPO with one.
Next we must add it to the material Ipo array in ipo.c. Search for the ma_ar initialisation part and add after MA_HASIZE the new define so that the line reads now: <ccode>MA_MODE, MA_HASIZE, MA_TRANSLU,</ccode>.
Next we make sure the ipo really uses ma->translucency, so in the function void *get_ipo_poin search for the if... else if... construct with GS(id->name)==ID_MA. Here look in the switch construct for <ccode>case MA_HASIZE:
poin= &(ma->hasize); break</ccode>
and add after that: <ccode>case MA_TRANSLU:
poin= &(ma->translucency); break</ccode>
Since translucency has a maximum value we set that too, in the function set_icu_vars. Again search for the if... else if part that says
<ccode>else if(icu->blocktype==ID_MA) {</ccode>
in the switch statement there add a <ccode>case MA_TRANSLU:
icu->ymax= 1.0; break;</ccode>
if the maximum value of translucency would have been 10.0, you would've put here icu->ymax= 10.0; In this particular function the minimum value is already set at 0.0 and needs no change for MA_TRANSLU, but if for another Ipo there's a minimum value, set icu->ymin to that value.
If translucency would have been an integer you would also have to set that with <ccode>icu->vartype= IPO_INT;</ccode>
There are two more small additions we have to do, and those are in editipo_lib.c. Since we're adding a Material Ipo, browse to the array named ma_ic_names[]. Add "Translu" add the end. This will ensure that the new name will be returned for that value. After that change the second value checked in getname_mat_ei(int nr) to MA_TRANSLU, so that the line reads <ccode>if(nr>=MA_COL_R && nr<=MA_TRANSLU) return ma_ic_names[nr-1];</ccode>
Then finally we add it also to the material Ipo key menu for the buttons window. Get yourself to common_insertkey and look for the CONTEXT_SHADING and TAB_SHADING_MAT parts. I opted for adding it to the "All Color" popup entry when pressing IKEY, so in the <ccode>if</ccode> for event 10 I added the line <ccode>insertkey(id, MA_TRANSLU);</ccode>
Of course, this popup menu could do with some reorganisation, but that's all trivial and should be clear from that particular part of the code.
<typolist>
When adding new Ipos, be sure to not change the values of existing defines. Otherwise you'll get a bunch of angry users. If they've added an Ipo for the R color component, and you add a new define with that number and you bump the rest, the user will not be happy to find out later that the R Ipo is a Displacement Ipo after all...
The current system allows for 50 channels (hardcoded), so if you get more than 50 channels for a particular view, you might wanna reconsider organisation. (You can get more than 50 channels by editing the queue handler for ipo in space.c)
</typolist>