Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

vrj::Projection Class Reference

Pure virtual base class for viewport definitions. More...

#include <Projection.h>

Inheritance diagram for vrj::Projection:

Inheritance graph
[legend]
List of all members.

Public Types

enum  Eye { LEFT = 1, RIGHT = 2 }
 Eye and type. More...


Public Methods

 Projection ()
 Projection (const Projection &p)
virtual ~Projection ()
virtual void config (jccl::ConfigElementPtr element)
 Configures the projection. More...

void setEye (Projection::Eye _eye)
int getEye ()
void setViewport (Viewport *vp)
ViewportgetViewport ()
virtual void calcViewMatrix (gmtl::Matrix44f &eyePos, const float scaleFactor)=0
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. More...

const gmtl::Matrix44f & getViewMatrix () const
 Returns this projection's view matrix. More...

vrj::Frustum getFrustum () const
 Returns a copy of this projection's frustum. More...

virtual std::ostream & outStream (std::ostream &out, const unsigned int indentLevel=0)
 Virtual output oporators. More...


Detailed Description

Pure virtual base class for viewport definitions.

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 57 of file Projection.h.


Member Enumeration Documentation

enum vrj::Projection::Eye
 

Eye and type.

Enumeration values:
LEFT  Left eye.
RIGHT  Right eye.

Definition at line 61 of file Projection.h.

00062    {
00063       LEFT = 1,   
00064       RIGHT = 2   
00065    };


Constructor & Destructor Documentation

vrj::Projection::Projection   [inline]
 

Definition at line 68 of file Projection.h.

00068                 : mEye(LEFT), mViewport(NULL), mFocusPlaneDist(1.0f)
00069    {
00070       ;
00071    }

vrj::Projection::Projection const Projection &    p [inline]
 

Definition at line 73 of file Projection.h.

00074       : mViewMat(p.mViewMat), mFrustum(p.mFrustum), mEye(p.mEye),
00075         mViewport(p.mViewport), mFocusPlaneDist(p.mFocusPlaneDist)
00076    {
00077    }

virtual vrj::Projection::~Projection   [inline, virtual]
 

Definition at line 79 of file Projection.h.

00080    {
00081       ;
00082    }


Member Function Documentation

void vrj::Projection::config jccl::ConfigElementPtr    element [virtual]
 

Configures the projection.

Default implementation does nothing.

Reimplemented in vrj::CameraProjection.

Definition at line 53 of file Projection.cpp.

00054 {
00055    boost::ignore_unused_variable_warning(element);
00056 }

void vrj::Projection::setEye Projection::Eye    _eye [inline]
 

Definition at line 89 of file Projection.h.

00090    { mEye = _eye; }

int vrj::Projection::getEye   [inline]
 

Definition at line 92 of file Projection.h.

00093    { return mEye;}

void vrj::Projection::setViewport Viewport   vp [inline]
 

Definition at line 95 of file Projection.h.

00096    { mViewport = vp; }

Viewport* vrj::Projection::getViewport   [inline]
 

Definition at line 97 of file Projection.h.

Referenced by vrj::CameraProjection::calcViewMatrix.

00098    { return mViewport; }

virtual void vrj::Projection::calcViewMatrix gmtl::Matrix44f &    eyePos,
const float    scaleFactor
[pure virtual]
 

Precondition:
eyePos is scaled by position factor.
scaleFactor is the scale current used.

Implemented in vrj::CameraProjection.

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.

Note:
This function is meant for debugging purposes.
Postcondition:
The given vars contain the values of the frustums corners in model space.

Definition at line 64 of file Projection.cpp.

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 116 of file Projection.h.

Referenced by vrj::OpenSGApp::draw, and vrj::GlWindow::setProjection.

00117    {
00118       return mViewMat;
00119    }

vrj::Frustum vrj::Projection::getFrustum   const [inline]
 

Returns a copy of this projection's frustum.

Definition at line 122 of file Projection.h.

Referenced by vrj::GlWindow::setProjection.

00123    {
00124       return mFrustum;
00125    }

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.

Definition at line 96 of file Projection.cpp.

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 }


The documentation for this class was generated from the following files:
Generated on Sun May 2 15:11:06 2004 for VR Juggler by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002