Revision: 38397
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38397
Author:   nazgul
Date:     2011-07-14 15:21:45 +0000 (Thu, 14 Jul 2011)
Log Message:
-----------
Camera tracking integration
===========================

Commiting patch #24427: Editable camera sensor size (meaningful focal length 
units)

Thanks to:
  Matt Ebb (author of original patch)
  Ejner Fergo (porting patch through versions)
  Brecht Van Lommel, Dalai Felinto, Campbell Barton (patch review)

Cant't commit changes to addons (they aren't branched, so some of them
could be broken now)

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_operators/presets.py
    
branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_data_camera.py
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h
    branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c
    branches/soc-2011-tomato/source/blender/blenlib/BLI_math_rotation.h
    branches/soc-2011-tomato/source/blender/blenlib/intern/math_rotation.c
    branches/soc-2011-tomato/source/blender/blenlib/intern/uvproject.c
    branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-tomato/source/blender/collada/CameraExporter.cpp
    branches/soc-2011-tomato/source/blender/collada/DocumentImporter.cpp
    branches/soc-2011-tomato/source/blender/editors/sculpt_paint/paint_image.c
    branches/soc-2011-tomato/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_view.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_camera_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_camera.c
    branches/soc-2011-tomato/source/blender/render/intern/include/render_types.h
    branches/soc-2011-tomato/source/blender/render/intern/source/envmap.c
    branches/soc-2011-tomato/source/blender/render/intern/source/initrender.c
    
branches/soc-2011-tomato/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    branches/soc-2011-tomato/source/gameengine/Ketsji/KX_Camera.cpp
    branches/soc-2011-tomato/source/gameengine/Ketsji/KX_Camera.h
    branches/soc-2011-tomato/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
    branches/soc-2011-tomato/source/gameengine/Rasterizer/RAS_CameraData.h
    branches/soc-2011-tomato/source/gameengine/Rasterizer/RAS_FramingManager.cpp
    branches/soc-2011-tomato/source/gameengine/Rasterizer/RAS_FramingManager.h
    branches/soc-2011-tomato/source/gameengine/VideoTexture/ImageRender.cpp

Added Paths:
-----------
    branches/soc-2011-tomato/release/scripts/presets/camera/
    branches/soc-2011-tomato/release/scripts/presets/camera/APS-C_DSLR.py
    branches/soc-2011-tomato/release/scripts/presets/camera/Blender.py
    
branches/soc-2011-tomato/release/scripts/presets/camera/full_frame_35mm_film.py
    branches/soc-2011-tomato/release/scripts/presets/camera/micro_four_thirds.py
    branches/soc-2011-tomato/release/scripts/presets/camera/super_16_film.py
    branches/soc-2011-tomato/release/scripts/presets/camera/super_35_film.py

Added: branches/soc-2011-tomato/release/scripts/presets/camera/APS-C_DSLR.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/presets/camera/APS-C_DSLR.py       
                        (rev 0)
+++ branches/soc-2011-tomato/release/scripts/presets/camera/APS-C_DSLR.py       
2011-07-14 15:21:45 UTC (rev 38397)
@@ -0,0 +1,3 @@
+import bpy
+bpy.context.object.data.sensor_x = 22.3
+bpy.context.object.data.sensor_y = 14.9

Added: branches/soc-2011-tomato/release/scripts/presets/camera/Blender.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/presets/camera/Blender.py          
                (rev 0)
+++ branches/soc-2011-tomato/release/scripts/presets/camera/Blender.py  
2011-07-14 15:21:45 UTC (rev 38397)
@@ -0,0 +1,3 @@
+import bpy
+bpy.context.object.data.sensor_x = 32
+bpy.context.object.data.sensor_y = 18

Added: 
branches/soc-2011-tomato/release/scripts/presets/camera/full_frame_35mm_film.py
===================================================================
--- 
branches/soc-2011-tomato/release/scripts/presets/camera/full_frame_35mm_film.py 
                            (rev 0)
+++ 
branches/soc-2011-tomato/release/scripts/presets/camera/full_frame_35mm_film.py 
    2011-07-14 15:21:45 UTC (rev 38397)
@@ -0,0 +1,3 @@
+import bpy
+bpy.context.object.data.sensor_x = 36
+bpy.context.object.data.sensor_y = 24

Added: 
branches/soc-2011-tomato/release/scripts/presets/camera/micro_four_thirds.py
===================================================================
--- 
branches/soc-2011-tomato/release/scripts/presets/camera/micro_four_thirds.py    
                            (rev 0)
