camera composition guides:
authorCampbell Barton <ideasman42@gmail.com>
Sun, 15 May 2011 05:43:59 +0000 (05:43 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 15 May 2011 05:43:59 +0000 (05:43 +0000)
 removed diagonal golden rule (not very common), added harmonious triangle and golden triangle options.

source/blender/editors/space_view3d/view3d_draw.c
source/blender/makesdna/DNA_camera_types.h
source/blender/makesrna/intern/rna_camera.c

index 40a38d7f78c333aab5fbd25e5cc92fda0cc3eca7..4ef02243cd5d27de3fa6dd292d1b5251e240ade7 100644 (file)
@@ -921,7 +921,7 @@ 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)
+static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float fac)
 {
        float x3, y3, x4, y4;
 
@@ -931,46 +931,63 @@ static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float f
        y4= y1 + (1.0f - fac) * (y2-y1);
 
        glBegin(GL_LINES);
-       switch(diagonal) {
-       case '\0':
-               glVertex2f(x1, y3);
-               glVertex2f(x2, y3);
+       glVertex2f(x1, y3);
+       glVertex2f(x2, y3);
 
-               glVertex2f(x1, y4);
-               glVertex2f(x2, y4);
+       glVertex2f(x1, y4);
+       glVertex2f(x2, y4);
 
-               glVertex2f(x3, y1);
-               glVertex2f(x3, y2);
+       glVertex2f(x3, y1);
+       glVertex2f(x3, y2);
 
-               glVertex2f(x4, y1);
-               glVertex2f(x4, y2);
-               break;
-       case 'H': /* hoz */
-               glVertex2f(x1, y1);
-               glVertex2f(x2, y4);
+       glVertex2f(x4, y1);
+       glVertex2f(x4, y2);
+       glEnd();
+}
+
+/* harmonious triangle */
+static void drawviewborder_triangle(float x1, float x2, float y1, float y2, const char golden, const char dir)
+{
+       float ofs;
+       float w= x2 - x1;
+       float h= y2 - y1;
+
+       glBegin(GL_LINES);
+       if(w > h) {
+               if(golden) {
+                       ofs = w * (1.0f-(1.0f/1.61803399));
+               }
+               else {
+                       ofs = h * (h / w);
+               }
+               if(dir == 'B') SWAP(float, y1, y2);
 
-               glVertex2f(x1, y3);
+               glVertex2f(x1, y1);
                glVertex2f(x2, y2);
 
                glVertex2f(x2, y1);
-               glVertex2f(x1, y4);
+               glVertex2f(x1 + (w - ofs), y2);
 
-               glVertex2f(x2, y3);
                glVertex2f(x1, y2);
-               break;
-       case 'V': /* vert */
-               glVertex2f(x1, y1);
-               glVertex2f(x4, y2);
+               glVertex2f(x1 + ofs, y1);
+       }
+       else {
+               if(golden) {
+                       ofs = h * (1.0f-(1.0f/1.61803399));
+               }
+               else {
+                       ofs = w * (w / h);
+               }
+               if(dir == 'B') SWAP(float, x1, x2);
 
-               glVertex2f(x3, y1);
+               glVertex2f(x1, y1);
                glVertex2f(x2, y2);
 
-               glVertex2f(x1, y2);
-               glVertex2f(x4, y1);
-
-               glVertex2f(x3, y2);
                glVertex2f(x2, y1);
-               break;
+               glVertex2f(x1, y1 + ofs);
+
+               glVertex2f(x1, y2);
+               glVertex2f(x2, y1 + (h - ofs));
        }
        glEnd();
 }
@@ -1083,22 +1100,32 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
 
                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');
+                       drawviewborder_grid3(x1, x2, y1, y2, 1.0f/3.0f);
                }
 
                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');
+                       drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399));
+               }
+
+               if (ca->dtx & CAM_DTX_GOLDEN_TRI_A) {
+                       UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
+                       drawviewborder_triangle(x1, x2, y1, y2, 0, 'A');
+               }
+
+               if (ca->dtx & CAM_DTX_GOLDEN_TRI_B) {
+                       UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
+                       drawviewborder_triangle(x1, x2, y1, y2, 0, 'B');
                }
 
-               if (ca->dtx & CAM_DTX_GOLDEN_DIAG_H) {
+               if (ca->dtx & CAM_DTX_HARMONY_TRI_A) {
                        UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
-                       drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399), 'H');
+                       drawviewborder_triangle(x1, x2, y1, y2, 1, 'A');
                }
 
-               if (ca->dtx & CAM_DTX_GOLDEN_DIAG_V) {
+               if (ca->dtx & CAM_DTX_HARMONY_TRI_B) {
                        UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
-                       drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399), 'V');
+                       drawviewborder_triangle(x1, x2, y1, y2, 1, 'B');
                }
 
                if (ca->flag & CAM_SHOWTITLESAFE) {
index d64b72c6f402c0360b701099bb3eb4b2f678a5a9..952b4e799b5d47c10e1b262ce25f684e20d57f44 100644 (file)
@@ -76,8 +76,10 @@ typedef struct Camera {
 #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
+#define CAM_DTX_GOLDEN_TRI_A   16
+#define CAM_DTX_GOLDEN_TRI_B   32
+#define CAM_DTX_HARMONY_TRI_A  64
+#define CAM_DTX_HARMONY_TRI_B  128
 
 /* flag */
 #define CAM_SHOWLIMITS 1
index 14a2f27bd8c1e5cec00d1a0350776e64a9e7446e..089c8c44943f75c5961adbe5ea7c3c0ddf07cb2a 100644 (file)
@@ -72,8 +72,10 @@ void RNA_def_camera(BlenderRNA *brna)
                {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", ""},
+               {CAM_DTX_GOLDEN_TRI_A, "GOLDEN_TRIANGLE_A", 0, "Golden Triangle A", ""},
+               {CAM_DTX_GOLDEN_TRI_B, "GOLDEN_TRIANGLE_B", 0, "Golden Triangle B", ""},
+               {CAM_DTX_HARMONY_TRI_A, "HARMONY_TRIANGLE_A", 0, "Harmonious Triangle A", ""},
+               {CAM_DTX_HARMONY_TRI_B, "HARMONY_TRIANGLE_B", 0, "Harmonious Triangle B", ""},
                {0, NULL, 0, NULL, NULL}};
        static EnumPropertyItem prop_lens_unit_items[] = {
                {0, "MILLIMETERS", 0, "Millimeters", ""},