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
00026
00027
00028
00029
00030
00031
00032
00033 #include <vrj/vrjConfig.h>
00034
00035 #include <jccl/Config/ConfigElement.h>
00036
00037 #include <gmtl/Output.h>
00038 #include <gmtl/Generate.h>
00039
00040 #include <vrj/Display/Display.h>
00041 #include <vrj/Display/CameraProjection.h>
00042
00043 #include <boost/concept_check.hpp>
00044
00045
00046 namespace vrj
00047 {
00048
00049 void CameraProjection::config(jccl::ConfigElementPtr element)
00050 {
00051 Projection::config(element);
00052 }
00053
00058 void CameraProjection::calcViewMatrix(const gmtl::Matrix44f& cameraPos,
00059 const float scaleFactor)
00060 {
00061 boost::ignore_unused_variable_warning(scaleFactor);
00062 mViewMat = cameraPos;
00063
00064 gmtl::Vec3f camera_trans = gmtl::makeTrans<gmtl::Vec3f>(cameraPos);
00065 vprDEBUG(vprDBG_ALL, vprDBG_DETAILED_LVL) << "calcView: Cam pos:" << camera_trans << std::endl << vprDEBUG_FLUSH;
00066
00067 int win_xo, win_yo, win_xs, win_ys;
00068 float vp_xo, vp_yo, vp_xs, vp_ys;
00069 float width, height;
00070 float aspect_ratio;
00071
00072 getViewport()->getDisplay()->getOriginAndSize(win_xo,win_yo, win_xs, win_ys);
00073 getViewport()->getOriginAndSize( vp_xo, vp_yo, vp_xs, vp_ys );
00074 width = float(win_xs) * vp_xs;
00075 height = float(win_ys) * vp_ys;
00076
00077 aspect_ratio = (width/height);
00078
00079
00080 float top, right;
00081 top = gmtl::Math::tan( gmtl::Math::deg2Rad(mVertFOV/2.0f) ) * mNearDist;
00082 right = aspect_ratio * top;
00083
00084
00085 mFrustum.set(-right, right, -top, top, mNearDist, mFarDist);
00086 }
00087
00088 std::ostream& CameraProjection::outStream(std::ostream& out,
00089 const unsigned int indentLevel)
00090 {
00091
00092 out.setf(std::ios::left);
00093
00094 const std::string indent_text(indentLevel, ' ');
00095
00096 out << indent_text << "vrj::CameraProjection:\n";
00097
00098 return Projection::outStream(out, indentLevel);
00099 }
00100
00101 }