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:
authorCampbell Barton <ideasman42@gmail.com>2010-03-05 17:06:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-03-05 17:06:39 +0300
commitf4298de8aaafd36cb8da6f7051c24ca630589001 (patch)
tree8f5f0b2b6879bbb956ab4224ec51a7bf5b8d9e35 /source/blender/render
parent19154014b8a87f1f63f5d75d6983adc5fa6dbc7f (diff)
utility function object_camera_matrix, moved code from RE_SetCamera into this.
use for getting the render matrix of a camera (view plane, winmat, clipstart/end) without rendering.
Diffstat (limited to 'source/blender/render')
-rw-r--r--source/blender/render/intern/source/initrender.c114
1 files changed, 3 insertions, 111 deletions
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 0976cd70c19..5542a036d9a 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -447,117 +447,9 @@ void make_sample_tables(Render *re)
/* per render, there's one persistant viewplane. Parts will set their own viewplanes */
void RE_SetCamera(Render *re, Object *camera)
{
- Camera *cam=NULL;
- rctf viewplane;
- float pixsize, clipsta, clipend;
- float lens, shiftx=0.0, shifty=0.0, winside, viewfac;
-
- /* question mark */
- re->ycor= ( (float)re->r.yasp)/( (float)re->r.xasp);
- if(re->r.mode & R_FIELDS)
- re->ycor *= 2.0f;
-
- if(camera->type==OB_CAMERA) {
- cam= camera->data;
-
- if(cam->type==CAM_ORTHO) re->r.mode |= R_ORTHO;
- if(cam->flag & CAM_PANORAMA) re->r.mode |= R_PANORAMA;
-
- /* solve this too... all time depending stuff is in convertblender.c?
- * Need to update the camera early because it's used for projection matrices
- * and other stuff BEFORE the animation update loop is done
- * */
-#if 0 // XXX old animation system
- if(cam->ipo) {
- calc_ipo(cam->ipo, frame_to_float(re->scene, re->r.cfra));
- execute_ipo(&cam->id, cam->ipo);
- }
-#endif // XXX old animation system
- lens= cam->lens;
- shiftx=cam->shiftx;
- shifty=cam->shifty;
-
- clipsta= cam->clipsta;
- clipend= cam->clipend;
- }
- else if(camera->type==OB_LAMP) {
- Lamp *la= camera->data;
- float fac= cos( M_PI*la->spotsize/360.0 );
- float phi= acos(fac);
-
- lens= 16.0*fac/sin(phi);
- if(lens==0.0f)
- lens= 35.0;
- clipsta= la->clipsta;
- clipend= la->clipend;
- }
- else { /* envmap exception... */
- lens= re->lens;
- if(lens==0.0f)
- lens= 16.0;
-
- clipsta= re->clipsta;
- clipend= re->clipend;
- if(clipsta==0.0f || clipend==0.0f) {
- clipsta= 0.1f;
- clipend= 1000.0f;
- }
- }
-
- /* ortho only with camera available */
- if(cam && (re->r.mode & R_ORTHO)) {
- if( (re->r.xasp*re->winx) >= (re->r.yasp*re->winy) ) {
- viewfac= re->winx;
- }
- else {
- viewfac= re->ycor*re->winy;
- }
- /* ortho_scale == 1.0 means exact 1 to 1 mapping */
- pixsize= cam->ortho_scale/viewfac;
- }
- else {
- if( (re->r.xasp*re->winx) >= (re->r.yasp*re->winy) ) {
- viewfac= (re->winx*lens)/32.0;
- }
- else {
- viewfac= re->ycor*(re->winy*lens)/32.0;
- }
-
- pixsize= clipsta/viewfac;
- }
-
- /* viewplane fully centered, zbuffer fills in jittered between -.5 and +.5 */
- winside= MAX2(re->winx, re->winy);
- viewplane.xmin= -0.5f*(float)re->winx + shiftx*winside;
- viewplane.ymin= -0.5f*re->ycor*(float)re->winy + shifty*winside;
- viewplane.xmax= 0.5f*(float)re->winx + shiftx*winside;
- viewplane.ymax= 0.5f*re->ycor*(float)re->winy + shifty*winside;
-
- if(re->flag & R_SEC_FIELD) {
- if(re->r.mode & R_ODDFIELD) {
- viewplane.ymin-= .5*re->ycor;
- viewplane.ymax-= .5*re->ycor;
- }
- else {
- viewplane.ymin+= .5*re->ycor;
- viewplane.ymax+= .5*re->ycor;
- }
- }
- /* the window matrix is used for clipping, and not changed during OSA steps */
- /* using an offset of +0.5 here would give clip errors on edges */
- viewplane.xmin= pixsize*(viewplane.xmin);
- viewplane.xmax= pixsize*(viewplane.xmax);
- viewplane.ymin= pixsize*(viewplane.ymin);
- viewplane.ymax= pixsize*(viewplane.ymax);
-
- re->viewdx= pixsize;
- re->viewdy= re->ycor*pixsize;
-
- if(re->r.mode & R_ORTHO)
- RE_SetOrtho(re, &viewplane, clipsta, clipend);
- else
- RE_SetWindow(re, &viewplane, clipsta, clipend);
-
+ object_camera_matrix(&re->r, camera, re->winx, re->winy, re->flag & R_SEC_FIELD,
+ re->winmat, &re->viewplane, &re->clipsta, &re->clipend,
+ &re->lens, &re->ycor, &re->viewdx, &re->viewdy);
}
void RE_SetPixelSize(Render *re, float pixsize)