+++ 
branches/soc-2011-tomato/release/scripts/presets/camera/micro_four_thirds.py    
    2011-07-14 15:21:45 UTC (rev 38397)
@@ -0,0 +1,3 @@
+import bpy
+bpy.context.object.data.sensor_x = 17.3
+bpy.context.object.data.sensor_y = 13.0

Added: branches/soc-2011-tomato/release/scripts/presets/camera/super_16_film.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/presets/camera/super_16_film.py    
                        (rev 0)
+++ branches/soc-2011-tomato/release/scripts/presets/camera/super_16_film.py    
2011-07-14 15:21:45 UTC (rev 38397)
@@ -0,0 +1,3 @@
+import bpy
+bpy.context.object.data.sensor_x = 12.52
+bpy.context.object.data.sensor_y = 7.41

Added: branches/soc-2011-tomato/release/scripts/presets/camera/super_35_film.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/presets/camera/super_35_film.py    
                        (rev 0)
+++ branches/soc-2011-tomato/release/scripts/presets/camera/super_35_film.py    
2011-07-14 15:21:45 UTC (rev 38397)
@@ -0,0 +1,3 @@
+import bpy
+bpy.context.object.data.sensor_x = 24.89
+bpy.context.object.data.sensor_y = 18.66

Modified: 
branches/soc-2011-tomato/release/scripts/startup/bl_operators/presets.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_operators/presets.py    
2011-07-14 15:21:23 UTC (rev 38396)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_operators/presets.py    
2011-07-14 15:21:45 UTC (rev 38397)
@@ -175,6 +175,24 @@
     preset_subdir = "render"
 
 
+class AddPresetCamera(AddPresetBase, bpy.types.Operator):
+    '''Add a Camera Preset'''
+    bl_idname = "camera.preset_add"
+    bl_label = "Add Camera Preset"
+    preset_menu = "CAMERA_MT_presets"
+
+    preset_defines = [
+        "cam = bpy.context.object.data"
+    ]
+
+    preset_values = [
+        "cam.sensor_x",
+        "cam.sensor_y",
+    ]
+
+    preset_subdir = "camera"
+
+
 class AddPresetSSS(AddPresetBase, bpy.types.Operator):
     '''Add a Subsurface Scattering Preset'''
     bl_idname = "material.sss_preset_add"

Modified: 
branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_data_camera.py
===================================================================
--- 
branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_data_camera.py
    2011-07-14 15:21:23 UTC (rev 38396)
+++ 
branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_data_camera.py
    2011-07-14 15:21:45 UTC (rev 38397)
@@ -32,6 +32,14 @@
         return context.camera and (engine in cls.COMPAT_ENGINES)
 
 
+class CAMERA_MT_presets(bpy.types.Menu):
+    bl_label = "Camera Presets"
+    preset_subdir = "camera"
+    preset_operator = "script.execute_preset"
+    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+    draw = bpy.types.Menu.draw_preset
+
+
 class DATA_PT_context_camera(CameraButtonsPanel, bpy.types.Panel):
     bl_label = ""
     bl_options = {'HIDE_HEADER'}
@@ -53,7 +61,7 @@
             split.separator()
 
 
-class DATA_PT_camera(CameraButtonsPanel, bpy.types.Panel):
+class DATA_PT_lens(CameraButtonsPanel, bpy.types.Panel):
     bl_label = "Lens"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
@@ -68,12 +76,17 @@
 
         col = split.column()
         if cam.type == 'PERSP':
-            if cam.lens_unit == 'MILLIMETERS':
-                col.prop(cam, "lens")
-            elif cam.lens_unit == 'DEGREES':
-                col.prop(cam, "angle")
+            col.prop(cam, "lens")
+
+            split = layout.split()
+
             col = split.column()
-            col.prop(cam, "lens_unit", text="")
+            if cam.angle_unit == 'HORIZONTAL':
+                col.prop(cam, "angle_x")
+            elif cam.angle_unit == 'VERTICAL':
+                col.prop(cam, "angle_y")
+            col = split.column()
+            col.prop(cam, "angle_unit", text="")
 
         elif cam.type == 'ORTHO':
             col.prop(cam, "ortho_scale")
@@ -89,26 +102,48 @@
 
         split = layout.split()
 
+        col = split.column()
+        col.label(text="Depth of Field:")
+
+        col.prop(cam, "dof_object", text="")
+
+        col = col.column()
+        if cam.dof_object != None:
+            col.enabled = False
+        col.prop(cam, "dof_distance", text="Distance")
+
         col = split.column(align=True)
         col.label(text="Shift:")
         col.prop(cam, "shift_x", text="X")
         col.prop(cam, "shift_y", text="Y")
 
