Index: release/scripts/startup/bl_ui/properties_data_camera.py =================================================================== --- release/scripts/startup/bl_ui/properties_data_camera.py (revision 36460) +++ release/scripts/startup/bl_ui/properties_data_camera.py (working copy) @@ -127,6 +127,7 @@ col.prop(cam, "show_mist", text="Mist") col.prop(cam, "show_title_safe", text="Title Safe") col.prop(cam, "show_name", text="Name") + col.prop(cam, "show_guides", text="Guides") col = split.column() col.prop(cam, "draw_size", text="Size") @@ -137,6 +138,19 @@ sub.prop(cam, "passepartout_alpha", text="Alpha", slider=True) +class DATA_PT_camera_guides(CameraButtonsPanel, bpy.types.Panel): + bl_label = "Guides" + bl_options = {'DEFAULT_CLOSED'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} + + def draw(self, context): + layout = self.layout + + col = layout.column() + col.operator("view3d.camera_guide_add", text="Add Guide") + col.operator("view3d.camera_guide_remove", text="Remove Guide") + + class DATA_PT_custom_props_camera(CameraButtonsPanel, PropertyPanel, bpy.types.Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "object.data" Index: source/blender/makesdna/DNA_camera_types.h =================================================================== --- source/blender/makesdna/DNA_camera_types.h (revision 36460) +++ source/blender/makesdna/DNA_camera_types.h (working copy) @@ -43,10 +43,20 @@ struct AnimData; struct Ipo; +typedef struct CamGuide { + struct CamGuide *next, *prev; + + float point1x, point1y; + float point2x, point2y; + float alpha, pad; +} CamGuide; + typedef struct Camera { ID id; struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ + ListBase guides; /* camera guides */ + short type, flag; float passepartalpha; float clipsta, clipend; @@ -78,6 +88,7 @@ #define CAM_ANGLETOGGLE 32 #define CAM_DS_EXPAND 64 #define CAM_PANORAMA 128 +#define CAM_GUIDES 256 /* yafray: dof sampling switch */ /* #define CAM_YF_NO_QMC 512 */ /* depreceated */ Index: source/blender/makesrna/intern/rna_camera.c =================================================================== --- source/blender/makesrna/intern/rna_camera.c (revision 36460) +++ source/blender/makesrna/intern/rna_camera.c (working copy) @@ -59,6 +59,41 @@ #else +static void rna_def_camera_guides(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "CameraGuides", NULL); + RNA_def_struct_sdna(srna, "CamGuide"); + RNA_def_struct_ui_text(srna, "Camera Guide Element", "Data for Camera guide for scene Composition"); + + prop= RNA_def_property(srna, "point1_x", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "point1x"); + RNA_def_property_ui_text(prop, "Point1 X", "The X position of the first point of the guide"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + + prop= RNA_def_property(srna, "point1_y", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "point1y"); + RNA_def_property_ui_text(prop, "Point1 Y", "The Y position of the first point of the guide"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + + prop= RNA_def_property(srna, "point2_x", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "point2x"); + RNA_def_property_ui_text(prop, "Point2 X", "The X position of the second point of the guide"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + + prop= RNA_def_property(srna, "point2_y", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "point2y"); + RNA_def_property_ui_text(prop, "Point2 Y", "The Y position of the second point of the guide"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + + prop= RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "alpha"); + RNA_def_property_ui_text(prop, "Alpha", "The visibility of the guide"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); +} + void RNA_def_camera(BlenderRNA *brna) { StructRNA *srna; @@ -184,8 +219,18 @@ RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); /* pointers */ + rna_def_camera_guides(brna); rna_def_animdata_common(srna); + prop= RNA_def_property(srna, "guides", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "CameraGuides"); + RNA_def_property_ui_text(prop, "Guides", "Camera Guides"); + + prop= RNA_def_property(srna, "show_guides", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_GUIDES); + RNA_def_property_ui_text(prop, "Show Guides", "Draw Camera Guides for framing and blocking"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + prop= RNA_def_property(srna, "dof_object", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_pointer_sdna(prop, NULL, "dof_ob"); Index: source/blender/editors/space_view3d/view3d_edit.c =================================================================== --- source/blender/editors/space_view3d/view3d_edit.c (revision 36460) +++ source/blender/editors/space_view3d/view3d_edit.c (working copy) @@ -2585,7 +2585,6 @@ RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file"); } - /* ***** remove image operator ******* */ static int background_image_remove_exec(bContext *C, wmOperator *op) { @@ -2623,6 +2622,99 @@ RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Background image index to remove ", 0, INT_MAX); } +/* ******************** add camera guide operator **************** */ + +static CamGuide *camera_guide_add(bContext *C) +{ + Object *ob= CTX_data_active_object(C); + Camera *cam= ob->data; + + CamGuide *camguide= MEM_callocN(sizeof(CamGuide), "Camera Guide"); + camguide->point1x= 0.5; + camguide->point1y= 0; + camguide->point2x= 0.5; + camguide->point2y= 1.0; + camguide->alpha= 1.0; + + BLI_addtail(&cam->guides, camguide); + + //MEM_freeN(camguide); + + return camguide; +} + +static int camera_guide_add_exec(bContext *C, wmOperator *UNUSED(op)) +{ + camera_guide_add(C); + + return OPERATOR_FINISHED; +} + +static int camera_guide_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + CamGuide *camguide; + View3D *v3d= CTX_wm_view3d(C); + + camguide = camera_guide_add(C); + + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); + + return OPERATOR_FINISHED; +} + +void VIEW3D_OT_camera_guide_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Add Camera Guide"; + ot->description= "Add a new background image"; + ot->idname = "VIEW3D_OT_camera_guide_add"; + + /* api callbacks */ + ot->invoke = camera_guide_add_invoke; + ot->exec = camera_guide_add_exec; + ot->poll= ED_operator_object_active_editable; +} + +/* ***** remove guide operator ******* */ +static int camera_guide_remove_exec(bContext *C, wmOperator *op) +{ + View3D *vd = CTX_wm_view3d(C); + Object *ob= CTX_data_active_object(C); + Camera *cam= ob->data; + int index = RNA_int_get(op->ptr, "index"); + CamGuide *camguide_rem= BLI_findlink(&cam->guides, index); + + if(camguide_rem) { + BLI_remlink(&cam->guides, camguide_rem); + MEM_freeN(camguide_rem); + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, vd); + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } + +} + +void VIEW3D_OT_camera_guide_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Remove Background Image"; + ot->description= "Remove a background image from the 3D view"; + ot->idname = "VIEW3D_OT_camera_guide_remove"; + + /* api callbacks */ + ot->exec = camera_guide_remove_exec; + ot->poll = ED_operator_view3d_active; + + /* flags */ + ot->flag = 0; + + RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Guide index to remove ", 0, INT_MAX); +} + + + /* ********************* set clipping operator ****************** */ static void calc_clipping_plane(float clip[6][4], BoundBox *clipbb) Index: source/blender/editors/space_view3d/view3d_draw.c =================================================================== --- source/blender/editors/space_view3d/view3d_draw.c (revision 36460) +++ source/blender/editors/space_view3d/view3d_draw.c (working copy) @@ -994,6 +994,31 @@ glRectf(x3, y3, x4, y4); } + if (ca && (ca->flag & CAM_GUIDES)) { + + CamGuide *guide; + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + + for(guide= ca->guides.first; guide; guide= guide->next) { + float g1x,g1y,g2x,g2y; + + g1x = x1+((x2-x1)*guide->point1x); + g1y = y1+((y2-y1)*guide->point1y); + + g2x = x1+((x2-x1)*guide->point2x); + g2y = y1+((y2-y1)*guide->point2y); + + glColor4f(0.0, 0.0, 0.0, guide->alpha); + glBegin(GL_LINES); + glVertex2f( g1x, g1y); + glVertex2f( g2x, g2y); + glEnd(); + } + glDisable(GL_BLEND); + } + /* safety border */ if (ca && (ca->flag & CAM_SHOWTITLESAFE)) { fac= 0.1; Index: source/blender/editors/space_view3d/view3d_ops.c =================================================================== --- source/blender/editors/space_view3d/view3d_ops.c (revision 36460) +++ source/blender/editors/space_view3d/view3d_ops.c (working copy) @@ -101,6 +101,9 @@ WM_operatortype_append(VIEW3D_OT_snap_cursor_to_center); WM_operatortype_append(VIEW3D_OT_snap_cursor_to_selected); WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active); + + WM_operatortype_append(VIEW3D_OT_camera_guide_add); + WM_operatortype_append(VIEW3D_OT_camera_guide_remove); transform_operatortypes(); } Index: source/blender/editors/space_view3d/view3d_intern.h =================================================================== --- source/blender/editors/space_view3d/view3d_intern.h (revision 36460) +++ source/blender/editors/space_view3d/view3d_intern.h (working copy) @@ -90,6 +90,9 @@ void VIEW3D_OT_zoom_border(struct wmOperatorType *ot); void VIEW3D_OT_drawtype(struct wmOperatorType *ot); +void VIEW3D_OT_camera_guide_add(struct wmOperatorType *ot); +void VIEW3D_OT_camera_guide_remove(struct wmOperatorType *ot); + void view3d_boxview_copy(ScrArea *sa, ARegion *ar); void view3d_persp_mat4(struct RegionView3D *rv3d, float mat[][4]);