Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-11-04 18:36:06 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-11-04 18:36:06 +0400
commit4ea816837de646af124ffc82758cae37950a0a51 (patch)
tree771c7a0e084446080d6f6d12258585a479bf2887 /source/blender/blenlib
parent82dc05391cdda573f1523325bfd4c6a2a5233323 (diff)
Configurable sensor size:
- Added support of variable size sensor width and height. - Added presets for most common cameras, also new presets can be defined by user. - Added option to control which dimension (vertical or horizontal) of sensor size defines FOV. Old behavior of automatic FOV calculation is also kept. - Renderer, viewport, game engine and collada importer/exporter should deal fine with this changes. Other exporters would be updated soon.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_rotation.h4
-rw-r--r--source/blender/blenlib/intern/math_rotation.c8
-rw-r--r--source/blender/blenlib/intern/uvproject.c2
3 files changed, 7 insertions, 7 deletions
diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h
index aef1c4bb46c..fca7c3469a1 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -179,8 +179,8 @@ void dquat_to_mat4(float R[4][4], DualQuat *dq);
void quat_apply_track(float quat[4], short axis, short upflag);
void vec_apply_track(float vec[3], short axis);
-float lens_to_angle(float lens);
-float angle_to_lens(float angle);
+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);
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 0ca8b72c1e3..7fecbae8229 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1688,14 +1688,14 @@ void vec_apply_track(float vec[3], short axis)
}
/* lens/angle conversion (radians) */
-float lens_to_angle(float lens)
+float focallength_to_fov(float focal_length, float sensor)
{
- return 2.0f * atanf(16.0f/lens);
+ return 2.0f * atanf((sensor/2.0f) / focal_length);
}
-float angle_to_lens(float angle)
+float fov_to_focallength(float hfov, float sensor)
{
- return 16.0f / tanf(angle * 0.5f);
+ return (sensor/2.0f) / tanf(hfov * 0.5f);
}
/* 'mod_inline(-3,4)= 1', 'fmod(-3,4)= -3' */
diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c
index 30625e7b34e..8b00d8e48a6 100644
--- a/source/blender/blenlib/intern/uvproject.c
+++ b/source/blender/blenlib/intern/uvproject.c
@@ -141,7 +141,7 @@ UvCameraInfo *project_camera_info(Object *ob, float (*rotmat)[4], float winx, fl
uci.do_pano = (camera->flag & CAM_PANORAMA);
uci.do_persp = (camera->type==CAM_PERSP);
- uci.camangle= lens_to_angle(camera->lens) / 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 */