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

Jeroen Bakker j.bakker at atmind.nl
Fri Oct 8 12:34:07 CEST 2010


Hi,

I have a small step by step mind dump, but have not yet had time to 
write the complete documentation about it. see below. there is also a 
developer website who mentions it, but cannot find it right now.

Add custom modifier
1. DNA_modifier_types.h --> add ModifierType enumeration (must start 
with eModifierType_[NAME])
2. DNA_modifier_types.h --> Add [NAME]ModifierData struct. first field 
must be ModifierData modifier
3. rna_modifier.c -->     {eModifierType_[NAME], "[NAME]", 
ICON_MOD_PHYSICS, "Surface", ""},

static void rna_def_modifier_test(BlenderRNA *brna)
{
     StructRNA *srna;

     srna= RNA_def_struct(brna, "TestModifier", "Modifier");
     RNA_def_struct_ui_text(srna, "Test Modifier", "just a test");
     RNA_def_struct_sdna(srna, "TestModifierData");
     RNA_def_struct_ui_icon(srna, ICON_MOD_PARTICLES);
}
add sdna fields
static StructRNA* rna_Modifier_refine(struct PointerRNA *ptr)
  add case

call method from register

4 modifier.c
         mti = INIT_TYPE(Test);
         mti->type = eModifierTypeType_Constructive;
         mti->flags = eModifierTypeFlag_AcceptsMesh;
         mti->initData = testModifier_initData; // method to be called 
when created
         mti->copyData = testModifier_copyData; // method to be called 
when copied
         mti->applyModifier = testModifier_applyModifier; // method to 
be called when applied
         mti->applyModifierEM = testModifier_applyModifierEM; // method 
to be called when applied
/** test modifier **/
static void testModifier_initData(ModifierData *md)
{
}

static void testModifier_copyData(ModifierData *md, ModifierData *target)
{
}
static DerivedMesh *testModifier_applyModifier(ModifierData *md,
                            Object *ob,
                            DerivedMesh *dm,
                            int useRenderParams,
                            int isFinalCalc)
{
     return dm;
}
static DerivedMesh *testModifier_applyModifierEM(ModifierData *md,
                              Object *ob,
                              EditMesh *editData,
                              DerivedMesh *derivedData)
{
     return testModifier_applyModifier(md, ob, derivedData, 0, 1);
}

5. add user interface panel.
properties_data_modifier.py
class DATA_PT_modifiers add method [NAME]

6. implement modifier.




On 10/08/2010 12:30 PM, Tobias Oelgarte wrote:
> Hello,
>
> Im currently looking into the sources of blender and try to understand
> how the modifiers are working. Writing a modifier seams to be simple,
> but on the other side there are many other files that are keeping lists
> of them (to know which are available). This is somehow like finding all
> needles in a haystack.
>
> Is there a documentation on modifiers, that lists all the files that
> need to be changed if you write/add your own modifier? Need this files
> to be changed, or will they be updated automatically? (guess not)
>
> Somehow i miss some document that points out how i can write my own
> modifier from scratch (including gui etc.). At least a very simple
> example would be nice.
>
> Currently i developed code to write a so called RestoreVolume-Modifer,
> that ensures that a closed mesh keeps/restores it's original volume
> after deformations (due to other modifiers). Simplest example would be a
> muscle that contracts and will grow on the sides (controllable by vertex
> group), because of the loss of volume in length.
>
> Any suggestions or hints?
>
> Best wishes Tobias Oelgarte
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>
>    


-- 

Met vriendelijke groet,

Jeroen Bakker

*At Mind BV
*

Telefoon: 06 50 611 262
E-mail: j.bakker at atmind.nl <mailto:j.bakker at atmind.nl>




More information about the Bf-committers mailing list