#include <SurfaceProjection.h>
Inheritance diagram for vrj::SurfaceProjection:


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 |
Responsible for storing and computing projection information of a surface specified.
Definition at line 52 of file SurfaceProjection.h.
|
||||||||||||||||||||
|
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 }
|
|
|
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 }
|
|
||||||||||||
|
Recalculate the projection matrix.
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 }
|
|
||||||||||||
|
Recalculate the view frustum.
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 }
|
|
||||||||||||
|
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 }
|
|
|
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 }
|
|
|
|
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 }
|
|
|
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 }
|
|
|
Definition at line 125 of file SurfaceProjection.h. Referenced by calculateOffsets, and calculateSurfaceRotation. |
|
|
Rotation of the surface Xfrom from the Base to the surface.
Definition at line 130 of file SurfaceProjection.h. Referenced by calculateOffsets. |
|
|
Definition at line 131 of file SurfaceProjection.h. Referenced by calculateCornersInBaseFrame, calculateOffsets, calcViewFrustum, and calcViewMatrix. |
|
|
Screen configuration (in Surface coordinate frame ).
Definition at line 135 of file SurfaceProjection.h. Referenced by assertPtsLegal, calculateCornersInBaseFrame, calculateSurfaceRotation, SurfaceProjection, and vrj::TrackedSurfaceProjection::updateSurfaceParams. |
|
|
Screen configuration (in Surface coordinate frame ).
Definition at line 135 of file SurfaceProjection.h. Referenced by assertPtsLegal, calculateCornersInBaseFrame, calculateSurfaceRotation, SurfaceProjection, and vrj::TrackedSurfaceProjection::updateSurfaceParams. |
|
|
Screen configuration (in Surface coordinate frame ).
Definition at line 135 of file SurfaceProjection.h. Referenced by assertPtsLegal, calculateCornersInBaseFrame, calculateSurfaceRotation, SurfaceProjection, and vrj::TrackedSurfaceProjection::updateSurfaceParams. |
|
|
Screen configuration (in Surface coordinate frame ).
Definition at line 135 of file SurfaceProjection.h. Referenced by assertPtsLegal, calculateCornersInBaseFrame, SurfaceProjection, and vrj::TrackedSurfaceProjection::updateSurfaceParams. |
|
|
Definition at line 136 of file SurfaceProjection.h. Referenced by calculateCornersInBaseFrame, and calculateOffsets. |
|
|
Definition at line 136 of file SurfaceProjection.h. Referenced by calculateCornersInBaseFrame, and calculateOffsets. |
|
|
Definition at line 136 of file SurfaceProjection.h. Referenced by calculateCornersInBaseFrame, and calculateOffsets. |
|
|
The corners transformed onto an x,y plane.
Definition at line 136 of file SurfaceProjection.h. Referenced by calculateCornersInBaseFrame. |
|
|
Definition at line 137 of file SurfaceProjection.h. Referenced by calculateOffsets, and calcViewFrustum. |
|
|
Definition at line 137 of file SurfaceProjection.h. Referenced by calculateOffsets, and calcViewFrustum. |
|
|
Definition at line 137 of file SurfaceProjection.h. Referenced by calculateOffsets, and calcViewFrustum. |
|
|
Definition at line 137 of file SurfaceProjection.h. Referenced by calculateOffsets, and calcViewFrustum. |
|
|
Definition at line 137 of file SurfaceProjection.h. Referenced by calculateOffsets, and calcViewFrustum. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002