feature request from colin levy, camera lens stamp.

This commit is contained in:
Campbell Barton 2011-01-13 19:16:35 +00:00
parent 1939ad3f94
commit 4cc4a73a9e
6 changed files with 38 additions and 4 deletions

@ -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")

@ -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);

@ -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);

@ -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

@ -2778,6 +2778,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
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);
RNA_def_property_ui_text(prop, "Stamp Scene", "Include the name of the active scene in image metadata");

@ -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 */