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

vrj::SurfaceProjection Class Reference

Surface specific class for projection definitions. More...

#include <SurfaceProjection.h>

Inheritance diagram for vrj::SurfaceProjection:

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

Collaboration graph
[legend]
List of all members.

Public Methods

 SurfaceProjection (gmtl::Point3f llCorner, gmtl::Point3f lrCorner, gmtl::Point3f urCorner, gmtl::Point3f ulCorner)
virtual void config (jccl::ConfigElementPtr element)
 Configures the projection using the element given. More...

virtual void calcViewMatrix (gmtl::Matrix44f &eyePos, const float scaleFactor)
 Recalculate the projection matrix. More...

virtual void calcViewFrustum (gmtl::Matrix44f &eyePos, const float scaleFactor)
 Recalculate the view frustum. More...

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


Protected Methods

void assertPtsLegal ()
 Checks the pts to make sure they form a legal surface. More...

void calculateOffsets ()
 These calculate mOriginToScreen, etc, from the screen corners. More...

void calculateSurfaceRotation ()
void calculateCornersInBaseFrame ()

Protected Attributes

gmtl::Matrix44f mSurfaceRotation
gmtl::Matrix44f m_base_M_surface
 Rotation of the surface Xfrom from the Base to the surface. More...

gmtl::Matrix44f m_surface_M_base
gmtl::Point3f mLLCorner
 Screen configuration (in Surface coordinate frame ). More...

gmtl::Point3f mLRCorner
 Screen configuration (in Surface coordinate frame ). More...

gmtl::Point3f mURCorner
 Screen configuration (in Surface coordinate frame ). More...

gmtl::Point3f mULCorner
 Screen configuration (in Surface coordinate frame ). More...

gmtl::Point3f mxLLCorner
gmtl::Point3f mxLRCorner
gmtl::Point3f mxURCorner
gmtl::Point3f mxULCorner
 The corners transformed onto an x,y plane. More...

float mOriginToScreen
float mOriginToRight
float mOriginToLeft
float mOriginToTop
float mOriginToBottom

Detailed Description

Surface specific class for projection definitions.

Responsible for storing and computing projection information of a surface specified.

Definition at line 52 of file SurfaceProjection.h.


Constructor & Destructor Documentation

vrj::SurfaceProjection::SurfaceProjection gmtl::Point3f    llCorner,
gmtl::Point3f    lrCorner,
gmtl::Point3f    urCorner,
gmtl::Point3f    ulCorner
[inline]
 

Parameters:
surfaceRot  - The rotation of the surface relative to the base world base_M_surface

Definition at line 59 of file SurfaceProjection.h.

References calculateOffsets, mLLCorner, mLRCorner, mULCorner, and mURCorner.

Referenced by vrj::TrackedSurfaceProjection::TrackedSurfaceProjection.

00061    {
00062       mLLCorner=llCorner;
00063       mLRCorner=lrCorner;
00064       mURCorner=urCorner;
00065       mULCorner=ulCorner;
00066 
00067       calculateOffsets();
00068    }


Member Function Documentation

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

Configures the projection using the element given.

Reimplemented from vrj::Projection.

Reimplemented in vrj::TrackedSurfaceProjection.

Definition at line 58 of file SurfaceProjection.cpp.

00059 {
00060    vprASSERT( element->getID() == "surface_viewport" );
00061 
00062    Projection::config(element);        // Call base class config first
00063 }

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

Recalculate the projection matrix.

Precondition:
WallRotation matrix must be set correctly. mOrigin*'s must all be set correctly.
eyePos is scaled by position factor.
scaleFactor is the scale current used
Postcondition:
frustum has been recomputed for given eyePos.

Implements vrj::Projection.

Reimplemented in vrj::TrackedSurfaceProjection.

Definition at line 79 of file SurfaceProjection.cpp.

References calcViewFrustum, and m_surface_M_base.

00080 {
00081    calcViewFrustum(eyePos, scaleFactor);
00082 
00083    //Coord eye_coord(eyePos);
00084    gmtl::Vec3f   eye_pos( gmtl::makeTrans<gmtl::Vec3f>(eyePos) );             // Non-xformed pos
00085 
00086    // Need to post translate to get the view matrix at the position of the eye
00087    mViewMat = m_surface_M_base * gmtl::makeTrans<gmtl::Matrix44f>( -eye_pos );
00088 }

