for ob in scn.objects:
ob.select = False
- scn.set_frame(IMPORT_START_FRAME)
+ scn.frame_set(IMPORT_START_FRAME)
arm_data = bpy.data.armatures.new("MyBVH")
arm_ob = bpy.data.objects.new("MyBVH", arm_data)
bmat = MATDICT[matName][1]
img = TEXTURE_DICT.get(bmat.name)
- bmesh.materials.link(bmat) # can be None
+ bmesh.materials.append(bmat) # can be None
if uv_faces and img:
for fidx in faces:
ob_base.update(scene)
# This causes the makeDisplayList command to effect the mesh
- scene.set_frame(scene.frame_current)
+ scene.frame_set(scene.frame_current)
# Blender.Set('curframe', Blender.Get('curframe'))
if ob_base.type == 'ARMATURE':
ob_base.update(scene)
# This causes the makeDisplayList command to effect the mesh
- scene.set_frame(scene.frame_current)
+ scene.frame_set(scene.frame_current)
# Blender.Set('curframe', Blender.Get('curframe'))
del tmp_ob_type, tmp_objects
'''
i = act_start
while i <= act_end:
- scene.set_frame(i)
+ scene.frame_set(i)
# Blender.Set('curframe', i)
for ob_generic in ob_anim_lists:
for my_ob in ob_generic:
file.write('\n}')
- scene.set_frame(frame_orig)
-# Blender.Set('curframe', frame_orig)
+ scene.frame_set(frame_orig)
else:
# no animation
# make sure the list isnt too big
for material in materials:
- me.materials.link(material)
+ me.materials.append(material)
me.vertices.add(len(verts_loc))
me.faces.add(len(faces))
bpy.ops.object.mode_set(mode='OBJECT')
orig_frame = scene.frame_current
- scene.set_frame(frame_start)
+ scene.frame_set(frame_start)
me = obj.create_mesh(scene, True, 'PREVIEW')
#Flip y and z
me_tmp.getFromObject(obj.name)
"""
- scene.set_frame(frame)
+ scene.frame_set(frame)
me = obj.create_mesh(scene, True, 'PREVIEW')
check_vertcount(me, numverts)
me.transform(mat_flip * obj.matrix_world)
Blender.Window.WaitCursor(0)
Blender.Set('curframe', orig_frame)
"""
- scene.set_frame(orig_frame)
+ scene.frame_set(orig_frame)
return {'FINISHED'}
# could spped this up by applying steps here too...
for f in frame_range:
- scene.set_frame(f)
+ scene.frame_set(f)
info = pose_info()
info_ls.append(info)
if ob.name in group.objects:
col = layout.column(align=True)
- col.set_context_pointer("group", group)
+ col.context_pointer_set("group", group)
row = col.box().row()
row.prop(group, "name", text="")
if md:
# remove modifier + settings
- split.set_context_pointer("modifier", md)
+ split.context_pointer_set("modifier", md)
split.operator("object.modifier_remove", text="Remove")
row = split.row(align=True)
def point_cache_ui(self, context, cache, enabled, cachetype):
layout = self.layout
- layout.set_context_pointer("point_cache", cache)
+ layout.context_pointer_set("point_cache", cache)
row = layout.row()
row.template_list(cache, "point_caches", cache.point_caches, "active_index", rows=2)
if md:
# remove modifier + settings
- split.set_context_pointer("modifier", md)
+ split.context_pointer_set("modifier", md)
split.operator("object.modifier_remove", text="Remove")
col = split.column()
if md:
# remove modifier + settings
- split.set_context_pointer("modifier", md)
+ split.context_pointer_set("modifier", md)
split.operator("object.modifier_remove", text="Remove")
row = split.row(align=True)
if md:
# remove modifier + settings
- split.set_context_pointer("modifier", md)
+ split.context_pointer_set("modifier", md)
split.operator("object.modifier_remove", text="Remove")
row = split.row(align=True)
if md:
# remove modifier + settings
- split.set_context_pointer("modifier", md)
+ split.context_pointer_set("modifier", md)
split.operator("object.modifier_remove", text="Remove")
row = split.row(align=True)
def draw_km(self, display_keymaps, kc, km, children, layout, level):
km = km.active()
- layout.set_context_pointer("keymap", km)
+ layout.context_pointer_set("keymap", km)
col = self.indented_layout(layout, level)
kmm = kc.keymaps.find_modal(kmi.idname)
if kmm:
self.draw_km(display_keymaps, kc, kmm, None, layout, level + 1)
- layout.set_context_pointer("keymap", km)
+ layout.context_pointer_set("keymap", km)
def draw_filtered(self, display_keymaps, filter_text, layout):
for km, kc in display_keymaps:
km = km.active()
- layout.set_context_pointer("keymap", km)
+ layout.context_pointer_set("keymap", km)
filtered_items = [kmi for kmi in km.items if filter_text in kmi.name.lower()]
row = subcol.row()
row.prop_search(wm.keyconfigs, "active", wm, "keyconfigs", text="Key Config:")
- layout.set_context_pointer("keyconfig", wm.keyconfigs.active)
+ layout.context_pointer_set("keyconfig", wm.keyconfigs.active)
row.operator("wm.keyconfig_remove", text="", icon='X')
row.prop(context.space_data, "filter_text", icon="VIEWZOOM")
struct Material ***give_matarar(struct Object *ob);
short *give_totcolp(struct Object *ob);
+struct Material ***give_matarar_id(struct ID *id); /* same but for ID's */
+short *give_totcolp_id(struct ID *id);
+
struct Material *give_current_material(struct Object *ob, int act);
struct ID *material_from(struct Object *ob, int act);
void assign_material(struct Object *ob, struct Material *ma, int act);
int object_add_material_slot(struct Object *ob);
int object_remove_material_slot(struct Object *ob);
+/* rna api */
+void material_append_id(struct ID *id, struct Material *ma);
+struct Material *material_pop_id(struct ID *id, int index);
+
/* rendering */
void init_render_material(struct Material *, int, float *);
return NULL;
}
+/* same as above but for ID's */
+Material ***give_matarar_id(ID *id)
+{
+ switch(GS(id->name)) {
+ case ID_ME:
+ return &(((Mesh *)id)->mat);
+ break;
+ case ID_CU:
+ return &(((Curve *)id)->mat);
+ break;
+ case ID_MB:
+ return &(((Curve *)id)->mat);
+ break;
+ }
+ return NULL;
+}
+
+short *give_totcolp_id(ID *id)
+{
+ switch(GS(id->name)) {
+ case ID_ME:
+ return &(((Mesh *)id)->totcol);
+ break;
+ case ID_CU:
+ return &(((Curve *)id)->totcol);
+ break;
+ case ID_MB:
+ return &(((Curve *)id)->totcol);
+ break;
+ }
+ return NULL;
+}
+
+void material_append_id(ID *id, Material *ma)
+{
+ Material ***matar;
+ if((matar= give_matarar_id(id))) {
+ short *totcol= give_totcolp_id(id);
+ Material **mat= MEM_callocN(sizeof(void *) * (*totcol) + 1, "newmatar");
+ if(*totcol) memcpy(mat, *matar, sizeof(void *) * (*totcol));
+ if(*matar) MEM_freeN(*matar);
+
+ *matar= mat;
+ (*matar)[(*totcol)++]= ma;
+
+ id_us_plus((ID *)ma);
+ test_object_materials(id);
+ }
+}
+
+Material *material_pop_id(ID *id, int index)
+{
+ Material *ret= NULL;
+ Material ***matar;
+ if((matar= give_matarar_id(id))) {
+ short *totcol= give_totcolp_id(id);
+ if(index >= 0 && index < (*totcol)) {
+ ret= (*matar)[index];
+ if(*totcol <= 1) {
+ *totcol= 0;
+ MEM_freeN(*matar);
+ *matar= NULL;
+ }
+ else {
+ Material **mat;
+
+ if(index + 1 != (*totcol))
+ memmove((*matar), (*matar) + 1, (*totcol) - (index + 1));
+
+ (*totcol)--;
+
+ mat= MEM_callocN(sizeof(void *) * (*totcol), "newmatar");
+ memcpy(mat, *matar, sizeof(void *) * (*totcol));
+ MEM_freeN(*matar);
+
+ *matar= mat;
+ test_object_materials(id);
+ }
+ }
+ }
+
+ return ret;
+}
+
Material *give_current_material(Object *ob, int act)
{
Material ***matarar, *ma;
{
mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
}
-
-/* always adds the material even if its linked alredy
- * for pradictable material indicies */
-void ED_mesh_material_link(Mesh *me, Material *ma)
-{
- int totcol = me->totcol + 1;
- Material **mat;
-
- mat= MEM_callocN(sizeof(void*)*totcol, "newmatar");
-
- if(me->totcol) memcpy(mat, me->mat, sizeof(void*) * me->totcol);
- if(me->mat) MEM_freeN(me->mat);
-
- me->mat = mat;
- me->mat[me->totcol++] = ma;
- if(ma)
- ma->id.us++;
-
- test_object_materials((ID*)me);
-}
-
dna_write(file, str, 4);
len= nr_names;
dna_write(file, &len, 4);
+ printf("LEEEN %d\n", len);
+
/* calculate size of datablock with strings */
cp= names[nr_names-1];
#include "BKE_idprop.h"
#include "BKE_library.h"
#include "BKE_animsys.h"
+#include "BKE_material.h"
/* name functions that ignore the first two ID characters */
void rna_ID_name_get(PointerRNA *ptr, char *value)
RNA_def_struct_name_property(srna, prop);
}
+
+static void rna_def_ID_materials(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ /* for mesh/mball/curve materials */
+ srna= RNA_def_struct(brna, "IDMaterials", NULL);
+ RNA_def_struct_sdna(srna, "ID");
+ RNA_def_struct_ui_text(srna, "ID Materials", "Collection of materials");
+
+ func= RNA_def_function(srna, "append", "material_append_id");
+ RNA_def_function_ui_description(func, "Add a new material to Mesh.");
+ parm= RNA_def_pointer(func, "material", "Material", "", "Material to add.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+
+ func= RNA_def_function(srna, "pop", "material_pop_id");
+ RNA_def_function_ui_description(func, "Add a new material to Mesh.");
+ parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "", "Frame number to set.", 0, INT_MAX);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm= RNA_def_pointer(func, "material", "Material", "", "Material to add.");
+ RNA_def_function_return(func, parm);
+}
+
static void rna_def_ID(BlenderRNA *brna)
{
StructRNA *srna;
rna_def_ID(brna);
rna_def_ID_properties(brna);
+ rna_def_ID_materials(brna);
rna_def_library(brna);
}
RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
RNA_def_property_struct_type(prop, "Material");
RNA_def_property_ui_text(prop, "Materials", "");
+ RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
}
static void rna_def_curve_nurb(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
}
-/* mesh.materials */
-static void rna_def_mesh_materials(BlenderRNA *brna, PropertyRNA *cprop)
-{
- StructRNA *srna;
- // PropertyRNA *prop;
-
- FunctionRNA *func;
- PropertyRNA *parm;
-
- RNA_def_property_srna(cprop, "MeshMaterials");
- srna= RNA_def_struct(brna, "MeshMaterials", NULL);
- RNA_def_struct_sdna(srna, "Mesh");
- RNA_def_struct_ui_text(srna, "Mesh Materials", "Collection of materials");
-
- func= RNA_def_function(srna, "link", "ED_mesh_material_link");
- RNA_def_function_ui_description(func, "Add a new material to Mesh.");
- parm= RNA_def_pointer(func, "material", "Material", "", "Material to add.");
- RNA_def_property_flag(parm, PROP_REQUIRED);
-
- /* TODO, unlink? */
-}
-
-
static void rna_def_mesh(BlenderRNA *brna)
{
StructRNA *srna;
RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
RNA_def_property_struct_type(prop, "Material");
RNA_def_property_ui_text(prop, "Materials", "");
- rna_def_mesh_materials(brna, prop);
+ RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
/* Mesh Draw Options for Edit Mode*/
RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
RNA_def_property_struct_type(prop, "Material");
RNA_def_property_ui_text(prop, "Materials", "");
+ RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
/* anim */
rna_def_animdata_common(srna);
-static void rna_Scene_set_frame(Scene *scene, int frame, float subframe)
+static void rna_Scene_frame_set(Scene *scene, int frame, float subframe)
{
scene->r.cfra= frame;
scene->r.subframe= subframe;
FunctionRNA *func;
PropertyRNA *parm;
- func= RNA_def_function(srna, "set_frame", "rna_Scene_set_frame");
+ func= RNA_def_function(srna, "frame_set", "rna_Scene_frame_set");
RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately.");
parm= RNA_def_int(func, "frame", 0, MINAFRAME, MAXFRAME, "", "Frame number to set.", MINAFRAME, MAXFRAME);
RNA_def_property_flag(parm, PROP_REQUIRED);
RNA_def_function_ui_description(func, "Item. Inserts empty space into the layout between items.");
/* context */
- func= RNA_def_function(srna, "set_context_pointer", "uiLayoutSetContextPointer");
+ func= RNA_def_function(srna, "context_pointer_set", "uiLayoutSetContextPointer");
parm= RNA_def_string(func, "name", "", 0, "Name", "Name of entry in the context.");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_pointer(func, "data", "AnyType", "", "Pointer to put in context.");