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

Tobias Oelgarte tobias.oelgarte at googlemail.com
Fri Oct 8 16:50:51 CEST 2010


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

pete larabell schrieb:
> Tobias,
>
> If/when you do get your modifier successfully compiled and running... is
> there any chance you could write up a quick documentation describing the
> process? I've inherited a modifier from someone else and am now trying to do
> the same thing you are, but so far I feel like I'm less far into the process
> than you are.
>
> Any notes that you could write up about your experience would be great to
> help ease the burden for everyone in the future. :)
>
> Thanks!
> Peter
>
>
> On Fri, Oct 8, 2010 at 8:22 AM, Tobias Oelgarte <
> tobias.oelgarte at googlemail.com> wrote:
>
>   
>> Ok, now i found out that i needed to add a padding of 4 bytes to the
>> float. After reading your link it made sense.
>>
>> Now i will go over to get the UI right, even it is even a little bit
>> more confusing. At least the other modifiers are good examples on how to
>> create and use it. Even if i quite don't understand how it interacts
>> with the modifier and vice versa. But maybe reading the code will open
>> my eyes.
>>
>> Jorge Bernal schrieb:
>>     
>>> Hi,
>>>
>>> Check this link:
>>> http://www.blender.org/development/architecture/notes-on-sdna/
>>>
>>> Regards,
>>> Jorge
>>>
>>>       
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers
>>
>>     
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>
>   



More information about the Bf-committers mailing list