void vrj::SurfaceProjection::calcViewFrustum gmtl::Matrix44f &    eyePos,
const float    scaleFactor
[virtual]
 

Recalculate the view frustum.

Note:
This function is called as part of calcViewMatrix.

Definition at line 103 of file SurfaceProjection.cpp.

References m_surface_M_base, mOriginToBottom, mOriginToLeft, mOriginToRight, mOriginToScreen, mOriginToTop, and vrjDBG_DISP_MGR.

Referenced by calcViewMatrix.

00104 {
00105    float near_dist, far_dist;
00106    near_dist = mNearDist;
00107    far_dist = mFarDist;
00108 
00109    // Distance measurements from eye to screen/edges
00110    // Distance to edges is from the point on the screen plane
00111    // where a normal line would go through the origin.
00112    float eye_to_screen, eye_to_right, eye_to_left, eye_to_top, eye_to_bottom;
00113 
00114    // Distances in near plane, in near plane from origin.  (Similar to above)
00115    float n_eye_to_right, n_eye_to_left, n_eye_to_top, n_eye_to_bottom;
00116 
00117    // Compute transformed eye position
00118    // - Converts eye coords into the surface's coord system
00119    gmtl::Point3f   eye_surface;         // Xformed position of eyes
00120    eye_surface = m_surface_M_base * gmtl::makeTrans<gmtl::Point3f>(eyePos);
00121 
00122    vprDEBUG(vrjDBG_DISP_MGR, vprDBG_HEX_LVL)
00123       << "SurfaceProjection::calcviewFrustum:    Base eye:" << gmtl::makeTrans<gmtl::Point3f>(eyePos)
00124       << "  Xformed eye:" << eye_surface
00125       << std::endl << vprDEBUG_FLUSH;
00126 
00127    // Compute dist from eye to screen/edges
00128    // Take into account scale since all origin to anythings are in meters
00129    eye_to_screen = (scaleFactor * mOriginToScreen) + eye_surface[gmtl::Zelt];
00130    eye_to_right =  (scaleFactor * mOriginToRight) - eye_surface[gmtl::Xelt];
00131    eye_to_left =   (scaleFactor * mOriginToLeft) + eye_surface[gmtl::Xelt];
00132    eye_to_top =    (scaleFactor * mOriginToTop) - eye_surface[gmtl::Yelt];
00133    eye_to_bottom = (scaleFactor * mOriginToBottom) + eye_surface[gmtl::Yelt];
00134 
00135    // Find dists on near plane using similar triangles
00136    float near_distFront = near_dist/eye_to_screen;      // constant factor
00137    n_eye_to_left = eye_to_left*near_distFront;
00138    n_eye_to_right = eye_to_right*near_distFront;
00139    n_eye_to_top = eye_to_top*near_distFront;
00140    n_eye_to_bottom = eye_to_bottom*near_distFront;
00141 
00142    // Set frustum and calulcate the matrix
00143    mFrustum.set(-n_eye_to_left, n_eye_to_right,
00144                 -n_eye_to_bottom, n_eye_to_top,
00145                 near_dist, far_dist);
00146 
00147    mFocusPlaneDist = eye_to_screen;    // Needed for drawing
00148 
00149    vprDEBUG(vrjDBG_DISP_MGR, vprDBG_HEX_LVL)
00150       << "SurfaceProjection::calcWallProjection: \n\tFrustum: " << mFrustum
00151       << std::endl << vprDEBUG_FLUSH;
00152 
00153 }

std::ostream & vrj::SurfaceProjection::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 from vrj::Projection.

Reimplemented in vrj::TrackedSurfaceProjection.

Definition at line 155 of file SurfaceProjection.cpp.

00157 {
00158 //   const int pad_width_dot(20 - indentLevel);
00159    out.setf(std::ios::left);
00160 
00161    const std::string indent_text(indentLevel, ' ');
00162 
00163    out << indent_text << "vrj::SurfaceProjection:\n";
00164 
00165    return Projection::outStream(out, indentLevel);
00166 }

void vrj::SurfaceProjection::assertPtsLegal   [inline, protected]
 

Checks the pts to make sure they form a legal surface.

Definition at line 94 of file SurfaceProjection.h.

References mLLCorner, mLRCorner, mULCorner, and mURCorner.

Referenced by calculateSurfaceRotation.

