diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-03-23 23:04:05 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-03-23 23:04:05 +0300 |
commit | c76a069bd16fe580ebb741493918a9793718f999 (patch) | |
tree | 468c7b10cdd62f1b3f0535d79510794ecc0cb4bf /source/blender/blenlib | |
parent | 169c4bf8a8f1853d482433ebae1e9de81cfd4b09 (diff) |
Panorama camera support for UV project modifier
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_uvproject.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/uvproject.c | 19 |
2 files changed, 14 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_uvproject.h b/source/blender/blenlib/BLI_uvproject.h index 8e9a85136bb..a77ca60fc15 100644 --- a/source/blender/blenlib/BLI_uvproject.h +++ b/source/blender/blenlib/BLI_uvproject.h @@ -23,6 +23,7 @@ #define BKE_UVPROJECT_H struct UvCameraInfo; +struct Object; /* create uv info from the camera, needs to be freed */ struct UvCameraInfo *project_camera_info(struct Object *ob, float rotmat[4][4], float winx, float winy); diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c index d6ba2d7da94..273cb01ce1c 100644 --- a/source/blender/blenlib/intern/uvproject.c +++ b/source/blender/blenlib/intern/uvproject.c @@ -36,7 +36,7 @@ typedef struct UvCameraInfo { float shiftx, shifty; float rotmat[4][4]; float caminv[4][4]; - short do_persp, do_pano; + short do_persp, do_pano, do_rotmat; } UvCameraInfo; void project_from_camera(float target[2], float source[3], UvCameraInfo *uci) @@ -47,7 +47,8 @@ void project_from_camera(float target[2], float source[3], UvCameraInfo *uci) pv4[3]= 1.0; /* rotmat is the object matrix in this case */ - mul_m4_v4(uci->rotmat, pv4); + if(uci->do_rotmat) + mul_m4_v4(uci->rotmat, pv4); /* caminv is the inverse camera matrix */ mul_m4_v4(uci->caminv, pv4); @@ -87,7 +88,7 @@ void project_from_view(float target[2], float source[3], float persmat[4][4], fl { float pv[3], pv4[4], x= 0.0, y= 0.0; - mul_m4_v3(rotmat, pv); + mul_v3_m4v3(pv, rotmat, source); copy_v3_v3(pv4, source); pv4[3]= 1.0; @@ -123,7 +124,7 @@ void project_from_view(float target[2], float source[3], float persmat[4][4], fl /* 'rotmat' can be obedit->obmat when uv project is used. * 'winx' and 'winy' can be from scene->r.xsch/ysch */ -UvCameraInfo *project_camera_info(Object *ob, float rotmat[4][4], float winx, float winy) +UvCameraInfo *project_camera_info(Object *ob, float (*rotmat)[4], float winx, float winy) { UvCameraInfo uci; Camera *camera= ob->data; @@ -138,7 +139,13 @@ UvCameraInfo *project_camera_info(Object *ob, float rotmat[4][4], float winx, fl UvCameraInfo *uci_pt; /* normal projection */ - copy_m4_m4(uci.rotmat, rotmat); + if(rotmat) { + copy_m4_m4(uci.rotmat, rotmat); + uci.do_rotmat= 1; + } + else { + uci.do_rotmat= 0; + } /* also make aspect ratio adjustment factors */ if (winx > winy) { @@ -166,7 +173,7 @@ void project_from_view_ortho(float target[2], float source[3], float rotmat[4][4 { float pv[3]; - mul_m4_v3(rotmat, pv); + mul_v3_m4v3(pv, rotmat, source); /* ortho projection */ target[0] = -pv[0]; |