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

vrj::SurfaceViewport Class Reference

Defines a display surface an associated projections. More...

#include <SurfaceViewport.h>

Inheritance diagram for vrj::SurfaceViewport:

Inheritance graph
[legend]
Collaboration diagram for vrj::SurfaceViewport:

Collaboration graph
[legend]
List of all members.

Public Methods

 SurfaceViewport ()
virtual ~SurfaceViewport ()
virtual void config (jccl::ConfigElementPtr element)
 Takes a display element and configures the viewport based on it. More...

virtual void updateProjections (const float positionScale)
 Updates the projection data for this display. More...

void getCorners (gmtl::Point3f &ll, gmtl::Point3f &lr, gmtl::Point3f &ur, gmtl::Point3f &ul)
virtual std::ostream & outStream (std::ostream &out, const unsigned int indentLevel=0)

Protected Attributes

gmtl::Point3f mLLCorner
gmtl::Point3f mLRCorner
gmtl::Point3f mURCorner
gmtl::Point3f mULCorner
 The corners in 3Space (for config). More...

bool mTracked
 Is this surface tracked? More...

std::string mTrackerProxyName
 If tracked, what is the name of the tracker. More...


Detailed Description

Defines a display surface an associated projections.

Definition at line 53 of file SurfaceViewport.h.


Constructor & Destructor Documentation

vrj::SurfaceViewport::SurfaceViewport   [inline]
 

Definition at line 56 of file SurfaceViewport.h.

References mTracked.

00056                      :  mTracked(false)
00057    {;}

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

Definition at line 59 of file SurfaceViewport.h.

00059 {}


Member Function Documentation

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

Takes a display element and configures the viewport based on it.

Precondition:
element is a valid configuration element.
Postcondition:
display is configured. If there is an error is the specified config, we output error and "fix" the error.
Note:
All derived display classes MUST call this function after doing local configuration.

Reimplemented from vrj::Viewport.

Definition at line 56 of file SurfaceViewport.cpp.

References mLLCorner, mLRCorner, mTracked, mTrackerProxyName, mULCorner, mURCorner, and vrj::Viewport::SURFACE.

00057 {
00058    vprASSERT(element.get() != NULL);
00059    vprASSERT(element->getID() == "surface_viewport");
00060 
00061    Viewport::config(element);     // Call base class config
00062 
00063    mType = SURFACE;
00064 
00065    // Read in the corners
00066    jccl::ConfigElementPtr ll_corner_elt =
00067       element->getProperty<jccl::ConfigElementPtr>("corners",0);
00068    jccl::ConfigElementPtr lr_corner_elt =
00069       element->getProperty<jccl::ConfigElementPtr>("corners",1);
00070    jccl::ConfigElementPtr ur_corner_elt =
00071       element->getProperty<jccl::ConfigElementPtr>("corners",2);
00072    jccl::ConfigElementPtr ul_corner_elt =
00073       element->getProperty<jccl::ConfigElementPtr>("corners",3);
00074    mLLCorner.set(ll_corner_elt->getProperty<float>("x"),
00075                  ll_corner_elt->getProperty<float>("y"),
00076                  ll_corner_elt->getProperty<float>("z"));
00077    mLRCorner.set(lr_corner_elt->getProperty<float>("x"),
00078                  lr_corner_elt->getProperty<float>("y"),
00079                  lr_corner_elt->getProperty<float>("z"));
00080    mURCorner.set(ur_corner_elt->getProperty<float>("x"),
00081                  ur_corner_elt->getProperty<float>("y"),
00082                  ur_corner_elt->getProperty<float>("z"));
00083    mULCorner.set(ul_corner_elt->getProperty<float>("x"),
00084                  ul_corner_elt->getProperty<float>("y"),
00085                  ul_corner_elt->getProperty<float>("z"));
00086 
00087    // Calculate the rotation and the pts
00088 //   calculateSurfaceRotation();
00089 //   calculateCornersInBaseFrame();
00090 
00091    // Get info about being tracked
00092    mTracked = element->getProperty<bool>("tracked");
00093    if(mTracked)
00094    {
00095       mTrackerProxyName = element->getProperty<std::string>("tracker_proxy");
00096    }
00097 
00098    // Create Projection objects
00099    // NOTE: The -'s are because we are measuring distance to
00100    //  the left(bottom) which is opposite the normal axis direction
00101    //vjMatrix rot_inv;
00102    //rot_inv.invert(mSurfaceRotation);
00103    if(!mTracked)
00104    {
00105       mLeftProj = new SurfaceProjection(mLLCorner,mLRCorner,mURCorner,mULCorner);
00106       mRightProj = new SurfaceProjection(mLLCorner,mLRCorner,mURCorner,mULCorner);
00107    }
00108    else
00109    {
00110       mLeftProj = new TrackedSurfaceProjection(mLLCorner,mLRCorner,mURCorner,mULCorner,mTrackerProxyName);
00111       mRightProj = new TrackedSurfaceProjection(mLLCorner,mLRCorner,mURCorner,mULCorner,mTrackerProxyName);
00112    }
00113    // Configure the projections
00114    mLeftProj->config(element);
00115    mLeftProj->setEye(Projection::LEFT);
00116    mLeftProj->setViewport(this);
00117 
00118    mRightProj->config(element);
00119    mRightProj->setEye(Projection::RIGHT);
00120    mRightProj->setViewport(this);
00121 }

