![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Functions | |
| ray | camray (scenedef *, int, int) |
Definition at line 71 of file camera.cpp.
References scenedef::aspectratio, scenedef::camcent, scenedef::camrightvec, scenedef::camupvec, scenedef::camviewvec, scenedef::camzoom, ray::d, ray::depth, ray::flags, scenedef::hres, ray::o, scenedef::raydepth, Raypnt(), RT_RAY_REGULAR, scenedef::vres, VSub(), vector::x, vector::y, and vector::z.
Referenced by render_one_pixel().
{
ray ray1, newray;
vector projcent;
vector projpixel;
flt px, py, sx, sy;
sx = (flt) scene->hres;
sy = (flt) scene->vres;
/* calculate the width and height of the image plane given the */
/* aspect ratio, image resolution, and zoom factor */
px=((sx / sy) / scene->aspectratio) / scene->camzoom;
py=1.0 / scene->camzoom;
/* assuming viewvec is a unit vector, then the center of the */
/* image plane is the camera center + vievec */
projcent.x = scene->camcent.x + scene->camviewvec.x;
projcent.y = scene->camcent.y + scene->camviewvec.y;
projcent.z = scene->camcent.z + scene->camviewvec.z;
/* starting from the center of the image plane, we move the */
/* center of the pel we're calculating, to */
/* projcent + (rightvec * x distance) */
ray1.o=projcent;
ray1.d=scene->camrightvec;
projpixel=Raypnt(&ray1, ((x*px/sx) - (px / 2.0)));
/* starting from the horizontally translated pel, we move the */
/* center of the pel we're calculating, to */
/* projcent + (upvec * y distance) */
ray1.o=projpixel;
ray1.d=scene->camupvec;
projpixel=Raypnt(&ray1, ((y*py/sy) - (py / 2.0)));
/* now that we have the exact pel center in the image plane */
/* we create the real primary ray that will be used by the */
/* rest of the system. */
/* The ray is expected to be re-normalized elsewhere, we're */
/* only really concerned about getting its direction right. */
newray.o=scene->camcent;
VSub(&projpixel, &scene->camcent, &newray.d);
newray.depth = scene->raydepth;
newray.flags = RT_RAY_REGULAR; /* camera only generates primary rays */
return newray;
}
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.