[Bf-committers] In need for help/documentation for modifiers

Tobias Oelgarte tobias.oelgarte at googlemail.com
Fri Oct 8 18:17:23 CEST 2010


Currently i have created a simple ui for my modifier and the properties 
are also correctly registered. I just followed the code from the 
simpledeform modifier and copied adjusted parts from it. Now i can focus 
on writing the modifier itself. Only problem is, that the callback 
functions are not as well documented as i expected. So i will have to go 
through trial and error, to find out what they are exactly for, and 
which i will have to implement.

If we wan't to write a documentation "how to write your own modifier" 
then we need something like a wiki to do so. I guess that i will sooner 
or later forget about the things and details i started of with. Any 
suggestions?

pete larabell schrieb:
> Thank you very much. If I'm able to get this working, or you are, I think we
> ought to write up a formal document on this process for the benefit of
> others. I'm more than willing to create such a document once I know it's
> accurate :)
>
> Thanks again!
> Peter
>
>
> On Fri, Oct 8, 2010 at 9:50 AM, Tobias Oelgarte <
> tobias.oelgarte at googlemail.com> wrote:
>
>   
>> Currently I'm able to compile it without any issue, but it misses all
>> functionality and the ui-interface. But at least it shows up in the menu
>> and runs like expected. Im oriented myself closely to the "simple deform
>> modifier", because it is simple and easier to understand than others.
>> Currently i did the following things:
>>
>> Some Notes:
>> <ModifierName> is the name of the modifier. In my case "RestoreVolume".
>> Note that the name is written in different style, at different places.
>> To know where in the files you will have to add the lines, you should
>> just look out for similar patterns.
>>
>> 1. At the end of MOD_util.c i added:
>>    INIT_TYPE(<ModifierName>);
>>
>> 2. In MOD_modifier_types.h i added:
>>    extern ModifierTypeInfo modifierType_<ModifierName>;
>>
>> 3. In RNA_access.h i added:
>>    extern StructRNA RNA_<ModifierName>VolumeModifier;
>>
>> 4. In DNA_modifier_types.h i added:
>>    eModifierType_<ModifierName>,
>>
>> 5. In DNA_modifier_types.h i added also:
>>    typedef struct <ModifierName>ModifierData {
>>        ModifierData modifier;
>>        // own data from here. Notice the padding, which is needed in
>> this case
>>        char name[32];
>>        float volume;
>>        char pad[4];
>>    } <ModifierName>ModifierData;
>>
>> 6. In rna_modifier.c i added:
>>    {eModifierType_<ModifierName>, "<MODIFIER_NAME>", ICON_MOD_PHYSICS,
>> "<Modifier Name>", ""},
>>
>> 7. In rna_modifier.c i added also:
>>    case eModifierType_<ModifierName>:
>>        return &RNA_<ModifierName>Modifier;
>>
>> 8. In rna_modifier.c i added also:
>>    static void rna_def_modifier_<modifiername>(BlenderRNA *brna)
>>    {
>>        StructRNA *srna;
>>
>>        srna= RNA_def_struct(brna, "<ModifierName>Modifier", "Modifier");
>>        RNA_def_struct_ui_text(srna, "<Modifier Name> Modifier",
>> "<description what it does>");
>>        RNA_def_struct_sdna(srna, "<ModifierName>ModifierData");
>>        RNA_def_struct_ui_icon(srna, ICON_MOD_PARTICLES); // maybe use
>> other icon
>>    }
>>
>> 9. In rna_modifier.c i added at the end also:
>>    rna_def_modifier_<modifiername>(brna);
>>
>> 10. In properties_data_modifier.py i added:
>>    def <MODIFIER_NAME>(self, layout, ob, md):
>>        layout.label(text="Volume:") // the following lines are specific
>> for my modifier
>>        layout.prop(md, "volume")
>>
>> Notice that #10 is python code, so care for indentation is needed. (I
>> hate it...)
>>
>> After that i copied MOD_simpledeform.c to MOD_<modifiername>.c and
>> deleted nearly everything from the file. Keep care to update and rename
>> the struct ModifierTypeInfo at the end of the file.
>>
>> Thats basically all i did so far. Currently i'm Missing my input-field
>> for volume inside the UI, since it blames me to not know about the
>> property. Guess i will have to register it somewhere.
>>
>> Message:
>> rna_uiItemR: property not found: RestoreVolumeModifier.volume
>>     



More information about the Bf-committers mailing list