Revision: 41384
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41384
Author:   nazgul
Date:     2011-10-30 14:11:16 +0000 (Sun, 30 Oct 2011)
Log Message:
-----------
Camera tracking integration
===========================

Camera sensor size changes:
- Now blender camera has got vertical sensor size property
  and setting to control how FOV is getting calculated
  (depending on aspect ratio, using horizontal sensor size or
  vertical only).
- Made changes in game engine and uv project modifier as well
- Presets should be updated (don't have settings by hand right now
  and the internet in debalie is really fails this year)

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/editors/sculpt_paint/paint_image.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
    branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_edit.c
    branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_intern.h
    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/modifiers/intern/MOD_uvproject.c
    branches/soc-2011-tomato/source/blender/render/intern/include/render_types.h
    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

Modified: 
branches/soc-2011-tomato/release/scripts/startup/bl_operators/presets.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_operators/presets.py    
2011-10-30 12:42:56 UTC (rev 41383)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_operators/presets.py    
2011-10-30 14:11:16 UTC (rev 41384)
@@ -206,7 +206,9 @@
     ]
 
     preset_values = [
-        "cam.sensor_width"
+        "cam.sensor_width",
+        "cam.sensor_height",
+        "cam.fov_mode"
     ]
 
     preset_subdir = "camera"

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-10-30 12:42:56 UTC (rev 41383)
+++ 
branches/soc-2011-tomato/release/scripts/startup/bl_ui/properties_data_camera.py
    2011-10-30 14:11:16 UTC (rev 41384)
@@ -129,8 +129,12 @@
         row.operator("camera.preset_add", text="", icon="ZOOMIN")
         row.operator("camera.preset_add", text="", 
icon="ZOOMOUT").remove_active = True
 
-        layout.prop(cam, "sensor_width")
+        layout.prop(cam, "fov_mode")
 
+        col = layout.column(align=True)
+        col.prop(cam, "sensor_width")
+        col.prop(cam, "sensor_height")
+
         layout.label(text="Clipping:")
         row = layout.row(align=True)
         row.prop(cam, "clip_start", text="Start")

Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h     
2011-10-30 12:42:56 UTC (rev 41383)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h     
2011-10-30 14:11:16 UTC (rev 41384)
@@ -145,7 +145,8 @@
                        float *clipsta, float *clipend, float *lens, float 
*sensor_x);
 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 *sensor_x, float *ycor,