00095    {
00096       gmtl::Vec3f norm1, norm2;
00097       gmtl::Vec3f bot_side = mLRCorner-mLLCorner;
00098       gmtl::Vec3f diag = mULCorner-mLRCorner;
00099       gmtl::Vec3f right_side = mURCorner-mLRCorner;
00100       gmtl::cross(norm1, bot_side, diag);
00101       gmtl::cross(norm2, bot_side, right_side);
00102       gmtl::normalize( norm1 ); gmtl::normalize(norm2);
00103       if(gmtl::isEqual(norm1,norm2,1e-4f)==false){
00104          vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL) << "ERROR: Invalid surface corners.\n" << vprDEBUG_FLUSH;
00105       }
00106    }

void vrj::SurfaceProjection::calculateOffsets   [protected]
 

These calculate mOriginToScreen, etc, from the screen corners.

calculateOffsets requires that mLLCorner to mULCorner be set correctly, and it will handle calling calculateSurfaceRotation & calculateCornersInBaseFrame

Definition at line 168 of file SurfaceProjection.cpp.

References calculateCornersInBaseFrame, calculateSurfaceRotation, m_base_M_surface, m_surface_M_base, mOriginToBottom, mOriginToLeft, mOriginToRight, mOriginToScreen, mOriginToTop, mSurfaceRotation, mxLLCorner, mxLRCorner, and mxURCorner.

Referenced by SurfaceProjection, and vrj::TrackedSurfaceProjection::updateSurfaceParams.

00168                                         {
00169       calculateSurfaceRotation();
00170 
00171       m_base_M_surface=mSurfaceRotation;
00172       gmtl::invert(m_surface_M_base,m_base_M_surface);
00173       
00174       calculateCornersInBaseFrame();
00175 
00176       mOriginToScreen=-mxLLCorner[gmtl::Zelt];
00177       mOriginToRight=mxLRCorner[gmtl::Xelt];
00178       mOriginToLeft=-mxLLCorner[gmtl::Xelt];
00179       mOriginToTop=mxURCorner[gmtl::Yelt];
00180       mOriginToBottom=-mxLRCorner[gmtl::Yelt];
00181 }

void vrj::SurfaceProjection::calculateSurfaceRotation   [protected]
 

Definition at line 183 of file SurfaceProjection.cpp.

References assertPtsLegal, mLLCorner, mLRCorner, mSurfaceRotation, and mURCorner.

Referenced by calculateOffsets.

00184 {
00185    assertPtsLegal();
00186 
00187    // Find the base vectors for the surface axiis (in terms of the base coord system)
00188    // With z out, x to the right, and y up
00189    gmtl::Vec3f x_base, y_base, z_base;
00190    x_base = (mLRCorner-mLLCorner);
00191    y_base = (mURCorner-mLRCorner);
00192    gmtl::cross( z_base, x_base, y_base);
00193 
00194    // They must be normalized
00195    gmtl::normalize(x_base); gmtl::normalize(y_base); gmtl::normalize(z_base);
00196 
00197    // Calculate the surfaceRotMat using law of cosines
00198    mSurfaceRotation = gmtl::makeDirCos<gmtl::Matrix44f>(x_base, y_base, z_base );
00199 }

void vrj::SurfaceProjection::calculateCornersInBaseFrame   [protected]
 

Definition at line 201 of file SurfaceProjection.cpp.

References m_surface_M_base, mLLCorner, mLRCorner, mULCorner, mURCorner, mxLLCorner, mxLRCorner, mxULCorner, and mxURCorner.

Referenced by calculateOffsets.

00202 {
00203    mxLLCorner = m_surface_M_base * mLLCorner;
00204    mxLRCorner = m_surface_M_base * mLRCorner;
00205    mxURCorner = m_surface_M_base * mURCorner;
00206    mxULCorner = m_surface_M_base * mULCorner;
00207 
00208    // Verify that they are all in the same x,y plane
00209    vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL) << std::setprecision(10)
00210                                           << mxLLCorner[gmtl::Zelt] << " "
00211                                           << mxLRCorner[gmtl::Zelt] << " "
00212                                           << mxURCorner[gmtl::Zelt] << " "
00213                                           << mxULCorner[gmtl::Zelt] << "\n"
00214                                           << vprDEBUG_FLUSH;
00215 
00216 #ifdef VJ_DEBUG
00217    // Use 1e-4f here, otherwise the floating point error can get big enough to mess this up for tracked surfaces
00218    vprASSERT(gmtl::Math::isEqual(mxLLCorner[gmtl::Zelt], mxLRCorner[gmtl::Zelt], 1e-4f) &&
00219              gmtl::Math::isEqual(mxURCorner[gmtl::Zelt], mxULCorner[gmtl::Zelt], 1e-4f) &&
00220              gmtl::Math::isEqual(mxLLCorner[gmtl::Zelt], mxULCorner[gmtl::Zelt], 1e-4f));
00221 #endif
00222 }


