00001 #include <gra/camera/OrthoProj.h>
00002
00003 using namespace gra;
00004
00005 OrthoProj::OrthoProj(double left,
00006 double right,
00007 double bottom,
00008 double top,
00009 double nr,
00010 double fr)
00011 : Projection(left, right, bottom, top, nr, fr)
00012 {
00013 if (_left == _right) {
00014 cerr << "OrhoProj(): invalid left and right clipping planes;" << endl;
00015 cerr << " switching to -1, 1" << endl;
00016 _left = -1.0;
00017 _right = 1.0;
00018 }
00019
00020 if (_bottom == _top) {
00021 cerr << "OrhoProj(): invalid bottom and top clipping planes;" << endl;
00022 cerr << " switching to -1, 1" << endl;
00023 _bottom = -1.0;
00024 _top = 1.0;
00025 }
00026
00027 if (_near == _far) {
00028 cerr << "OrhoProj(): invalid near and far clipping planes;" << endl;
00029 cerr << " switching to -1, 1" << endl;
00030 _near = -1.0;
00031 _far = 1.0;
00032 }
00033
00034 float rl = _right - _left;
00035 float tb = _top - _bottom;
00036 float fn = _far - _near;
00037
00038 _projMat.set(2.0/rl, 0.0, 0.0, (_right+_left)/rl,
00039 0.0, 2.0/tb, 0.0, (_top+_bottom)/tb,
00040 0.0, 0.0, -2.0/fn, (_far+_near)/fn,
00041 0.0, 0.0, 0.0, 1.0);
00042 }
00043
00044 Projection* OrthoProj::clone() const
00045 {
00046 return new OrthoProj(*this);
00047 }
00048
00049 Vector3 OrthoProj::getProjectionDirection(const Vector2&)
00050 {
00051 return Vector3(0, 0, -1);
00052 }