00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "pbrt.h"
00026 #include "camera.h"
00027 #include "film.h"
00028 #include "mc.h"
00029
00030 Camera::~Camera() {
00031 delete film;
00032 }
00033 Camera::Camera(const Transform &world2cam,
00034 float hither, float yon,
00035 float sopen, float sclose, Film *f) {
00036 WorldToCamera = world2cam;
00037 CameraToWorld = WorldToCamera.GetInverse();
00038 ClipHither = hither;
00039 ClipYon = yon;
00040 ShutterOpen = sopen;
00041 ShutterClose = sclose;
00042 film = f;
00043 if (WorldToCamera.HasScale())
00044 Warning("Scaling detected in world-to-camera transformation!\n"
00045 "The system has numerous assumptions, implicit and explicit,\n"
00046 "that this transform will have no scale factors in it.\n"
00047 "Proceed at your own risk; your image may have errors or\n"
00048 "the system may crash as a result of this.");
00049 }
00050 ProjectiveCamera::ProjectiveCamera(const Transform &w2c,
00051 const Transform &proj, const float Screen[4],
00052 float hither, float yon, float sopen,
00053 float sclose, float lensr, float focald, Film *f)
00054 : Camera(w2c, hither, yon, sopen, sclose, f) {
00055
00056 LensRadius = lensr;
00057 FocalDistance = focald;
00058
00059 CameraToScreen = proj;
00060 WorldToScreen = CameraToScreen * WorldToCamera;
00061
00062 ScreenToRaster = Scale(float(film->xResolution),
00063 float(film->yResolution), 1.f) *
00064 Scale(1.f / (Screen[1] - Screen[0]),
00065 1.f / (Screen[2] - Screen[3]), 1.f) *
00066 Translate(Vector(-Screen[0], -Screen[3], 0.f));
00067 RasterToScreen = ScreenToRaster.GetInverse();
00068 RasterToCamera =
00069 CameraToScreen.GetInverse() * RasterToScreen;
00070 }