-        col = split.column(align=True)
-        col.label(text="Clipping:")
-        col.prop(cam, "clip_start", text="Start")
-        col.prop(cam, "clip_end", text="End")
 
-        layout.label(text="Depth of Field:")
+class DATA_PT_camera(CameraButtonsPanel, bpy.types.Panel):
+    bl_label = "Camera"
+    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
 
+    def draw(self, context):
+        layout = self.layout
+
+        cam = context.camera
+
+        row = layout.row(align=True)
+
+        row.menu("CAMERA_MT_presets", 
text=bpy.types.CAMERA_MT_presets.bl_label)
+        row.operator("camera.preset_add", text="", icon="ZOOMIN")
+        row.operator("camera.preset_add", text="", 
icon="ZOOMOUT").remove_active = True
+
         split = layout.split()
-        split.prop(cam, "dof_object", text="")
 
-        col = split.column()
+        col = split.column(align=True)
+        col.label(text="Sensor Size:")
+        col.prop(cam, "sensor_x", text="X")
+        col.prop(cam, "sensor_y", text="Y")
 
-        if cam.dof_object != None:
-            col.enabled = False
-        col.prop(cam, "dof_distance", text="Distance")
+        col = split.column(align=True)
+        col.label(text="Clipping:")
+        col.prop(cam, "clip_start", text="Start")
+        col.prop(cam, "clip_end", text="End")
 
 
 class DATA_PT_camera_display(CameraButtonsPanel, bpy.types.Panel):
@@ -126,10 +161,12 @@
         col.prop(cam, "show_limits", text="Limits")
         col.prop(cam, "show_mist", text="Mist")
         col.prop(cam, "show_title_safe", text="Title Safe")
+        col.prop(cam, "show_sensor", text="Sensor")
         col.prop(cam, "show_name", text="Name")
-        col.prop_menu_enum(cam, "show_guide")
 
         col = split.column()
+        col.prop_menu_enum(cam, "show_guide")
+        col.separator()
         col.prop(cam, "draw_size", text="Size")
         col.separator()
         col.prop(cam, "show_passepartout", text="Passepartout")

Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h     
2011-07-14 15:21:23 UTC (rev 38396)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h     
2011-07-14 15:21:45 UTC (rev 38397)
@@ -142,7 +142,7 @@
 void object_camera_mode(struct RenderData *rd, struct Object *camera);
 void object_camera_matrix(
                struct RenderData *rd, struct Object *camera, int winx, int 
winy, short field_second,
-               float winmat[][4], struct rctf *viewplane, float *clipsta, 
float *clipend, float *lens, float *ycor,
+               float winmat[][4], struct rctf *viewplane, float *clipsta, 
float *clipend, float *lens, float *sensor_x, float *ycor,
                float *viewdx, float *viewdy);
 
 void object_relink(struct Object *ob);

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c  
2011-07-14 15:21:23 UTC (rev 38396)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c  
2011-07-14 15:21:45 UTC (rev 38397)
@@ -712,6 +712,8 @@
        cam=  alloc_libblock(&G.main->camera, ID_CA, name);
 
        cam->lens= 35.0f;
+       cam->sensor_x = 32.f;
+       cam->sensor_y = 18.f;
        cam->clipsta= 0.1f;
        cam->clipend= 100.0f;
        cam->drawsize= 0.5f;
@@ -2905,7 +2907,7 @@
 /* 'lens' may be set for envmap only */
 void object_camera_matrix(
                RenderData *rd, Object *camera, int winx, int winy, short 
field_second,
-               float winmat[][4], rctf *viewplane, float *clipsta, float 
*clipend, float *lens, float *ycor,
+               float winmat[][4], rctf *viewplane, float *clipsta, float 
*clipend, float *lens, float *sensor_x, float *ycor,
                float *viewdx, float *viewdy
 ) {
        Camera *cam=NULL;
@@ -2938,6 +2940,7 @@
                shiftx=cam->shiftx;
                shifty=cam->shifty;
                (*lens)= cam->lens;
+               (*sensor_x)= cam->sensor_x;
                (*clipsta)= cam->clipsta;
                (*clipend)= cam->clipend;
        }
@@ -2953,7 +2956,7 @@
                (*clipend)= la->clipend;
        }
        else {  /* envmap exception... */;
-               if((*lens)==0.0f)
+               if((*lens)==0.0f) /* is this needed anymore? */
                        (*lens)= 16.0f;
 
                if((*clipsta)==0.0f || (*clipend)==0.0f) {

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to