void vrj::SurfaceViewport::updateProjections const float    positionScale [virtual]
 

Updates the projection data for this display.

Uses the data for the head position for this window.

Parameters:
positionScale  - Scale value for converting from Juggler units (meters) to the display units

Implements vrj::Viewport.

Definition at line 123 of file SurfaceViewport.cpp.

00124 {
00125    gmtl::Matrix44f left_eye_pos, right_eye_pos;     // NOTE: Eye coord system is -z forward, x-right, y-up
00126 
00127    // -- Calculate Eye Positions -- //
00128    gmtl::Matrix44f cur_head_pos = mUser->getHeadPosProxy()->getData(positionScale);
00129    /*
00130    Coord  head_coord(cur_head_pos);       // Create a user readable version
00131 
00132    vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL)
00133       << "vjDisplay::updateProjections: Getting head position" << std::endl
00134       << vprDEBUG_FLUSH;
00135    vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL) << "\tHeadPos:" << head_coord.pos << "\tHeadOr:"
00136                         << head_coord.orient << std::endl << vprDEBUG_FLUSH;
00137                         */
00138 
00139    // Compute location of left and right eyes
00140    //float interocularDist = 2.75f/12.0f;
00141    float interocular_dist = mUser->getInterocularDistance();
00142    interocular_dist *= positionScale;              // Scale eye separation
00143    float eye_offset = interocular_dist/2.0f;      // Distance to move eye
00144 
00145    left_eye_pos = cur_head_pos * gmtl::makeTrans<gmtl::Matrix44f>(gmtl::Vec3f( -eye_offset, 0, 0));
00146    right_eye_pos = cur_head_pos * gmtl::makeTrans<gmtl::Matrix44f>(gmtl::Vec3f(eye_offset, 0, 0));
00147 
00148    mLeftProj->calcViewMatrix(left_eye_pos, positionScale);
00149    mRightProj->calcViewMatrix(right_eye_pos, positionScale);
00150 }

void vrj::SurfaceViewport::getCorners gmtl::Point3f &    ll,
gmtl::Point3f &    lr,
gmtl::Point3f &    ur,
gmtl::Point3f &    ul
[inline]
 

Definition at line 75 of file SurfaceViewport.h.

References mLLCorner, mLRCorner, mULCorner, and mURCorner.

00077    {
00078       ll = mLLCorner; lr = mLRCorner; ur = mURCorner; ul = mULCorner;
00079    }

std::ostream & vrj::SurfaceViewport::outStream std::ostream &    out,
const unsigned int    indentLevel = 0
[virtual]
 

Reimplemented from vrj::Viewport.

Definition at line 152 of file SurfaceViewport.cpp.

References vrj::Viewport::LEFT_EYE, vrj::Viewport::RIGHT_EYE, and vrj::Viewport::STEREO.

00154 {
00155    Viewport::outStream(out, indentLevel);
00156    out << std::endl;
00157 
00158    const std::string indent_text(indentLevel, ' ');
00159 
00160    /*
00161    out << "LL: " << mLLCorner << ", LR: " << mLRCorner
00162        << ", UR: " << mURCorner << ", UL:" << mULCorner << std::endl;
00163    out << "surfRot: \n" << mSurfaceRotation << std::endl;
00164    */
00165    if ( mView == vrj::Viewport::LEFT_EYE || mView == vrj::Viewport::STEREO )
00166    {
00167       out << indent_text << "Left projection:\n";
00168       mLeftProj->outStream(out, indentLevel + 2);
00169       out << std::endl;
00170    }
00171    if ( mView == vrj::Viewport::RIGHT_EYE || mView == vrj::Viewport::STEREO )
00172    {
00173       out << indent_text << "Right projection:\n";
00174       mRightProj->outStream(out, indentLevel + 2);
00175       out << std::endl;
00176    }
00177 
00178    return out;
00179 }


Member Data Documentation

gmtl::Point3f vrj::SurfaceViewport::mLLCorner [protected]
 

Definition at line 85 of file SurfaceViewport.h.

Referenced by config, and getCorners.

gmtl::Point3f vrj::SurfaceViewport::mLRCorner [protected]
 

Definition at line 85 of file SurfaceViewport.h.

Referenced by config, and getCorners.

gmtl::Point3f vrj::SurfaceViewport::mURCorner [protected]
 

Definition at line 85 of file SurfaceViewport.h.

Referenced by config, and getCorners.

gmtl::Point3f vrj::SurfaceViewport::mULCorner [protected]
 

The corners in 3Space (for config).

Definition at line 85 of file SurfaceViewport.h.

Referenced by config, and getCorners.

bool vrj::SurfaceViewport::mTracked [protected]
 

Is this surface tracked?

Definition at line 88 of file SurfaceViewport.h.

Referenced by config, and SurfaceViewport.

std::string vrj::SurfaceViewport::mTrackerProxyName [protected]
 

If tracked, what is the name of the tracker.

Definition at line 89 of file SurfaceViewport.h.

Referenced by config.


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