diff options
author | Ton Roosendaal <ton@blender.org> | 2007-03-23 16:12:11 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2007-03-23 16:12:11 +0300 |
commit | bc31d61c3b1817916a77d7b0244de3f1973388e9 (patch) | |
tree | 1b7362e0dabf242164d5dd64710e81d71898bd06 /source | |
parent | c448d2d3a57ed22ddf60fdbca61f3ac6969eabce (diff) |
patch 5341 by Juho
This adds option to show camera angle instead of camera lens value.
(Complete revised patch...)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 3 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 8 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_camera_types.h | 4 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Camera.c | 6 | ||||
-rw-r--r-- | source/blender/src/buttons_editing.c | 45 |
5 files changed, 59 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 742b417b154..4d747e3c942 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -496,6 +496,7 @@ void *add_camera(char *name) cam= alloc_libblock(&G.main->camera, ID_CA, name); cam->lens= 35.0f; + cam->angle= 49.14f; cam->clipsta= 0.1f; cam->clipend= 100.0f; cam->drawsize= 0.5f; @@ -2059,5 +2060,3 @@ void object_handle_update(Object *ob) // printf("set proxy pointer for later group stuff %s\n", ob->id.name); } } - - diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 9aebcd75116..5a5c4ab5591 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6368,6 +6368,14 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + if(main->versionfile <= 243) { + Camera *cam = main->camera.first; + + for(; cam; cam= cam->id.next) { + cam->angle= 360.0f * atan(16.0f/cam->lens) / M_PI; + printf("cam angle %f lens %f\n", cam->angle, cam->lens); + } + } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */ diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h index 8bf9d951f80..f25d8fd6412 100644 --- a/source/blender/makesdna/DNA_camera_types.h +++ b/source/blender/makesdna/DNA_camera_types.h @@ -47,7 +47,7 @@ typedef struct Camera { ID id; short type, flag; - float passepartalpha, pad1; + float passepartalpha, angle; float clipsta, clipend; float lens, ortho_scale, drawsize; float shiftx, shifty; @@ -76,6 +76,7 @@ typedef struct Camera { #define CAM_SHOWPASSEPARTOUT 4 #define CAM_SHOWTITLESAFE 8 #define CAM_SHOWNAME 16 +#define CAM_ANGLETOGGLE 32 /* yafray: dof sampling switch */ #define CAM_YF_NO_QMC 512 @@ -86,4 +87,3 @@ typedef struct Camera { #endif #endif - diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c index 04c94ef5dba..f77499b6c03 100644 --- a/source/blender/python/api2_2x/Camera.c +++ b/source/blender/python/api2_2x/Camera.c @@ -925,7 +925,11 @@ static PyGetSetDef BPy_Camera_getseters[] = { (getter)getFlagAttr, (setter)setFlagAttr, "toggle the passPartOut display flag", (void *)CAM_SHOWPASSEPARTOUT}, - {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ + {"angleToggle", + (getter)getFlagAttr, (setter)setFlagAttr, + "toggle the camera input unit flag", + (void *)CAM_ANGLETOGGLE}, + {NULL,NULL,NULL,NULL} /* Sentinel */ }; diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 6d6875e23d7..62e831a007b 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -2969,10 +2969,40 @@ static void editing_panel_curve_type(Object *ob, Curve *cu) /* *************************** CAMERA ******************************** */ +/* callback to handle angle to lens conversion */ +static void do_angletolensconversion_cb(void *lens1, void *angle1) +{ + float *lens= (float *)lens1; + float *angle= (float *)angle1; + float anglevalue= *angle; + + if(lens) { + *lens= 16.0f / tan(M_PI*anglevalue/360.0f); + } + + allqueue(REDRAWVIEW3D, 0); +} + +/* callback to handle lens to angle conversion */ +static void do_lenstoangleconversion_cb(void *lens1, void *angle1) +{ + float *lens= (float *)lens1; + float *angle= (float *)angle1; + float lensvalue= *lens; + + if(lens) { + *angle= 360.0f * atan(16.0f/lensvalue) / M_PI; + printf("cam angle %f lens %f\n", *angle, *lens); + + } + + allqueue(REDRAWVIEW3D, 0); +} static void editing_panel_camera_type(Object *ob, Camera *cam) { uiBlock *block; + uiBut *but; float grid=0.0; if(G.vd) grid= G.vd->grid; @@ -2987,8 +3017,19 @@ static void editing_panel_camera_type(Object *ob, Camera *cam) uiDefButF(block, NUM,REDRAWVIEW3D, "Scale:", 10, 160, 150, 20, &cam->ortho_scale, 0.01, 1000.0, 50, 0, "Specify the ortho scaling of the used camera"); } else { - uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:", - 10, 160, 150, 20, &cam->lens, 1.0, 250.0, 100, 0, "Specify the lens of the camera"); + if(cam->flag & CAM_ANGLETOGGLE) { + but= uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:", + 10, 160, 130, 20, &cam->angle, 1.0, 250.0, 100, 0, "Specify the lens of the camera in degrees"); + uiButSetFunc(but,do_angletolensconversion_cb, &cam->lens, &cam->angle); + } + else { + but= uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:", + 10, 160, 130, 20, &cam->lens, 1.0, 250.0, 100, 0, "Specify the lens of the camera"); + uiButSetFunc(but,do_lenstoangleconversion_cb, &cam->lens, &cam->angle); + } + + uiDefButS(block, TOG|BIT|5, B_REDR, "D", + 140, 160, 20, 20, &cam->flag, 0, 0, 0, 0, "Use degree as the unit of the camera lens"); } /* qdn: focal dist. param. from yafray now enabled for Blender as well, to use with defocus composit node */ |