Permalink
Browse files

Clipping for all cameras

  • Loading branch information...
1 parent 274f781 commit 240ea1d2bdbb728e996d68a7d5f25da1b3fc5bf5 Bert committed Mar 24, 2011
@@ -79,6 +79,8 @@ class YAFRAYCORE_EXPORT camera_t
vector3d_t vright;
float aspect_ratio; //<! Aspect ratio of camera (not image in pixel units!)
+
+ float nearClippingDistance, farClippingDistance;
};
__END_YAFRAY
@@ -61,6 +61,10 @@ ray_t angularCam_t::shootRay(PFLOAT px, PFLOAT py, float lu, float lv, PFLOAT &w
PFLOAT phi = radius * hor_phi;
//PFLOAT sp = sin(phi);
ray.dir = fSin(phi)*(fCos(theta)*vright + fSin(theta)*vup ) + fCos(phi)*vto;
+
+ ray.tmin = nearClippingDistance;
+ ray.tmax = farClippingDistance;
+
return ray;
}
@@ -70,6 +74,8 @@ camera_t* angularCam_t::factory(paraMap_t &params, renderEnvironment_t &render)
int resx=320, resy=200;
double aspect=1.0, angle=90, max_angle=90;
bool circular = true, mirrored = false;
+ float nearClip = 0.0f, farClip = -1.0f;
+
params.getParam("from", from);
params.getParam("to", to);
params.getParam("up", up);
@@ -81,10 +87,14 @@ camera_t* angularCam_t::factory(paraMap_t &params, renderEnvironment_t &render)
params.getParam("max_angle", max_angle);
params.getParam("circular", circular);
params.getParam("mirrored", mirrored);
+ params.getParam("nearClip", nearClip);
+ params.getParam("farClip", farClip);
angularCam_t *cam = new angularCam_t(from, to, up, resx, resy, aspect, angle, circular);
if(mirrored) cam->vright *= -1.0;
cam->max_r = max_angle/angle;
+ cam->nearClippingDistance = nearClip;
+ cam->farClippingDistance = farClip;
return cam;
}
@@ -2,7 +2,7 @@
*
* camera.cc: Camera implementation
* This is part of the yafray package
- * Copyright (C) 2002 Alejandro Conty Estévez
+ * Copyright (C) 2002 Alejandro Conty Est??vez
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -97,6 +97,8 @@ camera_t* architectCam_t::factory(paraMap_t &params, renderEnvironment_t &render
point3d_t from(0,1,0), to(0,0,0), up(0,1,1);
int resx=320, resy=200;
float aspect=1, dfocal=1, apt=0, dofd=0, bkhrot=0;
+ float nearClip = 0.0f, farClip = -1.0f;
+
params.getParam("from", from);
params.getParam("to", to);
params.getParam("up", up);
@@ -109,6 +111,9 @@ camera_t* architectCam_t::factory(paraMap_t &params, renderEnvironment_t &render
params.getParam("bokeh_bias", bkhbias);
params.getParam("bokeh_rotation", bkhrot);
params.getParam("aspect_ratio", aspect);
+ params.getParam("nearClip", nearClip);
+ params.getParam("farClip", farClip);
+
bokehType bt = BK_DISK1;
if (*bkhtype=="disk2") bt = BK_DISK2;
else if (*bkhtype=="triangle") bt = BK_TRI;
@@ -120,7 +125,12 @@ camera_t* architectCam_t::factory(paraMap_t &params, renderEnvironment_t &render
bkhBiasType bbt = BB_NONE;
if (*bkhbias=="center") bbt = BB_CENTER;
else if (*bkhbias=="edge") bbt = BB_EDGE;
- return new architectCam_t(from, to, up, resx, resy, aspect, dfocal, apt, dofd, bt, bbt, bkhrot);
+ architectCam_t* cam = new architectCam_t(from, to, up, resx, resy, aspect, dfocal, apt, dofd, bt, bbt, bkhrot);
+
+ cam->nearClippingDistance = nearClip;
+ cam->farClippingDistance = farClip;
+
+ return cam;
}
extern "C"
@@ -54,6 +54,10 @@ ray_t orthoCam_t::shootRay(PFLOAT px, PFLOAT py, float lu, float lv, PFLOAT &wt)
wt = 1; // for now always 1, except 0 for probe when outside sphere
ray.from = pos + vright*px + vup*py;
ray.dir = vto;
+
+ ray.tmin = nearClippingDistance;
+ ray.tmax = farClippingDistance;
+
return ray;
}
@@ -79,15 +83,24 @@ camera_t* orthoCam_t::factory(paraMap_t &params, renderEnvironment_t &render)
point3d_t from(0,1,0), to(0,0,0), up(0,1,1);
int resx=320, resy=200;
double aspect=1.0, scale=1.0;
+ float nearClip = 0.0f, farClip = -1.0f;
+
params.getParam("from", from);
params.getParam("to", to);
params.getParam("up", up);
params.getParam("resx", resx);
params.getParam("resy", resy);
params.getParam("scale", scale);
params.getParam("aspect_ratio", aspect);
+ params.getParam("nearClip", nearClip);
+ params.getParam("farClip", farClip);
+
+ orthoCam_t* cam = new orthoCam_t(from, to, up, resx, resy, aspect, scale);
+
+ cam->nearClippingDistance = nearClip;
+ cam->farClippingDistance = farClip;
- return new orthoCam_t(from, to, up, resx, resy, aspect, scale);
+ return cam;
}
extern "C"
@@ -2,7 +2,7 @@
*
* camera.cc: Camera implementation
* This is part of the yafray package
- * Copyright (C) 2002 Alejandro Conty Estévez
+ * Copyright (C) 2002 Alejandro Conty Est??vez
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -130,6 +130,9 @@ ray_t perspectiveCam_t::shootRay(PFLOAT px, PFLOAT py, float lu, float lv, PFLOA
ray.dir = vright*px + vup*py + vto;
ray.dir.normalize();
+ ray.tmin = nearClippingDistance;
+ ray.tmax = farClippingDistance;
+
if (aperture!=0) {
PFLOAT u, v;
@@ -190,6 +193,7 @@ camera_t* perspectiveCam_t::factory(paraMap_t &params, renderEnvironment_t &rend
point3d_t from(0,1,0), to(0,0,0), up(0,1,1);
int resx=320, resy=200;
float aspect=1, dfocal=1, apt=0, dofd=0, bkhrot=0;
+ float nearClip = 0.0f, farClip = -1.0f;
params.getParam("from", from);
params.getParam("to", to);
params.getParam("up", up);
@@ -202,6 +206,9 @@ camera_t* perspectiveCam_t::factory(paraMap_t &params, renderEnvironment_t &rend
params.getParam("bokeh_bias", bkhbias);
params.getParam("bokeh_rotation", bkhrot);
params.getParam("aspect_ratio", aspect);
+ params.getParam("nearClip", nearClip);
+ params.getParam("farClip", farClip);
+
bokehType bt = BK_DISK1;
if (*bkhtype=="disk2") bt = BK_DISK2;
else if (*bkhtype=="triangle") bt = BK_TRI;
@@ -213,7 +220,13 @@ camera_t* perspectiveCam_t::factory(paraMap_t &params, renderEnvironment_t &rend
bkhBiasType bbt = BB_NONE;
if (*bkhbias=="center") bbt = BB_CENTER;
else if (*bkhbias=="edge") bbt = BB_EDGE;
- return new perspectiveCam_t(from, to, up, resx, resy, aspect, dfocal, apt, dofd, bt, bbt, bkhrot);
+
+ perspectiveCam_t* cam = new perspectiveCam_t(from, to, up, resx, resy, aspect, dfocal, apt, dofd, bt, bbt, bkhrot);
+
+ cam->nearClippingDistance = nearClip;
+ cam->farClippingDistance = farClip;
+
+ return cam;
}
__END_YAFRAY

0 comments on commit 240ea1d

Please sign in to comment.