#include <vrj/Display/Projection.h>
Inheritance diagram for vrj::Projection:


Public Types | |
| enum | Eye { LEFT = 1, RIGHT = 2 } |
| Eye type. More... | |
Public Member Functions | |
| Projection () | |
| Projection (const Projection &p) | |
| virtual | ~Projection () |
| virtual void | config (jccl::ConfigElementPtr element) |
| Configures the projection. | |
| void | setEye (Projection::Eye _eye) |
| Sets the eye for this projection. | |
| Projection::Eye | getEye () const |
| Returns the eye for this projection. | |
| void | setViewport (Viewport *vp) |
| Sets the viewport associated with this projection. | |
| Viewport * | getViewport () const |
| Returns the viewport associated with this projection. | |
| virtual void | calcViewMatrix (const gmtl::Matrix44f &eyePos, const float scaleFactor)=0 |
| Calcualtes the view matrix. | |
| void | getFrustumApexAndCorners (gmtl::Vec3f &apex, gmtl::Vec3f &ur, gmtl::Vec3f &lr, gmtl::Vec3f &ul, gmtl::Vec3f &ll) |
| Helper to the frustum apex and corners in model coordinates. | |
| const gmtl::Matrix44f & | getViewMatrix () const |
| Returns this projection's view matrix. | |
| vrj::Frustum | getFrustum () const |
| Returns a copy of this projection's frustum. | |
| virtual std::ostream & | outStream (std::ostream &out, const unsigned int indentLevel=0) |
| Virtual output oporators. | |
Static Public Member Functions | |
| static void | setNearFar (float near_val, float far_val) |
| Sets the system-wide near and far values. | |
| static void | getNearFar (float &nearVal, float &farVal) |
| Retrieves the system-wide near and far values. | |
Protected Attributes | |
| gmtl::Matrix44f | mViewMat |
| The view transformation matrix for this projection. | |
| Frustum | mFrustum |
| The calculated view frustum for this projection. | |
| Eye | mEye |
| The eye that this projection is rendering. | |
| Viewport * | mViewport |
| The containing viewport for the projection. | |
| float | mFocusPlaneDist |
| Basically the distance to the surface. | |
Static Protected Attributes | |
Static near/far values | |
| static float | mNearDist |
| The near distance. | |
| static float | mFarDist |
| The far distance. | |
Responsible for storing and computing projection information based upon an eye positions. This class is an abstract base class for other classes that actually compute the projections.
Definition at line 59 of file Projection.h.
| enum vrj::Projection::Eye |
| vrj::Projection::Projection | ( | ) | [inline] |
Definition at line 70 of file Projection.h.
00071 : mEye(LEFT) 00072 , mViewport(NULL) 00073 , mFocusPlaneDist(1.0f) 00074 { 00075 ; 00076 }
| vrj::Projection::Projection | ( | const Projection & | p | ) | [inline] |
Definition at line 78 of file Projection.h.
00079 : mViewMat(p.mViewMat) 00080 , mFrustum(p.mFrustum) 00081 , mEye(p.mEye) 00082 , mViewport(p.mViewport) 00083 , mFocusPlaneDist(p.mFocusPlaneDist) 00084 { 00085 ; 00086 }
| virtual vrj::Projection::~Projection | ( | ) | [inline, virtual] |
| void vrj::Projection::config | ( | jccl::ConfigElementPtr | element | ) | [virtual] |
Configures the projection.
The default implementation does nothing.
Reimplemented in vrj::CameraProjection, vrj::SurfaceProjection, and vrj::TrackedSurfaceProjection.
Definition at line 53 of file Projection.cpp.
Referenced by vrj::TrackedSurfaceProjection::config(), vrj::SurfaceViewport::config(), vrj::SurfaceProjection::config(), vrj::SimViewport::config(), and vrj::CameraProjection::config().
| void vrj::Projection::setEye | ( | Projection::Eye | _eye | ) | [inline] |
Sets the eye for this projection.
Definition at line 99 of file Projection.h.
Referenced by vrj::SurfaceViewport::config(), and vrj::SimViewport::config().
00100 { 00101 mEye = _eye; 00102 }
| Projection::Eye vrj::Projection::getEye | ( | ) | const [inline] |
Returns the eye for this projection.
Definition at line 105 of file Projection.h.
00106 { 00107 return mEye; 00108 }
| void vrj::Projection::setViewport | ( | Viewport * | vp | ) | [inline] |
Sets the viewport associated with this projection.
Definition at line 111 of file Projection.h.
Referenced by vrj::SurfaceViewport::config(), and vrj::SimViewport::config().
00112 { 00113 mViewport = vp; 00114 }
| Viewport* vrj::Projection::getViewport | ( | ) | const [inline] |
Returns the viewport associated with this projection.
Definition at line 117 of file Projection.h.
Referenced by vrj::CameraProjection::calcViewMatrix().
00118 { 00119 return mViewport; 00120 }
| virtual void vrj::Projection::calcViewMatrix | ( | const gmtl::Matrix44f & | eyePos, | |
| const float | scaleFactor | |||
| ) | [pure virtual] |
Calcualtes the view matrix.
Implemented in vrj::CameraProjection, vrj::SurfaceProjection, and vrj::TrackedSurfaceProjection.
Referenced by vrj::PfBasicSimulator::updateProjectionData(), vrj::GlBasicSimulator::updateProjectionData(), and vrj::SurfaceViewport::updateProjections().
| void vrj::Projection::getFrustumApexAndCorners | ( | gmtl::Vec3f & | apex, | |
| gmtl::Vec3f & | ur, | |||
| gmtl::Vec3f & | lr, | |||
| gmtl::Vec3f & | ul, | |||
| gmtl::Vec3f & | ll | |||
| ) |
Helper to the frustum apex and corners in model coordinates.
Definition at line 64 of file Projection.cpp.
References mFocusPlaneDist, mFrustum, mViewMat, vrj::Frustum::VJ_BOTTOM, vrj::Frustum::VJ_LEFT, vrj::Frustum::VJ_NEAR, vrj::Frustum::VJ_RIGHT, and vrj::Frustum::VJ_TOP.
Referenced by vrj::GlBasicSimulator::drawProjections().
00067 { 00068 gmtl::Matrix44f view_mat_inv; 00069 gmtl::invert(view_mat_inv, mViewMat); 00070 00071 // vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL) << "GetApex:\nview mat:\n" << mViewMat << "\nviewMatInv:\n" << view_mat_inv << std::endl << vprDEBUG_FLUSH; 00072 00073 00074 //float near_dist = mFocusPlaneDist; 00075 // Use like triangles to get the params for the focus surface 00076 float mult_factor = mFocusPlaneDist/mFrustum[Frustum::VJ_NEAR]; 00077 float bot = mFrustum[Frustum::VJ_BOTTOM]*mult_factor; 00078 float left = mFrustum[Frustum::VJ_LEFT]*mult_factor; 00079 float top = mFrustum[Frustum::VJ_TOP]*mult_factor; 00080 float right = mFrustum[Frustum::VJ_RIGHT]*mult_factor; 00081 00082 // Create points in clip space 00083 gmtl::Point3f apexClip(0.0f, 0.0f, 0.0f); 00084 gmtl::Point3f urClip(right, top, -mFocusPlaneDist); 00085 gmtl::Point3f lrClip(right, bot, -mFocusPlaneDist); 00086 gmtl::Point3f ulClip(left, top, -mFocusPlaneDist); 00087 gmtl::Point3f llClip(left, bot, -mFocusPlaneDist); 00088 00089 apex = view_mat_inv * apexClip; 00090 ur = view_mat_inv * urClip; 00091 lr = view_mat_inv * lrClip; 00092 ul = view_mat_inv * ulClip; 00093 ll = view_mat_inv * llClip; 00094 }
| const gmtl::Matrix44f& vrj::Projection::getViewMatrix | ( | ) | const [inline] |
Returns this projection's view matrix.
Definition at line 144 of file Projection.h.
Referenced by vrj::OsgApp::draw(), vrj::OpenSGApp::draw(), vrj::GlWindow::setProjection(), and vrj::PfDrawManager::updatePfProjection().
00145 { 00146 return mViewMat; 00147 }
| vrj::Frustum vrj::Projection::getFrustum | ( | ) | const [inline] |
Returns a copy of this projection's frustum.
Definition at line 150 of file Projection.h.
Referenced by vrj::OsgApp::draw(), vrj::OpenSGApp::draw(), vrj::GlWindow::setProjection(), and vrj::PfDrawManager::updatePfProjection().
00151 { 00152 return mFrustum; 00153 }
| std::ostream & vrj::Projection::outStream | ( | std::ostream & | out, | |
| const unsigned int | indentLevel = 0 | |||
| ) | [virtual] |
Virtual output oporators.
Every class derived from us shoudl just define this, and the opertetor<< will "just work".
Reimplemented in vrj::CameraProjection, vrj::SurfaceProjection, and vrj::TrackedSurfaceProjection.
Definition at line 96 of file Projection.cpp.
References LEFT, mEye, mFrustum, and RIGHT.
Referenced by vrj::SurfaceViewport::outStream(), vrj::SurfaceProjection::outStream(), and vrj::CameraProjection::outStream().
00098 { 00099 const int pad_width_dot(20 - indentLevel); 00100 out.setf(std::ios::left); 00101 00102 const std::string indent_text(indentLevel, ' '); 00103 00104 out << indent_text << "vrj::Projection:\n"; 00105 out << indent_text << std::setw(pad_width_dot) << " Eye " << " "; 00106 00107 switch(mEye) 00108 { 00109 case Projection::LEFT: 00110 out << "Left"; 00111 break; 00112 case Projection::RIGHT: 00113 out << "Right"; 00114 break; 00115 } 00116 out << std::endl; 00117 out << indent_text << std::setw(pad_width_dot) 00118 << " Frustum " << " " << mFrustum; 00119 return out; 00120 }
| void vrj::Projection::setNearFar | ( | float | near_val, | |
| float | far_val | |||
| ) | [static] |
Sets the system-wide near and far values.
Definition at line 122 of file Projection.cpp.
References mFarDist, and mNearDist.
00123 { 00124 vprDEBUG(vprDBG_ALL,vprDBG_STATE_LVL) 00125 << clrOutNORM(clrCYAN,"vjProjection::setNearFar:") 00126 << "near: " << near_val << " far:" << far_val << std::endl 00127 << vprDEBUG_FLUSH; 00128 mNearDist = near_val; 00129 mFarDist = far_val; 00130 }
| void vrj::Projection::getNearFar | ( | float & | nearVal, | |
| float & | farVal | |||
| ) | [static] |
Retrieves the system-wide near and far values.
| nearVal | Storage for the returned near value. | |
| farVal | Storage for the returned far value. |
Definition at line 132 of file Projection.cpp.
References mFarDist, and mNearDist.
gmtl::Matrix44f vrj::Projection::mViewMat [protected] |
The view transformation matrix for this projection.
Definition at line 162 of file Projection.h.
Referenced by vrj::SurfaceProjection::calcViewMatrix(), vrj::CameraProjection::calcViewMatrix(), and getFrustumApexAndCorners().
Frustum vrj::Projection::mFrustum [protected] |
The calculated view frustum for this projection.
Definition at line 167 of file Projection.h.
Referenced by vrj::SurfaceProjection::calcViewFrustum(), vrj::CameraProjection::calcViewMatrix(), getFrustumApexAndCorners(), and outStream().
Eye vrj::Projection::mEye [protected] |
The eye that this projection is rendering.
Definition at line 169 of file Projection.h.
Referenced by outStream().
Viewport* vrj::Projection::mViewport [protected] |
The containing viewport for the projection.
Used in some projections to get size
Definition at line 170 of file Projection.h.
float vrj::Projection::mFocusPlaneDist [protected] |
Basically the distance to the surface.
Needed for drawing surface in simulator.
Definition at line 172 of file Projection.h.
Referenced by vrj::SurfaceProjection::calcViewFrustum(), and getFrustumApexAndCorners().
float vrj::Projection::mNearDist [static, protected] |
The near distance.
Definition at line 177 of file Projection.h.
Referenced by vrj::SurfaceProjection::calcViewFrustum(), vrj::CameraProjection::calcViewMatrix(), getNearFar(), and setNearFar().
float vrj::Projection::mFarDist [static, protected] |
The far distance.
Definition at line 178 of file Projection.h.
Referenced by vrj::SurfaceProjection::calcViewFrustum(), vrj::CameraProjection::calcViewMatrix(), getNearFar(), and setNearFar().
1.5.1