diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-10 07:03:53 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-10 07:03:53 +0400 |
commit | 2889f5ae2c8636037462791c013c22dbdfed81de (patch) | |
tree | d5d37a83b9719b0b9a246ebe05abf9f499ac920c | |
parent | 14c3714b81b0c264ff8e117f0230330cc0514ed2 (diff) |
camera composition guides: center, thirds, golden rule
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_camera.py | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 133 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_camera_types.h | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_camera.c | 15 |
4 files changed, 145 insertions, 16 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index e5076fd20d5..80cd5227fca 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -127,6 +127,7 @@ class DATA_PT_camera_display(CameraButtonsPanel, bpy.types.Panel): 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_menu_enum(cam, "show_guide") col = split.column() col.prop(cam, "draw_size", text="Size") diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index e967e8ed2e7..fe0b0b7c928 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -921,6 +921,60 @@ void view3d_calc_camera_border(Scene *scene, ARegion *ar, RegionView3D *rv3d, Vi } } +static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float fac, char diagonal) +{ + float x3, y3, x4, y4; + + x3= x1 + fac * (x2-x1); + y3= y1 + fac * (y2-y1); + x4= x1 + (1.0f - fac) * (x2-x1); + y4= y1 + (1.0f - fac) * (y2-y1); + + glBegin(GL_LINES); + switch(diagonal) { + case '\0': + glVertex2f(x1, y3); + glVertex2f(x2, y3); + + glVertex2f(x1, y4); + glVertex2f(x2, y4); + + glVertex2f(x3, y1); + glVertex2f(x3, y2); + + glVertex2f(x4, y1); + glVertex2f(x4, y2); + break; + case 'H': /* hoz */ + glVertex2f(x1, y1); + glVertex2f(x2, y4); + + glVertex2f(x1, y3); + glVertex2f(x2, y2); + + glVertex2f(x2, y1); + glVertex2f(x1, y4); + + glVertex2f(x2, y3); + glVertex2f(x1, y2); + break; + case 'V': /* vert */ + glVertex2f(x1, y1); + glVertex2f(x4, y2); + + glVertex2f(x3, y1); + glVertex2f(x2, y2); + + glVertex2f(x1, y2); + glVertex2f(x4, y1); + + glVertex2f(x3, y2); + glVertex2f(x2, y1); + break; + } + glEnd(); +} + static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) { float fac, a; @@ -995,21 +1049,70 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) } /* safety border */ - if (ca && (ca->flag & CAM_SHOWTITLESAFE)) { - fac= 0.1; - - a= fac*(x2-x1); - x1+= a; - x2-= a; - - a= fac*(y2-y1); - y1+= a; - y2-= a; - - UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - - uiSetRoundBox(15); - uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); + if(ca) { + if (ca->dtx & CAM_DTX_CENTER) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + + x3= x1+ 0.5f*(x2-x1); + y3= y1+ 0.5f*(y2-y1); + + glBegin(GL_LINES); + glVertex2f(x1, y3); + glVertex2f(x2, y3); + + glVertex2f(x3, y1); + glVertex2f(x3, y2); + glEnd(); + } + + if (ca->dtx & CAM_DTX_CENTER_DIAG) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + + glBegin(GL_LINES); + glVertex2f(x1, y1); + glVertex2f(x2, y2); + + glVertex2f(x1, y2); + glVertex2f(x2, y1); + glEnd(); + } + + if (ca->dtx & CAM_DTX_THIRDS) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f/3.0f, '\0'); + } + + if (ca->dtx & CAM_DTX_GOLDEN) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399), '\0'); + } + + if (ca->dtx & CAM_DTX_GOLDEN_DIAG_H) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399), 'H'); + } + + if (ca->dtx & CAM_DTX_GOLDEN_DIAG_V) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399), 'V'); + } + + if (ca->flag & CAM_SHOWTITLESAFE) { + fac= 0.1; + + a= fac*(x2-x1); + x1+= a; + x2-= a; + + a= fac*(y2-y1); + y1+= a; + y2-= a; + + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + + uiSetRoundBox(15); + uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); + } } setlinestyle(0); diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h index 4ebd7318ea8..d64b72c6f40 100644 --- a/source/blender/makesdna/DNA_camera_types.h +++ b/source/blender/makesdna/DNA_camera_types.h @@ -47,7 +47,9 @@ typedef struct Camera { ID id; struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ - short type, flag; + char type; /* CAM_PERSP or CAM_ORTHO */ + char dtx; /* draw type extra */ + short flag; float passepartalpha; float clipsta, clipend; float lens, ortho_scale, drawsize; @@ -69,6 +71,14 @@ typedef struct Camera { #define CAM_PERSP 0 #define CAM_ORTHO 1 +/* dtx */ +#define CAM_DTX_CENTER 1 +#define CAM_DTX_CENTER_DIAG 2 +#define CAM_DTX_THIRDS 4 +#define CAM_DTX_GOLDEN 8 +#define CAM_DTX_GOLDEN_DIAG_H 16 +#define CAM_DTX_GOLDEN_DIAG_V 32 + /* flag */ #define CAM_SHOWLIMITS 1 #define CAM_SHOWMIST 2 diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 34b1dc85881..ff25d6d49b0 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -67,6 +67,14 @@ void RNA_def_camera(BlenderRNA *brna) {CAM_PERSP, "PERSP", 0, "Perspective", ""}, {CAM_ORTHO, "ORTHO", 0, "Orthographic", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem prop_draw_type_extra_items[] = { + {CAM_DTX_CENTER, "CENTER", 0, "Center", ""}, + {CAM_DTX_CENTER_DIAG, "CENTER_DIAGONAL", 0, "Center Diagonal", ""}, + {CAM_DTX_THIRDS, "THIRDS", 0, "Thirds", ""}, + {CAM_DTX_GOLDEN, "GOLDEN", 0, "Golden", ""}, + {CAM_DTX_GOLDEN_DIAG_H, "GOLDEN_DIAGONAL_H", 0, "Golden Diagonal Hoz", ""}, + {CAM_DTX_GOLDEN_DIAG_V, "GOLDEN_DIAGONAL_V", 0, "Golden Diagonal Vert", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_lens_unit_items[] = { {0, "MILLIMETERS", 0, "Millimeters", ""}, {CAM_ANGLETOGGLE, "DEGREES", 0, "Degrees", ""}, @@ -81,6 +89,13 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_type_items); RNA_def_property_ui_text(prop, "Type", "Camera types"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + + prop= RNA_def_property(srna, "show_guide", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "dtx"); + RNA_def_property_enum_items(prop, prop_draw_type_extra_items); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_ui_text(prop, "Comosition Guide", "Draw overlay"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); /* Number values */ |