feature request from colin levy, camera lens stamp.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 13 Jan 2011 19:16:35 +0000 (19:16 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 13 Jan 2011 19:16:35 +0000 (19:16 +0000)
release/scripts/ui/properties_render.py
source/blender/blenkernel/intern/image.c
source/blender/blenlib/intern/math_rotation.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c
source/blender/nodes/intern/CMP_util.h

index 9ea41b080af0380cf60a179104d4f3317b422256..ed25fc1b0e73de427b68cb79e94b79ee72515cef 100644 (file)
@@ -588,6 +588,7 @@ class RENDER_PT_stamp(RenderButtonsPanel, bpy.types.Panel):
         col.prop(rd, "use_stamp_frame", text="Frame")
         col.prop(rd, "use_stamp_scene", text="Scene")
         col.prop(rd, "use_stamp_camera", text="Camera")
+        col.prop(rd, "use_stamp_lens", text="Lens")
         col.prop(rd, "use_stamp_filename", text="Filename")
         col.prop(rd, "use_stamp_marker", text="Marker")
         col.prop(rd, "use_stamp_sequencer_strip", text="Seq. Strip")
index d8876705ebb5ad8e59c7f475f6daed83f0251c1a..3d69f51851f36309858b5d62fa26adff6f7db8a7 100644 (file)
@@ -54,6 +54,7 @@
 
 #include "DNA_packedFile_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_object_types.h"
 #include "DNA_camera_types.h"
 #include "DNA_sequence_types.h"
 #include "DNA_userdef_types.h"
@@ -859,6 +860,7 @@ typedef struct StampData {
        char    time[512];
        char    frame[512];
        char    camera[64];
+       char    cameralens[64];
        char    scene[64];
        char    strip[64];
        char    rendertime[64];
@@ -955,7 +957,7 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
        }
 
        if (scene->r.stamp & R_STAMP_CAMERA) {
-               if (scene->camera) strcpy(text, ((Camera *) scene->camera)->id.name+2);
+               if (scene->camera) strcpy(text, scene->camera->id.name+2);
                else            strcpy(text, "<none>");
                
                if (do_prefix)          sprintf(stamp_data->camera, "Camera %s", text);
@@ -964,6 +966,18 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
                stamp_data->camera[0] = '\0';
        }
 
+       if (scene->r.stamp & R_STAMP_CAMERALENS) {
+               if (scene->camera && scene->camera->type == OB_CAMERA) {
+                       sprintf(text, "%.2f", ((Camera *)scene->camera->data)->lens);
+               }
+               else            strcpy(text, "<none>");
+
+               if (do_prefix)          sprintf(stamp_data->cameralens, "Lens %s", text);
+               else                            sprintf(stamp_data->cameralens, "%s", text);
+       } else {
+               stamp_data->cameralens[0] = '\0';
+       }
+
        if (scene->r.stamp & R_STAMP_SCENE) {
                if (do_prefix)          sprintf(stamp_data->scene, "Scene %s", scene->id.name+2);
                else                            sprintf(stamp_data->scene, "%s", scene->id.name+2);
@@ -1145,6 +1159,18 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
                buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2);
                BLF_position(mono, x, y+3, 0.0);
                BLF_draw_buffer(mono, stamp_data.camera);
+
+               /* space width. */
+               x += w + pad;
+       }
+
+       if (stamp_data.cameralens[0]) {
+               BLF_width_and_height(mono, stamp_data.cameralens, &w, &h); h= h_fixed;
+
+               /* extra space for background. */
+               buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2);
+               BLF_position(mono, x, y+3, 0.0);
+               BLF_draw_buffer(mono, stamp_data.cameralens);
        }
        
        if (stamp_data.scene[0]) {
@@ -1195,6 +1221,7 @@ void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf)
        if (stamp_data.time[0])         IMB_metadata_change_field (ibuf, "Time",                stamp_data.time);
        if (stamp_data.frame[0])        IMB_metadata_change_field (ibuf, "Frame",       stamp_data.frame);
        if (stamp_data.camera[0])       IMB_metadata_change_field (ibuf, "Camera",      stamp_data.camera);
+       if (stamp_data.cameralens[0]) IMB_metadata_change_field (ibuf, "Lens",  stamp_data.cameralens);
        if (stamp_data.scene[0])        IMB_metadata_change_field (ibuf, "Scene",       stamp_data.scene);
        if (stamp_data.strip[0])        IMB_metadata_change_field (ibuf, "Strip",       stamp_data.strip);
        if (stamp_data.rendertime[0]) IMB_metadata_change_field (ibuf, "RenderTime", stamp_data.rendertime);
index 6799fef3b5c3afdf10791d498b44980f1cf62af6..28a37d9675ad84a97d849eae0c19bbfba364bc6e 100644 (file)
@@ -1650,7 +1650,7 @@ void vec_apply_track(float vec[3], short axis)
        }
 }
 
-/* lense/angle conversion (radians) */
+/* lens/angle conversion (radians) */
 float lens_to_angle(float lens)
 {
        return 2.0f * atan(16.0f/lens);
index de589f27abc2bc08a0628cef7800bbab26c869ab..93fe0f0b4e5475c724d27617c293a0bcdfaca8f8 100644 (file)
@@ -946,7 +946,8 @@ typedef struct Scene {
 #define R_STAMP_FILENAME       0x0100
 #define R_STAMP_SEQSTRIP       0x0200
 #define R_STAMP_RENDERTIME     0x0400
-#define R_STAMP_ALL            (R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_CAMERA|R_STAMP_SCENE|R_STAMP_NOTE|R_STAMP_MARKER|R_STAMP_FILENAME|R_STAMP_SEQSTRIP|R_STAMP_RENDERTIME)
+#define R_STAMP_CAMERALENS     0x0800
+#define R_STAMP_ALL            (R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_CAMERA|R_STAMP_SCENE|R_STAMP_NOTE|R_STAMP_MARKER|R_STAMP_FILENAME|R_STAMP_SEQSTRIP|R_STAMP_RENDERTIME|R_STAMP_CAMERALENS)
 
 /* alphamode */
 #define R_ADDSKY               0
index 13a46e088149ab5b17778ae1d58e1b614bd49889..3372055ee3ed2b6aa4718f18e95b7d2c3e63d4d0 100644 (file)
@@ -2777,6 +2777,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_CAMERA);
        RNA_def_property_ui_text(prop, "Stamp Camera", "Include the name of the active camera in image metadata");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
+
+       prop= RNA_def_property(srna, "use_stamp_lens", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_CAMERALENS);
+       RNA_def_property_ui_text(prop, "Stamp Lens", "Include the name of the active cameras lens in image metadata");
+       RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        
        prop= RNA_def_property(srna, "use_stamp_scene", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_SCENE);
index 1f91ee8a457a2de80294523c3a4878543992747f..df583767f76c0283b491e7d03b978241c2e9d717 100644 (file)
@@ -164,7 +164,7 @@ void convolve(CompBuf* dst, CompBuf* in1, CompBuf* in2);
 extern void node_ID_title_cb(void *node_v, void *unused_v);
 
 
-/* utility functions used by glare, tonemap and lense distortion */
+/* utility functions used by glare, tonemap and lens distortion */
 /* soms macros for color handling */
 typedef float fRGB[4];
 /* clear color */