+               float winmat[][4], struct rctf *viewplane, float *clipsta, 
float *clipend, float *lens,
+               float *sensor_x, float *sensor_y, short *fov_mode, float *ycor,
                float *viewdx, float *viewdy);
 
 void camera_view_frame_ex(struct Scene *scene, struct Camera *camera, float 
drawsize, const short do_clip, const float scale[3],

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c  
2011-10-30 12:42:56 UTC (rev 41383)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c  
2011-10-30 14:11:16 UTC (rev 41384)
@@ -2977,13 +2977,17 @@
 }
 
 void object_camera_intrinsics(Object *camera, Camera **cam_r, short *is_ortho, 
float *shiftx, float *shifty,
-                       float *clipsta, float *clipend, float *lens, float 
*sensor_x)
+                       float *clipsta, float *clipend, float *lens, float 
*sensor_x, float *sensor_y, short *fov_mode)
 {
        Camera *cam= NULL;
 
        (*shiftx)= 0.0f;
        (*shifty)= 0.0f;
 
+       (*sensor_x)= DEFAULT_SENSOR_WIDTH;
+       (*sensor_y)= DEFAULT_SENSOR_HEIGHT;
+       (*fov_mode)= CAMERA_FOV_AUTO;
+
        if(camera->type==OB_CAMERA) {
                cam= camera->data;
 
@@ -3005,8 +3009,10 @@
                (*shifty)=cam->shifty;
                (*lens)= cam->lens;
                (*sensor_x)= cam->sensor_x;
+               (*sensor_y)= cam->sensor_y;
                (*clipsta)= cam->clipsta;
                (*clipend)= cam->clipend;
+               (*fov_mode)= cam->fov_mode;
        }
        else if(camera->type==OB_LAMP) {
                Lamp *la= camera->data;
@@ -3035,9 +3041,10 @@
 /* '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 *sensor_x, float *ycor,
-               float *viewdx, float *viewdy
-) {
+               float winmat[][4], rctf *viewplane, float *clipsta, float 
*clipend, float *lens,
+               float *sensor_x, float *sensor_y, short *fov_mode, float *ycor,
+               float *viewdx, float *viewdy)
+{
        Camera *cam=NULL;
        float pixsize;
        float shiftx=0.0, shifty=0.0, winside, viewfac;
@@ -3048,22 +3055,36 @@
        if(rd->mode & R_FIELDS)
                (*ycor) *= 2.0f;
 
-       object_camera_intrinsics(camera, &cam, &is_ortho, &shiftx, &shifty, 
clipsta, clipend, lens, sensor_x);
+       object_camera_intrinsics(camera, &cam, &is_ortho, &shiftx, &shifty, 
clipsta, clipend, lens, sensor_x, sensor_y, fov_mode);
 
        /* ortho only with camera available */
        if(cam && is_ortho) {
-               if(rd->xasp*winx >= rd->yasp*winy) {
+               if((*fov_mode)==CAMERA_FOV_AUTO) {
+                       if(rd->xasp*winx >= rd->yasp*winy) viewfac= winx;
+                       else viewfac= (*ycor) * winy;
+               }
+               else if((*fov_mode)==CAMERA_FOV_HOR) {
                        viewfac= winx;
                }
                else {
                        viewfac= (*ycor) * winy;
                }
+
                /* ortho_scale == 1.0 means exact 1 to 1 mapping */
                pixsize= cam->ortho_scale/viewfac;
        }
        else {
-               if(rd->xasp*winx >= rd->yasp*winy)      viewfac= ((*lens) * 
winx) / (*sensor_x);
-               else                                    viewfac= (*ycor) * 
((*lens) * winy) / (*sensor_x);
+               if((*fov_mode)==CAMERA_FOV_AUTO) {
+                       if(rd->xasp*winx >= rd->yasp*winy)      viewfac= 
((*lens) * winx) / (*sensor_x);
+                       else                                    viewfac= 
(*ycor) * ((*lens) * winy) / (*sensor_x);
+               }
+               else if((*fov_mode)==CAMERA_FOV_HOR) {
+                       viewfac= ((*lens) * winx) / (*sensor_x);
+               }
+               else if((*fov_mode)==CAMERA_FOV_VERT) {
+                       viewfac= ((*lens) * winy) / (*sensor_y);
+               }
+
                pixsize= (*clipsta) / viewfac;
        }
 

Modified: branches/soc-2011-tomato/source/blender/blenlib/BLI_math_rotation.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenlib/BLI_math_rotation.h 
2011-10-30 12:42:56 UTC (rev 41383)
+++ branches/soc-2011-tomato/source/blender/blenlib/BLI_math_rotation.h 
2011-10-30 14:11:16 UTC (rev 41384)
@@ -179,8 +179,8 @@
 void quat_apply_track(float quat[4], short axis, short upflag);
 void vec_apply_track(float vec[3], short axis);
 
-float focallength_to_hfov(float focal_length, float sensor_x);
-float hfov_to_focallength(float hfov, float sensor_x);
+float focallength_to_fov(float focal_length, float sensor);
+float fov_to_focallength(float fov, float sensor);
 
 float angle_wrap_rad(float angle);
 float angle_wrap_deg(float angle);

Modified: branches/soc-2011-tomato/source/blender/blenlib/intern/math_rotation.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenlib/intern/math_rotation.c      
2011-10-30 12:42:56 UTC (rev 41383)
+++ branches/soc-2011-tomato/source/blender/blenlib/intern/math_rotation.c      
2011-10-30 14:11:16 UTC (rev 41384)
@@ -1688,14 +1688,14 @@
 }
 
 /* lens/angle conversion (radians) */
-float focallength_to_hfov(float focal_length, float sensor_x)
+float focallength_to_fov(float focal_length, float sensor)
 {
-       return 2.0f * atanf((sensor_x/2.0f) / focal_length);
+       return 2.0f * atanf((sensor/2.0f) / focal_length);
 }
 
-float hfov_to_focallength(float hfov, float sensor_x)
+float fov_to_focallength(float hfov, float sensor)
 {
-       return (sensor_x/2.0f) / tanf(hfov * 0.5f);
+       return (sensor/2.0f) / tanf(hfov * 0.5f);
 }
 
 /* 'mod_inline(-3,4)= 1', 'fmod(-3,4)= -3' */

Modified: branches/soc-2011-tomato/source/blender/blenlib/intern/uvproject.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenlib/intern/uvproject.c  
2011-10-30 12:42:56 UTC (rev 41383)
+++ branches/soc-2011-tomato/source/blender/blenlib/intern/uvproject.c  
2011-10-30 14:11:16 UTC (rev 41384)
@@ -141,7 +141,7 @@
        uci.do_pano = (camera->flag & CAM_PANORAMA);
        uci.do_persp = (camera->type==CAM_PERSP);
 
-       uci.camangle= focallength_to_hfov(camera->lens, camera->sensor_x) / 
2.0f;
+       uci.camangle= focallength_to_fov(camera->lens, camera->sensor_x) / 2.0f;
        uci.camsize= uci.do_persp ? tanf(uci.camangle) : camera->ortho_scale;
 
        /* account for scaled cameras */

Modified: branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c        
2011-10-30 12:42:56 UTC (rev 41383)
+++ branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c        
2011-10-30 14:11:16 UTC (rev 41384)
@@ -12360,9 +12360,11 @@
                        }
 
                        for(cam= main->camera.first; cam; cam= cam->id.next) {
-                               if (cam->sensor_x < 0.01) {
-                                       cam->sensor_x = 32.f;
-                               }
+                               if (cam->sensor_x < 0.01)
+                                       cam->sensor_x = DEFAULT_SENSOR_WIDTH;
+
+                               if (cam->sensor_y < 0.01)
+                                       cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
                        }
 
                        for (clip= main->movieclip.first; clip; clip= 
clip->id.next) {

Modified: 
branches/soc-2011-tomato/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/sculpt_paint/paint_image.c  
2011-10-30 12:42:56 UTC (rev 41383)
+++ branches/soc-2011-tomato/source/blender/editors/sculpt_paint/paint_image.c  
2011-10-30 14:11:16 UTC (rev 41384)
@@ -57,6 +57,7 @@
 #include "IMB_imbuf_types.h"
 
 #include "DNA_brush_types.h"
+#include "DNA_camera_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_node_types.h"
@@ -3000,7 +3001,8 @@
                                Object *camera= ps->scene->camera;
 
                                /* dont actually use these */
-                               float _viewdx, _viewdy, _ycor, _lens=0.0f, 
_sensor_x=0.0f;
+                               float _viewdx, _viewdy, _ycor, _lens=0.0f, 
_sensor_x=DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT;
+                               short _fov_mode= CAMERA_FOV_AUTO;
                                rctf _viewplane;
 
                                /* viewmat & viewinv */
@@ -3012,7 +3014,7 @@
                                object_camera_mode(&ps->scene->r, camera);
                                object_camera_matrix(&ps->scene->r, camera, 
ps->winx, ps->winy, 0,
                                                winmat, &_viewplane, 
&ps->clipsta, &ps->clipend,
-                                               &_lens, &_sensor_x, &_ycor, 
&_viewdx, &_viewdy);
+                                               &_lens, &_sensor_x, &_sensor_x, 
&_fov_mode, &_ycor, &_viewdx, &_viewdy);
 
                                ps->is_ortho= (ps->scene->r.mode & R_ORTHO) ? 1 
: 0;
                        }

Modified: 
branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c   
2011-10-30 12:42:56 UTC (rev 41383)

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