Member Data Documentation

gmtl::Matrix44f vrj::SurfaceProjection::mSurfaceRotation [protected]
 

Definition at line 125 of file SurfaceProjection.h.

Referenced by calculateOffsets, and calculateSurfaceRotation.

gmtl::Matrix44f vrj::SurfaceProjection::m_base_M_surface [protected]
 

Rotation of the surface Xfrom from the Base to the surface.

Definition at line 130 of file SurfaceProjection.h.

Referenced by calculateOffsets.

gmtl::Matrix44f vrj::SurfaceProjection::m_surface_M_base [protected]
 

Definition at line 131 of file SurfaceProjection.h.

Referenced by calculateCornersInBaseFrame, calculateOffsets, calcViewFrustum, and calcViewMatrix.

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

Screen configuration (in Surface coordinate frame ).

Definition at line 135 of file SurfaceProjection.h.

Referenced by assertPtsLegal, calculateCornersInBaseFrame, calculateSurfaceRotation, SurfaceProjection, and vrj::TrackedSurfaceProjection::updateSurfaceParams.

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

Screen configuration (in Surface coordinate frame ).

Definition at line 135 of file SurfaceProjection.h.

Referenced by assertPtsLegal, calculateCornersInBaseFrame, calculateSurfaceRotation, SurfaceProjection, and vrj::TrackedSurfaceProjection::updateSurfaceParams.

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

Screen configuration (in Surface coordinate frame ).

Definition at line 135 of file SurfaceProjection.h.

Referenced by assertPtsLegal, calculateCornersInBaseFrame, calculateSurfaceRotation, SurfaceProjection, and vrj::TrackedSurfaceProjection::updateSurfaceParams.

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

Screen configuration (in Surface coordinate frame ).

Definition at line 135 of file SurfaceProjection.h.

Referenced by assertPtsLegal, calculateCornersInBaseFrame, SurfaceProjection, and vrj::TrackedSurfaceProjection::updateSurfaceParams.

gmtl::Point3f vrj::SurfaceProjection::mxLLCorner [protected]
 

Definition at line 136 of file SurfaceProjection.h.

Referenced by calculateCornersInBaseFrame, and calculateOffsets.

gmtl::Point3f vrj::SurfaceProjection::mxLRCorner [protected]
 

Definition at line 136 of file SurfaceProjection.h.

Referenced by calculateCornersInBaseFrame, and calculateOffsets.

gmtl::Point3f vrj::SurfaceProjection::mxURCorner [protected]
 

Definition at line 136 of file SurfaceProjection.h.

Referenced by calculateCornersInBaseFrame, and calculateOffsets.

gmtl::Point3f vrj::SurfaceProjection::mxULCorner [protected]
 

The corners transformed onto an x,y plane.

Definition at line 136 of file SurfaceProjection.h.

Referenced by calculateCornersInBaseFrame.

float vrj::SurfaceProjection::mOriginToScreen [protected]
 

Definition at line 137 of file SurfaceProjection.h.

Referenced by calculateOffsets, and calcViewFrustum.

float vrj::SurfaceProjection::mOriginToRight [protected]
 

Definition at line 137 of file SurfaceProjection.h.

Referenced by calculateOffsets, and calcViewFrustum.

float vrj::SurfaceProjection::mOriginToLeft [protected]
 

Definition at line 137 of file SurfaceProjection.h.

Referenced by calculateOffsets, and calcViewFrustum.

float vrj::SurfaceProjection::mOriginToTop [protected]
 

Definition at line 137 of file SurfaceProjection.h.

Referenced by calculateOffsets, and calcViewFrustum.

float vrj::SurfaceProjection::mOriginToBottom [protected]
 

Definition at line 137 of file SurfaceProjection.h.

Referenced by calculateOffsets, and calcViewFrustum.


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